Hi, curious has anyone successfully implemented two columns using image/image_manual and choice?
This is in my prodigy.json:
"global_css": ".prodigy-content, .c01185 {width: 100%;display: grid;grid-template-columns: 1fr 1fr;grid-gap: 20px;}",
This is in my recipe:
import prodigy
from prodigy.components.loaders import Images
from prodigy.util import split_string
from typing import List, Optional
# Recipe decorator with argument annotations: (description, argument type,
# shortcut, type / converter function called on value before it's passed to
# the function). Descriptions are also shown when typing --help.
@prodigy.recipe("image2.manual",
dataset=("The dataset to use", "positional", None, str),
source=("Path to a directory of images", "positional", None, str),
loader=("Loader if source is not directory of images", "option", "lo", 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),
remove_base64=("Remove base64-encoded image data before storing example in the DB. (Caution: if enabled, make sure to keep original files!)",
"flag", "R", bool))
def image2_manual(
dataset: str,
source: str,
loader: str = "jsonl",
label: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
darken: bool = False,
no_fetch=("Don't fetch images as base64", "flag", "NF", bool),
remove_base64: bool = False,
):
# 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.
def get_stream():
stream = Images(source)
options = [
{"id": 0, "text": "1"},
{"id": 1, "text": "2"},
{"id": 2, "text": "3"},
{"id": 3, "text": "4"},
{"id": 4, "text": "5"},
{"id": 5, "text": "6"},
{"id": 6, "text": "7"},
{"id": 7, "text": "8"},
{"id": 8, "text": "9"},
{"id": 9, "text": "10+"},
]
for eg in stream:
eg["options"] = options
yield eg
blocks = [
{"view_id": "image_manual"},
{"view_id": "choice", "image": None, "text": None},
]
"""
Manually annotate images by drawing rectangular bounding boxes or polygon
shapes on the image.
"""
# with open('./template.html', 'r') as f:
# html_template = f.read()
def before_db(examples):
# Remove all data URIs before storing example in the database
for eg in examples:
if eg["image"].startswith("data:"):
eg["image"] = eg.get("path")
return examples
return {
"view_id": "blocks", # Annotation interface to use
"dataset": dataset, # Name of dataset to save annotations
"stream": get_stream(), # Incoming stream of examples
"before_db": before_db if remove_base64 else None,
"exclude": exclude, # List of dataset names to exclude
"config": { # Additional config settings, mostly for app UI
"blocks": blocks,
"label": ", ".join(label) if label is not None else "all",
"labels": label, # Selectable label options,
"darken_image": 0.2 if darken else 0,
"show_bounding_box_center": True,
"show_bounding_box_size": True,
"choice_style": "single",
"show_stats": True
},
}
However, everything is simply just 50% wide but the choices are not in the second column next to the image.