Dataset that store all the information related to a given piece of data. When you query and manipulate a Dataset object using dataset views, a DatasetView object is returned, which represents a filtered view into a subset of the underlying dataset’s contents.Dataset and DatasetView objects come with a variety of methods that make performing these add and merge operations easy.samples, to a dataset, dataset, then you can use the add_samples() and add_collection() methods for the most part interchangeably. However, if there are samples that appear multiple times in your workflows, due to sources of randomness, for instance, then these two methods have different consequences.add_samples() encounters samples that are already present in the dataset to which the method is applied, it generates a new sample with a new id, and adds this to the dataset. On the other hand, add_collection() ignores the sample and moves on.add_collection() leaves the dataset unchanged, whereas add_samples() increases the size of the dataset:import fiftyone as fo
import fiftyone.zoo as foz
# 200 samples
dataset = foz.load_zoo_dataset("quickstart")
# randomly select 50 samples
samples = dataset.take(50)
# doesn’t change dataset size
dataset.add_collection(samples)
# 200 samples → 250 samples
dataset.add_samples(samples)DatasetImporter classes allow you to import data in various formats without needing to write your own loops and I/O scripts.from_dir() method:import fiftyone as fo
name = "my-dataset"
data_path = "/path/to/images"
labels_path = "/path/to/voc-labels"
# Import dataset by explicitly providing paths to the source media and labels
dataset = fo.Dataset.from_dir(
dataset_type=fo.types.VOCDetectionDataset,
data_path=data_path,
labels_path=labels_path,
name=name,
)add_dir() method, you can extend the logic of any existing DatasetImporter to data that is stored in multiple directories. To add train and val data in YOLOv5 format to a single dataset, you can run the following:import fiftyone as fo
name = "my-dataset"
dataset_dir = "/path/to/yolov5-dataset"
# The splits to load
splits = ["train", "val"]
# Load the dataset, using tags to mark the samples in each split
dataset = fo.Dataset(name)
for split in splits:
dataset.add_dir(
dataset_dir=dataset_dir,
dataset_type=fo.types.YOLOv5Dataset,
split=split,
tags=split,
)merge_dir() can also be similarly useful!.zip, .tar, or .tar.gz stored on disk, you can use the add_dir() or merge_dir() methods to add this data to your dataset. If the archived data has not been unpacked yet, FiftyOne will handle this extraction for you!merge_samples() method. If we have a predictions_view only containing predictions, and a dataset with all other information, we can merge the predictions into our base dataset as follows:import fiftyone as fo
import fiftyone.zoo as foz
# Create a dataset containing only ground truth objects
dataset = foz.load_zoo_dataset("quickstart")
dataset = dataset.exclude_fields("predictions").clone()
# Example predictions view
predictions_view = dataset1.select_fields("predictions")
# Merge the predictions
dataset.merge_samples(predictions_view)merge_labels()Label fields and you want to export your data using a common format, you can use the merge_labels() method to merge all of these label fields into one field for export.ground_truth, model1_predictions, and model2_predictions, you can merge all of these labels as follows:import fiftyone as fo
dataset = fo.load_dataset(...)
## clone label fields into temporary fields
dataset.clone_sample_field("ground_truth", "tmp")
dataset.clone_sample_field("model1_predictions", "tmp1")
dataset.clone_sample_field("model2_predictions", "tmp2")
## merge model1 predictions into ground_truth
dataset.merge_labels("tmp1", "tmp")
## merge model2 predictions into ground_truth
dataset.merge_labels("tmp2", "tmp")
## export the merged labels field
dataset.export(..., label_field="tmp")
## clean up
dataset.delete_sample_fields(["tmp", "tmp1", "tmp2"])dataset.persistent = True© 2026 Voxel51 All Rights Reserved


