module documentation

Utilities for working with datasets in CVAT format.

Copyright 2017-2025, Voxel51, Inc.

Class CVATAnnotationAPI A class to facilitate connection to and management of tasks in CVAT.
Class CVATAnnotationResults Class that stores all relevant information needed to monitor the progress of an annotation run sent to CVAT and download the results.
Class CVATAttribute An attribute in CVAT image format.
Class CVATBackend Class for interacting with the CVAT annotation backend.
Class CVATBackendConfig Class for configuring CVATBackend instances.
Class CVATImage An annotated image in CVAT image format.
Class CVATImageAnno Mixin for annotations in CVAT image format.
Class CVATImageAnnotationWriter Class for writing annotations in CVAT image format.
Class CVATImageBox An object bounding box in CVAT image format.
Class CVATImageDatasetExporter Exporter that writes CVAT image datasets to disk.
Class CVATImageDatasetImporter Importer for CVAT image datasets stored on disk.
Class CVATImagePoints A set of keypoints in CVAT image format.
Class CVATImagePolygon A polygon in CVAT image format.
Class CVATImagePolyline A polyline in CVAT image format.
Class CVATImageTag A tag in CVAT image format.
Class CVATLabel A label returned by the CVAT API.
Class CVATShape A shape returned by the CVAT API.
Class CVATTag A tag returned by the CVAT API.
Class CVATTaskLabels Description of the labels in a CVAT image annotation task.
Class CVATTrack An annotation track in CVAT video format.
Class CVATVideoAnno Mixin for annotations in CVAT video format.
Class CVATVideoAnnotationWriter Class for writing annotations in CVAT video format.
Class CVATVideoBox An object bounding box in CVAT video format.
Class CVATVideoDatasetExporter Exporter that writes CVAT video datasets to disk.
Class CVATVideoDatasetImporter Importer for CVAT video datasets stored on disk.
Class CVATVideoPoints A set of keypoints in CVAT video format.
Class CVATVideoPolygon A polygon in CVAT video format.
Class CVATVideoPolyline A polyline in CVAT video format.
Class HasCVATBinaryMask Mixin for CVAT annotations that store RLE format instance masks.
Class HasCVATPoints Mixin for CVAT annotations that store a list of (x, y) pixel coordinates.
Function import_annotations Imports annotations from the specified CVAT project or task(s) into the given sample collection.
Function load_cvat_image_annotations Loads the CVAT image annotations from the given XML file.
Function load_cvat_video_annotations Loads the CVAT video annotations from the given XML file.
Variable logger Undocumented
Function _build_sparse_frame_id_map Undocumented
Function _cvat_tracks_to_frames_dict Undocumented
Function _do_download_media Undocumented
Function _download_annotations Undocumented
Function _download_media Undocumented
Function _ensure_list Undocumented
Function _frames_to_cvat_tracks Undocumented
Function _from_int_bool Undocumented
Function _get_interpolated_shapes Undocumented
Function _get_next_frame Undocumented
Function _get_single_polyline_points Undocumented
Function _is_supported_attribute_type Undocumented
Function _parse_frame_step Undocumented
Function _parse_occlusion_value Undocumented
Function _parse_task_metadata Undocumented
Function _parse_value Undocumented
Function _remap_annotation_frame Undocumented
Function _remap_annotation_frames Undocumented
Function _render_frame_arg Undocumented
Function _stringify_value Undocumented
Function _to_int_bool Undocumented
Function _validate_frame_arg Undocumented
def import_annotations(sample_collection, project_name=None, project_id=None, task_ids=None, data_path=None, label_types=None, insert_new=True, download_media=False, num_workers=None, occluded_attr=None, group_id_attr=None, backend='cvat', **kwargs): (source)

Imports annotations from the specified CVAT project or task(s) into the given sample collection.

Provide one of project_name, project_id, or task_ids to perform an import.

This method can be configured in any of the following three ways:

  1. Pass the data_path argument to define a mapping between media filenames in CVAT and local filepaths to the same media.
  2. Pass the download_media=True option to download both the annotations and the media files themselves, which are stored in a directory you specify via the data_path argument.
  3. Don't provide data_path or download_media=True, in which case it is assumed that the CVAT filenames correspond to the base filenames of existing sample filepaths in the provided sample_collection.
