computer-vision multi-label example fails out-of-the-box when using `print-dataset`

hello!

i'm super excited to be trying this library out.

i've followed the recipe here (exactly): https://prodi.gy/docs/computer-vision#classification-multi to check how things work.

i'm using prodigy 1.9.6

i can label things fine. great!

>prodigy classify-images img-test-1 ./images -F recipe.py

but when i run a thing to print the dataset:

> prodigy print-dataset img-test-1 --style auto

I get an error:

Traceback (most recent call last):
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/site-packages/prodigy/__main__.py", line 60, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src/prodigy/core.pyx", line 213, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/site-packages/plac_core.py", line 367, in call
    cmd, result = parser.consume(arglist)
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/site-packages/plac_core.py", line 232, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/home/noon/tools/miniconda3/envs/prodigy-experiments/lib/python3.6/site-packages/prodigy/recipes/generic.py", line 115, in print_dataset
    printers.pretty_print(examples, views=[style])
  File "cython_src/prodigy/components/printers.pyx", line 220, in prodigy.components.printers.pretty_print
  File "cython_src/prodigy/components/printers.pyx", line 189, in prodigy.components.printers.format_label
TypeError: sequence item 0: expected str instance, int found

and if i try printing the spans, it just puts an empty string, instead of the actual labels i picked:

> prodigy print-dataset img-test-1 --style spans
('1580797806', '\n')
('1580797729', '\n')
('1580797751', '\n')
('1580797724', '\n')
('1580797746', '\n')
('1580797793', '\n')
('1580797738', '\n')

Hi! What are the "id" values you're using for your options? I think the problem is that the printer currently doesn't handle integer IDs correctly. Just fixed this and the fix will be included with the next release.

If your options are images and the main content is text, the print-dataset recipe should work and be reasonably useful. If the main content is also an image, it's less useful, since there's not really a satisfying way to pretty-print image annotations on the command line.

In the meantime, you can always view the raw JSON annotations with db-out, e.g.:

prodigy db-out img-test-1 | less

Hey @ines, thanks for the prompt response!

here's the code for the recipe:

import prodigy
from prodigy.components.loaders import Images

options = [
        { "id": 0, "text": "Thing"},
        { "id": 1, "text": "Other thing"},
        { "id": 2, "text": "Final thing"}
        ]

@prodigy.recipe("classify-images")
def classify_images(dataset, source):
    def get_stream():
        stream = Images(source)
        for eg in stream:
            eg["options"] = options
            yield eg

    return {
        "dataset": dataset,
        "stream": get_stream(),
        "view_id": "choice",
        "config": {
            "choice_style": "single",
            "choice_auto_accept": True,
        }
    }

i.e. just integers; as in the example from the docs.