# fiftyone.utils.cvat¶

Utilities for working with datasets in CVAT format.

Classes:

 CVATAttribute(name, value) An attribute in CVAT image format. CVATImage(id, name, width, height[, boxes, …]) An annotated image in CVAT image format. CVATImageAnno([occluded, attributes]) Mixin for annotations in CVAT image format. Class for writing annotations in CVAT image format. CVATImageBox(label, xtl, ytl, xbr, ybr[, …]) An object bounding box in CVAT image format. CVATImageDatasetExporter([export_dir, …]) Exporter that writes CVAT image datasets to disk. CVATImageDatasetImporter([dataset_dir, …]) Importer for CVAT image datasets stored on disk. CVATImagePoints(label, points[, occluded, …]) A set of keypoints in CVAT image format. CVATImagePolygon(label, points[, occluded, …]) A polygon in CVAT image format. CVATImagePolyline(label, points[, occluded, …]) A polyline in CVAT image format. CVATTaskLabels([labels]) Description of the labels in a CVAT image annotation task. CVATTrack(id, label, width, height[, boxes, …]) An annotation track in CVAT video format. CVATVideoAnno([outside, occluded, keyframe, …]) Mixin for annotations in CVAT video format. Class for writing annotations in CVAT video format. CVATVideoBox(frame, label, xtl, ytl, xbr, ybr) An object bounding box in CVAT video format. CVATVideoDatasetExporter([export_dir, …]) Exporter that writes CVAT video datasets to disk. CVATVideoDatasetImporter([dataset_dir, …]) Importer for CVAT video datasets stored on disk. CVATVideoPoints(frame, label, points[, …]) A set of keypoints in CVAT video format. CVATVideoPolygon(frame, label, points[, …]) A polygon in CVAT video format. CVATVideoPolyline(frame, label, points[, …]) A polyline in CVAT video format. HasCVATPoints(points) Mixin for CVAT annotations that store a list of (x, y) pixel coordinates.

Functions:

 load_cvat_image_annotations(xml_path) Loads the CVAT image annotations from the given XML file. load_cvat_video_annotations(xml_path) Loads the CVAT video annotations from the given XML file.
class fiftyone.utils.cvat.CVATImageDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, include_all_data=False, shuffle=False, seed=None, max_samples=None)

Importer for CVAT image datasets stored on disk.

Parameters
• dataset_dir (None) – the dataset directory

• data_path (None) –

an optional parameter that enables explicit control over the location of the media. Can be any of the following:

• a folder name like "data" or "data/" specifying a subfolder of dataset_dir where the media files reside

• an absolute directory path where the media files reside. In this case, the dataset_dir has no effect on the location of the data

• a filename like "data.json" specifying the filename of the JSON data manifest file in dataset_dir

• an absolute filepath specifying the location of the JSON data manifest. In this case, dataset_dir has no effect on the location of the data

If None, this parameter will default to whichever of data/ or data.json exists in the dataset directory

• labels_path (None) –

an optional parameter that enables explicit control over the location of the labels. Can be any of the following:

• a filename like "labels.xml" specifying the location of the labels in dataset_dir

• an absolute filepath to the labels. In this case, dataset_dir has no effect on the location of the labels

If None, the parameter will default to labels.xml

• include_all_data (False) – whether to generate samples for all images in the data directory (True) rather than only creating samples for images with label entries (False)

• shuffle (False) – whether to randomly shuffle the order in which the samples are imported

• seed (None) – a random seed to use when shuffling

• max_samples (None) – a maximum number of samples to import. By default, all samples are imported

Methods:

 close(*args) Performs any necessary actions after the last sample has been imported. Returns the dataset info for the dataset. Performs any necessary setup before importing the first sample in the dataset.

Attributes:

 has_dataset_info Whether this importer produces a dataset info dictionary. has_image_metadata Whether this importer produces fiftyone.core.metadata.ImageMetadata instances for each image. label_cls The fiftyone.core.labels.Label class(es) returned by this importer.
property has_dataset_info

Whether this importer produces a dataset info dictionary.

property has_image_metadata

Whether this importer produces fiftyone.core.metadata.ImageMetadata instances for each image.

property label_cls

