class documentation

Importer for COCO detection datasets stored on disk.

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

Parameters
dataset_dirthe dataset directory. If omitted, data_path and/or labels_path must be provided
data_path

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
  • a dict mapping filenames to absolute filepaths

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

labels_path

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

  • a filename like "labels.json" 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.json

label_typesa label type or list of label types to load. The supported values are ("detections", "segmentations", "keypoints"). By default, all label types are loaded
classesa string or list of strings specifying required classes to load. Only samples containing at least one instance of a specified class will be loaded
image_ids

an optional list of specific image IDs to load. Can be provided in any of the following formats:

  • a list of <image-id> ints or strings
  • a list of <split>/<image-id> strings
  • the path to a text (newline-separated), JSON, or CSV file containing the list of image IDs to load in either of the first two formats
include_idwhether to include the COCO ID of each sample in the loaded labels
include_annotation_idwhether to include the COCO ID of each annotation in the loaded labels
include_license

whether to include the license ID of each sample in the loaded labels, if available. Supported values are:

  • "False": don't load the license
  • True/"name": store the string license name
  • "id": store the integer license ID
  • "url": store the license URL

Note that the license descriptions (if available) are always loaded into dataset.info["licenses"] and can be used to convert between ID, name, and URL later

extra_attrs

whether to load extra annotation attributes onto the imported labels. Supported values are:

  • True: load all extra attributes found
  • False: do not load extra attributes
  • a name or list of names of specific attributes to load
only_matchingwhether to only load labels that match the classes requirement that you provide (True), or to load all labels for samples that match the requirements (False)
use_polylineswhether to represent segmentations as fiftyone.core.labels.Polylines instances rather than fiftyone.core.labels.Detections with dense masks
tolerancea tolerance, in pixels, when generating approximate polylines for instance masks. Typical values are 1-3 pixels
shufflewhether to randomly shuffle the order in which the samples are imported
seeda random seed to use when shuffling
max_samplesa maximum number of samples to load. If label_types and/or classes are also specified, first priority will be given to samples that contain all of the specified label types and/or classes, followed by samples that contain at least one of the specified labels types or classes. The actual number of samples loaded may be less than this maximum value if the dataset does not contain sufficient samples matching your requirements. By default, all matching samples are loaded
Method __init__ Undocumented
Method __iter__ Undocumented
Method __len__ The total number of samples that will be imported.
Method __next__ Returns information about the next sample in the dataset.
Method get_dataset_info Returns the dataset info for the dataset.
Method setup Performs any necessary setup before importing the first sample in the dataset.
Instance Variable classes Undocumented
Instance Variable data_path Undocumented
Instance Variable extra_attrs Undocumented
Instance Variable image_ids Undocumented
Instance Variable include_annotation_id Undocumented
Instance Variable include_id Undocumented
Instance Variable include_license Undocumented
Instance Variable label_types Undocumented
Instance Variable labels_path Undocumented
Instance Variable only_matching Undocumented
Instance Variable tolerance Undocumented
Instance Variable use_polylines Undocumented
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.
Instance Variable _annotations Undocumented
Instance Variable _class_ids Undocumented
Instance Variable _classes_map Undocumented
Instance Variable _filenames Undocumented
Instance Variable _image_dicts_map Undocumented
Instance Variable _image_paths_map Undocumented
Instance Variable _info Undocumented
Instance Variable _iter_filenames Undocumented
Instance Variable _label_types Undocumented
Instance Variable _license_map Undocumented
Instance Variable _supercategory_map Undocumented
Property _has_scalar_labels Undocumented

Inherited from DatasetImporter (via LabeledImageDatasetImporter):

Method __enter__ Undocumented
Method __exit__ Undocumented
Method close Performs any necessary actions after the last sample has been imported.
Method _preprocess_list Internal utility that preprocesses the given list---which is presumed to be a list defining the samples that should be imported---by applying the values of the shuffle, seed, and max_samples parameters of the importer.

Inherited from ImportPathsMixin (via LabeledImageDatasetImporter, DatasetImporter):

Static Method _load_data_map Helper function that parses either a data directory or a data manifest file into a UUID -> filepath map.
Static Method _parse_data_path Helper function that computes default values for the data_path parameter supported by many importers.
Static Method _parse_labels_path Helper function that computes default values for the labels_path parameter supported by many importers.
def __init__(self, dataset_dir=None, data_path=None, labels_path=None, label_types=None, classes=None, image_ids=None, include_id=False, include_annotation_id=False, include_license=False, extra_attrs=True, only_matching=False, use_polylines=False, tolerance=None, shuffle=False, seed=None, max_samples=None): (source)
def __len__(self): (source)

The total number of samples that will be imported.

Raises
TypeErrorif the total number is not known
def __next__(self): (source)

Returns information about the next sample in the dataset.

Returns
an(image_path, image_metadata, label)
tuple
, where
Raises
StopIterationif there are no more samples to import
def get_dataset_info(self): (source)

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
def setup(self): (source)

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__.

Undocumented

data_path: None = (source)

Undocumented

extra_attrs: True = (source)

Undocumented

image_ids: None = (source)

Undocumented

include_annotation_id: False = (source)

Undocumented

include_id: False = (source)

Undocumented

include_license: False = (source)

Undocumented

label_types: None = (source)

Undocumented

labels_path: None = (source)

Undocumented

only_matching: False = (source)

Undocumented

tolerance: None = (source)

Undocumented

use_polylines: False = (source)

Undocumented

@property
has_dataset_info = (source)

Whether this importer produces a dataset info dictionary.

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 list or tuple of fiftyone.core.labels.Label classes. In this case, the importer can produce a single label field of any of these types
  • 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
_annotations = (source)

Undocumented

_class_ids = (source)

Undocumented

_classes_map = (source)

Undocumented

_filenames = (source)

Undocumented

_image_dicts_map = (source)

Undocumented

_image_paths_map = (source)

Undocumented

Undocumented

_iter_filenames = (source)

Undocumented

_label_types = (source)

Undocumented

_license_map = (source)

Undocumented

_supercategory_map = (source)

Undocumented

@property
_has_scalar_labels = (source)

Undocumented