To import annotations in Labelbox, you need to create an annotations payload. In this section, we provide this payload for every supported annotation type.
This workflow functionality allows you to bulk import your ground truth annotations from an external or third-party labeling system into Labelbox Annotate. Using the label import API to import external data is a useful way to consolidate and migrate all annotations into Labelbox as a single source of truth.
Use temporal classifications to attach time-based classification labels to an audio asset. Temporal ranges are represented in milliseconds from the start of the asset.When using NDJSON, temporal classifications use a unifiedanswer: [...] list structure:
For temporal radio, answer is a single-item list (unlike global radio, which uses an object).
For temporal checklist, answer is a multi-item list.
For temporal text, answer is a list of { "value": <text>, "frames": [{"start": <ms>, "end": <ms>}] }.
Temporal classifications support nested hierarchies (for example: Text > Text > Text, or Radio > Radio > Radio).
The steps to import annotations as pre-labels (machine-assisted learning) are similar to those to import annotations as ground truth labels. However, they vary slightly, and we will describe the differences for each scenario.
Data rows must first be uploaded to Catalog to attach annotations.This example shows how to create a data row in Catalog by attaching it to a dataset .
Your project ontology should support the tools and classifications required by your annotations. To ensure accurate schema feature mapping, the value used as the name parameter should match the value of the name field in your annotation.For example, when we created an annotation above, we provided a nameannotation_name. Now, when we set up our ontology, we must ensure that the name of our bounding box tool is also anotations_name. The same alignment must hold true for the other tools and classifications we create in our ontology.This example shows how to create an ontology containing all supported annotation types .
# Create a batch to send to your MAL projectbatch = project.create_batch( "first-batch-audio-demo", # Each batch in a project must have a unique name global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys priority=5 # priority between 1(Highest) - 5(lowest))print("Batch: ", batch)
For help understanding annotation payloads, see overview. To declare payloads, you can use Python annotation types (preferred) or NDJSON objects. For annotations that you want to import as ground truth labels, you can also specify benchmarks using the is_benchmark_reference flag.These examples demonstrate each format and how to compose annotations into labels attached to data rows.
label = []label.append( lb_types.Label( data={"global_key" : global_key }, annotations=[ text_annotation, checklist_annotation, radio_annotation, temporal_text_annotation, temporal_radio_annotation, temporal_checklist_annotation ], # Optional: set the label as a benchmark # Only supported for groud truth imports is_benchmark_reference = True ))
For prelabeled (model-assisted labeling) scenarios, pass your payload as the value of the predictions parameter. For ground truths, pass the payload to the labels parameter.
This option is helpful for speeding up the initial labeling process and reducing the manual labeling workload for high-volume datasets.
# Upload MAL label for this data row in projectupload_job = lb.MALPredictionImport.create_from_objects( client = client, project_id = project.uid, name="mal_job"+str(uuid.uuid4()), predictions=label)print(f"Errors: {upload_job.errors}", )print(f"Status of uploads: {upload_job.statuses}")
Option B: Upload to a labeling project as ground truth
This option is helpful for loading high-confidence labels from another platform or previous projects that just need review rather than manual labeling effort.
# Upload label for this data row in projectupload_job = lb.LabelImport.create_from_objects( client = client, project_id = project.uid, name="label_import_job"+str(uuid.uuid4()), labels=label)print(f"Errors: {upload_job.errors}", )print(f"Status of uploads: {upload_job.statuses}")