Parameters
sample_collectiona fiftyone.core.collections.SampleCollection
project_name:Nonethe name of a CVAT project to import
project_id:Nonethe ID of a CVAT project to import
task_ids:Nonea CVAT task ID or iterable of CVAT task IDs to import
data_path:None

a parameter that defines the correspondence between the filenames in CVAT and the filepaths of sample_collection. Can be any of the following:

  • a directory on disk where the media files reside. In this case, the filenames must match those in CVAT
  • a dict mapping CVAT filenames to absolute filepaths to the corresponding media on disk
  • the path to a JSON manifest on disk containing a mapping between CVAT filenames and absolute filepaths to the media on disk

By default, only annotations whose filename matches an existing filepath in sample_collection will be imported

label_types:None

an optional parameter specifying the label types to import. Can be any of the following:

  • None (default): all label types will be stored in fields of the same name on sample_collection
  • a list of label types to load. In this case, the labels will be stored in fields of the same names in sample_collection
  • a dict mapping label types to field names of sample_collection in which to store the labels
  • "prompt": present an interactive prompt to decide/discard field names in which to store each label type
insert_new:Truewhether to create new samples for any media for which annotations are found in CVAT but which do not exist in sample_collection
download_media:Falsewhether to download the images or videos found in CVAT to the directory or filepaths in data_path if not already present
num_workers:Nonea suggested number of threads to use when downloading media
occluded_attr:Nonean optional attribute name in which to store the occlusion information for all spatial labels
group_id_attr:Nonean optional attribute name in which to store the group id for labels
backend:"cvat"the name of the CVAT backend to use
**kwargsCVAT authentication credentials to pass to CVATBackendConfig
def load_cvat_image_annotations(xml_path): (source)

Loads the CVAT image annotations from the given XML file.

See :ref:`this page <CVATImageDataset-import>` for format details.

Parameters
xml_paththe path to the annotations XML file
Returns
a tuple of
  • info: a dict of dataset info
  • cvat_task_labels: a CVATTaskLabels instance
  • cvat_images: a list of CVATImage instances
def load_cvat_video_annotations(xml_path): (source)

Loads the CVAT video annotations from the given XML file.

See :ref:`this page <CVATVideoDataset-import>` for format details.

Parameters
xml_paththe path to the annotations XML file
Returns
a tuple of
  • info: a dict of dataset info
  • cvat_task_labels: a CVATTaskLabels instance
  • cvat_tracks: a list of CVATTrack instances

Undocumented

def _build_sparse_frame_id_map(dataset, cvat_id_map): (source)

Undocumented

def _cvat_tracks_to_frames_dict(cvat_tracks): (source)

Undocumented

def _do_download_media(task): (source)

Undocumented

def _download_annotations(dataset, task_ids, cvat_id_map, label_schema, label_types, anno_backend, anno_key, **kwargs): (source)

Undocumented

def _download_media(tasks, num_workers): (source)

Undocumented

def _ensure_list(value): (source)

Undocumented

def _frames_to_cvat_tracks(frames, frame_size): (source)

Undocumented

def _from_int_bool(value): (source)

Undocumented

def _get_interpolated_shapes(track_shapes): (source)

Undocumented

def _get_next_frame(next_frame_idx, frame_step): (source)

Undocumented

def _get_single_polyline_points(polyline): (source)

Undocumented

def _is_supported_attribute_type(value): (source)

Undocumented

def _parse_frame_step(data_resp): (source)

Undocumented

def _parse_occlusion_value(value): (source)

Undocumented

def _parse_task_metadata(api, task_id, data_map, task_filepaths, ignored_filenames, download_tasks, data_dir=None, download_media=False): (source)

Undocumented

def _parse_value(value): (source)

Undocumented

def _remap_annotation_frame(frame_value, frame_start, frame_step): (source)

Undocumented

def _remap_annotation_frames(annos, frame_start, frame_stop, frame_step): (source)

Undocumented

def _render_frame_arg(arg, idx, samples_batch): (source)

Undocumented

def _stringify_value(value): (source)

Undocumented

def _to_int_bool(value): (source)

Undocumented

def _validate_frame_arg(arg, arg_name): (source)

Undocumented