The fiftyone.core.labels.Label class(es) returned by this importer.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the importer is guaranteed to return labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the importer will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labels

• None. In this case, the importer makes no guarantees about the labels that it may return

setup()

Performs any necessary setup before importing the first sample in the dataset.

This method is called when the importer’s context manager interface is entered, DatasetImporter.__enter__().

get_dataset_info()

Returns the dataset info for the dataset.

By convention, this method should be called after all samples in the dataset have been imported.

Returns

a dict of dataset info

close(*args)

Performs any necessary actions after the last sample has been imported.

This method is called when the importer’s context manager interface is exited, DatasetImporter.__exit__().

Parameters

*args – the arguments to DatasetImporter.__exit__()

class fiftyone.utils.cvat.CVATVideoDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, include_all_data=False, shuffle=False, seed=None, max_samples=None)

Importer for CVAT video datasets stored on disk.

Parameters
• dataset_dir (None) – the dataset directory

• data_path (None) –

an optional parameter that enables explicit control over the location of the media. Can be any of the following:

• a folder name like "data" or "data/" specifying a subfolder of dataset_dir where the media files reside

• an absolute directory path where the media files reside. In this case, the dataset_dir has no effect on the location of the data

• a filename like "data.json" specifying the filename of the JSON data manifest file in dataset_dir

• an absolute filepath specifying the location of the JSON data manifest. In this case, dataset_dir has no effect on the location of the data

If None, this parameter will default to whichever of data/ or data.json exists in the dataset directory

• labels_path (None) –

an optional parameter that enables explicit control over the location of the labels. Can be any of the following:

• a folder name like "labels" or "labels/" specifying the location of the labels in dataset_dir

• an absolute folder path to the labels. In this case, dataset_dir has no effect on the location of the labels

If None, the parameter will default to labels/

• include_all_data (False) – whether to generate samples for all videos in the data directory (True) rather than only creating samples for videos with label entries (False)

• shuffle (False) – whether to randomly shuffle the order in which the samples are imported

• seed (None) – a random seed to use when shuffling

• max_samples (None) – a maximum number of samples to import. By default, all samples are imported

Methods:

 close(*args) Performs any necessary actions after the last sample has been imported. Returns the dataset info for the dataset. Performs any necessary setup before importing the first sample in the dataset.

Attributes:

 frame_labels_cls The fiftyone.core.labels.Label class(es) returned by this importer within the frame labels that it produces. has_dataset_info Whether this importer produces a dataset info dictionary. has_video_metadata Whether this importer produces fiftyone.core.metadata.VideoMetadata instances for each video. label_cls The fiftyone.core.labels.Label class(es) returned by this importer within the sample-level labels that it produces.
property has_dataset_info

Whether this importer produces a dataset info dictionary.

property has_video_metadata

Whether this importer produces fiftyone.core.metadata.VideoMetadata instances for each video.

property label_cls

The fiftyone.core.labels.Label class(es) returned by this importer within the sample-level labels that it produces.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the importer is guaranteed to return sample-level labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the importer will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labels

• None. In this case, the importer makes no guarantees about the sample-level labels that it may return

property frame_labels_cls

The fiftyone.core.labels.Label class(es) returned by this importer within the frame labels that it produces.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the importer is guaranteed to return frame labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the importer will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frame

• None. In this case, the importer makes no guarantees about the frame labels that it may return

setup()

Performs any necessary setup before importing the first sample in the dataset.

This method is called when the importer’s context manager interface is entered, DatasetImporter.__enter__().

get_dataset_info()

Returns the dataset info for the dataset.

By convention, this method should be called after all samples in the dataset have been imported.

Returns

a dict of dataset info

close(*args)

Performs any necessary actions after the last sample has been imported.

This method is called when the importer’s context manager interface is exited, DatasetImporter.__exit__().

Parameters

*args – the arguments to DatasetImporter.__exit__()

class fiftyone.utils.cvat.CVATImageDatasetExporter(export_dir=None, data_path=None, labels_path=None, export_media=None, image_format=None)

Exporter that writes CVAT image datasets to disk.

Parameters
• export_dir (None) – the directory to write the export. This has no effect if data_path and labels_path are absolute paths

