fiftyone.utils.fiw#
Utilities for working with the Families in the Wild dataset.
Classes:
|
Importer for Faces in the Wild-formatted datasets stored on disk. |
Functions:
|
Gets a list of all pairs of people that are related and the label of their relation, either through the "kinships" or "relationships" field. |
|
Creates a mapping of |
|
Downloads and extracts the Families in the Wild dataset. |
- class fiftyone.utils.fiw.FIWDatasetImporter(dataset_dir=None, shuffle=False, seed=None, max_samples=None)#
Bases:
BatchDatasetImporterImporter for Faces in the Wild-formatted datasets stored on disk.
See this page for format details.
Methods:
import_samples(dataset[, tags])Imports samples and labels stored on disk following the format of the Families in the Wild dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
Returns the dataset info for the dataset.
Returns the media-source entries the importing dataset records before any sample is added, or None.
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)#
Imports samples and labels stored on disk following the format of the Families in the Wild dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasettags (None) – an optional list of tags to attach to each sample
- 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
- get_media_sources()#
Returns the media-source entries the importing dataset records before any sample is added, or None.
Only importers of media-reference-backed samples provide these; see
fiftyone.utils.lerobot.LeRobotDatasetImporter.
- 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__().
- fiftyone.utils.fiw.get_pairwise_labels(samples, label_type='kinships')#
Gets a list of all pairs of people that are related and the label of their relation, either through the “kinships” or “relationships” field.
Example:
[ ["F0009/MID2", "F0009/MID4", "sibling"], ... ]
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionlabel_type ("kinships") – the type of label of which to return pairwise listings options are
("kinships", "relationships")
- Returns:
a list of triplets containing the identifier of person 1, identifier of person 2, and their kinship or relationship
- fiftyone.utils.fiw.get_identifier_filepaths_map(samples)#
Creates a mapping of
family_id/member_ididentifier to a list of filepaths for each person.Example:
{ "F0325/MID4": [ "/path/to/fiftyone/fiw/train/data/F0325/MID4/P03451_face4.jpg", ... ], ... }
- Parameters:
samples – a
fiftyone.core.collections.SampleCollection- Returns:
a dict mapping
family_id/member_ididentifiers to a list of filepaths containing images of the corresponding person
- fiftyone.utils.fiw.download_fiw_dataset(dataset_dir, split, scratch_dir=None, cleanup=False)#
Downloads and extracts the Families in the Wild dataset.
Any existing files are not re-downloaded.
- Parameters:
dataset_dir – the directory to output the final dataset
split – the split being loaded
scratch_dir (None) – a scratch directory to use to store temporary files
cleanup (True) – whether to cleanup the scratch directory after extraction