Cannot import custom recipe


I cannot import custom recipe though the name matches.
The command line is:

prodigy image_bb Image_Bounding -F /home/weiy/core/contract_analysis_weiy/


For some other custom recipes I wrote, if there is error, there would be error message which line has issue. I'm not sure if it's because "view_id" is "image.manual" in this case.

Not sure if this helps but as well as running from the command line, you can run your recipe from the python script - add the following to the bottom of

prodigy.serve("image_bb Image_Bounding", port=8080)

That might produce a python stack trace which could point you in the correct direction.

Also check that the @prodigy.recipe() decorator contains the correct name ("image_bb") as the first argument.

Are you 100% sure that the file path is correct and the file exists? That specific error message is raised if Path(file_path).is_file() doesn't return True, so if the path you're providing is not considered a file.

@david-waterworth Thanks! Your method works. Though still not sure what causes the import error.

@ines It's a valid path.

I tried David's method and I encounter the following error, however, my view_id is "image_manual", why do I need a text field?

yield {"image": filename, "meta": { "source": df['image_loc'][i].split("/")[-1] } }

I tried to add key "text" with an empty string. But it's not loading the intended image but the empty string, though the view_id is image_manual.

yield {"image": filename, "meta": { "source": df['image_loc'][i].split("/")[-1] }, "text":""}

Are you calling add_tokens? Do you need to do that if you're not using text annotation - the example doesn't? I'm only familiar with text annotation but the stack trace implies to me that it's looking for a text rather than image key.

1 Like

Yes, that's also how it looks to me! You shouldn't need to add tokens if there's no text, and if there's no text, add_tokens will raise an error.

Where does your filename come from? Is it a local path or an URL? If it's your local path, that wouldn't work in the UI, because pretty much all modern browsers block images from local paths for security reasons. So you can either load from a URL, a local web server, or convert the image to a base64-string you can send inline with the JSON. Prodigy's Images and ImageServer loaders can help you with that. Also see here for details: