I'm using a custom recipe that combines image.manual
and text_input
. I found that if I type something in the previous page, it'll show up on the next page too, after I click accept. Like this:
(See the progress bar, and you'll find that they come from different page)
However, the Apple
on the second page will not be saved, if I don't make any changes to the text input. There will be no new_label
key in the output jsonl for the second page (new_label is my field_id).
I'm not sure if this is a bug, or if the text on the second page is just something like a placeholder that doesn't really exist.
Just for reference, the code for my recipe is here
import prodigy
from prodigy.components.loaders import JSONL
from prodigy.util import split_string
from typing import List, Optional
@prodigy.recipe(
"image.text_input",
dataset=("The dataset to use", "positional", None, str),
source=("Path to a directory of images", "positional", None, str),
label=("One or more comma-separated labels", "option", "l", split_string),
exclude=("Names of datasets to exclude", "option", "e", split_string),
darken=("Darken image to make boxes stand out more", "flag", "D", bool),
)
def image_text_input(
dataset: str,
source: str,
label: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
darken: bool = False,
):
"""
Manually annotate images by drawing rectangular bounding boxes or polygon
shapes on the image.
"""
# Load a stream of images from a directory and return a generator that
# yields a dictionary for each example in the data. All images are
# converted to base64-encoded data URIs.
stream = JSONL(source)
return {
"view_id": "blocks", # Annotation interface to use
"dataset": dataset, # Name of dataset to save annotations
"stream": stream, # Incoming stream of examples
"exclude": exclude, # List of dataset names to exclude
"config": { # Additional config settings, mostly for app UI
"label": ", ".join(label) if label is not None else "all",
"labels": label, # Selectable label options,
"darken_image": 0.3 if darken else 0,
"blocks": [
{"view_id": "image_manual"},
{"view_id": "text_input", "field_id": "new_label"}
],
},
}