• data_path (None) –

an optional parameter that enables explicit control over the location of the exported media. Can be any of the following:

• a folder name like "data" or "data/" specifying a subfolder of export_dir in which to export the media

• an absolute directory path in which to export the media. In this case, the export_dir has no effect on the location of the data

• a JSON filename like "data.json" specifying the filename of the manifest file in export_dir generated when export_media is "manifest"

• an absolute filepath specifying the location to write the JSON manifest file when export_media is "manifest". In this case, export_dir has no effect on the location of the data

If None, the default value of this parameter will be chosen based on the value of the export_media parameter

• labels_path (None) –

an optional parameter that enables explicit control over the location of the exported labels. Can be any of the following:

• a filename like "labels.xml" specifying the location in export_dir in which to export the labels

• an absolute filepath to which to export the labels. In this case, the export_dir has no effect on the location of the labels

If None, the labels will be exported into export_dir using the default filename

• export_media (None) –

controls how to export the raw media. The supported values are:

• True: copy all media files into the output directory

• False: don’t export media

• "move": move all media files into the output directory

• "symlink": create symlinks to the media files in the output directory

• "manifest": create a data.json in the output directory that maps UUIDs used in the labels files to the filepaths of the source media, rather than exporting the actual media

If None, the default value of this parameter will be chosen based on the value of the data_path parameter

• image_format (None) – the image format to use when writing in-memory images to disk. By default, fiftyone.config.default_image_ext is used

Methods:

 close(*args) Performs any necessary actions after the last sample has been exported. export_sample(image_or_path, labels[, metadata]) Exports the given sample to the dataset. log_collection(sample_collection) Logs any relevant information about the fiftyone.core.collections.SampleCollection whose samples will be exported. Performs any necessary setup before exporting the first sample in the dataset.

Attributes:

 label_cls The fiftyone.core.labels.Label class(es) exported by this exporter. requires_image_metadata Whether this exporter requires fiftyone.core.metadata.ImageMetadata instances for each sample being exported.
property requires_image_metadata

Whether this exporter requires fiftyone.core.metadata.ImageMetadata instances for each sample being exported.

property label_cls

The fiftyone.core.labels.Label class(es) exported by this exporter.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the exporter directly exports labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the exporter can handle label dictionaries with value-types specified by this dictionary. Not all keys need be present in the exported label dicts

• None. In this case, the exporter makes no guarantees about the labels that it can export

setup()

Performs any necessary setup before exporting the first sample in the dataset.

This method is called when the exporter’s context manager interface is entered, DatasetExporter.__enter__().

log_collection(sample_collection)

Logs any relevant information about the fiftyone.core.collections.SampleCollection whose samples will be exported.

Subclasses can optionally implement this method if their export format can record information such as the fiftyone.core.collections.SampleCollection.info() or fiftyone.core.collections.SampleCollection.classes() of the collection being exported.

By convention, this method must be optional; i.e., if it is not called before the first call to export_sample(), then the exporter must make do without any information about the fiftyone.core.collections.SampleCollection (which may not be available, for example, if the samples being exported are not stored in a collection).

Parameters

sample_collection – the fiftyone.core.collections.SampleCollection whose samples will be exported

export_sample(image_or_path, labels, metadata=None)

Exports the given sample to the dataset.

Parameters
close(*args)

Performs any necessary actions after the last sample has been exported.

This method is called when the exporter’s context manager interface is exited, DatasetExporter.__exit__().

Parameters

*args – the arguments to DatasetExporter.__exit__()

class fiftyone.utils.cvat.CVATVideoDatasetExporter(export_dir=None, data_path=None, labels_path=None, export_media=None)

Exporter that writes CVAT video datasets to disk.

Parameters
• export_dir (None) – the directory to write the export. This has no effect if data_path and labels_path are absolute paths

• data_path (None) –

an optional parameter that enables explicit control over the location of the exported media. Can be any of the following:

• a folder name like "data" or "data/" specifying a subfolder of export_dir in which to export the media

• an absolute directory path in which to export the media. In this case, the export_dir has no effect on the location of the data

• a JSON filename like "data.json" specifying the filename of the manifest file in export_dir generated when export_media is "manifest"

