module documentation

Utilities for working with annotations in Labelbox format.

Copyright 2017-2025, Voxel51, Inc.

Class LabelboxAnnotationAPI A class to facilitate connection to and management of projects in Labelbox.
Class LabelboxAnnotationResults Class that stores all relevant information needed to monitor the progress of an annotation run sent to Labelbox and download the results.
Class LabelboxBackend Class for interacting with the Labelbox annotation backend.
Class LabelboxBackendConfig Class for configuring LabelboxBackend instances.
Class LabelboxExportVersion Enum for Labelbox export formats and API versions.
Function convert_labelbox_export_to_import Converts a Labelbox NDJSON export generated by export_to_labelbox into the format expected by import_from_labelbox.
Function download_labels_from_labelbox Downloads the labels for the given Labelbox project.
Function export_to_labelbox Exports labels from the FiftyOne samples to Labelbox format.
Function import_from_labelbox Imports the labels from the Labelbox project into the FiftyOne dataset.
Function upload_labels_to_labelbox Uploads labels to a Labelbox project.
Function upload_media_to_labelbox Uploads the raw media for the FiftyOne samples to Labelbox.
Variable lb Undocumented
Variable lbo Undocumented
Variable lbr Undocumented
Variable lbs Undocumented
Variable logger Undocumented
Class _FiftyOneToLabelboxConverterBase Undocumented
Class _FiftyOneToLabelboxExportConverterV1 Undocumented
Class _LabelboxExportToFiftyOneConverterV1 Undocumented
Class _LabelboxExportToFiftyOneConverterV2 Undocumented
Function _convert_labelbox_frames_export_to_import Undocumented
Function _download_labels_from_labelbox_v1 Undocumented
Function _download_or_load_ndjson Undocumented
Function _get_attr_type Undocumented
Function _get_frame_labels Undocumented
Function _get_labels Undocumented
Function _ingest_label Undocumented
Function _make_video_anno Undocumented
Function _parse_attribute Undocumented
Function _warn_labelbox_v1 Undocumented
Constant _UNIQUE_TYPE_MAP Undocumented
def convert_labelbox_export_to_import(inpath, outpath=None, video_outdir=None): (source)

Converts a Labelbox NDJSON export generated by export_to_labelbox into the format expected by import_from_labelbox.

The output JSON file will have the same format that is generated when exporting a Labelbox project's labels.

The Labeled Data fields of the output labels will be None.

Parameters
inpaththe path to an NDJSON file generated (for example) by export_to_labelbox
outpath:Nonethe path to write a JSON file containing the converted labels. If omitted, the input file will be overwritten
video_outdir:Nonea directory to write the converted video frame labels (if applicable). If omitted, the input frame label files will be overwritten
def download_labels_from_labelbox(labelbox_project, outpath=None, export_version=LabelboxExportVersion.V2): (source)

Downloads the labels for the given Labelbox project.

Parameters
labelbox_projecta labelbox.schema.project.Project
outpath:Nonethe path to write the JSON export on disk
export_version:"v2"the Labelbox export format and API version to use. Supported values are ("v1", "v2")
Returns
None if an outpath is provided, or the loaded JSON itself if no outpath is provided
def export_to_labelbox(sample_collection, ndjson_path, video_labels_dir=None, labelbox_id_field='labelbox_id', label_field=None, frame_labels_field=None, progress=None): (source)

Exports labels from the FiftyOne samples to Labelbox format.

This function is useful for loading predictions into Labelbox for model-assisted labeling.

You can use upload_labels_to_labelbox to upload the exported labels to a Labelbox project.

You can use upload_media_to_labelbox to upload sample media to Labelbox and populate the labelbox_id_field field, if necessary.

The IDs of the Labelbox DataRows corresponding to each sample must be stored in the labelbox_id_field of the samples. Any samples with no value in labelbox_id_field will be skipped.

When exporting frame labels for video datasets, the frames key of the exported labels will contain the paths on disk to per-sample NDJSON files that are written to video_labels_dir as follows:

video_labels_dir/
    <labelbox-id1>.json
    <labelbox-id2>.json
    ...

where each NDJSON file contains the frame labels for the video with the corresponding Labelbox ID.

Parameters
sample_collectiona fiftyone.core.collections.SampleCollection
ndjson_paththe path to write an NDJSON export of the labels
video_labels_dir:Nonea directory to write the per-sample video labels. Only applicable for video datasets
labelbox_id_field:"labelbox_id"the sample field to lookup/store the IDs of the Labelbox DataRows
label_field:None

