fiftyone.utils.activitynet#

Utilities for working with the ActivityNet dataset <http://activity-net.org/index.html>.

Copyright 2017-2025, Voxel51, Inc.

Functions:

download_activitynet_split(dataset_dir, split)

Utility that downloads full or partial splits of the ActivityNet dataset.

Classes:

ActivityNetDatasetImporter([dataset_dir, ...])

Class for importing AcitivityNet dataset splits downloaded via download_activitynet_split().

ActivityNetDownloadConfig(split[, ...])

Configuration class for downloading full or partial splits from the ActivityNet dataset.

ActivityNetDatasetManager(foz_dir, version)

Class that manages the sample IDs and labels that need to be downloaded to load the specified subset of an ActivityNet dataset.

ActivityNetInfo(raw_annotations)

Necessary information used to parse and format annotations.

ActivityNetSplitInfo(split_dir[, version, ...])

Class that contains information related to paths, labels, and sample IDs of a single ActivityNet split.

ActivityNetDatasetInfo(foz_dir)

Class that stores information related to paths, labels, and sample IDs for an ActivityNet dataset download.

ActivityNet100DatasetInfo(foz_dir)

ActivityNet 100 dataset info.

ActivityNet200DatasetInfo(foz_dir)

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 downloaded

  • copy_files (True) – whether to move (False) or create copies (True) of the source files when populating dataset_dir. This is only relevant when a source_dir is provided

  • num_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 loaded

  • version ("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 downloaded

  • classes: the list of all classes, or None if everything was already downloaded

  • did_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 of dataset_dir where the media files reside

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

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

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

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

  • labels_path (None) –

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

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

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

    If None, the parameter will default to labels.json

  • 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 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

Attributes:

has_dataset_info

Whether this importer produces a dataset info dictionary.

frame_labels_cls

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

has_video_metadata

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

label_cls

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

Methods:

setup()

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

get_dataset_info()

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 type

  • a 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 types

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

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

property has_video_metadata#

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

property label_cls#

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

This can be any of the following:

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

  • a 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 types

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

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

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:

update_existing_sample_ids()

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)

update_existing_sample_ids()

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)

update_existing_sample_ids()

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)

update_existing_sample_ids()

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#