• an absolute filepath specifying the location to write the JSON manifest file when export_media is "manifest". In this case, export_dir has no effect on the location of the data

If None, the default value of this parameter will be chosen based on the value of the export_media parameter

• labels_path (None) –

an optional parameter that enables explicit control over the location of the exported labels. Can be any of the following:

• a folder name like "labels" or "labels/" specifying the location in export_dir in which to export the labels

• an absolute filepath to which to export the labels. In this case, the export_dir has no effect on the location of the labels

If None, the labels will be exported into export_dir using the default folder name

• export_media (None) –

controls how to export the raw media. The supported values are:

• True: copy all media files into the output directory

• False: don’t export media

• "move": move all media files into the output directory

• "symlink": create symlinks to the media files in the output directory

• "manifest": create a data.json in the output directory that maps UUIDs used in the labels files to the filepaths of the source media, rather than exporting the actual media

If None, the default value of this parameter will be chosen based on the value of the data_path parameter

Methods:

 close(*args) Performs any necessary actions after the last sample has been exported. export_sample(video_path, _, frames[, metadata]) Exports the given sample to the dataset. log_collection(sample_collection) Logs any relevant information about the fiftyone.core.collections.SampleCollection whose samples will be exported. Performs any necessary setup before exporting the first sample in the dataset.

Attributes:

 frame_labels_cls The fiftyone.core.labels.Label class(es) that can be exported by this exporter at the frame-level. label_cls The fiftyone.core.labels.Label class(es) that can be exported at the sample-level. requires_video_metadata Whether this exporter requires fiftyone.core.metadata.VideoMetadata instances for each sample being exported.
property requires_video_metadata

Whether this exporter requires fiftyone.core.metadata.VideoMetadata instances for each sample being exported.

property label_cls

The fiftyone.core.labels.Label class(es) that can be exported at the sample-level.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the exporter directly exports sample-level labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the exporter can export multiple label fields with value-types specified by this dictionary. Not all keys need be present in the exported sample-level labels

• None. In this case, the exporter makes no guarantees about the sample-level labels that it can export

property frame_labels_cls

The fiftyone.core.labels.Label class(es) that can be exported by this exporter at the frame-level.

This can be any of the following:

• a fiftyone.core.labels.Label class. In this case, the exporter directly exports frame labels of this type

• a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the exporter can export multiple frame label fields with value-types specified by this dictionary. Not all keys need be present in the exported frame labels

• None. In this case, the exporter makes no guarantees about the frame labels that it can export

setup()

Performs any necessary setup before exporting the first sample in the dataset.

This method is called when the exporter’s context manager interface is entered, DatasetExporter.__enter__().

log_collection(sample_collection)

Logs any relevant information about the fiftyone.core.collections.SampleCollection whose samples will be exported.

Subclasses can optionally implement this method if their export format can record information such as the fiftyone.core.collections.SampleCollection.info() or fiftyone.core.collections.SampleCollection.classes() of the collection being exported.

By convention, this method must be optional; i.e., if it is not called before the first call to export_sample(), then the exporter must make do without any information about the fiftyone.core.collections.SampleCollection (which may not be available, for example, if the samples being exported are not stored in a collection).

Parameters

sample_collection – the fiftyone.core.collections.SampleCollection whose samples will be exported

export_sample(video_path, _, frames, metadata=None)

Exports the given sample to the dataset.

Parameters
close(*args)

Performs any necessary actions after the last sample has been exported.

This method is called when the exporter’s context manager interface is exited, DatasetExporter.__exit__().

Parameters

*args – the arguments to DatasetExporter.__exit__()

class fiftyone.utils.cvat.CVATTaskLabels(labels=None)

Bases: object

Description of the labels in a CVAT image annotation task.

Parameters

labels (None) –

a list of label dicts in the following format:

[
{
"name": "car",
"attributes": [
{
"name": "type"
"categories": ["coupe", "sedan", "truck"]
},
...
}
},
...
]


