fiftyone.utils.activitynet#
Utilities for working with the ActivityNet dataset <http://activity-net.org/index.html>.
Functions:
|
Utility that downloads full or partial splits of the ActivityNet dataset. |
Classes:
|
Class for importing AcitivityNet dataset splits downloaded via |
|
Configuration class for downloading full or partial splits from the ActivityNet dataset. |
|
Class that manages the sample IDs and labels that need to be downloaded to load the specified subset of an ActivityNet dataset. |
|
Necessary information used to parse and format annotations. |
|
Class that contains information related to paths, labels, and sample IDs of a single ActivityNet split. |
|
Class that stores information related to paths, labels, and sample IDs for an ActivityNet dataset download. |
|
ActivityNet 100 dataset info. |
|
ActivityNet 200 dataset info. |
- fiftyone.utils.activitynet.download_activitynet_split(dataset_dir, split, source_dir=None, classes=None, max_duration=None, copy_files=True, num_workers=None, shuffle=None, seed=None, max_samples=None, version='200')#
Utility that downloads full or partial splits of the ActivityNet dataset.
- Parameters:
dataset_dir – the directory to download the dataset
split – the split to download. Supported values are
("train", "validation", "test")
source_dir (None) – the directory containing the manually downloaded ActivityNet files
classes (None) – a string or list of strings specifying required classes to load. If provided, only samples containing at least one instance of a specified class will be loaded
max_duration (None) – only videos with a duration in seconds that is less than or equal to the
max_duration
will be downloaded. By default, all videos are downloadedcopy_files (True) – whether to move (False) or create copies (True) of the source files when populating
dataset_dir
. This is only relevant when asource_dir
is providednum_workers (None) – a suggested number of threads to use when downloading individual videos
shuffle (False) – whether to randomly shuffle the order in which samples are chosen for partial downloads
seed (None) – a random seed to use when shuffling
max_samples (None) – a maximum number of samples to load per split. If
classes
are also specified, only up to the number of samples that contain at least one specified class will be loaded. By default, all matching samples are loadedversion ("200") – the ActivityNet dataset version to download. The supported values are
("100", "200")
- Returns:
num_samples: the total number of downloaded videos, or
None
if everything was already downloadedclasses: the list of all classes, or
None
if everything was already downloadeddid_download: whether any content was downloaded (True) or if all necessary files were already downloaded (False)
- Return type:
a tuple of
- class fiftyone.utils.activitynet.ActivityNetDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, classes=None, max_duration=None, compute_metadata=False, shuffle=False, seed=None, max_samples=None)#
Bases:
FiftyOneTemporalDetectionDatasetImporter
Class for importing AcitivityNet dataset splits downloaded via
download_activitynet_split()
.- Parameters:
dataset_dir (None) – the dataset directory
data_path (None) –
an optional parameter that enables explicit control over the location of the media. Can be any of the following:
a folder name like
"data"
or"data"/
specifying a subfolder ofdataset_dir
where the media files residean absolute directory path where the media files reside. In this case, the
dataset_dir
has no effect on the location of the dataa filename like
"data.json"
specifying the filename of the JSON data manifest file indataset_dir
an absolute filepath specifying the location of the JSON data manifest. In this case,
dataset_dir
has no effect on the location of the data
If None, this parameter will default to whichever of
data/
ordata.json
exists 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_dir
an absolute filepath to the labels. In this case,
dataset_dir
has no effect on the location of the labels
If None, the parameter will default to
labels.json
classes (None) – a string or list of strings specifying required classes to load. If provided, only samples containing at least one instance of a specified class will be loaded
max_duration (None) – only videos with a duration in seconds that is less than or equal to the max_duration will be loaded. By default, all videos are loaded
compute_metadata (False) – whether to produce
fiftyone.core.metadata.VideoMetadata
instances 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.
The
fiftyone.core.labels.Label
class(es) returned by this importer within the frame labels that it produces.Whether this importer produces
fiftyone.core.metadata.VideoMetadata
instances for each video.The
fiftyone.core.labels.Label
class(es) returned by this importer within the sample-level 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.
- 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__()
- property frame_labels_cls#
The
fiftyone.core.labels.Label
class(es) returned by this importer within the frame labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Label
class. In this case, the importer is guaranteed to return frame labels of this typea list or tuple of
fiftyone.core.labels.Label
classes. In this case, the importer can produce a single frame label field of any of these typesa dict mapping keys to
fiftyone.core.labels.Label
classes. In this case, the importer will return frame label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in each frameNone
. In this case, the importer makes no guarantees about the frame labels that it may return
- property has_video_metadata#
Whether this importer produces
fiftyone.core.metadata.VideoMetadata
instances for each video.
- property label_cls#
The
fiftyone.core.labels.Label
class(es) returned by this importer within the sample-level labels that it produces.This can be any of the following:
a
fiftyone.core.labels.Label
class. In this case, the importer is guaranteed to return sample-level labels of this typea list or tuple of
fiftyone.core.labels.Label
classes. 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.Label
classes. In this case, the importer will return sample-level label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labelsNone
. In this case, the importer makes no guarantees about the sample-level labels that it may return
- class fiftyone.utils.activitynet.ActivityNetDownloadConfig(split, source_dir=None, classes=None, max_duration=None, copy_files=True, num_workers=None, shuffle=None, seed=None, max_samples=None)#
Bases:
object
Configuration class for downloading full or partial splits from the ActivityNet dataset.
Attributes:
Methods:
- property load_entire_split#
- validate()#
- validate_split()#
- validate_max_duration()#
- class fiftyone.utils.activitynet.ActivityNetDatasetManager(foz_dir, version)#
Bases:
object
Class that manages the sample IDs and labels that need to be downloaded to load the specified subset of an ActivityNet dataset.
Attributes:
Methods:
existing_split_sample_ids
(split)split_sample_ids
(split)process_source
(source_dir, copy_files)download_necessary_samples
(config)write_data_json
(split)from_dataset_dir
(dataset_dir, version)- property info#
- property all_classes#
- existing_split_sample_ids(split)#
- split_sample_ids(split)#
- process_source(source_dir, copy_files)#
- download_necessary_samples(config)#
- write_data_json(split)#
- classmethod from_dataset_dir(dataset_dir, version)#
- class fiftyone.utils.activitynet.ActivityNetInfo(raw_annotations)#
Bases:
object
Necessary information used to parse and format annotations.
Methods:
get_matching_samples
([split, max_duration, ...])format_annotations
(sample_ids[, split])- get_matching_samples(split=None, max_duration=None, classes=None, ids=None)#
- format_annotations(sample_ids, split=None)#
- class fiftyone.utils.activitynet.ActivityNetSplitInfo(split_dir, version=None, raw_annotations=None)#
Bases:
ActivityNetInfo
Class that contains information related to paths, labels, and sample IDs of a single ActivityNet split.
Attributes:
Methods:
cleanup
()format_annotations
(sample_ids[, split])get_matching_samples
([split, max_duration, ...])- property raw_anno_path#
- property data_dir#
- property data_json_path#
- property error_path#
- update_existing_sample_ids()#
- cleanup()#
- format_annotations(sample_ids, split=None)#
- get_matching_samples(split=None, max_duration=None, classes=None, ids=None)#
- class fiftyone.utils.activitynet.ActivityNetDatasetInfo(foz_dir)#
Bases:
ActivityNetInfo
Class that stores information related to paths, labels, and sample IDs for an ActivityNet dataset download.
Methods:
split_info
(split)split_sample_ids
(split)existing_split_sample_ids
(split)split_dir
(split)data_dir
(split)data_json_path
(split)error_path
(split)cleanup_split
(split)get_dir_info
(dataset_dir)get_sample_split
(sample_id)get_sample_dataset_version
(sample_id)format_annotations
(sample_ids[, split])get_matching_samples
([split, max_duration, ...])Attributes:
- split_info(split)#
- property splits#
- property version#
- property dataset_dir#
- property raw_anno_path#
- split_sample_ids(split)#
- existing_split_sample_ids(split)#
- split_dir(split)#
- data_dir(split)#
- data_json_path(split)#
- error_path(split)#
- update_existing_sample_ids()#
- cleanup_split(split)#
- classmethod get_dir_info(dataset_dir)#
- get_sample_split(sample_id)#
- get_sample_dataset_version(sample_id)#
- format_annotations(sample_ids, split=None)#
- get_matching_samples(split=None, max_duration=None, classes=None, ids=None)#
- class fiftyone.utils.activitynet.ActivityNet100DatasetInfo(foz_dir)#
Bases:
ActivityNetDatasetInfo
ActivityNet 100 dataset info.
Attributes:
Methods:
get_sample_dataset_version
(sample_id)cleanup_split
(split)data_dir
(split)data_json_path
(split)error_path
(split)existing_split_sample_ids
(split)format_annotations
(sample_ids[, split])get_dir_info
(dataset_dir)get_matching_samples
([split, max_duration, ...])get_sample_split
(sample_id)split_dir
(split)split_info
(split)split_sample_ids
(split)- property version#
- get_sample_dataset_version(sample_id)#
- update_existing_sample_ids()#
- cleanup_split(split)#
- data_dir(split)#
- data_json_path(split)#
- property dataset_dir#
- error_path(split)#
- existing_split_sample_ids(split)#
- format_annotations(sample_ids, split=None)#
- classmethod get_dir_info(dataset_dir)#
- get_matching_samples(split=None, max_duration=None, classes=None, ids=None)#
- get_sample_split(sample_id)#
- property raw_anno_path#
- split_dir(split)#
- split_info(split)#
- split_sample_ids(split)#
- property splits#
- class fiftyone.utils.activitynet.ActivityNet200DatasetInfo(foz_dir)#
Bases:
ActivityNetDatasetInfo
ActivityNet 200 dataset info.
Attributes:
Methods:
get_sample_dataset_version
(sample_id)cleanup_split
(split)data_dir
(split)data_json_path
(split)error_path
(split)existing_split_sample_ids
(split)format_annotations
(sample_ids[, split])get_dir_info
(dataset_dir)get_matching_samples
([split, max_duration, ...])get_sample_split
(sample_id)split_dir
(split)split_info
(split)split_sample_ids
(split)- property version#
- get_sample_dataset_version(sample_id)#
- update_existing_sample_ids()#
- cleanup_split(split)#
- data_dir(split)#
- data_json_path(split)#
- property dataset_dir#
- error_path(split)#
- existing_split_sample_ids(split)#
- format_annotations(sample_ids, split=None)#
- classmethod get_dir_info(dataset_dir)#
- get_matching_samples(split=None, max_duration=None, classes=None, ids=None)#
- get_sample_split(sample_id)#
- property raw_anno_path#
- split_dir(split)#
- split_info(split)#
- split_sample_ids(split)#
- property splits#