fiftyone.utils.data#
- fiftyone.utils.data.base
- fiftyone.utils.data.converters
- fiftyone.utils.data.exporters
export_samples()write_dataset()build_dataset_exporter()ExportPathsMixinMediaExporterImageExporterVideoExporterDatasetExporterBatchDatasetExporterGenericSampleDatasetExporterGroupDatasetExporterUnlabeledImageDatasetExporterUnlabeledVideoDatasetExporterUnlabeledMediaDatasetExporterLabeledImageDatasetExporterLabeledVideoDatasetExporterLegacyFiftyOneDatasetExporterFiftyOneDatasetExporterImageDirectoryExporterVideoDirectoryExporterMediaDirectoryExporterFiftyOneImageClassificationDatasetExporterFiftyOneImageClassificationDatasetExporter.requires_image_metadataFiftyOneImageClassificationDatasetExporter.label_clsFiftyOneImageClassificationDatasetExporter.setup()FiftyOneImageClassificationDatasetExporter.export_sample()FiftyOneImageClassificationDatasetExporter.close()FiftyOneImageClassificationDatasetExporter.log_collection()
ImageClassificationDirectoryTreeExporterImageClassificationDirectoryTreeExporter.requires_image_metadataImageClassificationDirectoryTreeExporter.label_clsImageClassificationDirectoryTreeExporter.setup()ImageClassificationDirectoryTreeExporter.export_sample()ImageClassificationDirectoryTreeExporter.close()ImageClassificationDirectoryTreeExporter.log_collection()
VideoClassificationDirectoryTreeExporterVideoClassificationDirectoryTreeExporter.requires_video_metadataVideoClassificationDirectoryTreeExporter.label_clsVideoClassificationDirectoryTreeExporter.frame_labels_clsVideoClassificationDirectoryTreeExporter.setup()VideoClassificationDirectoryTreeExporter.export_sample()VideoClassificationDirectoryTreeExporter.close()VideoClassificationDirectoryTreeExporter.log_collection()
FiftyOneImageDetectionDatasetExporterFiftyOneImageDetectionDatasetExporter.requires_image_metadataFiftyOneImageDetectionDatasetExporter.label_clsFiftyOneImageDetectionDatasetExporter.setup()FiftyOneImageDetectionDatasetExporter.export_sample()FiftyOneImageDetectionDatasetExporter.close()FiftyOneImageDetectionDatasetExporter.log_collection()
FiftyOneTemporalDetectionDatasetExporterFiftyOneTemporalDetectionDatasetExporter.requires_video_metadataFiftyOneTemporalDetectionDatasetExporter.label_clsFiftyOneTemporalDetectionDatasetExporter.frame_labels_clsFiftyOneTemporalDetectionDatasetExporter.setup()FiftyOneTemporalDetectionDatasetExporter.export_sample()FiftyOneTemporalDetectionDatasetExporter.close()FiftyOneTemporalDetectionDatasetExporter.log_collection()
ImageSegmentationDirectoryExporterFiftyOneImageLabelsDatasetExporterFiftyOneVideoLabelsDatasetExporterFiftyOneVideoLabelsDatasetExporter.requires_video_metadataFiftyOneVideoLabelsDatasetExporter.label_clsFiftyOneVideoLabelsDatasetExporter.frame_labels_clsFiftyOneVideoLabelsDatasetExporter.setup()FiftyOneVideoLabelsDatasetExporter.log_collection()FiftyOneVideoLabelsDatasetExporter.export_sample()FiftyOneVideoLabelsDatasetExporter.close()
- fiftyone.utils.data.importers
import_samples()merge_samples()build_dataset_importer()parse_dataset_info()ImportPathsMixinDatasetImporterBatchDatasetImporterGenericSampleDatasetImporterGenericSampleDatasetImporter.__len__()GenericSampleDatasetImporter.__next__()GenericSampleDatasetImporter.has_sample_field_schemaGenericSampleDatasetImporter.get_sample_field_schema()GenericSampleDatasetImporter.close()GenericSampleDatasetImporter.get_dataset_info()GenericSampleDatasetImporter.has_dataset_infoGenericSampleDatasetImporter.setup()
GroupDatasetImporterGroupDatasetImporter.__len__()GroupDatasetImporter.__next__()GroupDatasetImporter.group_fieldGroupDatasetImporter.get_group_media_types()GroupDatasetImporter.close()GroupDatasetImporter.get_dataset_info()GroupDatasetImporter.get_sample_field_schema()GroupDatasetImporter.has_dataset_infoGroupDatasetImporter.has_sample_field_schemaGroupDatasetImporter.setup()
UnlabeledImageDatasetImporterUnlabeledImageDatasetImporter.__len__()UnlabeledImageDatasetImporter.__next__()UnlabeledImageDatasetImporter.has_image_metadataUnlabeledImageDatasetImporter.close()UnlabeledImageDatasetImporter.get_dataset_info()UnlabeledImageDatasetImporter.has_dataset_infoUnlabeledImageDatasetImporter.setup()
UnlabeledVideoDatasetImporterUnlabeledVideoDatasetImporter.__len__()UnlabeledVideoDatasetImporter.__next__()UnlabeledVideoDatasetImporter.has_video_metadataUnlabeledVideoDatasetImporter.close()UnlabeledVideoDatasetImporter.get_dataset_info()UnlabeledVideoDatasetImporter.has_dataset_infoUnlabeledVideoDatasetImporter.setup()
UnlabeledMediaDatasetImporterLabeledImageDatasetImporterLabeledImageDatasetImporter.__len__()LabeledImageDatasetImporter.__next__()LabeledImageDatasetImporter.has_image_metadataLabeledImageDatasetImporter.label_clsLabeledImageDatasetImporter.close()LabeledImageDatasetImporter.get_dataset_info()LabeledImageDatasetImporter.has_dataset_infoLabeledImageDatasetImporter.setup()
LabeledVideoDatasetImporterLabeledVideoDatasetImporter.__len__()LabeledVideoDatasetImporter.__next__()LabeledVideoDatasetImporter.has_video_metadataLabeledVideoDatasetImporter.label_clsLabeledVideoDatasetImporter.frame_labels_clsLabeledVideoDatasetImporter.close()LabeledVideoDatasetImporter.get_dataset_info()LabeledVideoDatasetImporter.has_dataset_infoLabeledVideoDatasetImporter.setup()
LegacyFiftyOneDatasetImporterLegacyFiftyOneDatasetImporter.has_sample_field_schemaLegacyFiftyOneDatasetImporter.has_dataset_infoLegacyFiftyOneDatasetImporter.setup()LegacyFiftyOneDatasetImporter.get_sample_field_schema()LegacyFiftyOneDatasetImporter.get_dataset_info()LegacyFiftyOneDatasetImporter.import_extras()LegacyFiftyOneDatasetImporter.close()
FiftyOneDatasetImporterImageDirectoryImporterVideoDirectoryImporterMediaDirectoryImporterFiftyOneImageClassificationDatasetImporterFiftyOneImageClassificationDatasetImporter.has_dataset_infoFiftyOneImageClassificationDatasetImporter.has_image_metadataFiftyOneImageClassificationDatasetImporter.label_clsFiftyOneImageClassificationDatasetImporter.setup()FiftyOneImageClassificationDatasetImporter.get_dataset_info()FiftyOneImageClassificationDatasetImporter.close()
ImageClassificationDirectoryTreeImporterImageClassificationDirectoryTreeImporter.has_image_metadataImageClassificationDirectoryTreeImporter.has_dataset_infoImageClassificationDirectoryTreeImporter.label_clsImageClassificationDirectoryTreeImporter.setup()ImageClassificationDirectoryTreeImporter.get_dataset_info()ImageClassificationDirectoryTreeImporter.close()
VideoClassificationDirectoryTreeImporterVideoClassificationDirectoryTreeImporter.has_video_metadataVideoClassificationDirectoryTreeImporter.has_dataset_infoVideoClassificationDirectoryTreeImporter.label_clsVideoClassificationDirectoryTreeImporter.frame_labels_clsVideoClassificationDirectoryTreeImporter.setup()VideoClassificationDirectoryTreeImporter.get_dataset_info()VideoClassificationDirectoryTreeImporter.close()
FiftyOneImageDetectionDatasetImporterFiftyOneImageDetectionDatasetImporter.has_dataset_infoFiftyOneImageDetectionDatasetImporter.has_image_metadataFiftyOneImageDetectionDatasetImporter.label_clsFiftyOneImageDetectionDatasetImporter.setup()FiftyOneImageDetectionDatasetImporter.get_dataset_info()FiftyOneImageDetectionDatasetImporter.close()
FiftyOneTemporalDetectionDatasetImporterFiftyOneTemporalDetectionDatasetImporter.has_dataset_infoFiftyOneTemporalDetectionDatasetImporter.has_video_metadataFiftyOneTemporalDetectionDatasetImporter.label_clsFiftyOneTemporalDetectionDatasetImporter.frame_labels_clsFiftyOneTemporalDetectionDatasetImporter.setup()FiftyOneTemporalDetectionDatasetImporter.get_dataset_info()FiftyOneTemporalDetectionDatasetImporter.close()
ImageSegmentationDirectoryImporterFiftyOneImageLabelsDatasetImporterFiftyOneVideoLabelsDatasetImporterFiftyOneVideoLabelsDatasetImporter.has_dataset_infoFiftyOneVideoLabelsDatasetImporter.has_video_metadataFiftyOneVideoLabelsDatasetImporter.label_clsFiftyOneVideoLabelsDatasetImporter.frame_labels_clsFiftyOneVideoLabelsDatasetImporter.setup()FiftyOneVideoLabelsDatasetImporter.get_dataset_info()FiftyOneVideoLabelsDatasetImporter.close()
- fiftyone.utils.data.ingestors
- fiftyone.utils.data.parsers
add_images()add_labeled_images()add_videos()add_labeled_videos()SampleParserUnlabeledImageSampleParserUnlabeledImageSampleParser.has_image_pathUnlabeledImageSampleParser.has_image_metadataUnlabeledImageSampleParser.get_image()UnlabeledImageSampleParser.get_image_path()UnlabeledImageSampleParser.get_image_metadata()UnlabeledImageSampleParser.clear_sample()UnlabeledImageSampleParser.current_sampleUnlabeledImageSampleParser.with_sample()
UnlabeledVideoSampleParserUnlabeledMediaSampleParserImageSampleParserVideoSampleParserMediaSampleParserLabeledImageSampleParserLabeledImageSampleParser.has_image_pathLabeledImageSampleParser.has_image_metadataLabeledImageSampleParser.label_clsLabeledImageSampleParser.get_image()LabeledImageSampleParser.get_image_path()LabeledImageSampleParser.get_image_metadata()LabeledImageSampleParser.get_label()LabeledImageSampleParser.clear_sample()LabeledImageSampleParser.current_sampleLabeledImageSampleParser.with_sample()
LabeledVideoSampleParserLabeledVideoSampleParser.has_video_metadataLabeledVideoSampleParser.label_clsLabeledVideoSampleParser.frame_labels_clsLabeledVideoSampleParser.get_video_path()LabeledVideoSampleParser.get_video_metadata()LabeledVideoSampleParser.get_label()LabeledVideoSampleParser.get_frame_labels()LabeledVideoSampleParser.clear_sample()LabeledVideoSampleParser.current_sampleLabeledVideoSampleParser.with_sample()
LabeledImageTupleSampleParserLabeledImageTupleSampleParser.has_image_pathLabeledImageTupleSampleParser.has_image_metadataLabeledImageTupleSampleParser.label_clsLabeledImageTupleSampleParser.get_image()LabeledImageTupleSampleParser.get_image_path()LabeledImageTupleSampleParser.get_label()LabeledImageTupleSampleParser.clear_sample()LabeledImageTupleSampleParser.current_sampleLabeledImageTupleSampleParser.get_image_metadata()LabeledImageTupleSampleParser.with_sample()
ImageClassificationSampleParserImageClassificationSampleParser.label_clsImageClassificationSampleParser.get_label()ImageClassificationSampleParser.clear_sample()ImageClassificationSampleParser.current_sampleImageClassificationSampleParser.get_image()ImageClassificationSampleParser.get_image_metadata()ImageClassificationSampleParser.get_image_path()ImageClassificationSampleParser.has_image_metadataImageClassificationSampleParser.has_image_pathImageClassificationSampleParser.with_sample()
ImageDetectionSampleParserImageDetectionSampleParser.label_clsImageDetectionSampleParser.get_label()ImageDetectionSampleParser.clear_sample()ImageDetectionSampleParser.current_sampleImageDetectionSampleParser.get_image()ImageDetectionSampleParser.get_image_metadata()ImageDetectionSampleParser.get_image_path()ImageDetectionSampleParser.has_image_metadataImageDetectionSampleParser.has_image_pathImageDetectionSampleParser.with_sample()
ImageLabelsSampleParserImageLabelsSampleParser.label_clsImageLabelsSampleParser.get_label()ImageLabelsSampleParser.clear_sample()ImageLabelsSampleParser.current_sampleImageLabelsSampleParser.get_image()ImageLabelsSampleParser.get_image_metadata()ImageLabelsSampleParser.get_image_path()ImageLabelsSampleParser.has_image_metadataImageLabelsSampleParser.has_image_pathImageLabelsSampleParser.with_sample()
FiftyOneImageClassificationSampleParserFiftyOneImageClassificationSampleParser.clear_sample()FiftyOneImageClassificationSampleParser.current_sampleFiftyOneImageClassificationSampleParser.get_image()FiftyOneImageClassificationSampleParser.get_image_metadata()FiftyOneImageClassificationSampleParser.get_image_path()FiftyOneImageClassificationSampleParser.get_label()FiftyOneImageClassificationSampleParser.has_image_metadataFiftyOneImageClassificationSampleParser.has_image_pathFiftyOneImageClassificationSampleParser.label_clsFiftyOneImageClassificationSampleParser.with_sample()
FiftyOneTemporalDetectionSampleParserFiftyOneTemporalDetectionSampleParser.has_video_metadataFiftyOneTemporalDetectionSampleParser.label_clsFiftyOneTemporalDetectionSampleParser.frame_labels_clsFiftyOneTemporalDetectionSampleParser.with_sample()FiftyOneTemporalDetectionSampleParser.get_video_path()FiftyOneTemporalDetectionSampleParser.get_video_metadata()FiftyOneTemporalDetectionSampleParser.get_label()FiftyOneTemporalDetectionSampleParser.get_frame_labels()FiftyOneTemporalDetectionSampleParser.clear_sample()FiftyOneTemporalDetectionSampleParser.current_sample
FiftyOneImageDetectionSampleParserFiftyOneImageDetectionSampleParser.clear_sample()FiftyOneImageDetectionSampleParser.current_sampleFiftyOneImageDetectionSampleParser.get_image()FiftyOneImageDetectionSampleParser.get_image_metadata()FiftyOneImageDetectionSampleParser.get_image_path()FiftyOneImageDetectionSampleParser.get_label()FiftyOneImageDetectionSampleParser.has_image_metadataFiftyOneImageDetectionSampleParser.has_image_pathFiftyOneImageDetectionSampleParser.label_clsFiftyOneImageDetectionSampleParser.with_sample()
FiftyOneImageLabelsSampleParserFiftyOneImageLabelsSampleParser.clear_sample()FiftyOneImageLabelsSampleParser.current_sampleFiftyOneImageLabelsSampleParser.get_image()FiftyOneImageLabelsSampleParser.get_image_metadata()FiftyOneImageLabelsSampleParser.get_image_path()FiftyOneImageLabelsSampleParser.get_label()FiftyOneImageLabelsSampleParser.has_image_metadataFiftyOneImageLabelsSampleParser.has_image_pathFiftyOneImageLabelsSampleParser.label_clsFiftyOneImageLabelsSampleParser.with_sample()
VideoLabelsSampleParserVideoLabelsSampleParser.has_video_metadataVideoLabelsSampleParser.label_clsVideoLabelsSampleParser.frame_labels_clsVideoLabelsSampleParser.get_video_path()VideoLabelsSampleParser.get_label()VideoLabelsSampleParser.get_frame_labels()VideoLabelsSampleParser.clear_sample()VideoLabelsSampleParser.current_sampleVideoLabelsSampleParser.get_video_metadata()VideoLabelsSampleParser.with_sample()
FiftyOneVideoLabelsSampleParserFiftyOneVideoLabelsSampleParser.clear_sample()FiftyOneVideoLabelsSampleParser.current_sampleFiftyOneVideoLabelsSampleParser.frame_labels_clsFiftyOneVideoLabelsSampleParser.get_frame_labels()FiftyOneVideoLabelsSampleParser.get_label()FiftyOneVideoLabelsSampleParser.get_video_metadata()FiftyOneVideoLabelsSampleParser.get_video_path()FiftyOneVideoLabelsSampleParser.has_video_metadataFiftyOneVideoLabelsSampleParser.label_clsFiftyOneVideoLabelsSampleParser.with_sample()
FiftyOneUnlabeledImageSampleParserFiftyOneUnlabeledImageSampleParser.has_image_pathFiftyOneUnlabeledImageSampleParser.has_image_metadataFiftyOneUnlabeledImageSampleParser.get_image()FiftyOneUnlabeledImageSampleParser.get_image_path()FiftyOneUnlabeledImageSampleParser.get_image_metadata()FiftyOneUnlabeledImageSampleParser.clear_sample()FiftyOneUnlabeledImageSampleParser.current_sampleFiftyOneUnlabeledImageSampleParser.with_sample()
FiftyOneLabeledImageSampleParserFiftyOneLabeledImageSampleParser.has_image_pathFiftyOneLabeledImageSampleParser.has_image_metadataFiftyOneLabeledImageSampleParser.label_clsFiftyOneLabeledImageSampleParser.get_image()FiftyOneLabeledImageSampleParser.get_image_path()FiftyOneLabeledImageSampleParser.get_image_metadata()FiftyOneLabeledImageSampleParser.get_label()FiftyOneLabeledImageSampleParser.clear_sample()FiftyOneLabeledImageSampleParser.current_sampleFiftyOneLabeledImageSampleParser.with_sample()
ExtractClipsMixinFiftyOneUnlabeledVideoSampleParserFiftyOneUnlabeledVideoSampleParser.has_video_metadataFiftyOneUnlabeledVideoSampleParser.get_video_path()FiftyOneUnlabeledVideoSampleParser.get_video_metadata()FiftyOneUnlabeledVideoSampleParser.clear_sample()FiftyOneUnlabeledVideoSampleParser.current_sampleFiftyOneUnlabeledVideoSampleParser.with_sample()
FiftyOneLabeledVideoSampleParserFiftyOneLabeledVideoSampleParser.has_video_metadataFiftyOneLabeledVideoSampleParser.label_clsFiftyOneLabeledVideoSampleParser.frame_labels_clsFiftyOneLabeledVideoSampleParser.get_video_path()FiftyOneLabeledVideoSampleParser.get_video_metadata()FiftyOneLabeledVideoSampleParser.get_label()FiftyOneLabeledVideoSampleParser.get_frame_labels()FiftyOneLabeledVideoSampleParser.clear_sample()FiftyOneLabeledVideoSampleParser.current_sampleFiftyOneLabeledVideoSampleParser.with_sample()
FiftyOneUnlabeledMediaSampleParser
Module contents#
Data utilities.
Classes:
alias of |
|
defaultdict(default_factory=None, /, [...]) --> dict with default factory |
|
|
Parser for |
Parser for |
|
Parser for |
|
Parser for |
|
Parser for |
|
|
Generic parser for image classification(s) samples whose labels are represented as |
Sample parser that parses unlabeled image samples. |
|
Mixin for |
|
|
Base class for |
|
Utility class for |
|
Utility class for |
|
Base interface for exporting datasets. |
|
Base interface for exporters that export entire |
|
Interface for exporting datasets of arbitrary |
|
Interface for exporting grouped datasets. |
|
Interface for exporting datasets of unlabeled image samples. |
|
Interface for exporting datasets of unlabeled video samples. |
|
Interface for exporting datasets of unlabeled samples. |
|
Interface for exporting datasets of labeled image samples. |
|
Interface for exporting datasets of labeled video samples. |
|
Legacy exporter that writes an entire FiftyOne dataset to disk in a serialized JSON format along with its source media. |
|
Exporter that writes an entire FiftyOne dataset to disk in a serialized JSON format along with its source media. |
|
Exporter that writes a directory of images to disk. |
|
Exporter that writes a directory of videos to disk. |
|
Exporter that writes a directory of media files of arbitrary type to disk. |
Exporter that writes an image classification dataset to disk in a simple JSON format. |
|
Exporter that writes an image classification directory tree to disk. |
|
Exporter that writes a video classification directory tree to disk. |
|
Exporter that writes an image detection dataset to disk in a simple JSON format. |
|
Exporter that writes a temporal video detection dataset to disk in a simple JSON format. |
|
Exporter that writes an image segmentation dataset to disk. |
|
|
Exporter that writes a labeled image dataset to disk with labels stored in ETA ImageLabels format. |
|
Exporter that writes a labeled video dataset with labels stored in ETA VideoLabels format. |
|
The year, month and day arguments are required. |
|
A sample in a |
Parser for samples in FiftyOne image classification datasets. |
|
Parser for samples in FiftyOne temporal detection datasets. |
|
|
Parser for samples in FiftyOne image detection datasets. |
|
Parser for samples in FiftyOne image labels datasets. |
|
Parser for samples in FiftyOne video labels datasets. |
Mixin for |
|
|
Base interface for importing datasets stored on disk into FiftyOne. |
|
Base interface for importers that load all of their samples in a single call to |
|
Interface for importing datasets that contain arbitrary |
|
Interface for importing datasets that contain arbitrary grouped |
|
Interface for importing datasets of unlabeled image samples. |
|
Interface for importing datasets of unlabeled video samples. |
|
Interface for importing datasets of unlabeled media samples. |
|
Interface for importing datasets of labeled image samples. |
|
Interface for importing datasets of labeled video samples. |
|
Legacy importer for FiftyOne datasets stored on disk in a serialized JSON format. |
|
Importer for FiftyOne datasets stored on disk in serialized JSON format. |
|
Importer for a directory of images stored on disk. |
|
Importer for a directory of videos stored on disk. |
|
Importer for a directory of media files stored on disk. |
Importer for image classification datasets stored on disk in a simple JSON format. |
|
Importer for an image classification directory tree stored on disk. |
|
Importer for a viideo classification directory tree stored on disk. |
|
Importer for image detection datasets stored on disk in a simple JSON format. |
|
Importer for temporal video detection datasets stored on disk in a simple JSON format. |
|
Importer for image segmentation datasets stored on disk. |
|
|
|
|
|
|
Mixin for |
|
Dataset importer that ingests unlabeled images into the provided |
|
Dataset importer that ingests labeled images into the provided |
|
Mixin for |
|
Dataset importer that ingests unlabeled videos into the provided |
|
Dataset importer that ingests labeled videos into the provided |
Base interface for sample parsers. |
|
Interface for |
|
Interface for |
|
Interface for |
|
Sample parser that parses unlabeled video samples. |
|
Sample parser that parses unlabeled media samples. |
|
Interface for |
|
Interface for |
|
Generic sample parser that parses samples that are |
|
|
Generic parser for image detection samples whose labels are represented as |
|
Generic parser for multitask image prediction samples whose labels are stored in |
|
Generic parser for labeled video samples whose labels are represented in |
|
Mixin for sample parsers that extract clips from |
Functions:
|
Maps the values in the given field to new values for each sample in the collection. |
|
Parses the contents of the given directory of images. |
|
Parses the contents of the given directory of videos. |
|
Parses the contents of the given image classification dataset directory tree, which should have the following format. |
|
Downloads the classification dataset specified by the given CSV file, which should have the following format. |
|
Downloads the images from the given URLs. |
|
Builds the |
|
Builds the |
|
Converts a dataset stored on disk to another format on disk. |
|
Exports the given samples to disk. |
|
Writes the samples to disk as a dataset in the specified format. |
|
Get a registered Document class by name. |
|
Adds the samples from the given |
|
Merges the samples from the given |
|
Parses the info returned by |
|
Adds the given images to the dataset. |
|
Adds the given labeled images to the dataset. |
|
Adds the given videos to the dataset. |
|
Adds the given labeled videos to the dataset. |
- fiftyone.utils.data.map_values(sample_collection, path, map, progress=False)#
Maps the values in the given field to new values for each sample in the collection.
This function performs the same operation as
map_values()but it immediately saves the mapped values to the database rather than creating a view.Examples:
import random import fiftyone as fo import fiftyone.zoo as foz import fiftyone.utils.data as foud from fiftyone import ViewField as F ANIMALS = [ "bear", "bird", "cat", "cow", "dog", "elephant", "giraffe", "horse", "sheep", "zebra" ] dataset = foz.load_zoo_dataset("quickstart") values = [random.choice(ANIMALS) for _ in range(len(dataset))] dataset.set_values("str_field", values) dataset.set_values("list_field", [[v] for v in values]) dataset.set_field("ground_truth.detections.tags", [F("label")]).save() # Map all animals to string "animal" mapping = {a: "animal" for a in ANIMALS} # # Map values in top-level fields # foud.map_values(dataset, "str_field", mapping) print(dataset.count_values("str_field")) # {"animal": 200} foud.map_values(dataset, "list_field", mapping) print(dataset.count_values("list_field")) # {"animal": 200} # # Map values in nested fields # foud.map_values(dataset, "ground_truth.detections.label", mapping) print(dataset.count_values("ground_truth.detections.label")) # {"animal": 183, ...} foud.map_values(dataset, "ground_truth.detections.tags", mapping) print(dataset.count_values("ground_truth.detections.tags")) # {"animal": 183, ...}
- Parameters:
sample_collection – a
fiftyone.core.collections.SampleCollectionpath – the field or
embedded.field.nameto mapmap – a dict mapping values to new values
progress (False) – whether 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
- fiftyone.utils.data.parse_images_dir(dataset_dir, recursive=True)#
Parses the contents of the given directory of images.
- Parameters:
dataset_dir – the dataset directory
recursive (True) – whether to recursively traverse subdirectories
- Returns:
a list of image paths
- fiftyone.utils.data.parse_videos_dir(dataset_dir, recursive=True)#
Parses the contents of the given directory of videos.
- Parameters:
dataset_dir – the dataset directory
recursive (True) – whether to recursively traverse subdirectories
- Returns:
a list of video paths
- fiftyone.utils.data.parse_image_classification_dir_tree(dataset_dir)#
Parses the contents of the given image classification dataset directory tree, which should have the following format:
<dataset_dir>/ <classA>/ <image1>.<ext> <image2>.<ext> ... <classB>/ <image1>.<ext> <image2>.<ext> ...
- Parameters:
dataset_dir – the dataset directory
- Returns:
a list of
(image_path, target)pairs classes: a list of class label strings- Return type:
samples
- fiftyone.utils.data.download_image_classification_dataset(csv_path, dataset_dir, classes=None, num_workers=None)#
Downloads the classification dataset specified by the given CSV file, which should have the following format:
<label1>,<image_url1> <label2>,<image_url2> ...
The image filenames are the basenames of the URLs, which are assumed to be unique.
The dataset is written to disk in
fiftyone.types.FiftyOneImageClassificationDatasetformat.- Parameters:
csv_path – a CSV file containing the labels and image URLs
dataset_dir – the directory to write the dataset
classes (None) – an optional list of classes. By default, this will be inferred from the contents of
csv_pathnum_workers (None) – a suggested number of threads to use to download images
- fiftyone.utils.data.download_images(image_urls, output_dir, num_workers=None)#
Downloads the images from the given URLs.
The filenames in
output_dirare the basenames of the URLs, which are assumed to be unique.- Parameters:
image_urls – a list of image URLs to download
output_dir – the directory to write the images
num_workers (None) – a suggested number of threads to use
- Returns:
the list of downloaded image paths
- fiftyone.utils.data.build_dataset_exporter(dataset_type, strip_none=True, warn_unused=True, **kwargs)#
Builds the
DatasetExporterinstance for the given parameters.- Parameters:
dataset_type – the
fiftyone.types.Datasettypestrip_none (True) – whether to exclude None-valued items from
kwargswarn_unused (True) – whether to issue warnings for any non-None unused parameters encountered
**kwargs – keyword arguments to pass to the dataset exporter’s constructor via
DatasetExporter(**kwargs)
- Returns:
the
DatasetExporterinstancea dict of unused keyword arguments
- Return type:
a tuple of
- fiftyone.utils.data.build_dataset_importer(dataset_type, strip_none=True, warn_unused=True, name=None, **kwargs)#
Builds the
DatasetImporterinstance for the given parameters.- Parameters:
dataset_type – the
fiftyone.types.Datasettypestrip_none (True) – whether to exclude None-valued items from
kwargswarn_unused (True) – whether to issue warnings for any non-None unused parameters encountered
name (None) – the name of the dataset being imported into, if known
**kwargs – keyword arguments to pass to the dataset importer’s constructor via
DatasetImporter(**kwargs)
- Returns:
the
DatasetImporterinstancea dict of unused keyword arguments
- Return type:
a tuple of
- fiftyone.utils.data.convert_dataset(input_dir=None, input_type=None, input_kwargs=None, dataset_importer=None, output_dir=None, output_type=None, output_kwargs=None, dataset_exporter=None, overwrite=False)#
Converts a dataset stored on disk to another format on disk.
The input dataset may be specified by providing either an
input_dirand a correspondinginput_typeor by providing adataset_importer.The output dataset may be specified by providing either an
output_dirand a correspondingoutput_typeor by providing adataset_exporter.- Parameters:
input_dir (None) – the input dataset directory
input_type (None) – the
fiftyone.types.Datasettype of the dataset ininput_dirinput_kwargs (None) – optional kwargs dict to pass to the constructor of the
fiftyone.utils.data.importers.DatasetImporterfor theinput_typeyou specifydataset_importer (None) – a
fiftyone.utils.data.importers.DatasetImporterto use to import the input datasetoutput_dir (None) – the directory to which to write the output dataset
output_type (None) – the
fiftyone.types.Datasettype to write tooutput_diroutput_kwargs (None) – optional kwargs dict to pass to the constructor of the
fiftyone.utils.data.exporters.DatasetExporterfor theoutput_typeyou specifydataset_exporter (None) – a
fiftyone.utils.data.exporters.DatasetExporterto use to export the datasetoverwrite (False) – whether to delete existing directories before performing the export (True) or to merge the export with existing files and directories (False)
- class fiftyone.utils.data.defaultdict#
Bases:
dictdefaultdict(default_factory=None, /, […]) –> dict with default factory
The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.
Methods:
clear()copy()fromkeys([value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()Attributes:
Factory for default value called by __missing__().
- clear() None. Remove all items from D.#
- copy() a shallow copy of D.#
- default_factory#
Factory for default value called by __missing__().
- fromkeys(value=None, /)#
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)#
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items#
- keys() a set-like object providing a view on D's keys#
- pop(k[, d]) v, remove specified key and return the corresponding value.#
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()#
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.#
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values#
- class fiftyone.utils.data.FiftyOneLabeledImageSampleParser(label_field, label_fcn=None, compute_metadata=False)#
Bases:
LabeledImageSampleParserParser for
fiftyone.core.sample.Sampleinstances that contain labeled images.- Parameters:
label_field – the name of the label field to parse, or a dictionary mapping label field names to keys for the return label dictionaries
label_fcn (None) – an optional function or dictionary mapping label field names to functions (must match
label_field) to apply to each label before returning itcompute_metadata (False) – whether to compute
fiftyone.core.metadata.ImageMetadatainstances on-the-fly ifget_image_metadata()is called and no metadata is available
Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Returns the image metadata for the current sample.
Returns the label for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_label()#
Returns the label for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeled
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneLabeledVideoSampleParser(label_field=None, frame_labels_field=None, label_fcn=None, frame_labels_fcn=None, compute_metadata=False, write_clips=True, clip_dir=None, video_format=None)#
Bases:
ExtractClipsMixin,LabeledVideoSampleParserParser for
fiftyone.core.sample.Sampleinstances that contain labeled videos.This class also supports
fiftyone.core.clips.ClipViewinstances.- Parameters:
label_field (None) – the name of a label field to parse, or a dictionary mapping label field names to output keys to use in the returned sample-level labels dictionary
frame_labels_field (None) – the name of a frame label field to parse, or a dictionary mapping field names to output keys describing the frame label fields to export
label_fcn (None) – an optional function or dictionary mapping label field names to functions (must match
label_field) to apply to each sample label before returning itframe_labels_fcn (None) – an optional function or dictionary mapping frame label field names to functions (must match
frame_labels_field) to apply to each frame label before returning itcompute_metadata (False) – whether to compute
fiftyone.core.metadata.VideoMetadatainstances on-the-fly ifget_video_metadata()is called and no metadata is availablewrite_clips (True) – whether to write clips when
get_video_path()is calledclip_dir (None) – a directory to write clips. Only applicable when parsing
fiftyone.core.clips.ClipViewinstancesvideo_format (None) – the video format to use when writing video clips to disk. By default,
fiftyone.config.default_video_extis used
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.The current sample.
Methods:
Returns the video path for the current sample.
Returns the video metadata for the current sample.
Returns the sample-level labels for the current sample.
Returns the frame labels for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the sample-level labels that it may return
- property frame_labels_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone. In this case, the parser makes no guarantees about the frame labels that it may return
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_label()#
Returns the sample-level labels for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labels
- get_frame_labels()#
Returns the frame labels for the current sample.
- Returns:
a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frame, orNoneif the sample has no frame labels
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneUnlabeledImageSampleParser(compute_metadata=False)#
Bases:
UnlabeledImageSampleParserParser for
fiftyone.core.sample.Sampleinstances that contain images.- Parameters:
compute_metadata (False) – whether to compute
fiftyone.core.metadata.ImageMetadatainstances on-the-fly ifget_image_metadata()is called and no metadata is available
Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Returns the image metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneUnlabeledMediaSampleParser(compute_metadata=False)#
Bases:
MediaSampleParserParser for
fiftyone.core.sample.Sampleinstances that contain unlabeled media.- Parameters:
compute_metadata (False) – whether to compute
fiftyone.core.metadata.Metadatainstances on-the-fly ifget_metadata()is called and no metadata is available
Attributes:
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.The current sample.
Methods:
Returns the media path for the current sample.
Returns the metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_metadata#
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.
- get_media_path()#
Returns the media path for the current sample.
- Returns:
the path to the media on disk
- get_metadata()#
Returns the metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.Metadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneUnlabeledVideoSampleParser(compute_metadata=False, write_clips=True, clip_dir=None, video_format=None)#
Bases:
ExtractClipsMixin,UnlabeledVideoSampleParserParser for
fiftyone.core.sample.Sampleinstances that contain videos.This class also supports
fiftyone.core.clips.ClipViewinstances.- Parameters:
compute_metadata (False) – whether to compute
fiftyone.core.metadata.VideoMetadatainstances on-the-fly ifget_video_metadata()is called and no metadata is availablewrite_clips (True) – whether to write clips when
get_video_path()is calledclip_dir (None) – a directory to write clips. Only applicable when parsing
fiftyone.core.clips.ClipViewinstancesvideo_format (None) – the video format to use when writing video clips to disk. By default,
fiftyone.config.default_video_extis used
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the video path for the current sample.
Returns the video metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.VideoMetadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.ImageClassificationSampleParser(classes=None)#
Bases:
LabeledImageTupleSampleParserGeneric parser for image classification(s) samples whose labels are represented as
fiftyone.core.labels.Classificationinstances.This implementation supports samples that are
(image_or_path, target)tuples, where:image_or_pathis either an image that can be converted to numpy format vianp.asarray()or the path to an image on disktargetcan be any of the following:None, for unlabeled images
a label string or list of label strings
a class ID or list of class IDs, if
classesis provideda dict or list of dicts of the following form:
{ "label": <label-or-target>, "confidence": <confidence>, "attributes": <optional-attributes>, }
a
fiftyone.core.labels.Classificationorfiftyone.core.labels.Classificationsinstance
- Parameters:
classes (None) – an optional list of class label strings. If provided, it is assumed that
targetcontains class ID that should be mapped to label strings viaclasses[target]
Attributes:
The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
Methods:
Returns the label for the current sample.
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_label()#
Returns the label for the current sample.
- Parameters:
sample – the sample
- Returns:
a
fiftyone.core.labels.Classificationinstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.ImageSampleParser#
Bases:
UnlabeledImageSampleParserSample parser that parses unlabeled image samples.
This implementation assumes that the provided sample is either an image that can be converted to numpy format via
np.asarray()or the path to an image on disk.Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Clears the current sample.
Returns the image metadata for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- fiftyone.utils.data.export_samples(samples, export_dir=None, dataset_type=None, data_path=None, labels_path=None, export_media=None, rel_dir=None, dataset_exporter=None, label_field=None, frame_labels_field=None, progress=None, num_samples=None, **kwargs)#
Exports the given samples to disk.
You can perform exports with this method via the following basic patterns:
Provide
export_diranddataset_typeto export the content to a directory in the default layout for the specified format, as documented in this pageProvide
dataset_typealong withdata_path,labels_path, and/orexport_mediato directly specify where to export the source media and/or labels (if applicable) in your desired format. This syntax provides the flexibility to, for example, perform workflows like labels-only exportsProvide a
dataset_exporterto which to feed samples to perform a fully-customized export
In all workflows, the remaining parameters of this method can be provided to further configure the export.
See this page for more information about the available export formats and examples of using this method.
See this guide for more details about exporting datasets in custom formats by defining your own
fiftyone.utils.data.exporters.DatasetExporter.This method will automatically coerce the data to match the requested export in the following cases:
When exporting in either an unlabeled image or image classification format, if a spatial label field is provided (
fiftyone.core.labels.Detection,fiftyone.core.labels.Detections,fiftyone.core.labels.Polyline, orfiftyone.core.labels.Polylines), then the image patches of the provided samples will be exportedWhen exporting in labeled image dataset formats that expect list-type labels (
fiftyone.core.labels.Classifications,fiftyone.core.labels.Detections,fiftyone.core.labels.Keypoints, orfiftyone.core.labels.Polylines), if a label field contains labels in non-list format (e.g.,fiftyone.core.labels.Classification), the labels will be automatically upgraded to single-label listsWhen exporting in labeled image dataset formats that expect
fiftyone.core.labels.Detectionslabels, if afiftyone.core.labels.Classificationfield is provided, the labels will be automatically upgraded to detections that span the entire images
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionexport_dir (None) – the directory to which to export the samples in format
dataset_typedataset_type (None) – the
fiftyone.types.Datasettype to writedata_path (None) –
an optional parameter that enables explicit control over the location of the exported media for certain export formats. Can be any of the following:
a folder name like
"data"or"data/"specifying a subfolder ofexport_dirin which to export the mediaan absolute directory path in which to export the media. In this case, the
export_dirhas no effect on the location of the dataa filename like
"data.json"specifying the filename of a JSON manifest file inexport_dirgenerated whenexport_mediais"manifest"an absolute filepath specifying the location to write the JSON manifest file when
export_mediais"manifest". In this case,export_dirhas no effect on the location of the data
If None, a default value of this parameter will be chosen based on the value of the
export_mediaparameter. Note that this parameter is not applicable to certain export formats such as binary types like TF recordslabels_path (None) –
an optional parameter that enables explicit control over the location of the exported labels. Only applicable when exporting in certain labeled dataset formats. Can be any of the following:
a type-specific folder name like
"labels"or"labels/"or a filename like"labels.json"or"labels.xml"specifying the location inexport_dirin which to export the labelsan absolute directory or filepath in which to export the labels. In this case, the
export_dirhas no effect on the location of the labels
For labeled datasets, the default value of this parameter will be chosen based on the export format so that the labels will be exported into
export_direxport_media (None) –
controls how to export the raw media. The supported values are:
True: copy all media files into the output directoryFalse: don’t export media. This option is only useful when exporting labeled datasets whose label format stores sufficient information to locate the associated media"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory"manifest": create adata.jsonin 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, an appropriate default value of this parameter will be chosen based on the value of the
data_pathparameter. Note that some dataset formats may not support certain values for this parameter (e.g., when exporting in binary formats such as TF records, “symlink” is not an option)rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each media. When exporting media, this identifier is joined with
data_pathto generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()dataset_exporter (None) – a
DatasetExporterto use to write the datasetlabel_field (None) – the name of the label field to export, or a dictionary mapping field names to output keys describing the label fields to export. Only applicable if
dataset_exporteris aLabeledImageDatasetExporterorLabeledVideoDatasetExporter, or if you are exporting image patchesframe_labels_field (None) – the name of the frame label field to export, or a dictionary mapping field names to output keys describing the frame label fields to export. Only applicable if
dataset_exporteris aLabeledVideoDatasetExporterprogress (None) – whether to render a progress bar (True/False), use the default value
fiftyone.config.show_progress_bars(None), or a progress callback function to invoke insteadnum_samples (None) – the number of samples in
samples. If omitted, this is computed (if possible) vialen(samples)if needed for progress tracking**kwargs – optional keyword arguments to pass to the dataset exporter’s constructor. If you are exporting image patches, this can also contain keyword arguments for
fiftyone.utils.patches.ImagePatchesExtractor
- fiftyone.utils.data.write_dataset(samples, sample_parser, dataset_exporter, sample_collection=None, progress=None, num_samples=None)#
Writes the samples to disk as a dataset in the specified format.
- Parameters:
samples – an iterable of samples that can be parsed by
sample_parsersample_parser – a
fiftyone.utils.data.parsers.SampleParserto use to parse the samplesdataset_exporter – a
DatasetExporterto use to write the datasetsample_collection (None) – the
fiftyone.core.collections.SampleCollectionfrom whichsampleswere extracted. Ifsamplesis itself afiftyone.core.collections.SampleCollection, this parameter defaults tosamples. This parameter is optional and is only passed toDatasetExporter.log_collection()progress (None) – whether to render a progress bar (True/False), use the default value
fiftyone.config.show_progress_bars(None), or a progress callback function to invoke insteadnum_samples (None) – the number of samples in
samples. If omitted, this is computed (if possible) vialen(samples)if needed for progress tracking
- class fiftyone.utils.data.ExportPathsMixin#
Bases:
objectMixin for
DatasetExporterclasses that provides convenience methods for parsing thedata_path,labels_path, andexport_mediaparameters supported by many exporters.
- class fiftyone.utils.data.MediaExporter(export_mode, export_path=None, rel_dir=None, chunk_size=None, supported_modes=None, default_ext=None, ignore_exts=False)#
Bases:
objectBase class for
DatasetExporterutilities that provide support for populating a directory or manifest of media files.This class is designed for populating a single, flat directory or manifest of media files, and automatically takes care of things like name clashes as necessary.
The export strategy used is defined by the
export_modeparameter, and users of this class can restrict the available options via thesupported_modesparameter.- Parameters:
export_mode –
the export mode to use. The supported values are:
True: copy all media files into the output directoryFalse: don’t export media. This option is only useful when exporting labeled datasets whose label format stores sufficient information to locate the associated media"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory"manifest": create adata.jsonin the output directory that maps UUIDs used in the labels files to the filepaths of the source media, rather than exporting the actual media
export_path (None) –
the location to export the media. Can be any of the following:
When
export_mediais True, “move”, or “symlink”, a directory in which to export the mediaWhen
export_modeis “manifest”, the path to write a JSON file mapping UUIDs to input filepathsWhen
export_mediais False, this parameter has no effect
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each media. When exporting media, this identifier is joined with
export_pathto generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()chunk_size (None) – an optional chunk size to use when exporting media files. If provided, media files will be nested in subdirectories of the output directory with at most this many media files per subdirectory. Has no effect if a
rel_diris providedsupported_modes (None) – an optional tuple specifying a subset of the
export_modevalues that are alloweddefault_ext (None) – the file extension to use when generating default output paths
ignore_exts (False) – whether to omit file extensions when generating UUIDs for files
Methods:
setup()Performs necessary setup to begin exporting media.
export(media_or_path[, outpath])Exports the given media.
close()Performs any necessary actions to complete the export.
- setup()#
Performs necessary setup to begin exporting media.
DatasetExporterclasses using this class should invoke this method inDatasetExporter.setup().
- export(media_or_path, outpath=None)#
Exports the given media.
- Parameters:
media_or_path – the media or path to the media on disk
outpath (None) – a manually-specified location to which to export the media. By default, the media will be exported into
export_path
- Returns:
the path to the exported media
the UUID of the exported media
- Return type:
a tuple of
- close()#
Performs any necessary actions to complete the export.
- class fiftyone.utils.data.ImageExporter(*args, default_ext=None, **kwargs)#
Bases:
MediaExporterUtility class for
DatasetExporterinstances that export images.See
MediaExporterfor details.Methods:
close()Performs any necessary actions to complete the export.
export(media_or_path[, outpath])Exports the given media.
setup()Performs necessary setup to begin exporting media.
- close()#
Performs any necessary actions to complete the export.
- export(media_or_path, outpath=None)#
Exports the given media.
- Parameters:
media_or_path – the media or path to the media on disk
outpath (None) – a manually-specified location to which to export the media. By default, the media will be exported into
export_path
- Returns:
the path to the exported media
the UUID of the exported media
- Return type:
a tuple of
- setup()#
Performs necessary setup to begin exporting media.
DatasetExporterclasses using this class should invoke this method inDatasetExporter.setup().
- class fiftyone.utils.data.VideoExporter(*args, default_ext=None, **kwargs)#
Bases:
MediaExporterUtility class for
DatasetExporterinstances that export videos.See
MediaExporterfor details.Methods:
close()Performs any necessary actions to complete the export.
export(media_or_path[, outpath])Exports the given media.
setup()Performs necessary setup to begin exporting media.
- close()#
Performs any necessary actions to complete the export.
- export(media_or_path, outpath=None)#
Exports the given media.
- Parameters:
media_or_path – the media or path to the media on disk
outpath (None) – a manually-specified location to which to export the media. By default, the media will be exported into
export_path
- Returns:
the path to the exported media
the UUID of the exported media
- Return type:
a tuple of
- setup()#
Performs necessary setup to begin exporting media.
DatasetExporterclasses using this class should invoke this method inDatasetExporter.setup().
- class fiftyone.utils.data.DatasetExporter(export_dir=None)#
Bases:
objectBase interface for exporting datasets.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.export_sample(*args, **kwargs)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
- 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.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- export_sample(*args, **kwargs)#
Exports the given sample to the dataset.
- Parameters:
*args – subclass-specific positional arguments
**kwargs – subclass-specific keyword arguments
- 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.data.BatchDatasetExporter(export_dir=None)#
Bases:
DatasetExporterBase interface for exporters that export entire
fiftyone.core.collections.SampleCollectioninstances in a single batch.This interface allows for greater efficiency for export formats that handle aggregating over the samples themselves.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Methods:
export_sample(*args, **kwargs)Exports the given sample to the dataset.
export_samples(sample_collection[, progress])Exports the given sample collection.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- export_sample(*args, **kwargs)#
Exports the given sample to the dataset.
- Parameters:
*args – subclass-specific positional arguments
**kwargs – subclass-specific keyword arguments
- export_samples(sample_collection, progress=None)#
Exports the given sample collection.
- Parameters:
sample_collection – a
fiftyone.core.collections.SampleCollectionprogress (None) – whether 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
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.GenericSampleDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of arbitrary
fiftyone.core.sample.Sampleinstances.See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Methods:
export_sample(sample)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- export_sample(sample)#
Exports the given sample to the dataset.
- Parameters:
sample – a
fiftyone.core.sample.Sample
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.GroupDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting grouped datasets.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Methods:
export_sample(*args, **kwargs)Exports the given sample to the dataset.
export_group(group)Exports the given group to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- export_sample(*args, **kwargs)#
Exports the given sample to the dataset.
- Parameters:
*args – subclass-specific positional arguments
**kwargs – subclass-specific keyword arguments
- export_group(group)#
Exports the given group to the dataset.
- Parameters:
group – a dict mapping group slice names to
fiftyone.core.sample.Sampleinstances
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.UnlabeledImageDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of unlabeled image samples.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.Methods:
export_sample(image_or_path[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- export_sample(image_or_path, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
metadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.UnlabeledVideoDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of unlabeled video samples.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.Methods:
export_sample(video_path[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- export_sample(video_path, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
metadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.UnlabeledMediaDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of unlabeled samples.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Attributes:
Whether this exporter requires
fiftyone.core.metadata.Metadatainstances for each sample being exported.Methods:
export_sample(filepath[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- property requires_metadata#
Whether this exporter requires
fiftyone.core.metadata.Metadatainstances for each sample being exported.
- export_sample(filepath, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
filepath – a media path
metadata (None) – a
fiftyone.core.metadata.Metadatainstance for the sample. Only required whenrequires_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.LabeledImageDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of labeled image samples.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
export_sample(image_or_path, label[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. In this case, the exporter makes no guarantees about the labels that it can export
- export_sample(image_or_path, label, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.LabeledVideoDatasetExporter(export_dir=None)#
Bases:
DatasetExporterInterface for exporting datasets of labeled video samples.
See this page for information about implementing/using dataset exporters.
- Parameters:
export_dir (None) – the directory to write the export. This may be optional for some exporters
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.The
fiftyone.core.labels.Labelclass(es) that can be exported by this exporter at the frame-level.Methods:
export_sample(video_path, label, frames[, ...])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.setup()Performs any necessary setup before exporting the first sample in the dataset.
- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) that can be exported by this exporter at the frame-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. In this case, the exporter makes no guarantees about the frame labels that it can export
- export_sample(video_path, label, frames, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labelsframes – a dictionary mapping frame numbers to dictionaries that map field names to
fiftyone.core.labels.Labelinstances, orNoneif the sample has no frame-level labelsmetadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- 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__().
- class fiftyone.utils.data.LegacyFiftyOneDatasetExporter(export_dir, export_media=None, rel_dir=None, chunk_size=None, abs_paths=False, export_saved_views=True, export_runs=True, export_workspaces=True, pretty_print=False)#
Bases:
GenericSampleDatasetExporterLegacy exporter that writes an entire FiftyOne dataset to disk in a serialized JSON format along with its source media.
Warning
The
fiftyone.types.FiftyOneDatasetformat was upgraded infiftyone==0.8and this exporter is now deprecated. The new exporter isFiftyOneDatasetExporter.- Parameters:
export_dir – the directory to write the export
export_media (None) –
defines how to export the raw media contained in the dataset. The supported values are:
True(default): copy all media files into the export directoryFalse: don’t export media"move": move media files into the export directory"symlink": create symlinks to each media file in the export directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each media. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()chunk_size (None) – an optional chunk size to use when exporting media files. If provided, media files will be nested in subdirectories of the output directory with at most this many media files per subdirectory. Has no effect if a
rel_diris providedabs_paths (False) – whether to store absolute paths to the media in the exported labels
export_saved_views (True) – whether to include saved views in the export. Only applicable when exporting full datasets
export_runs (True) – whether to include annotation/brain/evaluation runs in the export. Only applicable when exporting full datasets
export_workspaces (True) – whether to include saved workspaces in the export. Only applicable when exporting full datasets
pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.export_sample(sample)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
- 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.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- export_sample(sample)#
Exports the given sample to the dataset.
- Parameters:
sample – a
fiftyone.core.sample.Sample
- 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.data.FiftyOneDatasetExporter(export_dir, export_media=None, rel_dir=None, chunk_size=None, export_saved_views=True, export_runs=True, export_workspaces=True, use_dirs=False, ordered=True)#
Bases:
BatchDatasetExporterExporter that writes an entire FiftyOne dataset to disk in a serialized JSON format along with its source media.
See this page for format details.
- Parameters:
export_dir – the directory to write the export
export_media (None) –
defines how to export the raw media contained in the dataset. The supported values are:
True(default): copy all media files into the export directoryFalse: don’t export media"move": move media files into the export directory"symlink": create symlinks to each media file in the export directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each media. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()chunk_size (None) – an optional chunk size to use when exporting media files. If provided, media files will be nested in subdirectories of the output directory with at most this many media files per subdirectory. Has no effect if a
rel_diris providedexport_saved_views (True) – whether to include saved views in the export. Only applicable when exporting full datasets
export_runs (True) – whether to include annotation/brain/evaluation runs in the export. Only applicable when exporting full datasets
export_workspaces (True) – whether to include saved workspaces in the export. Only applicable when exporting full datasets
use_dirs (False) – whether to export metadata into directories of per sample/frame files
ordered (True) – whether to preserve the order of the exported collections
Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_samples(sample_collection[, progress])Exports the given sample collection.
close(*args)Performs any necessary actions after the last sample has been exported.
export_sample(*args, **kwargs)Exports the given sample to the dataset.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- 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__().
- export_samples(sample_collection, progress=None)#
Exports the given sample collection.
- Parameters:
sample_collection – a
fiftyone.core.collections.SampleCollectionprogress (None) – whether 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
- 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__()
- export_sample(*args, **kwargs)#
Exports the given sample to the dataset.
- Parameters:
*args – subclass-specific positional arguments
**kwargs – subclass-specific keyword arguments
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.ImageDirectoryExporter(export_dir, export_media=None, rel_dir=None, image_format=None)#
Bases:
UnlabeledImageDatasetExporterExporter that writes a directory of images to disk.
See this page for format details.
The filenames of input image paths will be maintained in the export directory, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
defines how to export the raw media contained in the dataset. The supported values are:
True(default): copy all media files into the export directory"move": move media files into the export directory"symlink": create symlinks to each media file in the export directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported image. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis used
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(image_or_path[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- 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__().
- export_sample(image_or_path, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
metadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.VideoDirectoryExporter(export_dir, export_media=None, rel_dir=None)#
Bases:
UnlabeledVideoDatasetExporterExporter that writes a directory of videos to disk.
See this page for format details.
The filenames of the input videos will be maintained in the export directory, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
defines how to export the raw media contained in the dataset. The supported values are:
True(default): copy all media files into the export directory"move": move media files into the export directory"symlink": create symlinks to each media file in the export directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each video. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported video. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(video_path[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- 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__().
- export_sample(video_path, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
metadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.MediaDirectoryExporter(export_dir, export_media=None, rel_dir=None)#
Bases:
UnlabeledMediaDatasetExporterExporter that writes a directory of media files of arbitrary type to disk.
See this page for format details.
The filenames of the input media files will be maintained in the export directory, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
defines how to export the raw media contained in the dataset. The supported values are:
True(default): copy all media files into the export directory"move": move media files into the export directory"symlink": create symlinks to each media file in the export directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each output file. This identifier is joined with
export_dirto generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()
Attributes:
Whether this exporter requires
fiftyone.core.metadata.Metadatainstances for each sample being exported.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(filepath[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_metadata#
Whether this exporter requires
fiftyone.core.metadata.Metadatainstances for each sample being exported.
- 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__().
- export_sample(filepath, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
filepath – a media path
metadata (None) – a
fiftyone.core.metadata.Metadatainstance for the sample. Only required whenrequires_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.FiftyOneImageClassificationDatasetExporter(export_dir=None, data_path=None, labels_path=None, export_media=None, rel_dir=None, abs_paths=False, include_confidence=False, include_attributes=False, classes=None, image_format=None, pretty_print=False)#
Bases:
LabeledImageDatasetExporter,ExportPathsMixinExporter that writes an image classification dataset to disk in a simple JSON format.
See this page for format details.
If the path to an image is provided, the image is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir (None) – the directory to write the export. This has no effect if
data_pathandlabels_pathare absolute pathsdata_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 ofexport_dirin which to export the mediaan absolute directory path in which to export the media. In this case, the
export_dirhas no effect on the location of the dataa JSON filename like
"data.json"specifying the filename of the manifest file inexport_dirgenerated whenexport_mediais"manifest"an absolute filepath specifying the location to write the JSON manifest file when
export_mediais"manifest". In this case,export_dirhas 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_mediaparameterlabels_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.json"specifying the location inexport_dirin which to export the labelsan absolute filepath to which to export the labels. In this case, the
export_dirhas no effect on the location of the labels
If None, the labels will be exported into
export_dirusing the default filenameexport_media (None) –
controls how to export the raw media. The supported values are:
True: copy all media files into the output directoryFalse: 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 adata.jsonin 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_pathparameterrel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
data_pathto generate an output path for each exported image. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()abs_paths (False) – whether to store absolute paths to the images in the exported labels
include_confidence (False) –
whether to include classification confidences in the export. The supported values are:
False(default): do not include confidencesTrue: always include confidencesNone: include confidences only if they exist
include_attributes (False) –
whether to include dynamic attributes of the classifications in the export. Supported values are:
False(default): do not include attributesTrue: always include a (possibly empty) attributes dictNone: include attributes only if they exista name or iterable of names of specific attributes to include
classes (None) – the list of possible class labels
image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedpretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(image_or_path, label[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. 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__().
- export_sample(image_or_path, label, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.ImageClassificationDirectoryTreeExporter(export_dir, export_media=None, rel_dir=None, image_format=None)#
Bases:
LabeledImageDatasetExporterExporter that writes an image classification directory tree to disk.
See this page for format details.
The filenames of the input images are maintained, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
controls how to export the raw media. The supported values are:
True(default): copy all media files into the output directory"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported image. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis used
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(image_or_path, classification)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. 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__().
- export_sample(image_or_path, classification, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.VideoClassificationDirectoryTreeExporter(export_dir, export_media=None, rel_dir=None)#
Bases:
LabeledVideoDatasetExporterExporter that writes a video classification directory tree to disk.
See this page for format details.
The filenames of the input images are maintained, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
controls how to export the raw media. The supported values are:
True(default): copy all media files into the output directoryFalse: don’t export media"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each video. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported video. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.The
fiftyone.core.labels.Labelclass(es) that can be exported by this exporter at the frame-level.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(video_path, classification, _)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) that can be exported by this exporter at the frame-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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__().
- export_sample(video_path, classification, _, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labelsframes – a dictionary mapping frame numbers to dictionaries that map field names to
fiftyone.core.labels.Labelinstances, orNoneif the sample has no frame-level labelsmetadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.FiftyOneImageDetectionDatasetExporter(export_dir=None, data_path=None, labels_path=None, export_media=None, rel_dir=None, abs_paths=False, classes=None, include_confidence=None, include_attributes=None, image_format=None, pretty_print=False)#
Bases:
LabeledImageDatasetExporter,ExportPathsMixinExporter that writes an image detection dataset to disk in a simple JSON format.
See this page for format details.
If the path to an image is provided, the image is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir (None) – the directory to write the export. This has no effect if
data_pathandlabels_pathare absolute pathsdata_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 ofexport_dirin which to export the mediaan absolute directory path in which to export the media. In this case, the
export_dirhas no effect on the location of the dataa JSON filename like
"data.json"specifying the filename of the manifest file inexport_dirgenerated whenexport_mediais"manifest"an absolute filepath specifying the location to write the JSON manifest file when
export_mediais"manifest". In this case,export_dirhas 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_mediaparameterlabels_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.json"specifying the location inexport_dirin which to export the labelsan absolute filepath to which to export the labels. In this case, the
export_dirhas no effect on the location of the labels
If None, the labels will be exported into
export_dirusing the default filenameexport_media (None) –
controls how to export the raw media. The supported values are:
True: copy all media files into the output directoryFalse: 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 adata.jsonin 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_pathparameterrel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
data_pathto generate an output path for each exported image. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()abs_paths (False) – whether to store absolute paths to the images in the exported labels
classes (None) – the list of possible class labels
include_confidence (None) –
whether to include detection confidences in the export. The supported values are:
None(default): include confidences only if they existTrue: always include confidencesFalse: do not include confidences
include_attributes (None) –
whether to include dynamic attributes of the detections in the export. Supported values are:
None(default): include attributes only if they existTrue: always include a (possibly empty) attributes dictFalse: do not include attributesa name or iterable of names of specific attributes to include
image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedpretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(image_or_path, detections[, ...])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. 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__().
- export_sample(image_or_path, detections, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.FiftyOneTemporalDetectionDatasetExporter(export_dir=None, data_path=None, labels_path=None, export_media=None, rel_dir=None, abs_paths=False, use_timestamps=False, classes=None, include_confidence=None, include_attributes=None, pretty_print=False)#
Bases:
LabeledVideoDatasetExporter,ExportPathsMixinExporter that writes a temporal video detection dataset to disk in a simple JSON format.
See this page for format details.
Each input video is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir (None) – the directory to write the export. This has no effect if
data_pathandlabels_pathare absolute pathsdata_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 ofexport_dirin which to export the mediaan absolute directory path in which to export the media. In this case, the
export_dirhas no effect on the location of the dataa JSON filename like
"data.json"specifying the filename of the manifest file inexport_dirgenerated whenexport_mediais"manifest"an absolute filepath specifying the location to write the JSON manifest file when
export_mediais"manifest". In this case,export_dirhas 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_mediaparameterlabels_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.json"specifying the location inexport_dirin which to export the labelsan absolute filepath to which to export the labels. In this case, the
export_dirhas no effect on the location of the labels
If None, the labels will be exported into
export_dirusing the default filenameexport_media (None) –
controls how to export the raw media. The supported values are:
True: copy all media files into the output directoryFalse: 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 adata.jsonin 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_pathparameterrel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each video. When exporting media, this identifier is joined with
data_pathto generate an output path for each exported video. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()abs_paths (False) – whether to store absolute paths to the videos in the exported labels
use_timestamps (False) – whether to export the support of each temporal detection in seconds rather than frame numbers
classes (None) – the list of possible class labels
include_confidence (None) –
whether to include detection confidences in the export. The supported values are:
None(default): include confidences only if they existTrue: always include confidencesFalse: do not include confidences
include_attributes (None) –
whether to include dynamic attributes of the detections in the export. Supported values are:
None(default): include attributes only if they existTrue: always include a (possibly empty) attributes dictFalse: do not include attributesa name or iterable of names of specific attributes to include
pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.The
fiftyone.core.labels.Labelclass(es) that can be exported by this exporter at the frame-level.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(video_path, temporal_detections, _)Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) that can be exported by this exporter at the frame-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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__().
- export_sample(video_path, temporal_detections, _, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labelsframes – a dictionary mapping frame numbers to dictionaries that map field names to
fiftyone.core.labels.Labelinstances, orNoneif the sample has no frame-level labelsmetadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.ImageSegmentationDirectoryExporter(export_dir=None, data_path=None, labels_path=None, export_media=None, rel_dir=None, image_format=None, mask_format='.png', mask_size=None, mask_targets=None, thickness=1)#
Bases:
LabeledImageDatasetExporter,ExportPathsMixinExporter that writes an image segmentation dataset to disk.
See this page for format details.
If the path to an image is provided, the image is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir (None) – the directory to write the export. This has no effect if
data_pathandlabels_pathare absolute pathsdata_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 ofexport_dirin which to export the mediaan absolute directory path in which to export the media. In this case, the
export_dirhas no effect on the location of the dataa JSON filename like
"data.json"specifying the filename of the manifest file inexport_dirgenerated whenexport_mediais"manifest"an absolute filepath specifying the location to write the JSON manifest file when
export_mediais"manifest". In this case,export_dirhas 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_mediaparameterlabels_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 inexport_dirin which to export the masksan absolute directory in which to export the masks. In this case, the
export_dirhas no effect on the location of the masks
If None, the masks will be exported into
export_dirusing the default folder nameexport_media (None) –
controls how to export the raw media. The supported values are:
True: copy all media files into the output directoryFalse: 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 adata.jsonin 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_pathparameterrel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
data_pathandlabels_pathto generate output paths for each exported image and mask. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedmask_format (".png") – the image format to use when writing masks to disk
mask_size (None) – the
(width, height)at which to render segmentation masks when exporting instances or polylines. If not provided, masks will be rendered to match the resolution of each input imagemask_targets (None) – a dict mapping integer pixel values in
[0, 255]to label strings defining which object classes to render and which pixel values to use for each class. If omitted, all objects are rendered with pixel value 255thickness (1) – the thickness, in pixels, at which to render (non-filled) polylines
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
export_sample(image_or_path, label[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. 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__().
- export_sample(image_or_path, label, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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__()
- log_collection(sample_collection)#
Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- class fiftyone.utils.data.FiftyOneImageLabelsDatasetExporter(export_dir, export_media=None, rel_dir=None, image_format=None, pretty_print=False)#
Bases:
LabeledImageDatasetExporterExporter that writes a labeled image dataset to disk with labels stored in ETA ImageLabels format.
See this page for format details.
If the path to an image is provided, the image is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
controls how to export the raw media. The supported values are:
True(default): copy all media files into the output directory"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each image. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported image. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedpretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Attributes:
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) exported by this exporter.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.export_sample(image_or_path, labels[, metadata])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
- property requires_image_metadata#
Whether this exporter requires
fiftyone.core.metadata.ImageMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) exported by this exporter.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 dictsNone. 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.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- export_sample(image_or_path, labels, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
image_or_path – an image or the path to the image on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeledmetadata (None) – a
fiftyone.core.metadata.ImageMetadatainstance for the sample. Only required whenrequires_image_metadata()isTrue
- 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.data.FiftyOneVideoLabelsDatasetExporter(export_dir, export_media=None, rel_dir=None, pretty_print=False)#
Bases:
LabeledVideoDatasetExporterExporter that writes a labeled video dataset with labels stored in ETA VideoLabels format.
See this page for format details.
If the path to a video is provided, the video is directly copied to its destination, maintaining the original filename, unless a name conflict would occur, in which case an index of the form
"-%d" % countis appended to the base filename.- Parameters:
export_dir – the directory to write the export
export_media (None) –
controls how to export the raw media. The supported values are:
True(default): copy all media files into the output directory"move": move all media files into the output directory"symlink": create symlinks to the media files in the output directory
rel_dir (None) – an optional relative directory to strip from each input filepath to generate a unique identifier for each video. When exporting media, this identifier is joined with
export_dirto generate an output path for each exported video. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
Attributes:
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.The
fiftyone.core.labels.Labelclass(es) that can be exported by this exporter at the frame-level.Methods:
setup()Performs any necessary setup before exporting the first sample in the dataset.
log_collection(sample_collection)Logs any relevant information about the
fiftyone.core.collections.SampleCollectionwhose samples will be exported.export_sample(video_path, label, frames[, ...])Exports the given sample to the dataset.
close(*args)Performs any necessary actions after the last sample has been exported.
- property requires_video_metadata#
Whether this exporter requires
fiftyone.core.metadata.VideoMetadatainstances for each sample being exported.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) that can be exported at the sample-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) that can be exported by this exporter at the frame-level.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the exporter directly exports frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the exporter can export a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.SampleCollectionwhose 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()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 thefiftyone.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.SampleCollectionwhose samples will be exported
- export_sample(video_path, label, frames, metadata=None)#
Exports the given sample to the dataset.
- Parameters:
video_path – the path to a video on disk
label – an instance of
label_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labelsframes – a dictionary mapping frame numbers to dictionaries that map field names to
fiftyone.core.labels.Labelinstances, orNoneif the sample has no frame-level labelsmetadata (None) – a
fiftyone.core.metadata.VideoMetadatainstance for the sample. Only required whenrequires_video_metadata()isTrue
- 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.data.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])#
Bases:
dateThe year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
Attributes:
Methods:
timestamp[, tz] -> tz's local time from POSIX timestamp.
Construct a naive UTC datetime from a POSIX timestamp.
now()Returns new datetime object representing current time local to tz.
Return a new datetime representing UTC day and time.
date, time -> datetime with same date and time fields
string -> datetime from a string in most ISO 8601 formats
Return time tuple, compatible with time.localtime().
Return POSIX timestamp as float.
Return UTC time tuple, compatible with time.localtime().
Return date object with same year, month and day.
Return time object with same time but with tzinfo=None.
Return time object with same time and tzinfo.
Return datetime with new specified fields.
tz -> convert to local time in new timezone tz
Return ctime() style string.
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].
string, format -> new datetime parsed from a string (like time.strptime()).
Return self.tzinfo.utcoffset(self).
Return self.tzinfo.tzname(self).
Return self.tzinfo.dst(self).
int, int, int -> Construct a date from the ISO year, week number and weekday.
int -> date corresponding to a proleptic Gregorian ordinal.
Return a named tuple containing ISO year, week number, and weekday.
Return the day of the week represented by the date.
format -> strftime() style string.
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
Return proleptic Gregorian ordinal.
Return the day of the week represented by the date.
- hour#
- minute#
- second#
- microsecond#
- tzinfo#
- fold#
- fromtimestamp()#
timestamp[, tz] -> tz’s local time from POSIX timestamp.
- utcfromtimestamp()#
Construct a naive UTC datetime from a POSIX timestamp.
- now()#
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- utcnow()#
Return a new datetime representing UTC day and time.
- combine()#
date, time -> datetime with same date and time fields
- fromisoformat()#
string -> datetime from a string in most ISO 8601 formats
- timetuple()#
Return time tuple, compatible with time.localtime().
- timestamp()#
Return POSIX timestamp as float.
- utctimetuple()#
Return UTC time tuple, compatible with time.localtime().
- date()#
Return date object with same year, month and day.
- time()#
Return time object with same time but with tzinfo=None.
- timetz()#
Return time object with same time and tzinfo.
- replace()#
Return datetime with new specified fields.
- astimezone()#
tz -> convert to local time in new timezone tz
- ctime()#
Return ctime() style string.
- isoformat()#
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.
- strptime()#
string, format -> new datetime parsed from a string (like time.strptime()).
- utcoffset()#
Return self.tzinfo.utcoffset(self).
- tzname()#
Return self.tzinfo.tzname(self).
- dst()#
Return self.tzinfo.dst(self).
- day#
- fromisocalendar()#
int, int, int -> Construct a date from the ISO year, week number and weekday.
This is the inverse of the date.isocalendar() function
- fromordinal()#
int -> date corresponding to a proleptic Gregorian ordinal.
- isocalendar()#
Return a named tuple containing ISO year, week number, and weekday.
- isoweekday()#
Return the day of the week represented by the date. Monday == 1 … Sunday == 7
- max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)#
- min = datetime.datetime(1, 1, 1, 0, 0)#
- month#
- resolution = datetime.timedelta(microseconds=1)#
- strftime()#
format -> strftime() style string.
- today()#
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
- toordinal()#
Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
- weekday()#
Return the day of the week represented by the date. Monday == 0 … Sunday == 6
- year#
- fiftyone.utils.data.get_document(name)#
Get a registered Document class by name.
- class fiftyone.utils.data.Sample(filepath, tags=None, metadata=None, **kwargs)#
Bases:
_SampleMixin,DocumentA sample in a
fiftyone.core.dataset.Dataset.Samples store all information associated with a particular piece of data in a dataset, including basic metadata about the data, one or more sets of labels (ground truth, user-provided, or FiftyOne-generated), and additional features associated with subsets of the data and/or label sets.
Note
Sampleinstances that are in datasets are singletons, i.e.,dataset[sample_id]will always return the sameSampleinstance.- Parameters:
filepath – the path to the data on disk. The path is converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path()tags (None) – a list of tags for the sample
metadata (None) – a
fiftyone.core.metadata.Metadatainstance**kwargs – additional fields to dynamically set on the sample
Methods:
reload([hard, include_frames])Reloads the sample from the database.
save()Saves the sample to the database.
from_frame(frame[, filepath])Creates a sample from the given frame.
from_doc(doc[, dataset])Creates a sample backed by the given document.
from_dict(d)Loads the sample from a JSON dictionary.
add_labels(labels[, label_field, ...])Adds the given labels to the sample.
clear_field(field_name)Clears the value of a field of the document.
compute_metadata([overwrite, skip_failures])Populates the
metadatafield of the sample.copy([fields, omit_fields])Returns a deep copy of the sample that has not been added to the database.
from_json(s)Loads the document from a JSON string.
get_field(field_name)Gets the value of a field of the document.
has_field(field_name)Determines whether the document has the given field.
iter_fields([include_id, include_timestamps])Returns an iterator over the
(name, value)pairs of the public fields of the document.merge(sample[, fields, omit_fields, ...])Merges the fields of the given sample into this sample.
set_field(field_name, value[, create, ...])Sets the value of a field of the document.
to_dict([include_frames, include_private])Serializes the sample to a JSON dictionary.
to_json([pretty_print])Serializes the document to a JSON string.
to_mongo_dict([include_id])Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database.
update_fields(fields_dict[, expand_schema, ...])Sets the dictionary of fields on the document.
Attributes:
The dataset to which this document belongs, or
Noneif it has not been added to a dataset.An ordered tuple of the public field names of this document.
The basename of the media's filepath.
Whether the document has been added to a dataset.
The media type of the sample.
- reload(hard=False, include_frames=True)#
Reloads the sample from the database.
- Parameters:
hard (False) – whether to reload the sample’s schema in addition to its field values. This is necessary if new fields may have been added to the dataset schema
include_frames (True) – whether to reload any in-memory frames of video samples
- save()#
Saves the sample to the database.
- classmethod from_frame(frame, filepath=None)#
Creates a sample from the given frame.
- Parameters:
frame – a
fiftyone.core.frame.Framefilepath (None) – the path to the corresponding image frame on disk, if not available
- Returns:
a
Sample
- classmethod from_doc(doc, dataset=None)#
Creates a sample backed by the given document.
- Parameters:
doc – a
fiftyone.core.odm.sample.DatasetSampleDocumentorfiftyone.core.odm.sample.NoDatasetSampleDocumentdataset (None) – the
fiftyone.core.dataset.Datasetthat the sample belongs to
- Returns:
a
Sample
- classmethod from_dict(d)#
Loads the sample from a JSON dictionary.
The returned sample will not belong to a dataset.
- Returns:
a
Sample
- add_labels(labels, label_field=None, confidence_thresh=None, expand_schema=True, validate=True, dynamic=False)#
Adds the given labels to the sample.
The provided
labelscan be any of the following:A
fiftyone.core.labels.Labelinstance, in which case the labels are directly saved in the specifiedlabel_fieldA dict mapping keys to
fiftyone.core.labels.Labelinstances. In this case, the labels are added as follows:for key, value in labels.items(): sample[label_key(key)] = value
A dict mapping frame numbers to
fiftyone.core.labels.Labelinstances. In this case, the provided labels are interpreted as frame-level labels that should be added as follows:sample.frames.merge( { frame_number: {label_field: label} for frame_number, label in labels.items() } )
A dict mapping frame numbers to dicts mapping keys to
fiftyone.core.labels.Labelinstances. In this case, the provided labels are interpreted as frame-level labels that should be added as follows:sample.frames.merge( { frame_number: { label_key(key): value for key, value in frame_dict.items() } for frame_number, frame_dict in labels.items() } )
In the above, the
label_keyfunction maps label dict keys to field names, and is defined fromlabel_fieldas follows:if isinstance(label_field, dict): label_key = lambda k: label_field.get(k, k) elif label_field is not None: label_key = lambda k: label_field + "_" + k else: label_key = lambda k: k
- Parameters:
labels – a
fiftyone.core.labels.Labelor dict of labels per the description abovelabel_field (None) – the sample field, prefix, or dict defining in which field(s) to save the labels
confidence_thresh (None) – an optional confidence threshold to apply to any applicable labels before saving them
expand_schema (True) – whether to dynamically add new fields encountered to the dataset schema. If False, an error is raised if any fields are not in the dataset schema
validate (True) – whether to validate values for existing fields
dynamic (False) – whether to declare dynamic attributes
- clear_field(field_name)#
Clears the value of a field of the document.
- Parameters:
field_name – the name of the field to clear
- Raises:
AttributeError – if the field does not exist
- compute_metadata(overwrite=False, skip_failures=False)#
Populates the
metadatafield of the sample.- Parameters:
overwrite (False) – whether to overwrite existing metadata
skip_failures (False) – whether to gracefully continue without raising an error if metadata cannot be computed
- copy(fields=None, omit_fields=None)#
Returns a deep copy of the sample that has not been added to the database.
- Parameters:
fields (None) – an optional field or iterable of fields to which to restrict the copy. This can also be a dict mapping existing field names to new field names
omit_fields (None) – an optional field or iterable of fields to exclude from the copy
- Returns:
a
Sample
- property dataset#
The dataset to which this document belongs, or
Noneif it has not been added to a dataset.
- property dataset_id#
- property field_names#
An ordered tuple of the public field names of this document.
- property filename#
The basename of the media’s filepath.
- classmethod from_json(s)#
Loads the document from a JSON string.
The returned document will not belong to a dataset.
- Parameters:
s – the JSON string
- Returns:
a
Document
- get_field(field_name)#
Gets the value of a field of the document.
- Parameters:
field_name – the field name
- Returns:
the field value
- Raises:
AttributeError – if the field does not exist
- has_field(field_name)#
Determines whether the document has the given field.
- Parameters:
field_name – the field name
- Returns:
True/False
- property in_dataset#
Whether the document has been added to a dataset.
- iter_fields(include_id=False, include_timestamps=False)#
Returns an iterator over the
(name, value)pairs of the public fields of the document.- Parameters:
include_id (False) – whether to include the
idfieldinclude_timestamps (False) – whether to include the
created_atandlast_modified_atfields
- Returns:
an iterator that emits
(name, value)tuples
- property media_type#
The media type of the sample.
- merge(sample, fields=None, omit_fields=None, merge_lists=True, merge_embedded_docs=False, overwrite=True, expand_schema=True, validate=True, dynamic=False)#
Merges the fields of the given sample into this sample.
The behavior of this method is highly customizable. By default, all top-level fields from the provided sample are merged in, overwriting any existing values for those fields, with the exception of list fields (e.g.,
tags) and label list fields (e.g.,fiftyone.core.labels.Detectionsfields), in which case the elements of the lists themselves are merged. In the case of label list fields, labels with the sameidin both samples are updated rather than duplicated.To avoid confusion between missing fields and fields whose value is
None,None-valued fields are always treated as missing while merging.This method can be configured in numerous ways, including:
Whether new fields can be added to the dataset schema
Whether list fields should be treated as ordinary fields and merged as a whole rather than merging their elements
Whether to merge only specific fields, or all but certain fields
Mapping input sample fields to different field names of this sample
- Parameters:
sample – a
fiftyone.core.sample.Samplefields (None) – an optional field or iterable of fields to which to restrict the merge. May contain frame fields for video samples. This can also be a dict mapping field names of the input sample to field names of this sample
omit_fields (None) – an optional field or iterable of fields to exclude from the merge. May contain frame fields for video samples
merge_lists (True) – whether to merge the elements of list fields (e.g.,
tags) and label list fields (e.g.,fiftyone.core.labels.Detectionsfields) rather than merging the entire top-level field like other field types. For label lists fields, existingfiftyone.core.label.Labelelements are either replaced (whenoverwriteis True) or kept (whenoverwriteis False) when theiridmatches a label from the provided samplemerge_embedded_docs (False) – whether to merge the attributes of embedded documents (True) rather than merging the entire top-level field (False)
overwrite (True) – whether to overwrite (True) or skip (False) existing fields and label elements
expand_schema (True) – whether to dynamically add new fields encountered to the dataset schema. If False, an error is raised if any fields are not in the dataset schema
validate (True) – whether to validate values for existing fields
dynamic (False) – whether to declare dynamic embedded document fields
- set_field(field_name, value, create=True, validate=True, dynamic=False)#
Sets the value of a field of the document.
- Parameters:
field_name – the field name
value – the field value
create (True) – whether to create the field if it does not exist
validate (True) – whether to validate values for existing fields
dynamic (False) – whether to declare dynamic embedded document fields
- Raises:
ValueError – if
field_nameis not an allowed field nameAttributeError – if the field does not exist and
create == False
- to_dict(include_frames=False, include_private=False)#
Serializes the sample to a JSON dictionary.
- Parameters:
include_frames (False) – whether to include the frame labels for video samples
include_private (False) – whether to include private fields
- Returns:
a JSON dict
- to_json(pretty_print=False)#
Serializes the document to a JSON string.
The document ID and private fields are excluded in this representation.
- Parameters:
pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
- Returns:
a JSON string
- to_mongo_dict(include_id=False)#
Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database.
- Parameters:
include_id (False) – whether to include the document ID
- Returns:
a BSON dict
- update_fields(fields_dict, expand_schema=True, validate=True, dynamic=False)#
Sets the dictionary of fields on the document.
- Parameters:
fields_dict – a dict mapping field names to values
expand_schema (True) – whether to dynamically add new fields encountered to the document schema. If False, an error is raised if any fields are not in the document schema
validate (True) – whether to validate values for existing fields
dynamic (False) – whether to declare dynamic embedded document fields
- Raises:
AttributeError – if
expand_schema == Falseand a field does not exist
- class fiftyone.utils.data.FiftyOneImageClassificationSampleParser(classes=None)#
Bases:
ImageClassificationSampleParserParser for samples in FiftyOne image classification datasets.
See this page for format details.
- Parameters:
classes (None) – an optional list of class label strings. If provided, it is assumed that
targetis a class ID that should be mapped to a label string viaclasses[target]
Methods:
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
Returns the label for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Attributes:
The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
The
fiftyone.core.labels.Labelclass(es) returned by this parser.- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_label()#
Returns the label for the current sample.
- Parameters:
sample – the sample
- Returns:
a
fiftyone.core.labels.Classificationinstance
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneTemporalDetectionSampleParser(classes=None, compute_metadata=False)#
Bases:
LabeledVideoSampleParserParser for samples in FiftyOne temporal detection datasets.
See this page for format details.
- Parameters:
classes (None) – an optional list of class label strings. If provided, it is assumed that
targetis a class ID that should be mapped to a label string viaclasses[target]compute_metadata (False) – whether to compute
fiftyone.core.metadata.VideoMetadatainstances on-the-fly ifget_video_metadata()is called and no metadata is available
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.The current sample.
Methods:
with_sample(sample[, metadata])Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Returns the video path for the current sample.
Returns the video metadata for the current sample.
Returns the sample-level labels for the current sample.
Returns the frame labels for the current sample.
Clears the current sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the sample-level labels that it may return
- property frame_labels_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone. In this case, the parser makes no guarantees about the frame labels that it may return
- with_sample(sample, metadata=None)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_label()#
Returns the sample-level labels for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labels
- get_frame_labels()#
Returns the frame labels for the current sample.
- Returns:
a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frame, orNoneif the sample has no frame labels
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- class fiftyone.utils.data.FiftyOneImageDetectionSampleParser(classes=None)#
Bases:
ImageDetectionSampleParserParser for samples in FiftyOne image detection datasets.
See this page for format details.
- Parameters:
classes (None) – an optional list of class label strings. If provided, it is assumed that the
targetvalues are class IDs that should be mapped to label strings viaclasses[target]
Methods:
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
Returns the label for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Attributes:
The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
The
fiftyone.core.labels.Labelclass(es) returned by this parser.- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_label()#
Returns the label for the current sample.
- Returns:
a
fiftyone.core.labels.Detectionsinstance
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneImageLabelsSampleParser(prefix=None, labels_dict=None, multilabel=False, skip_non_categorical=False)#
Bases:
ImageLabelsSampleParserParser for samples in FiftyOne image labels datasets.
See this page for format details.
- Parameters:
prefix (None) – a string prefix to prepend to each label name in the expanded label dictionary
labels_dict (None) – a dictionary mapping names of attributes/objects in the image labels to field names into which to expand them
multilabel (False) – whether to store attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical attributes (True) or cast them to strings (False)
Methods:
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
Returns the label for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Attributes:
The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
The
fiftyone.core.labels.Labelclass(es) returned by this parser.- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_label()#
Returns the label for the current sample.
- Returns:
a labels dictionary
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.FiftyOneVideoLabelsSampleParser(prefix=None, labels_dict=None, frame_labels_dict=None, multilabel=False, skip_non_categorical=False)#
Bases:
VideoLabelsSampleParserParser for samples in FiftyOne video labels datasets.
See this page for format details.
- Parameters:
expand (True) – whether to expand the labels for each frame into separate
fiftyone.core.labels.Labelinstancesprefix (None) – a string prefix to prepend to each label name in the expanded frame label dictionaries
labels_dict (None) – a dictionary mapping names of attributes/objects in the frame labels to field names into which to expand them
multilabel (False) – whether to store attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical attributes (True) or cast them to strings (False)
Methods:
Clears the current sample.
Returns the frame labels for the current sample.
Returns the sample-level labels for the current sample.
Returns the video metadata for the current sample.
Returns the video path for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Attributes:
The current sample.
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- property frame_labels_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone. In this case, the parser makes no guarantees about the frame labels that it may return
- get_frame_labels()#
Returns the frame labels for the current sample.
- Returns:
a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frame, orNoneif the sample has no frame labels
- get_label()#
Returns the sample-level labels for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labels
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the sample-level labels that it may return
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- fiftyone.utils.data.import_samples(dataset, dataset_importer, label_field=None, tags=None, expand_schema=True, dynamic=False, add_info=True, generator=False, progress=None)#
Adds the samples from the given
DatasetImporterto the dataset.See this guide for more details about importing datasets in custom formats by defining your own
DatasetImporter.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetdataset_importer – a
DatasetImporterlabel_field (None) – controls the field(s) in which imported labels are stored. Only applicable if
dataset_importeris aLabeledImageDatasetImporterorLabeledVideoDatasetImporter. If the importer produces a singlefiftyone.core.labels.Labelinstance per sample/frame, this argument specifies the name of the field to use; the default is"ground_truth". If the importer produces a dictionary of labels per sample, this argument can be either a string prefix to prepend to each label key or a dict mapping label keys to field names; the default in this case is to directly use the keys of the imported label dictionaries as field namestags (None) – an optional tag or iterable of tags to attach to each sample
expand_schema (True) – whether to dynamically add new sample fields encountered to the dataset schema. If False, an error is raised if a sample’s schema is not a subset of the dataset schema
dynamic (False) – whether to declare dynamic attributes of embedded document fields that are encountered
add_info (True) – whether to add dataset info from the importer (if any) to the dataset
generator (False) – whether to yield ID batches as a generator as samples are added to the dataset
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- fiftyone.utils.data.merge_samples(dataset, dataset_importer, label_field=None, tags=None, key_field='filepath', key_fcn=None, skip_existing=False, insert_new=True, fields=None, omit_fields=None, merge_lists=True, merge_embedded_docs=False, overwrite=True, expand_schema=True, dynamic=False, add_info=True, progress=None)#
Merges the samples from the given
DatasetImporterinto the dataset.See this guide for more details about importing datasets in custom formats by defining your own
DatasetImporter.By default, samples with the same absolute
filepathare merged, but you can customize this behavior via thekey_fieldandkey_fcnparameters. For example, you could setkey_fcn = lambda sample: os.path.basename(sample.filepath)to merge samples with the same base filename.The behavior of this method is highly customizable. By default, all top-level fields from the imported samples are merged in, overwriting any existing values for those fields, with the exception of list fields (e.g.,
tags) and label list fields (e.g.,fiftyone.core.labels.Detectionsfields), in which case the elements of the lists themselves are merged. In the case of label list fields, labels with the sameidin both collections are updated rather than duplicated.To avoid confusion between missing fields and fields whose value is
None,None-valued fields are always treated as missing while merging.This method can be configured in numerous ways, including:
Whether existing samples should be modified or skipped
Whether new samples should be added or omitted
Whether new fields can be added to the dataset schema
Whether list fields should be treated as ordinary fields and merged as a whole rather than merging their elements
Whether to merge only specific fields, or all but certain fields
Mapping input fields to different field names of this dataset
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetdataset_importer – a
DatasetImporterlabel_field (None) – controls the field(s) in which imported labels are stored. Only applicable if
dataset_importeris aLabeledImageDatasetImporterorLabeledVideoDatasetImporter. If the importer produces a singlefiftyone.core.labels.Labelinstance per sample/frame, this argument specifies the name of the field to use; the default is"ground_truth". If the importer produces a dictionary of labels per sample, this argument can be either a string prefix to prepend to each label key or a dict mapping label keys to field names; the default in this case is to directly use the keys of the imported label dictionaries as field namestags (None) – an optional tag or iterable of tags to attach to each sample
key_field ("filepath") – the sample field to use to decide whether to join with an existing sample
key_fcn (None) – a function that accepts a
fiftyone.core.sample.Sampleinstance and computes a key to decide if two samples should be merged. If akey_fcnis provided,key_fieldis ignoredskip_existing (False) – whether to skip existing samples (True) or merge them (False)
insert_new (True) – whether to insert new samples (True) or skip them (False)
fields (None) – an optional field or iterable of fields to which to restrict the merge. If provided, fields other than these are omitted from
sampleswhen merging or adding samples. One exception is thatfilepathis always included when adding new samples, since the field is required. This can also be a dict mapping field names of the input collection to field names of this datasetomit_fields (None) – an optional field or iterable of fields to exclude from the merge. If provided, these fields are omitted from imported samples, if present. One exception is that
filepathis always included when adding new samples, since the field is requiredmerge_lists (True) – whether to merge the elements of list fields (e.g.,
tags) and label list fields (e.g.,fiftyone.core.labels.Detectionsfields) rather than merging the entire top-level field like other field types. For label lists fields, existingfiftyone.core.label.Labelelements are either replaced (whenoverwriteis True) or kept (whenoverwriteis False) when theiridmatches a label from the provided samplesmerge_embedded_docs (False) – whether to merge the attributes of embedded documents (True) rather than merging the entire top-level field (False)
overwrite (True) – whether to overwrite (True) or skip (False) existing fields and label elements
expand_schema (True) – whether to dynamically add new fields encountered to the dataset schema. If False, an error is raised if a sample’s schema is not a subset of the dataset schema
dynamic (False) – whether to declare dynamic attributes of embedded document fields that are encountered
add_info (True) – whether to add dataset info from the importer (if any) to the dataset
progress (None) – whether 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
- fiftyone.utils.data.parse_dataset_info(dataset, info, overwrite=True)#
Parses the info returned by
DatasetImporter.get_dataset_info()and stores it on the relevant properties of the dataset.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetinfo – an info dict
overwrite (True) – whether to overwrite existing dataset info fields
- class fiftyone.utils.data.ImportPathsMixin#
Bases:
objectMixin for
DatasetImporterclasses that provides convenience methods for parsing thedata_pathandlabels_pathparameters supported by many importers.
- class fiftyone.utils.data.DatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
objectBase interface for importing datasets stored on disk into FiftyOne.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
subclass-specific information for the sample
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces a dataset info dictionary.
Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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.data.BatchDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterBase interface for importers that load all of their samples in a single call to
import_samples().This interface allows for greater efficiency for import formats that handle aggregating over the samples themselves.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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:
import_samples(dataset[, tags, progress])Imports the samples into the given dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
Attributes:
Whether this importer produces a dataset info dictionary.
- import_samples(dataset, tags=None, progress=None)#
Imports the samples into the given dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasettags (None) – an optional list of tags to attach to each sample
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.GenericSampleDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets that contain arbitrary
fiftyone.core.sample.Sampleinstances.Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
a
fiftyone.core.sample.Sampleinstance- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces a sample field schema.
Whether this importer produces a dataset info dictionary.
Methods:
Returns a dictionary describing the field schema of the samples loaded by this importer.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_sample_field_schema#
Whether this importer produces a sample field schema.
- get_sample_field_schema()#
Returns a dictionary describing the field schema of the samples loaded by this importer.
- Returns:
a dict mapping field names to
fiftyone.core.fields.Fieldinstances orstr(field)representations of them
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.GroupDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
GenericSampleDatasetImporterInterface for importing datasets that contain arbitrary grouped
fiftyone.core.sample.Sampleinstances.Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported across all group slices.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next group in the dataset.
- Returns:
a dict mapping slice names to
fiftyone.core.sample.Sampleinstances- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
The name of the group field to populate on each sample.
Whether this importer produces a dataset info dictionary.
Whether this importer produces a sample field schema.
Methods:
Returns a dictionary describing the group slices of the samples loaded by this importer.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
Returns a dictionary describing the field schema of the samples loaded by this importer.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property group_field#
The name of the group field to populate on each sample.
- get_group_media_types()#
Returns a dictionary describing the group slices of the samples loaded by this importer.
- Returns:
a dict mapping slice names to media types
- 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__()
- 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
- get_sample_field_schema()#
Returns a dictionary describing the field schema of the samples loaded by this importer.
- Returns:
a dict mapping field names to
fiftyone.core.fields.Fieldinstances orstr(field)representations of them
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_sample_field_schema#
Whether this importer produces a sample field schema.
- 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__().
- class fiftyone.utils.data.UnlabeledImageDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets of unlabeled image samples.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
an
(image_path, image_metadata)tuple, whereimage_path: the path to the image on diskimage_metadata: anfiftyone.core.metadata.ImageMetadatainstances for the image, orNoneifhas_image_metadata()isFalse
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.Whether this importer produces a dataset info dictionary.
Methods:
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.UnlabeledVideoDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets of unlabeled video samples.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
an
(video_path, video_metadata)tuple, wherevideo_path: the path to the video on diskvideo_metadata: anfiftyone.core.metadata.VideoMetadatainstances for the video, orNoneifhas_video_metadata()isFalse
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.Whether this importer produces a dataset info dictionary.
Methods:
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.UnlabeledMediaDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets of unlabeled media samples.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
an
(filepath, metadata)tuple, wherefilepath: the path to the media on diskmetadata: afiftyone.core.metadata.Metadatainstance for the media, orNoneifhas_metadata()isFalse
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.Metadatainstances for each sample.Whether this importer produces a dataset info dictionary.
Methods:
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_metadata#
Whether this importer produces
fiftyone.core.metadata.Metadatainstances for each sample.
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.LabeledImageDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets of labeled image samples.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
an
(image_path, image_metadata, label)tuple, whereimage_path: the path to the image on diskimage_metadata: anfiftyone.core.metadata.ImageMetadatainstances for the image, orNoneifhas_image_metadata()isFalselabel: an instance oflabel_cls(), or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeled
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Whether this importer produces a dataset info dictionary.
Methods:
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. In this case, the importer makes no guarantees about the labels that it may return
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.LabeledVideoDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
DatasetImporterInterface for importing datasets of labeled video samples.
Typically, dataset importers should implement the parameters documented on this class, although this is not mandatory.
See this page for information about implementing/using dataset importers.
- __len__()#
The total number of samples that will be imported.
- Raises:
TypeError – if the total number is not known
- __next__()#
Returns information about the next sample in the dataset.
- Returns:
an
(video_path, video_metadata, labels, frames)tuple, wherevideo_path: the path to the video on diskvideo_metadata: anfiftyone.core.metadata.VideoMetadatainstances for the video, orNoneifhas_video_metadata()isFalselabels: sample-level labels for the video, which can be any of the following:a
fiftyone.core.labels.Labelinstancea dictionary mapping label fields to
fiftyone.core.labels.LabelinstancesNoneif the sample has no sample-level labels
frames: frame-level labels for the video, which can be any of the following:a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frameNoneif the sample has no frame-level labels
- Raises:
StopIteration – if there are no more samples to import
- Parameters:
dataset_dir (None) – the dataset directory. This may be optional for some importers
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the frame labels that it produces.Whether this importer produces a dataset info dictionary.
Methods:
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
setup()Performs any necessary setup before importing the first sample in the dataset.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 frameNone. In this case, the importer makes no guarantees about the frame labels that it may return
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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__().
- class fiftyone.utils.data.LegacyFiftyOneDatasetImporter(dataset_dir, rel_dir=None, import_saved_views=True, import_runs=True, import_workspaces=True, shuffle=False, seed=None, max_samples=None)#
Bases:
GenericSampleDatasetImporterLegacy importer for FiftyOne datasets stored on disk in a serialized JSON format.
Warning
The
fiftyone.types.FiftyOneDatasetformat was upgraded infiftyone==0.8and this importer is now deprecated.However, to maintain backwards compatibility,
FiftyOneDatasetImporterwill check for instances of datasets of this type at runtime and defer to this class to load them.- Parameters:
dataset_dir – the dataset directory
rel_dir (None) – a relative directory to prepend to each filepath if it is not absolute. This path is converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path()import_saved_views (True) – whether to include saved views in the import. Only applicable when importing full datasets
import_runs (True) – whether to include annotation/brain/evaluation runs in the import. Only applicable when importing full datasets
import_workspaces (True) – whether to include saved workspaces in the import. Only applicable when importing full datasets
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
Attributes:
Whether this importer produces a sample field schema.
Whether this importer produces a dataset info dictionary.
Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns a dictionary describing the field schema of the samples loaded by this importer.
Returns the dataset info for the dataset.
import_extras(sample_collection)close(*args)Performs any necessary actions after the last sample has been imported.
- property has_sample_field_schema#
Whether this importer produces a sample field schema.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- 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_sample_field_schema()#
Returns a dictionary describing the field schema of the samples loaded by this importer.
- Returns:
a dict mapping field names to
fiftyone.core.fields.Fieldinstances orstr(field)representations of them
- 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
- import_extras(sample_collection)#
- 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.data.FiftyOneDatasetImporter(dataset_dir, rel_dir=None, import_saved_views=True, import_runs=True, import_workspaces=True, ordered=True, shuffle=False, seed=None, max_samples=None)#
Bases:
BatchDatasetImporterImporter for FiftyOne datasets stored on disk in serialized JSON format.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
rel_dir (None) – a relative directory to prepend to the
filepathof each sample if the filepath is not absolute. This path is converted to an absolute path (if necessary) viafiftyone.core.storage.normalize_path()import_saved_views (True) – whether to include saved views in the import. Only applicable when importing full datasets
import_runs (True) – whether to include annotation/brain/evaluation runs in the import. Only applicable when importing full datasets
import_workspaces (True) – whether to include saved workspaces in the import. Only applicable when importing full datasets
ordered (True) – whether to preserve document order when importing
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:
setup()Performs any necessary setup before importing the first sample in the dataset.
import_samples(dataset[, tags, progress])Imports the samples into the given dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
Attributes:
Whether this importer produces a dataset info dictionary.
- 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__().
- import_samples(dataset, tags=None, progress=None)#
Imports the samples into the given dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasettags (None) – an optional list of tags to attach to each sample
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- 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__()
- 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
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- class fiftyone.utils.data.ImageDirectoryImporter(dataset_dir, recursive=True, compute_metadata=False, shuffle=False, seed=None, max_samples=None)#
Bases:
UnlabeledImageDatasetImporterImporter for a directory of images stored on disk.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
recursive (True) – whether to recursively traverse subdirectories
compute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importingshuffle (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- 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__().
- 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__()
- 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
- class fiftyone.utils.data.VideoDirectoryImporter(dataset_dir, recursive=True, compute_metadata=False, shuffle=False, seed=None, max_samples=None)#
Bases:
UnlabeledVideoDatasetImporterImporter for a directory of videos stored on disk.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
recursive (True) – whether to recursively traverse subdirectories
compute_metadata (False) – whether to produce
fiftyone.core.metadata.VideoMetadatainstances for each video when importingshuffle (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- 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__().
- 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__()
- 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
- class fiftyone.utils.data.MediaDirectoryImporter(dataset_dir, recursive=True, compute_metadata=False, shuffle=False, seed=None, max_samples=None)#
Bases:
UnlabeledMediaDatasetImporterImporter for a directory of media files stored on disk.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
recursive (True) – whether to recursively traverse subdirectories
compute_metadata (False) – whether to produce
fiftyone.core.metadata.Metadatainstances for each media file when importingshuffle (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.Metadatainstances for each sample.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_metadata#
Whether this importer produces
fiftyone.core.metadata.Metadatainstances for each sample.
- 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__().
- 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__()
- 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
- class fiftyone.utils.data.FiftyOneImageClassificationDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, compute_metadata=False, include_all_data=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledImageDatasetImporter,ImportPathsMixinImporter for image classification datasets stored on disk in a simple JSON format.
See this page for format details.
- Parameters:
dataset_dir (None) – the dataset directory. If omitted,
data_pathand/orlabels_pathmust be provideddata_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 ofdataset_dirwhere the media files residean absolute directory path where the media files reside. In this case, the
dataset_dirhas no effect on the location of the dataa filename like
"data.json"specifying the filename of the JSON data manifest file indataset_diran absolute filepath specifying the location of the JSON data manifest. In this case,
dataset_dirhas no effect on the location of the dataa dict mapping filenames to absolute filepaths
If None, this parameter will default to whichever of
data/ordata.jsonexists in the dataset directorylabels_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.json"specifying the location of the labels indataset_diran absolute filepath to the labels. In this case,
dataset_dirhas no effect on the location of the labels
If None, the parameter will default to
labels.jsoncompute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importinginclude_all_data (False) – whether to generate samples for all images in the data directory (True) rather than only creating samples for images with labels (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.data.ImageClassificationDirectoryTreeImporter(dataset_dir, compute_metadata=False, classes=None, unlabeled='_unlabeled', shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledImageDatasetImporterImporter for an image classification directory tree stored on disk.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
compute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importingclasses (None) – an optional string or list of strings specifying a subset of classes to load
unlabeled ("_unlabeled") – the name of the subdirectory containing unlabeled images
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.Whether this importer produces a dataset info dictionary.
The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.data.VideoClassificationDirectoryTreeImporter(dataset_dir, compute_metadata=False, classes=None, unlabeled='_unlabeled', shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledVideoDatasetImporterImporter for a viideo classification directory tree stored on disk.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
compute_metadata (False) – whether to produce
fiftyone.core.metadata.VideoMetadatainstances for each video when importingclasses (None) – an optional string or list of strings specifying a subset of classes to load
unlabeled ("_unlabeled") – the name of the subdirectory containing unlabeled images
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
Attributes:
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.Whether this importer produces a dataset info dictionary.
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the frame labels that it produces.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 frameNone. 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.data.FiftyOneImageDetectionDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, compute_metadata=False, include_all_data=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledImageDatasetImporter,ImportPathsMixinImporter for image detection datasets stored on disk in a simple JSON format.
See this page for format details.
- Parameters:
dataset_dir (None) – the dataset directory. If omitted,
data_pathand/orlabels_pathmust be provideddata_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 ofdataset_dirwhere the media files residean absolute directory path where the media files reside. In this case, the
dataset_dirhas no effect on the location of the dataa filename like
"data.json"specifying the filename of the JSON data manifest file indataset_diran absolute filepath specifying the location of the JSON data manifest. In this case,
dataset_dirhas no effect on the location of the dataa dict mapping filenames to absolute filepaths
If None, this parameter will default to whichever of
data/ordata.jsonexists in the dataset directorylabels_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.json"specifying the location of the labels indataset_diran absolute filepath to the labels. In this case,
dataset_dirhas no effect on the location of the labels
If None, the parameter will default to
labels.jsoncompute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importinginclude_all_data (False) – whether to generate samples for all images in the data directory (True) rather than only creating samples for images with labels (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.data.FiftyOneTemporalDetectionDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, compute_metadata=False, include_all_data=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledVideoDatasetImporter,ImportPathsMixinImporter for temporal video detection datasets stored on disk in a simple JSON format.
See this page for format details.
- Parameters:
dataset_dir (None) – the dataset directory. If omitted,
data_pathand/orlabels_pathmust be provideddata_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 ofdataset_dirwhere the media files residean absolute directory path where the media files reside. In this case, the
dataset_dirhas no effect on the location of the dataa filename like
"data.json"specifying the filename of the JSON data manifest file indataset_diran absolute filepath specifying the location of the JSON data manifest. In this case,
dataset_dirhas no effect on the location of the dataa dict mapping filenames to absolute filepaths
If None, this parameter will default to whichever of
data/ordata.jsonexists in the dataset directorylabels_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.json"specifying the location of the labels indataset_diran absolute filepath to the labels. In this case,
dataset_dirhas no effect on the location of the labels
If None, the parameter will default to
labels.jsoncompute_metadata (False) – whether to produce
fiftyone.core.metadata.VideoMetadatainstances for each video when importinginclude_all_data (False) – whether to generate samples for all videos in the data directory (True) rather than only creating samples for videos with labels (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the frame labels that it produces.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 frameNone. 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.data.ImageSegmentationDirectoryImporter(dataset_dir=None, data_path=None, labels_path=None, load_masks=False, force_grayscale=False, compute_metadata=False, include_all_data=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledImageDatasetImporter,ImportPathsMixinImporter for image segmentation datasets stored on disk.
See this page for format details.
- Parameters:
dataset_dir (None) – the dataset directory. If omitted,
data_pathand/orlabels_pathmust be provideddata_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 ofdataset_dirwhere the media files residean absolute directory path where the media files reside. In this case, the
dataset_dirhas no effect on the location of the dataa filename like
"data.json"specifying the filename of the JSON data manifest file indataset_diran absolute filepath specifying the location of the JSON data manifest. In this case,
dataset_dirhas no effect on the location of the dataa dict mapping filenames to absolute filepaths
If None, this parameter will default to whichever of
data/ordata.jsonexists in the dataset directorylabels_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 indataset_diran absolute filepath to the labels. In this case,
dataset_dirhas no effect on the location of the labels
If None, the parameter will default to
labels/load_masks (False) – whether to load the masks into the database (True) or simply record the paths to the masks (False)
force_grayscale (False) – whether to load RGB masks as grayscale by storing only the first channel
compute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importinginclude_all_data (False) – whether to generate samples for all images in the data directory (True) rather than only creating samples for images with masks (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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__().
- 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__()
- 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
- class fiftyone.utils.data.FiftyOneImageLabelsDatasetImporter(dataset_dir, compute_metadata=False, prefix=None, labels_dict=None, multilabel=False, skip_non_categorical=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledImageDatasetImporterImporter for labeled image datasets whose labels are stored in ETA ImageLabels format.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
compute_metadata (False) – whether to produce
fiftyone.core.metadata.ImageMetadatainstances for each image when importingprefix (None) – a string prefix to prepend to each label name in the expanded label dictionary
labels_dict (None) – a dictionary mapping names of attributes/objects in the image labels to field names into which to expand them
multilabel (False) – whether to store frame attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical frame attributes (True) or cast them to strings (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.data.FiftyOneVideoLabelsDatasetImporter(dataset_dir, compute_metadata=False, prefix=None, labels_dict=None, frame_labels_dict=None, multilabel=False, skip_non_categorical=False, shuffle=False, seed=None, max_samples=None)#
Bases:
LabeledVideoDatasetImporterImporter for labeled video datasets whose labels are stored in ETA VideoLabels format.
See this page for format details.
- Parameters:
dataset_dir – the dataset directory
compute_metadata (False) – whether to produce
fiftyone.core.metadata.VideoMetadatainstances for each video when importingprefix (None) – a string prefix to prepend to each label name in the expanded sample/frame label dictionaries
labels_dict (None) – a dictionary mapping names of attributes/objects in the sample labels to field names into which to expand them. By default, all sample labels are loaded
frame_labels_dict (None) – a dictionary mapping names of attributes/objects in the frame labels to field names into which to expand them. By default, all frame labels are loaded
multilabel (False) – whether to store frame attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical frame attributes (True) or cast them to strings (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
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the frame labels that it produces.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
Returns the dataset info for the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 frameNone. 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.data.ImageIngestor(dataset_dir, image_format=None)#
Bases:
objectMixin for
fiftyone.utils.data.importers.DatasetImporterinstances that ingest images into the provideddataset_dirduring import.- Parameters:
dataset_dir – the directory where input images will be ingested into
image_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis used
- class fiftyone.utils.data.UnlabeledImageDatasetIngestor(dataset_dir, samples, sample_parser, image_format=None, max_samples=None)#
Bases:
UnlabeledImageDatasetImporter,ImageIngestorDataset importer that ingests unlabeled images into the provided
dataset_dirduring import.The source images are parsed from the provided
samplesusing the providedfiftyone.utils.data.parsers.UnlabeledImageSampleParser.If an image path is available via
fiftyone.utils.data.parsers.UnlabeledImageSampleParser.get_image_path(), then the image is directly copied from its source location intodataset_dir. In this case, the original filename is maintained, unless a name conflict would occur, in which case an index of the form"-%d" % countis appended to the base filename.If no image path is available, the image is read in-memory via
fiftyone.utils.data.parsers.UnlabeledImageSampleParser.get_image()and written todataset_dirin the following format:<dataset_dir>/<image_count><image_format>
where
image_countis the number of files indataset_dir.- Parameters:
dataset_dir – the directory where input images will be ingested into
samples – an iterable of samples that can be parsed by
sample_parsersample_parser – an
fiftyone.utils.data.parsers.UnlabeledImageSampleParserto use to parse the samplesimage_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedmax_samples (None) – a maximum number of samples to import. By default, all samples are imported
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- 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__().
- 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__()
- 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
- class fiftyone.utils.data.LabeledImageDatasetIngestor(dataset_dir, samples, sample_parser, image_format=None, max_samples=None)#
Bases:
LabeledImageDatasetImporter,ImageIngestorDataset importer that ingests labeled images into the provided
dataset_dirduring import.The source images and labels are parsed from the provided
samplesusing the providedfiftyone.utils.data.parsers.LabeledImageSampleParser.If an image path is available via
fiftyone.utils.data.parsers.LabeledImageSampleParser.get_image_path(), then the image is directly copied from its source location intodataset_dir. In this case, the original filename is maintained, unless a name conflict would occur, in which case an index of the form"-%d" % countis appended to the base filename.If no image path is available, the image is read in-memory via
fiftyone.utils.data.parsers.LabeledImageSampleParser.get_image()and written todataset_dirin the following format:<dataset_dir>/<image_count><image_format>
where
image_countis the number of files indataset_dir.- Parameters:
dataset_dir – the directory where input images will be ingested into
samples – an iterable of samples that can be parsed by
sample_parsersample_parser – an
fiftyone.utils.data.parsers.LabeledImageSampleParserto use to parse the samplesimage_format (None) – the image format to use when writing in-memory images to disk. By default,
fiftyone.config.default_image_extis usedmax_samples (None) – a maximum number of samples to import. By default, all samples are imported
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.The
fiftyone.core.labels.Labelclass(es) returned by this importer.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_image_metadata#
Whether this importer produces
fiftyone.core.metadata.ImageMetadatainstances for each image.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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__().
- 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__()
- 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
- class fiftyone.utils.data.VideoIngestor(dataset_dir)#
Bases:
objectMixin for
fiftyone.utils.data.importers.DatasetImporterinstances that ingest videos into the provideddataset_dirduring import.- Parameters:
dataset_dir – the directory where input videos will be ingested into
- class fiftyone.utils.data.UnlabeledVideoDatasetIngestor(dataset_dir, samples, sample_parser, max_samples=None)#
Bases:
UnlabeledVideoDatasetImporter,VideoIngestorDataset importer that ingests unlabeled videos into the provided
dataset_dirduring import.The source videos are parsed from the provided
samplesusing the providedfiftyone.utils.data.parsers.UnlabeledVideoSampleParser.The source videos are directly copied from their source locations into
dataset_dir, maintaining the original filenames, unless a name conflict would occur, in which case an index of the form"-%d" % countis appended to the base filename.- Parameters:
dataset_dir – the directory where input videos will be ingested into
samples – an iterable of samples that can be parsed by
sample_parsersample_parser – an
fiftyone.utils.data.parsers.UnlabeledVideoSampleParserto use to parse the samplesmax_samples (None) – a maximum number of samples to import. By default, all samples are imported
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- 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__().
- 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__()
- 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
- class fiftyone.utils.data.LabeledVideoDatasetIngestor(dataset_dir, samples, sample_parser, max_samples=None)#
Bases:
LabeledVideoDatasetImporter,VideoIngestorDataset importer that ingests labeled videos into the provided
dataset_dirduring import.The source videos and labels are parsed from the provided
samplesusing the providedfiftyone.utils.data.parsers.LabeledVideoSampleParser.The source videos are directly copied from their source locations into
dataset_dir, maintaining the original filenames, unless a name conflict would occur, in which case an index of the form"-%d" % countis appended to the base filename.- Parameters:
dataset_dir – the directory where input videos will be ingested into
samples – an iterable of samples that can be parsed by
sample_parsersample_parser – an
fiftyone.utils.data.parsers.LabeledVideoSampleParserto use to parse the samplesmax_samples (None) – a maximum number of samples to import. By default, all samples are imported
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this importer within the frame labels that it produces.Methods:
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadatainstances for each video.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 labelsNone. 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.Labelclass(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. 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 frameNone. 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__().
- 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__()
- 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
- fiftyone.utils.data.add_images(dataset, samples, sample_parser, tags=None, generator=False, progress=None)#
Adds the given images to the dataset.
This operation does not read the images.
See this guide for more details about adding images to a dataset by defining your own
UnlabeledImageSampleParser.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsamples – an iterable of samples that can be parsed by
sample_parsersample_parser – a
UnlabeledImageSampleParserinstance to use to parse the samplestags (None) – an optional tag or iterable of tags to attach to each sample
generator (False) – whether to yield ID batches as a generator as samples are added to the dataset
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- fiftyone.utils.data.add_labeled_images(dataset, samples, sample_parser, label_field=None, tags=None, expand_schema=True, dynamic=False, generator=False, progress=None)#
Adds the given labeled images to the dataset.
This operation will iterate over all provided samples, but the images will not be read (unless the sample parser requires it in order to compute image metadata).
See this guide for more details about adding labeled images to a dataset by defining your own
LabeledImageSampleParser.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsamples – an iterable of samples that can be parsed by
sample_parsersample_parser – a
LabeledImageSampleParserinstance to use to parse the sampleslabel_field (None) – controls the field(s) in which imported labels are stored. If the parser produces a single
fiftyone.core.labels.Labelinstance per sample, this argument specifies the name of the field to use; the default is"ground_truth". If the parser produces a dictionary of labels per sample, this argument can be either a string prefix to prepend to each label key or a dict mapping label keys to field names; the default in this case is to directly use the keys of the imported label dictionaries as field namestags (None) – an optional tag or iterable of tags to attach to each sample
expand_schema (True) – whether to dynamically add new sample fields encountered to the dataset schema. If False, an error is raised if a sample’s schema is not a subset of the dataset schema
dynamic (False) – whether to declare dynamic attributes of embedded document fields that are encountered
generator (False) – whether to yield ID batches as a generator as samples are added to the dataset
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- fiftyone.utils.data.add_videos(dataset, samples, sample_parser, tags=None, generator=False, progress=None)#
Adds the given videos to the dataset.
This operation does not read the videos.
See this guide for more details about adding videos to a dataset by defining your own
UnlabeledVideoSampleParser.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsamples – an iterable of samples that can be parsed by
sample_parsersample_parser – a
UnlabeledVideoSampleParserinstance to use to parse the samplestags (None) – an optional tag or iterable of tags to attach to each sample
generator (False) – whether to yield ID batches as a generator as samples are added to the dataset
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- fiftyone.utils.data.add_labeled_videos(dataset, samples, sample_parser, label_field=None, tags=None, expand_schema=True, dynamic=False, generator=False, progress=None)#
Adds the given labeled videos to the dataset.
This operation will iterate over all provided samples, but the videos will not be read/decoded/etc.
See this guide for more details about adding labeled videos to a dataset by defining your own
LabeledVideoSampleParser.- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsamples – an iterable of samples that can be parsed by
sample_parsersample_parser – a
LabeledVideoSampleParserinstance to use to parse the sampleslabel_field (None) – controls the field(s) in which imported labels are stored. If the parser produces a single
fiftyone.core.labels.Labelinstance per sample/frame, this argument specifies the name of the field to use; the default is"ground_truth". If the parser produces a dictionary of labels per sample/frame, this argument can be either a string prefix to prepend to each label key or a dict mapping label keys to field names; the default in this case is to directly use the keys of the imported label dictionaries as field namestags (None) – an optional tag or iterable of tags to attach to each sample
expand_schema (True) – whether to dynamically add new sample fields encountered to the dataset schema. If False, an error is raised if a sample’s schema is not a subset of the dataset schema
dynamic (False) – whether to declare dynamic attributes of embedded document fields that are encountered
generator (False) – whether to yield ID batches as a generator as samples are added to the dataset
progress (None) – whether 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
- Returns:
a list of IDs of the samples that were added to the dataset
- class fiftyone.utils.data.SampleParser#
Bases:
objectBase interface for sample parsers.
SampleParserinstances are used to parse samples emitted by dataset iterators when ingesting them intofiftyone.core.dataset.Datasetinstances.The general recipe for using
SampleParserinstances is as follows:sample_parser = SampleParser(...) for sample in samples: sample_parser.with_sample(sample) field = sample_parser.get_<field>()
where
fieldis a subclass specific field to parse from the sample.Attributes:
The current sample.
Methods:
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Clears the current sample.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- class fiftyone.utils.data.UnlabeledImageSampleParser#
Bases:
SampleParserInterface for
SampleParserinstances that parse unlabeled image samples.Instances of this class must return images in
numpyformat.The general recipe for using
UnlabeledImageSampleParserinstances is as follows:sample_parser = UnlabeledImageSampleParser(...) for sample in samples: sample_parser.with_sample(sample) img = sample_parser.get_image() if sample_parser.has_image_path: image_path = sample_parser.get_image_path() if sample_parser.has_image_metadata: image_metadata = sample_parser.get_image_metadata()
Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Returns the image metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.UnlabeledVideoSampleParser#
Bases:
SampleParserInterface for
SampleParserinstances that parse unlabeled video samples.The general recipe for using
UnlabeledVideoSampleParserinstances is as follows:sample_parser = UnlabeledVideoSampleParser(...) for sample in samples: sample_parser.with_sample(sample) video_path = sample_parser.get_video_path() video_metadata = sample_parser.get_video_metadata()
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the video path for the current sample.
Returns the video metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.VideoMetadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.UnlabeledMediaSampleParser#
Bases:
SampleParserInterface for
SampleParserinstances that parse unlabeled media samples.The general recipe for using
UnlabeledMediaSampleParserinstances is as follows:sample_parser = UnlabeledMediaSampleParser(...) for sample in samples: sample_parser.with_sample(sample) filepath = sample_parser.get_media_path() metadata = sample_parser.get_metadata()
Attributes:
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.The current sample.
Methods:
Returns the media path for the current sample.
Returns the metadata for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_metadata#
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.
- get_media_path()#
Returns the media path for the current sample.
- Returns:
the path to the media on disk
- get_metadata()#
Returns the metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.Metadatainstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.VideoSampleParser#
Bases:
UnlabeledVideoSampleParserSample parser that parses unlabeled video samples.
This implementation assumes that the provided sample is a path to a video on disk.
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The current sample.
Methods:
Returns the video path for the current sample.
Clears the current sample.
Returns the video metadata for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.VideoMetadatainstance
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.MediaSampleParser#
Bases:
UnlabeledMediaSampleParserSample parser that parses unlabeled media samples.
This implementation assumes that the provided sample is a path to a media file on disk.
Attributes:
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.The current sample.
Methods:
Returns the media path for the current sample.
Clears the current sample.
Returns the metadata for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_metadata#
Whether this parser produces
fiftyone.core.metadata.Metadatainstances for samples that it parses.
- get_media_path()#
Returns the media path for the current sample.
- Returns:
the path to the media on disk
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_metadata()#
Returns the metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.Metadatainstance
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.LabeledImageSampleParser#
Bases:
SampleParserInterface for
SampleParserinstances that parse labeled image samples.Instances of this class must return images in
numpyformat and labels asfiftyone.core.labels.Labelinstances.The general recipe for using
LabeledImageSampleParserinstances is as follows:sample_parser = LabeledImageSampleParser(...) for sample in samples: sample_parser.with_sample(sample) img = sample_parser.get_image() label = sample_parser.get_label() if sample_parser.has_image_path: image_path = sample_parser.get_image_path() if sample_parser.has_image_metadata: image_metadata = sample_parser.get_image_metadata()
Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Returns the image metadata for the current sample.
Returns the label for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_label()#
Returns the label for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeled
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.LabeledVideoSampleParser#
Bases:
SampleParserInterface for
SampleParserinstances that parse labeled video samples.The general recipe for using
LabeledVideoSampleParserinstances is as follows:sample_parser = LabeledVideoSampleParser(...) for sample in samples: sample_parser.with_sample(sample) video_path = sample_parser.get_video_path() label = sample_parser.get_label() frames = sample_parser.get_frame_labels() if sample_parser.has_video_metadata: video_metadata = sample_parser.get_video_metadata()
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.The current sample.
Methods:
Returns the video path for the current sample.
Returns the video metadata for the current sample.
Returns the sample-level labels for the current sample.
Returns the frame labels for the current sample.
Clears the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the sample-level labels that it may return
- property frame_labels_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone. In this case, the parser makes no guarantees about the frame labels that it may return
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_label()#
Returns the sample-level labels for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labels
- get_frame_labels()#
Returns the frame labels for the current sample.
- Returns:
a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frame, orNoneif the sample has no frame labels
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.LabeledImageTupleSampleParser#
Bases:
LabeledImageSampleParserGeneric sample parser that parses samples that are
(image_or_path, label)tuples, where:image_or_pathis either an image that can be converted to numpy format vianp.asarray()or the path to an image on disklabelis afiftyone.core.labels.Labelinstance
This implementation provides a
_current_image()property that caches the image for the current sample, for efficiency in case multiple getters require access to the image (e.g., to normalize coordinates, compute metadata, etc).See the following subclasses of this parser for implementations that parse labels for common tasks:
Image classification:
ImageClassificationSampleParserObject detection:
ImageDetectionSampleParserMultitask image prediction:
ImageLabelsSampleParser
Attributes:
Whether this parser produces paths to images on disk for samples that it parses.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Methods:
Returns the image from the current sample.
Returns the image path for the current sample.
Returns the label for the current sample.
Clears the current sample.
Returns the image metadata for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- get_label()#
Returns the label for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample is unlabeled
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.ImageDetectionSampleParser(label_field='label', bounding_box_field='bounding_box', confidence_field=None, attributes_field=None, classes=None, normalized=True)#
Bases:
LabeledImageTupleSampleParserGeneric parser for image detection samples whose labels are represented as
fiftyone.core.labels.Detectionsinstances.This implementation supports samples that are
(image_or_path, detections_or_path)tuples, where:image_or_pathis either an image that can be converted to numpy format vianp.asarray()or the path to an image on diskdetections_or_pathcan be any of the following:None, for unlabeled images
a list of detections in the following format:
[ { "<label_field>": <label-or-target>, "<bounding_box_field>": [ <top-left-x>, <top-left-y>, <width>, <height> ], "<confidence_field>": <optional-confidence>, "<attributes_field>": { <optional-name>: <optional-value>, ... } }, ... ]
In the above,
label-or-targetis either a class ID (ifclassesis provided) or a label string, and the bounding box coordinates can either be relative coordinates in[0, 1](ifnormalized == True) or absolute pixels coordinates (ifnormalized == False). The confidence and attributes fields are optional for each sample.The input field names can be configured as necessary when instantiating the parser.
the path on disk to a file in the above format
a
fiftyone.core.labels.Detectionsinstance
- Parameters:
label_field ("label") – the name of the object label field in the target dicts
bounding_box_field ("bounding_box") – the name of the bounding box field in the target dicts
confidence_field (None) – the name of the optional confidence field in the target dicts
attributes_field (None) – the name of the optional attributes field in the target dicts
classes (None) – an optional list of class label strings. If provided, it is assumed that the
targetvalues are class IDs that should be mapped to label strings viaclasses[target]normalized (True) – whether the bounding box coordinates are absolute pixel coordinates (
False) or relative coordinates in [0, 1] (True)
Attributes:
The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
Methods:
Returns the label for the current sample.
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_label()#
Returns the label for the current sample.
- Returns:
a
fiftyone.core.labels.Detectionsinstance
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.ImageLabelsSampleParser(prefix=None, labels_dict=None, multilabel=False, skip_non_categorical=False)#
Bases:
LabeledImageTupleSampleParserGeneric parser for multitask image prediction samples whose labels are stored in
eta.core.image.ImageLabelsformat.This implementation provided by this class supports samples that are
(image_or_path, image_labels_or_path)tuples, where:image_or_pathis either an image that can be converted to numpy format vianp.asarray()or the path to an image on diskimage_labels_or_pathis aneta.core.image.ImageLabelsinstance, aneta.core.frames.FrameLabelsinstance, a serialized dict representation of either, or the path to either on disk
- Parameters:
prefix (None) – a string prefix to prepend to each label name in the expanded label dictionary
labels_dict (None) – a dictionary mapping names of attributes/objects in the image labels to field names into which to expand them
multilabel (False) – whether to store attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical attributes (True) or cast them to strings (False)
Attributes:
The
fiftyone.core.labels.Labelclass(es) returned by this parser.The current sample.
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.Whether this parser produces paths to images on disk for samples that it parses.
Methods:
Returns the label for the current sample.
Clears the current sample.
Returns the image from the current sample.
Returns the image metadata for the current sample.
Returns the image path for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the labels that it may return
- get_label()#
Returns the label for the current sample.
- Returns:
a labels dictionary
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_image()#
Returns the image from the current sample.
- Returns:
a numpy image
- get_image_metadata()#
Returns the image metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- get_image_path()#
Returns the image path for the current sample.
- Returns:
the path to the image on disk
- property has_image_metadata#
Whether this parser produces
fiftyone.core.metadata.ImageMetadatainstances for samples that it parses.
- property has_image_path#
Whether this parser produces paths to images on disk for samples that it parses.
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.VideoLabelsSampleParser(prefix=None, labels_dict=None, frame_labels_dict=None, multilabel=False, skip_non_categorical=False)#
Bases:
LabeledVideoSampleParserGeneric parser for labeled video samples whose labels are represented in
eta.core.video.VideoLabelsformat.This implementation provided by this class supports samples that are
(video_path, video_labels_or_path)tuples, where:video_pathis the path to a video on diskvideo_labels_or_pathis aneta.core.video.VideoLabelsinstance, a serialized dict representation of one, or the path to one on disk
- Parameters:
prefix (None) – a string prefix to prepend to each label name in the expanded sample/frame label dictionaries
labels_dict (None) – a dictionary mapping names of attributes/objects in the sample labels to field names into which to expand them. By default, all sample labels are loaded
frame_labels_dict (None) – a dictionary mapping names of attributes/objects in the frame labels to field names into which to expand them. By default, all frame labels are loaded
multilabel (False) – whether to store attributes in a single
fiftyone.core.labels.Classificationsinstanceskip_non_categorical (False) – whether to skip non-categorical attributes (True) or cast them to strings (False)
Attributes:
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.The current sample.
Methods:
Returns the video path for the current sample.
Returns the sample-level labels for the current sample.
Returns the frame labels for the current sample.
Clears the current sample.
Returns the video metadata for the current sample.
with_sample(sample)Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
- property has_video_metadata#
Whether this parser produces
fiftyone.core.metadata.VideoMetadatainstances for samples that it parses.
- property label_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single sample-level label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone. In this case, the parser makes no guarantees about the sample-level labels that it may return
- property frame_labels_cls#
The
fiftyone.core.labels.Labelclass(es) returned by this parser within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Labelclass. In this case, the parser is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Labelclasses. In this case, the parser can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Labelclasses. In this case, the parser will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone. In this case, the parser makes no guarantees about the frame labels that it may return
- get_video_path()#
Returns the video path for the current sample.
- Returns:
the path to the video on disk
- get_label()#
Returns the sample-level labels for the current sample.
- Returns:
a
fiftyone.core.labels.Labelinstance, or a dictionary mapping field names tofiftyone.core.labels.Labelinstances, orNoneif the sample has no sample-level labels
- get_frame_labels()#
Returns the frame labels for the current sample.
- Returns:
a dictionary mapping frame numbers to dictionaries that map label fields to
fiftyone.core.labels.Labelinstances for each video frame, orNoneif the sample has no frame labels
- clear_sample()#
Clears the current sample.
Also clears any cached sample information stored by the parser.
- property current_sample#
The current sample.
- Raises:
ValueError – if there is no current sample
- get_video_metadata()#
Returns the video metadata for the current sample.
- Returns:
a
fiftyone.core.metadata.ImageMetadatainstance
- with_sample(sample)#
Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Guaranteed to call
clear_sample()before setting the current sample.- Parameters:
sample – a sample
- class fiftyone.utils.data.ExtractClipsMixin(compute_metadata=False, write_clips=True, clip_dir=None, video_format=None)#
Bases:
objectMixin for sample parsers that extract clips from
fiftyone.core.clips.ClipViewinstances.- Parameters:
compute_metadata (False) – whether to compute
fiftyone.core.metadata.VideoMetadatainstances on-the-fly when no pre-computed metadata is availablewrite_clips (True) – whether to write clips when their paths are requested
clip_dir (None) – a directory to write clips. Only applicable when parsing
fiftyone.core.clips.ClipViewinstancesvideo_format (None) – the video format to use when writing video clips to disk. By default,
fiftyone.config.default_video_extis used