Methods:

 from_cvat_images(cvat_images) Creates a CVATTaskLabels instance that describes the active schema of the given annotations. from_cvat_tracks(cvat_tracks) Creates a CVATTaskLabels instance that describes the active schema of the given annotations. Creates a CVATTaskLabels instance from the  tag of a CVAT image annotation XML file. from_schema(schema) Creates a CVATTaskLabels instance from an eta.core.image.ImageLabelsSchema. merge_task_labels(task_labels) Merges the given CVATTaskLabels into this instance. Returns an eta.core.image.ImageLabelsSchema representation of the task labels.
merge_task_labels(task_labels)

Merges the given CVATTaskLabels into this instance.

Parameters

task_labels – a CVATTaskLabels

to_schema()

Returns an eta.core.image.ImageLabelsSchema representation of the task labels.

Note that CVAT’s task labels schema does not distinguish between boxes, polylines, and keypoints, so the returned schema stores all annotations under the "objects" field.

Returns

an eta.core.image.ImageLabelsSchema

classmethod from_cvat_images(cvat_images)

Creates a CVATTaskLabels instance that describes the active schema of the given annotations.

Parameters

cvat_images – a list of CVATImage instances

Returns
classmethod from_cvat_tracks(cvat_tracks)

Creates a CVATTaskLabels instance that describes the active schema of the given annotations.

Parameters

cvat_tracks – a list of CVATTrack instances

Returns
classmethod from_labels_dict(d)

Creates a CVATTaskLabels instance from the <labels> tag of a CVAT image annotation XML file.

Parameters

d – a dict representation of a <labels> tag

Returns
classmethod from_schema(schema)

Creates a CVATTaskLabels instance from an eta.core.image.ImageLabelsSchema.

Parameters

schema – an eta.core.image.ImageLabelsSchema

Returns
class fiftyone.utils.cvat.CVATImage(id, name, width, height, boxes=None, polygons=None, polylines=None, points=None)

Bases: object

An annotated image in CVAT image format.

Parameters

Methods:

 Creates a CVATImage from an  tag of a CVAT image annotations XML file. from_labels(labels, metadata) Creates a CVATImage from a dictionary of labels. Returns a fiftyone.core.metadata.ImageMetadata instance for the annotations. Returns an iterator over the annotations in the image. Returns fiftyone.core.labels.ImageLabel representations of the annotations.

Attributes:

 has_boxes Whether this image has 2D boxes. has_points Whether this image has keypoints. has_polylines Whether this image has polygons or polylines.
property has_boxes

Whether this image has 2D boxes.

property has_polylines

Whether this image has polygons or polylines.

property has_points

Whether this image has keypoints.

iter_annos()

Returns an iterator over the annotations in the image.

Returns

an iterator that emits CVATImageAnno instances

get_image_metadata()

Returns a fiftyone.core.metadata.ImageMetadata instance for the annotations.

Returns
to_labels()

Returns fiftyone.core.labels.ImageLabel representations of the annotations.

Returns

a dictionary mapping field keys to fiftyone.core.labels.ImageLabel containers

classmethod from_labels(labels, metadata)

Creates a CVATImage from a dictionary of labels.

Parameters
Returns
classmethod from_image_dict(d)

Creates a CVATImage from an <image> tag of a CVAT image annotations XML file.

Parameters

d – a dict representation of an <image> tag

Returns
class fiftyone.utils.cvat.HasCVATPoints(points)

Bases: object

Mixin for CVAT annotations that store a list of (x, y) pixel coordinates.

points

a list of (x, y) pixel coordinates defining points

Attributes:

property points_str
class fiftyone.utils.cvat.CVATImageAnno(occluded=None, attributes=None)

Bases: object

Mixin for annotations in CVAT image format.

Parameters
class fiftyone.utils.cvat.CVATImageBox(label, xtl, ytl, xbr, ybr, occluded=None, attributes=None)

An object bounding box in CVAT image format.

Parameters
• label – the object label string

• xtl – the top-left x-coordinate of the box, in pixels

• ytl – the top-left y-coordinate of the box, in pixels

• xbr – the bottom-right x-coordinate of the box, in pixels

• ybr – the bottom-right y-coordinate of the box, in pixels

• occluded (None) – whether the object is occluded

• attributes (None) – a list of CVATAttribute instances

