How to attach regions to a task

If you added regions: true in the specs.yaml file for a task, the function that implements that task should return a tuple, with task value as the first element, and the list of regions as second element, like so:

@task(name="task_name")
def task_name(image_input: Image) -> Tuple[str, List[Region]] :
    task = "value"
    region1 = Region()
    region2 = Region(xmin=0.4, ymin=0.5, xmax=0.6, ymax=0.7)
    return task, [region1, region2]

Use the create_region_from_prediction function to easily create those regions from predictions:

from deepomatic.workflows.v2.cv import create_region_from_prediction

region = create_region_from_prediction({entry_name}, prediction)