Uploading Annotations from SDK

After creating your Annotation objects, you just need to upload them to Nucleus. You can add various types of annotations to the same dataset at once.

This can be accomplished with a single call to Dataset.annotate. See example usage below.

We recommend setting asynchronous=True to drastically speed up the upload. This will also allow you to check on the job's status in the dashboard or via the API (see our docs on Async Jobs).

import nucleus

# construct various annotations
box_gt_1 = nucleus.BoxAnnotation(...)
box_gt_2 = nucleus.BoxAnnotation(...)
polygon_gt = nucleus.PolygonAnnotation(...)
line_gt = nucleus.LineAnnotation(...)
cuboid_gt = nucleus.CuboidAnnotation(...)
segmentation_gt = nucleus.SegmentationAnnotation(...)

# fetch dataset
client = nucleus.NucleusClient("YOUR_SCALE_API_KEY")
dataset = client.get_dataset("YOUR_DATASET_ID")

# upload annotations to dataset
job = dataset.annotate(
    annotations=[box_gt_1, box_gt_2, polygon_gt, line_gt, cuboid_gt, segmentation_gt],