Methods:

 Creates a CVATImageBox from a  tag of a CVAT image annotation XML file. from_detection(detection, metadata) Creates a CVATImageBox from a fiftyone.core.labels.Detection. to_detection(frame_size) Returns a fiftyone.core.labels.Detection representation of the box.
to_detection(frame_size)

Returns a fiftyone.core.labels.Detection representation of the box.

Parameters

frame_size – the (width, height) of the image

Returns
classmethod from_detection(detection, metadata)

Creates a CVATImageBox from a fiftyone.core.labels.Detection.

Parameters
Returns
classmethod from_box_dict(d)

Creates a CVATImageBox from a <box> tag of a CVAT image annotation XML file.

Parameters

d – a dict representation of a <box> tag

Returns
class fiftyone.utils.cvat.CVATImagePolygon(label, points, occluded=None, attributes=None)

A polygon in CVAT image format.

Parameters
• label – the polygon label string

• points – a list of (x, y) pixel coordinates defining the vertices of the polygon

• occluded (None) – whether the polygon is occluded

• attributes (None) – a list of CVATAttribute instances

Methods:

 Creates a CVATImagePolygon from a  tag of a CVAT image annotation XML file. from_polyline(polyline, metadata) to_polyline(frame_size) Returns a fiftyone.core.labels.Polyline representation of the polygon.

Attributes:

to_polyline(frame_size)

Returns a fiftyone.core.labels.Polyline representation of the polygon.

Parameters

frame_size – the (width, height) of the image

Returns
classmethod from_polyline(polyline, metadata)

If the fiftyone.core.labels.Polyline is composed of multiple shapes, one CVATImagePolygon per shape will be generated.

Parameters
Returns

a list of CVATImagePolygon instances

classmethod from_polygon_dict(d)

Creates a CVATImagePolygon from a <polygon> tag of a CVAT image annotation XML file.

Parameters

d – a dict representation of a <polygon> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATImagePolyline(label, points, occluded=None, attributes=None)

A polyline in CVAT image format.

Parameters
• label – the polyline label string

• points – a list of (x, y) pixel coordinates defining the vertices of the polyline

• occluded (None) – whether the polyline is occluded

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_polyline(polyline, metadata) Creates a CVATImagePolyline from a  tag of a CVAT image annotation XML file. to_polyline(frame_size) Returns a fiftyone.core.labels.Polyline representation of the polyline.

Attributes:

to_polyline(frame_size)

Returns a fiftyone.core.labels.Polyline representation of the polyline.

Parameters

frame_size – the (width, height) of the image

Returns
classmethod from_polyline(polyline, metadata)

If the fiftyone.core.labels.Polyline is composed of multiple shapes, one CVATImagePolyline per shape will be generated.

Parameters
Returns

a list of CVATImagePolyline instances

classmethod from_polyline_dict(d)

Creates a CVATImagePolyline from a <polyline> tag of a CVAT image annotation XML file.

Parameters

d – a dict representation of a <polyline> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATImagePoints(label, points, occluded=None, attributes=None)

A set of keypoints in CVAT image format.

Parameters
• label – the keypoints label string

• points – a list of (x, y) pixel coordinates defining the vertices of the keypoints

• occluded (None) – whether the keypoints are occluded

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_keypoint(keypoint, metadata) Creates a CVATImagePoints from a fiftyone.core.labels.Keypoint. Creates a CVATImagePoints from a  tag of a CVAT image annotation XML file. to_keypoint(frame_size) Returns a fiftyone.core.labels.Keypoint representation of the points.

Attributes:

to_keypoint(frame_size)

Returns a fiftyone.core.labels.Keypoint representation of the points.

Parameters

frame_size – the (width, height) of the image

Returns
classmethod from_keypoint(keypoint, metadata)

Creates a CVATImagePoints from a fiftyone.core.labels.Keypoint.

Parameters
Returns
classmethod from_points_dict(d)

Creates a CVATImagePoints from a <points> tag of a CVAT image annotation XML file.

Parameters

d – a dict representation of a <points> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATTrack(id, label, width, height, boxes=None, polygons=None, polylines=None, points=None)

Bases: object

An annotation track in CVAT video format.

Parameters