optional label field(s) to export. Can be any of the following:

  • the name of a label field to export
  • a glob pattern of label field(s) to export
  • a list or tuple of label field(s) to export
  • a dictionary mapping label field names to keys to use when constructing the exported labels

By default, no labels are exported

frame_labels_field:None

optional frame label field(s) to export. Only applicable to video datasets. Can be any of the following:

  • the name of a frame label field to export
  • a glob pattern of frame label field(s) to export
  • a list or tuple of frame label field(s) to export
  • a dictionary mapping frame label field names to keys to use when constructing the exported frame labels

By default, no frame labels are exported

progress:Nonewhether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead
def import_from_labelbox(dataset, json_path, label_prefix=None, download_dir=None, labelbox_id_field='labelbox_id', progress=None): (source)

Imports the labels from the Labelbox project into the FiftyOne dataset.

The labelbox_id_field of the FiftyOne samples are used to associate the corresponding Labelbox labels.

If a download_dir is provided, any Labelbox IDs with no matching FiftyOne sample are added to the FiftyOne dataset, and their media is downloaded into download_dir.

The provided json_path should contain a JSON file in the following format:

[
    {
        "DataRow ID": <labelbox-id>,
        "Labeled Data": <url-or-None>,
        "Label": {...}
    }
]

When importing image labels, the Label field should contain a dict of Labelbox image labels:

{
    "objects": [...],
    "classifications": [...]
}

When importing video labels, the Label field should contain a dict as follows:

{
    "frames": <url-or-filepath>
}

where the frames field can either contain a URL, in which case the file is downloaded from the web, or the path to NDJSON file on disk of Labelbox video labels:

{"frameNumber": 1, "objects": [...], "classifications": [...]}
{"frameNumber": 2, "objects": [...], "classifications": [...]}
...
Parameters
dataseta fiftyone.core.dataset.Dataset
json_paththe path to the Labelbox JSON export to load
label_prefix:Nonea prefix to prepend to the sample label field(s) that are created, separated by an underscore
download_dir:Nonea directory into which to download the media for any Labelbox IDs with no corresponding sample with the matching labelbox_id_field value. This can be omitted if all IDs are already present or you do not wish to download media and add new samples
labelbox_id_field:"labelbox_id"the sample field to lookup/store the IDs of the Labelbox DataRows
progress:Nonewhether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead
def upload_labels_to_labelbox(labelbox_project, annos_or_ndjson_path, batch_size=None): (source)

Uploads labels to a Labelbox project.

Use this function to load predictions into Labelbox for model-assisted labeling.

Use export_to_labelbox to export annotations in the format expected by this method.

Parameters
labelbox_projecta labelbox.schema.project.Project
annos_or_ndjson_patha list of annotation dicts or the path to an NDJSON file on disk containing annotations
batch_size:Nonean optional batch size to use when uploading the annotations. By default, annos_or_ndjson_path is passed directly to labelbox_project.upload_annotations()
def upload_media_to_labelbox(labelbox_dataset, sample_collection, labelbox_id_field='labelbox_id', progress=None): (source)

Uploads the raw media for the FiftyOne samples to Labelbox.

The IDs of the Labelbox DataRows that are created are stored in the labelbox_id_field of the samples.

Parameters
labelbox_dataseta labelbox.schema.dataset.Dataset to which to add the media
sample_collectiona fiftyone.core.collections.SampleCollection
labelbox_id_field:"labelbox_id"the sample field in which to store the IDs of the Labelbox DataRows
progress:Nonewhether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

def _convert_labelbox_frames_export_to_import(inpath, outpath): (source)

Undocumented

def _download_labels_from_labelbox_v1(labelbox_project, outpath=None): (source)

Undocumented

def _download_or_load_ndjson(url_or_filepath): (source)

Undocumented

def _get_attr_type(label_schema, label_field, attr_name, class_name=None): (source)

Undocumented

def _get_frame_labels(sample, frame_label_fields): (source)

Undocumented

def _get_labels(sample_or_frame, label_fields): (source)

Undocumented

def _ingest_label(din, d_label): (source)

Undocumented

def _make_video_anno(labels_path, data_row_id=None): (source)

Undocumented

def _parse_attribute(value): (source)

Undocumented

def _warn_labelbox_v1(): (source)

Undocumented

_UNIQUE_TYPE_MAP: dict[str, str] = (source)

Undocumented

Value
{'instance': 'segmentation',
 'instances': 'segmentation',
 'polygons': 'polylines',
 'polygon': 'polylines',
 'polyline': 'polylines'}