Examples

Adding a new BBox to existing data

"""In this tutorial, we show how you can use SceneBox client to add your
annotations to an existing images dataset on platform. First, we connect to
the platform by instantiating the client, then find a few images for annotation.
Finally, we show how to either download them locally or directly view them.
"""

from scenebox.clients import SceneEngineClient
from scenebox.models.annotation import BoundingBox, BoundingBoxAnnotation

AUTH_TOKEN = 'demococo-0988-4082-1372-614775852a44'

sec = SceneEngineClient(auth_token=AUTH_TOKEN)

# Search for assets
image_ids = sec.with_asset_state("images").search_assets(size=20, filters={"aux.caption": "~ocean"})

# Create an image dataset
set_id = sec.create_set(name="ocean images", asset_type="images")

# Add assets to dataset
job_id = sec.add_assets_to_set(ids=image_ids, set_id=set_id, wait_for_completion=True)

# create bounding box annotations
annotations = []
for image_id in image_ids:
    # each image has 3 bounding boxes
    bboxes = []
    for i in range(3):
    bboxes.append(
        BoundingBox(x_min=10.0 * i,
                    y_min=10.0 * i,
                    x_max=10.0 * i + 25.0 * (i + 1),
                    y_max=10.0 * i + 35.0 * (i + 1),
                    label="my_label_{}".format(i))
      )
    annotation = BoundingBoxAnnotation(image_id=image_id,
                                     provider="my_model",
                                     version="my_model_version",
                                     bounding_boxes=bboxes,
                                     annotation_group=AnnotationGroups.MODEL_GENERATED)


    annotations.append(annotation)

sec.add_annotations(annotations=annotations)

# Zip and download dataset
sec.zip_set_and_download(set_id=set_id, filename="my_set.zip")

sec.display_image(image_id="COCO_439180")