Methods:

 from_labels(id, labels, frame_size) Creates a CVATTrack from a dictionary of labels. from_track_dict(d, frame_size) Creates a CVATTrack from a  tag of a CVAT video annotation XML file. Returns an iterator over the annotations in the track. Returns fiftyone.core.labels.ImageLabel representations of the annotations.

Attributes:

 has_boxes Whether this track has 2D boxes. has_points Whether this track has keypoints. has_polylines Whether this track has polygons or polylines.
property has_boxes

Whether this track has 2D boxes.

property has_polylines

Whether this track has polygons or polylines.

property has_points

Whether this track has keypoints.

iter_annos()

Returns an iterator over the annotations in the track.

Returns

an iterator that emits CVATVideoAnno instances

to_labels()

Returns fiftyone.core.labels.ImageLabel representations of the annotations.

Returns

a dictionary mapping frame numbers to fiftyone.core.labels.ImageLabel instances

classmethod from_labels(id, labels, frame_size)

Creates a CVATTrack from a dictionary of labels.

Parameters
Returns
classmethod from_track_dict(d, frame_size)

Creates a CVATTrack from a <track> tag of a CVAT video annotation XML file.

Parameters
• d – a dict representation of an <track> tag

• frame_size – the (width, height) of the video frames

Returns
class fiftyone.utils.cvat.CVATVideoAnno(outside=None, occluded=None, keyframe=None, attributes=None)

Bases: object

Mixin for annotations in CVAT video format.

Parameters
• outside (None) – whether the object is truncated by the frame edge

• occluded (None) – whether the object is occluded

• keyframe (None) – whether the frame is a key frame

• attributes (None) – a list of CVATAttribute instances

class fiftyone.utils.cvat.CVATVideoBox(frame, label, xtl, ytl, xbr, ybr, outside=None, occluded=None, keyframe=None, attributes=None)

An object bounding box in CVAT video format.

Parameters
• frame – the frame number

• label – the object label string

• xtl – the top-left x-coordinate of the box, in pixels

• ytl – the top-left y-coordinate of the box, in pixels

• xbr – the bottom-right x-coordinate of the box, in pixels

• ybr – the bottom-right y-coordinate of the box, in pixels

• outside (None) – whether the object is truncated by the frame edge

• occluded (None) – whether the object is occluded

• keyframe (None) – whether the frame is a key frame

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_box_dict(label, d) Creates a CVATVideoBox from a  tag of a CVAT video annotation XML file. from_detection(frame_number, detection, …) Creates a CVATVideoBox from a fiftyone.core.labels.Detection. to_detection(frame_size) Returns a fiftyone.core.labels.Detection representation of the box.
to_detection(frame_size)

Returns a fiftyone.core.labels.Detection representation of the box.

Parameters

frame_size – the (width, height) of the video frames

Returns
classmethod from_detection(frame_number, detection, frame_size)

Creates a CVATVideoBox from a fiftyone.core.labels.Detection.

Parameters
Returns
classmethod from_box_dict(label, d)

Creates a CVATVideoBox from a <box> tag of a CVAT video annotation XML file.

Parameters
• label – the object label

• d – a dict representation of a <box> tag

Returns
class fiftyone.utils.cvat.CVATVideoPolygon(frame, label, points, outside=None, occluded=None, keyframe=None, attributes=None)

A polygon in CVAT video format.

Parameters
• frame – the frame number

• label – the polygon label string

• points – a list of (x, y) pixel coordinates defining the vertices of the polygon

• outside (None) – whether the polygon is truncated by the frame edge

• occluded (None) – whether the polygon is occluded

• keyframe (None) – whether the frame is a key frame

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_polygon_dict(label, d) Creates a CVATVideoPolygon from a  tag of a CVAT video annotation XML file. from_polyline(frame_number, polyline, frame_size) to_polyline(frame_size) Returns a fiftyone.core.labels.Polyline representation of the polygon.

Attributes:

to_polyline(frame_size)

Returns a fiftyone.core.labels.Polyline representation of the polygon.

Parameters

frame_size – the (width, height) of the video frames

Returns
classmethod from_polyline(frame_number, polyline, frame_size)
Parameters
Returns
classmethod from_polygon_dict(label, d)

