Skip to main content
Working with Data Group labels requires the use of Label Spaces. Each Data Group’s Label Row contains multiple Label Spaces, with each Space corresponding to a specific Data Group item. Multi-layer Data Groups also contain a root Label Space that contains labels pertaining to the Data Group as a whole.

Get Label Spaces

The following script gets all Label Spaces in Label Row and prints their IDs.
Get All Label Space IDs

Get & Update Labels

Use the following scripts to get all annotations in a Label Space. The script shows how annotations can be updated by changing the last_edited_by and annotation coordinates for each annotation in the Label Space. Ensure that you replace:
  • All variables in the User input section at the top of the script.
  • The names of objects in your Ontology.
  • The type and position of the label(s).
Label Spaces can be specified using:
  • A storage item’s unique ID: label_space = lr.get_space(id="7E3KERd9arYTiPicaijP6c1LfI73", type_="image")
  • Its Data Group layout key: label_space = lr.get_space(layout_key="2", type_="image").
Using layout_keys lets you reuse the same code across multiple label rows and Data Groups (for example, “left-video” and “right-video”), without needing to look up the underlying storage item ID each time.

Add Labels

The following scripts add a single object with an attribute, and a classification to two different Label Spaces.
Attributes are set on the object instance itself, so the same attribute values apply across all Label Spaces the instance is added to.
Ensure that you replace:
  • All variables in the User input section at the top of the script.
  • The names of objects in your Ontology.
  • The type and position of the label(s).
Use the on_overlap="replace" parameter in the put_classification_instance and put_object_instance methods if you want existing labels to be replaced by the new object.

Remove Labels

The following scripts remove an object from a Label Space. Ensure that you replace:
  • All variables in the User input section at the top of the script.
  • The names of objects in your Ontology.
  • The type and position of the label(s).

Put It All Together

The following is an example demonstrating how to use Label Spaces. We have Data Groups with five data units in the following layout:

Create Example Data Groups

The following script creates the Data Groups and specifies the layout.
Create Data Group

Pre-label Data Groups

We want to pre-label the classifications for all videos with the layout_key top-left in the Data Groups with Yes. This way annotators only need to update the classification for top-left videos where there the model predictions and summaries are incorrect. Our example Project uses a Dataset that contains our Data Groups. The Ontology looks like this: Classifications
  • Prediction correct?
    • YES! (Radio button)
    • No (Radio button)
      • What's wrong? (Text)
  • Summary correct?
    • YES! (Radio button)
    • No (Radio button)
      • What's wrong? (Text)
Data Groups Ontology
Import Classification values on top_left videos

Accessing Storage Item Metadata With Label Spaces

Label spaces provide a direct link to their storage items using the space_id property. It maps to the uuid of the corresponding StorageItem.
space.space_id is equivalent to the uuid of the storage item. This holds for all label spaces, not just image Data Groups.
This means you can use get_spaces() on a label row to traverse from a label space to its storage item and access all metadata such as image dimensions. The following example demonstrates this using a Data Group of plain images, fetching the height and width of each image through its label space:
Get image dimensions from storage item