Creates a CVATVideoPolygon from a <polygon> tag of a CVAT video annotation XML file.

Parameters
• label – the object label

• d – a dict representation of a <polygon> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATVideoPolyline(frame, label, points, outside=None, occluded=None, keyframe=None, attributes=None)

A polyline in CVAT video format.

Parameters
• frame – the frame number

• label – the polyline label string

• points – a list of (x, y) pixel coordinates defining the vertices of the polyline

• outside (None) – whether the polyline is truncated by the frame edge

• occluded (None) – whether the polyline is occluded

• keyframe (None) – whether the frame is a key frame

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_polyline(frame_number, polyline, frame_size) from_polyline_dict(label, d) Creates a CVATVideoPolyline from a  tag of a CVAT video annotation XML file. to_polyline(frame_size) Returns a fiftyone.core.labels.Polyline representation of the polyline.

Attributes:

to_polyline(frame_size)

Returns a fiftyone.core.labels.Polyline representation of the polyline.

Parameters

frame_size – the (width, height) of the video frames

Returns
classmethod from_polyline(frame_number, polyline, frame_size)
Parameters
Returns
classmethod from_polyline_dict(label, d)

Creates a CVATVideoPolyline from a <polyline> tag of a CVAT video annotation XML file.

Parameters
• label – the object label

• d – a dict representation of a <polyline> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATVideoPoints(frame, label, points, outside=None, occluded=None, keyframe=None, attributes=None)

A set of keypoints in CVAT video format.

Parameters
• frame – the frame number

• label – the keypoints label string

• points – a list of (x, y) pixel coordinates defining the keypoints

• outside (None) – whether the keypoints are truncated by the frame edge

• occluded (None) – whether the keypoints are occluded

• keyframe (None) – whether the frame is a key frame

• attributes (None) – a list of CVATAttribute instances

Methods:

 from_keypoint(frame_number, keypoint, frame_size) Creates a CVATVideoPoints from a fiftyone.core.labels.Keypoint. from_points_dict(label, d) Creates a CVATVideoPoints from a  tag of a CVAT video annotation XML file. to_keypoint(frame_size) Returns a fiftyone.core.labels.Keypoint representation of the points.

Attributes:

to_keypoint(frame_size)

Returns a fiftyone.core.labels.Keypoint representation of the points.

Parameters

frame_size – the (width, height) of the video frames

Returns
classmethod from_keypoint(frame_number, keypoint, frame_size)

Creates a CVATVideoPoints from a fiftyone.core.labels.Keypoint.

Parameters
Returns
classmethod from_points_dict(label, d)

Creates a CVATVideoPoints from a <points> tag of a CVAT video annotation XML file.

Parameters
• label – the object label

• d – a dict representation of a <points> tag

Returns
property points_str
class fiftyone.utils.cvat.CVATAttribute(name, value)

Bases: object

An attribute in CVAT image format.

Parameters
• name – the attribute name

• value – the attribute value

Methods:

 Returns an eta.core.data.Attribute representation of the attribute.
to_eta_attribute()

Returns an eta.core.data.Attribute representation of the attribute.

Returns

an eta.core.data.Attribute

class fiftyone.utils.cvat.CVATImageAnnotationWriter

Bases: object

Class for writing annotations in CVAT image format.

Methods:

 write(cvat_task_labels, cvat_images, xml_path) Writes the annotations to disk.
write(cvat_task_labels, cvat_images, xml_path, id=None, name=None)

Writes the annotations to disk.

Parameters
class fiftyone.utils.cvat.CVATVideoAnnotationWriter

Bases: object

Class for writing annotations in CVAT video format.

Methods:

 write(cvat_task_labels, cvat_tracks, …[, …]) Writes the annotations to disk.
write(cvat_task_labels, cvat_tracks, metadata, xml_path, id=None, name=None)

Writes the annotations to disk.

Parameters
fiftyone.utils.cvat.load_cvat_image_annotations(xml_path)

Loads the CVAT image annotations from the given XML file.

Parameters

xml_path – the path to the annotations XML file

Returns

a tuple of

fiftyone.utils.cvat.load_cvat_video_annotations(xml_path)

Loads the CVAT video annotations from the given XML file.