class documentation

A view into a fiftyone.core.dataset.Dataset.

Dataset views represent ordered collections of subsets of samples in a dataset.

Operations on dataset views are designed to be chained together to yield the desired subset of the dataset, which is then iterated over to directly access the sample views. Each stage in the pipeline defining a dataset view is represented by a fiftyone.core.stages.ViewStage instance.

The stages of a dataset view specify:

  • The subset of samples (and their order) that should be included
  • The possibly-filtered fields of each sample that should be included

Samples retrieved from dataset views are returned as fiftyone.core.sample.SampleView objects, as opposed to fiftyone.core.sample.Sample objects, since they may contain a subset of the sample's content.

See :ref:`this page <using-views>` for an overview of working with dataset views.

Parameters
datasetthe underlying fiftyone.core.dataset.Dataset for the view
Method __copy__ Undocumented
Method __eq__ Undocumented
Method __getitem__ Undocumented
Method __init__ Undocumented
Method __len__ Undocumented
Method app_config.setter Undocumented
Method classes.setter Undocumented
Method clear Deletes all samples in the view from the underlying dataset.
Method clear_frame_field Clears the values of the frame-level field from all samples in the view.
Method clear_frame_fields Clears the values of the frame-level fields from all samples in the view.
Method clear_frames Deletes all frame labels from the samples in the view from the underlying dataset.
Method clear_sample_field Clears the values of the field from all samples in the view.
Method clear_sample_fields Clears the values of the fields from all samples in the view.
Method clone Creates a new dataset containing a copy of the contents of the view.
Method clone_frame_field Clones the frame-level field of the view into a new field.
Method clone_frame_fields Clones the frame-level fields of the view into new frame-level fields of the dataset.
Method clone_sample_field Clones the given sample field of the view into a new field of the dataset.
Method clone_sample_fields Clones the given sample fields of the view into new fields of the dataset.
Method default_classes.setter Undocumented
Method default_mask_targets.setter Undocumented
Method default_skeleton.setter Undocumented
Method description.setter Undocumented
Method ensure_frames Ensures that the video view contains frame instances for every frame of each sample's source video.
Method get_dynamic_group Returns a view containing the samples from a dynamic grouped view with the given group value.
Method get_field_schema Returns a schema dictionary describing the fields of the samples in the view.
Method get_frame_field_schema Returns a schema dictionary describing the fields of the frames of the samples in the view.
Method get_group Returns a dict containing the samples for the given group ID.
Method group_slice.setter Undocumented
Method info.setter Undocumented
Method iter_dynamic_groups Returns an iterator over the dynamic groups in the view.
Method iter_groups Returns an iterator over the groups in the view.
Method iter_samples Returns an iterator over the samples in the view.
Method keep Deletes all samples that are not in the view from the underlying dataset.
Method keep_fields Deletes all fields that are excluded from the view from the underlying dataset.
Method keep_frames For each sample in the view, deletes all frames labels that are not in the view from the underlying dataset.
Method mask_targets.setter Undocumented
Method reload Reloads the view.
Method save Saves the contents of the view to the database.
Method skeletons.setter Undocumented
Method summary Returns a string summary of the view.
Method tags.setter Undocumented
Method to_dict Returns a JSON dictionary representation of the view.
Method view Returns a copy of this view.
Class Variable __slots__ Undocumented
Property app_config Dataset-specific settings that customize how this collection is visualized in the :ref:`FiftyOne App <fiftyone-app>`.
Property classes The classes of the underlying dataset.
Property dataset_name The name of the underlying dataset.
Property default_classes The default classes of the underlying dataset.
Property default_group_slice The default group slice of the view, or None if the view is not grouped.
Property default_mask_targets The default mask targets of the underlying dataset.
Property default_skeleton The default keypoint skeleton of the underlying dataset.
Property description A description of the underlying dataset.
Property group_field The group field of the view, or None if the view is not grouped.
Property group_media_types A dict mapping group slices to media types, or None if the view is not grouped.
Property group_slice The current group slice of the view, or None if the view is not grouped.
Property group_slices The list of group slices of the view, or None if the view is not grouped.
Property info The info dict of the underlying dataset.
Property is_saved Whether the view is a saved view or not.
Property mask_targets The mask targets of the underlying dataset.
Property media_type The media type of the view.
Property name The name of the view if it is a saved view; otherwise None.
Property skeletons The keypoint skeletons of the underlying dataset.
Property tags The list of tags of the underlying dataset.
Static Method _build Undocumented
Method _add_view_stage Returns a fiftyone.core.view.DatasetView containing the contents of the collection with the given fiftyone.core.stages.ViewStage` appended to its aggregation pipeline.
Method _aggregate Runs the MongoDB aggregation pipeline on the collection and returns the result.
Method _dynamic_groups_pipeline Undocumented
Method _get_edited_fields Undocumented
Method _get_filtered_fields Undocumented
Method _get_filtered_schema Undocumented
Method _get_group_media_types Undocumented
Method _get_missing_fields Undocumented
Method _get_selected_excluded_fields Undocumented
Method _init_make_frame Undocumented
Method _init_make_sample Undocumented
Method _iter_dynamic_groups Undocumented
Method _iter_groups Undocumented
Method _iter_samples Undocumented
Method _make_frame Undocumented
Method _make_sample Undocumented
Method _make_view_stages_str Undocumented
Method _needs_frames Undocumented
Method _outputs_dynamic_groups Undocumented
Method _parse_dynamic_groups Undocumented
Method _pipeline Returns the MongoDB aggregation pipeline for the collection.
Method _serialize Undocumented
Method _set_media_type Undocumented
Method _set_name Undocumented
Method _slice Undocumented
Instance Variable __dataset Undocumented
Instance Variable __group_slice Undocumented
Instance Variable __media_type Undocumented
Instance Variable __name Undocumented
Instance Variable __stages Undocumented
Instance Variable _make_frame_fcn Undocumented
Instance Variable _make_sample_fcn Undocumented
Property _all_stages Undocumented
Property _base_view Undocumented
Property _dataset The fiftyone.core.dataset.Dataset that serves the samples in this collection.
Property _frame_cls Undocumented
Property _has_slices Undocumented
Property _is_clips Whether this collection contains clips.
Property _is_dynamic_groups Whether this collection contains dynamic groups.
Property _is_frames Whether this collection contains frames of a video dataset.
Property _is_generated Whether this collection's contents is generated from another collection.
Property _is_patches Whether this collection contains patches.
Property _parent_media_type Undocumented
Property _root_dataset The root fiftyone.core.dataset.Dataset from which this collection is derived.
Property _sample_cls Undocumented
Property _stages Undocumented

Inherited from SampleCollection:

Class Method list_aggregations Returns a list of all available methods on this collection that apply fiftyone.core.aggregations.Aggregation operations to this collection.
Class Method list_view_stages Returns a list of all available methods on this collection that apply fiftyone.core.stages.ViewStage operations to this collection.
Method __add__ Undocumented
Method __bool__ Undocumented
Method __contains__ Undocumented
Method __iter__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method add_stage Applies the given fiftyone.core.stages.ViewStage to the collection.
Method aggregate Aggregates one or more fiftyone.core.aggregations.Aggregation instances.
Method annotate Exports the samples and optional label field(s) in this collection to the given annotation backend.
Method apply_model Applies the model to the samples in the collection.
Method bounds Computes the bounds of a numeric field of the collection.
Method compute_embeddings Computes embeddings for the samples in the collection using the given model.
Method compute_metadata Populates the metadata field of all samples in the collection.
Method compute_patch_embeddings Computes embeddings for the image patches defined by patches_field of the samples in the collection using the given model.
Method concat Concatenates the contents of the given SampleCollection to this collection.
Method count Counts the number of field values in the collection.
Method count_label_tags Counts the occurrences of all label tags in the specified label field(s) of this collection.
Method count_sample_tags Counts the occurrences of sample tags in this collection.
Method count_values Counts the occurrences of field values in the collection.
Method create_index Creates an index on the given field or with the given specification, if necessary.
Method delete_annotation_run Deletes the annotation run with the given key from this collection.
Method delete_annotation_runs Deletes all annotation runs from this collection.
Method delete_brain_run Deletes the brain method run with the given key from this collection.
Method delete_brain_runs Deletes all brain method runs from this collection.
Method delete_evaluation Deletes the evaluation results associated with the given evaluation key from this collection.
Method delete_evaluations Deletes all evaluation results from this collection.
Method delete_run Deletes the run with the given key from this collection.
Method delete_runs Deletes all runs from this collection.
Method distinct Computes the distinct values of a field in the collection.
Method draw_labels Renders annotated versions of the media in the collection with the specified label data overlaid to the given directory.
Method drop_index Drops the index for the given field or name, if necessary.
Method evaluate_classifications Evaluates the classification predictions in this collection with respect to the specified ground truth labels.
Method evaluate_detections Evaluates the specified predicted detections in this collection with respect to the specified ground truth detections.
Method evaluate_regressions Evaluates the regression predictions in this collection with respect to the specified ground truth values.
Method evaluate_segmentations Evaluates the specified semantic segmentation masks in this collection with respect to the specified ground truth masks.
Method exclude Excludes the samples with the given IDs from the collection.
Method exclude_by Excludes the samples with the given field values from the collection.
Method exclude_fields Excludes the fields with the given names from the samples in the collection.
Method exclude_frames Excludes the frames with the given IDs from the video collection.
Method exclude_groups Excludes the groups with the given IDs from the grouped collection.
Method exclude_labels Excludes the specified labels from the collection.
Method exists Returns a view containing the samples in the collection that have (or do not have) a non-None value for the given field or embedded field.
Method export Exports the samples in the collection to disk.
Method filter_field Filters the values of a field or embedded field of each sample in the collection.
Method filter_keypoints Filters the individual fiftyone.core.labels.Keypoint.points elements in the specified keypoints field of each sample in the collection.
Method filter_labels Filters the fiftyone.core.labels.Label field of each sample in the collection.
Method first Returns the first sample in the collection.
Method flatten Returns a flattened view that contains all samples in the dynamic grouped collection.
Method geo_near Sorts the samples in the collection by their proximity to a specified geolocation.
Method geo_within Filters the samples in this collection to only include samples whose geolocation is within a specified boundary.
Method get_annotation_info Returns information about the annotation run with the given key on this collection.
Method get_brain_info Returns information about the brain method run with the given key on this collection.
Method get_classes Gets the classes list for the given field, or None if no classes are available.
Method get_dynamic_field_schema Returns a schema dictionary describing the dynamic fields of the samples in the collection.
Method get_dynamic_frame_field_schema Returns a schema dictionary describing the dynamic fields of the frames in the collection.
Method get_evaluation_info Returns information about the evaluation with the given key on this collection.
Method get_field Returns the field instance of the provided path, or None if one does not exist.
Method get_index_information Returns a dictionary of information about the indexes on this collection.
Method get_mask_targets Gets the mask targets for the given field, or None if no mask targets are available.
Method get_run_info Returns information about the run with the given key on this collection.
Method get_skeleton Gets the keypoint skeleton for the given field, or None if no skeleton is available.
Method group_by Creates a view that groups the samples in the collection by a specified field or expression.
Method has_annotation_run Whether this collection has an annotation run with the given key.
Method has_brain_run Whether this collection has a brain method run with the given key.
Method has_classes Determines whether this collection has a classes list for the given field.
Method has_evaluation Whether this collection has an evaluation with the given key.
Method has_field Determines whether the collection has a field with the given name.
Method has_frame_field Determines whether the collection has a frame-level field with the given name.
Method has_mask_targets Determines whether this collection has mask targets for the given field.
Method has_run Whether this collection has a run with the given key.
Method has_sample_field Determines whether the collection has a sample field with the given name.
Method has_skeleton Determines whether this collection has a keypoint skeleton for the given field.
Method head Returns a list of the first few samples in the collection.
Method histogram_values Computes a histogram of the field values in the collection.
Method init_run Initializes a config instance for a new run.
Method init_run_results Initializes a results instance for the run with the given key.
Method last Returns the last sample in the collection.
Method limit Returns a view with at most the given number of samples.
Method limit_labels Limits the number of fiftyone.core.labels.Label instances in the specified labels list field of each sample in the collection.
Method list_annotation_runs Returns a list of annotation keys on this collection.
Method list_brain_runs Returns a list of brain keys on this collection.
Method list_evaluations Returns a list of evaluation keys on this collection.
Method list_indexes Returns the list of index names on this collection.
Method list_runs Returns a list of run keys on this collection.
Method list_schema Extracts the value type(s) in a specified list field across all samples in the collection.
Method load_annotation_results Loads the results for the annotation run with the given key on this collection.
Method load_annotation_view Loads the fiftyone.core.view.DatasetView on which the specified annotation run was performed on this collection.
Method load_annotations Downloads the labels from the given annotation run from the annotation backend and merges them into this collection.
Method load_brain_results Loads the results for the brain method run with the given key on this collection.
Method load_brain_view Loads the fiftyone.core.view.DatasetView on which the specified brain method run was performed on this collection.
Method load_evaluation_results Loads the results for the evaluation with the given key on this collection.
Method load_evaluation_view Loads the fiftyone.core.view.DatasetView on which the specified evaluation was performed on this collection.
Method load_run_results Loads the results for the run with the given key on this collection.
Method load_run_view Loads the fiftyone.core.view.DatasetView on which the specified run was performed on this collection.
Method make_unique_field_name Makes a unique field name with the given root name for the collection.
Method map_labels Maps the label values of a fiftyone.core.labels.Label field to new values for each sample in the collection.
Method match Filters the samples in the collection by the given filter.
Method match_frames Filters the frames in the video collection by the given filter.
Method match_labels Selects the samples from the collection that contain (or do not contain) at least one label that matches the specified criteria.
Method match_tags Returns a view containing the samples in the collection that have or don't have any/all of the given tag(s).
Method max Computes the maximum of a numeric field of the collection.
Method mean Computes the arithmetic mean of the field values of the collection.
Method merge_labels Merges the labels from the given input field into the given output field of the collection.
Method min Computes the minimum of a numeric field of the collection.
Method mongo Adds a view stage defined by a raw MongoDB aggregation pipeline.
Method one Returns a single sample in this collection matching the expression.
Method quantiles Computes the quantile(s) of the field values of a collection.
Method register_run Registers a run under the given key on this collection.
Method rename_annotation_run Replaces the key for the given annotation run with a new key.
Method rename_brain_run Replaces the key for the given brain run with a new key.
Method rename_evaluation Replaces the key for the given evaluation with a new key.
Method rename_run Replaces the key for the given run with a new key.
Method save_context Returns a context that can be used to save samples from this collection according to a configurable batching strategy.
Method save_run_results Saves run results for the run with the given key.
Method schema Extracts the names and types of the attributes of a specified embedded document field across all samples in the collection.
Method select Selects the samples with the given IDs from the collection.
Method select_by Selects the samples with the given field values from the collection.
Method select_fields Selects only the fields with the given names from the samples in the collection. All other fields are excluded.
Method select_frames Selects the frames with the given IDs from the video collection.
Method select_group_slices Selects the samples in the group collection from the given slice(s).
Method select_groups Selects the groups with the given IDs from the grouped collection.
Method select_labels Selects only the specified labels from the collection.
Method set_field Sets a field or embedded field on each sample in a collection by evaluating the given expression.
Method set_label_values Sets the fields of the specified labels in the collection to the given values.
Method set_values Sets the field or embedded field on each sample or frame in the collection to the given values.
Method shuffle Randomly shuffles the samples in the collection.
Method skip Omits the given number of samples from the head of the collection.
Method sort_by Sorts the samples in the collection by the given field(s) or expression(s).
Method sort_by_similarity Sorts the collection by similarity to a specified query.
Method split_labels Splits the labels from the given input field into the given output field of the collection.
Method stats Returns stats about the collection on disk.
Method std Computes the standard deviation of the field values of the collection.
Method sum Computes the sum of the field values of the collection.
Method sync_last_modified_at Syncs the last_modified_at property(s) of the dataset.
Method tag_labels Adds the tag(s) to all labels in the specified label field(s) of this collection, if necessary.
Method tag_samples Adds the tag(s) to all samples in this collection, if necessary.
Method tail Returns a list of the last few samples in the collection.
Method take Randomly samples the given number of samples from the collection.
Method to_clips Creates a view that contains one sample per clip defined by the given field or expression in the video collection.
Method to_evaluation_patches Creates a view based on the results of the evaluation with the given key that contains one sample for each true positive, false positive, and false negative example in the collection, respectively.
Method to_frames Creates a view that contains one sample per frame in the video collection.
Method to_json Returns a JSON string representation of the collection.
Method to_patches Creates a view that contains one sample per object patch in the specified field of the collection.
Method to_trajectories Creates a view that contains one clip for each unique object trajectory defined by their (label, index) in a frame-level field of a video collection.
Method untag_labels Removes the tag from all labels in the specified label field(s) of this collection, if necessary.
Method untag_samples Removes the tag(s) from all samples in this collection, if necessary.
Method update_run_config Updates the run config for the run with the given key.
Method validate_field_type Validates that the collection has a field of the given type.
Method validate_fields_exist Validates that the collection has field(s) with the given name(s).
Method values Extracts the values of a field from all samples in the collection.
Method write_json Writes the colllection to disk in JSON format.
Property has_annotation_runs Whether this collection has any annotation runs.
Property has_brain_runs Whether this collection has any brain runs.
Property has_evaluations Whether this collection has any evaluation results.
Property has_runs Whether this collection has any runs.
Async Method _async_aggregate Undocumented
Method _build_aggregation Undocumented
Method _build_batch_pipeline Undocumented
Method _build_big_pipeline Undocumented
Method _build_facets Undocumented
Method _contains_media_type Undocumented
Method _contains_videos Undocumented
Method _delete_labels Undocumented
Method _do_get_dynamic_field_schema Undocumented
Method _edit_label_tags Undocumented
Method _edit_sample_tags Undocumented
Method _expand_schema_from_values Undocumented
Method _get_db_fields_map Undocumented
Method _get_default_field Undocumented
Method _get_default_frame_fields Undocumented
Method _get_default_indexes Undocumented
Method _get_default_sample_fields Undocumented
Method _get_dynamic_field_schema Undocumented
Method _get_extremum Undocumented
Method _get_frame_label_field_schema Undocumented
Method _get_frames_bytes Computes the total size of the frame documents in the collection.
Method _get_geo_location_field Undocumented
Method _get_group_slices Undocumented
Method _get_label_attributes_schema Undocumented
Method _get_label_field_path Undocumented
Method _get_label_field_root Undocumented
Method _get_label_field_schema Undocumented
Method _get_label_field_type Undocumented
Method _get_label_fields Undocumented
Method _get_label_ids Undocumented
Method _get_media_fields Undocumented
Method _get_per_frame_bytes Returns a dictionary mapping frame IDs to document sizes (in bytes) for each frame in the video collection.
Method _get_per_sample_bytes Returns a dictionary mapping sample IDs to document sizes (in bytes) for each sample in the collection.
Method _get_per_sample_frames_bytes Returns a dictionary mapping sample IDs to total frame document sizes (in bytes) for each sample in the video collection.
Method _get_root_field_type Undocumented
Method _get_root_fields Undocumented
Method _get_samples_bytes Computes the total size of the sample documents in the collection.
Method _get_selected_labels Undocumented
Method _get_store Undocumented
Method _get_values_by_id Undocumented
Method _handle_db_field Undocumented
Method _handle_db_fields Undocumented
Method _handle_frame_field Undocumented
Method _handle_group_field Undocumented
Method _handle_id_fields Undocumented
Method _has_field Undocumented
Method _has_frame_fields Undocumented
Method _has_stores Undocumented
Method _is_default_field Undocumented
Method _is_frame_field Undocumented
Method _is_full_collection Undocumented
Method _is_group_field Undocumented
Method _is_label_field Undocumented
Method _is_read_only_field Undocumented
Method _list_stores Undocumented
Method _make_and_aggregate Undocumented
Method _make_set_field_pipeline Undocumented
Method _max Undocumented
Method _min Undocumented
Method _parse_aggregations Undocumented
Method _parse_big_result Undocumented
Method _parse_default_mask_targets Undocumented
Method _parse_default_skeleton Undocumented
Method _parse_faceted_result Undocumented
Method _parse_field Undocumented
Method _parse_field_name Undocumented
Method _parse_frame_labels_field Undocumented
Method _parse_label_field Undocumented
Method _parse_mask_targets Undocumented
Method _parse_media_field Undocumented
Method _parse_skeletons Undocumented
Method _process_aggregations Undocumented
Method _serialize_default_mask_targets Undocumented
Method _serialize_default_skeleton Undocumented
Method _serialize_field_schema Undocumented
Method _serialize_frame_field_schema Undocumented
Method _serialize_mask_targets Undocumented
Method _serialize_schema Undocumented
Method _serialize_skeletons Undocumented
Method _set_doc_values Undocumented
Method _set_frame_values Undocumented
Method _set_label_list_values Undocumented
Method _set_labels Undocumented
Method _set_list_values_by_id Undocumented
Method _set_sample_values Undocumented
Method _set_values Undocumented
Method _split_frame_fields Undocumented
Method _sync_dataset_last_modified_at Undocumented
Method _sync_samples_last_modified_at Undocumented
Method _tag_labels Undocumented
Method _to_fields_str Undocumented
Method _untag_labels Undocumented
Method _unwind_values Undocumented
Method _validate_root_field Undocumented
Constant _FRAMES_PREFIX Undocumented
Constant _GROUPS_PREFIX Undocumented
Property _element_str Undocumented
Property _elements_str Undocumented
def __eq__(self, other): (source)

Undocumented

def __getitem__(self, id_filepath_slice): (source)
def __init__(self, dataset, _stages=None, _media_type=None, _group_slice=None, _name=None): (source)
@app_config.setter
def app_config(self, config): (source)

Undocumented

@classes.setter
def classes(self, classes): (source)

Undocumented

def clear(self): (source)

Deletes all samples in the view from the underlying dataset.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

def clear_frame_field(self, field_name): (source)

Clears the values of the frame-level field from all samples in the view.

The field will remain in the dataset's frame schema, and all frames in the view will have the value None for the field.

You can use dot notation (embedded.field.name) to clear embedded frame fields.

Only applicable to views that contain videos.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If the field name you specify is an embedded field, be aware that this operation will save the entire top-level field after clearing the field, which may result in data modification/loss if this view modifies the field in any other ways.

Parameters
field_namethe field name or embedded.field.name
def clear_frame_fields(self, field_names): (source)

Clears the values of the frame-level fields from all samples in the view.

The fields will remain in the dataset's frame schema, and all frames in the view will have the value None for the fields.

You can use dot notation (embedded.field.name) to clear embedded frame fields.

Only applicable to views that contain videos.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If any of the field names you specify are embedded fields, be aware that this operation will save the entire top-level field after clearing the fields, which may result in data modification/loss if this view modifies these fields in any other ways.

Parameters
field_namesthe field name or iterable of field names
def clear_frames(self): (source)

Deletes all frame labels from the samples in the view from the underlying dataset.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

def clear_sample_field(self, field_name): (source)

Clears the values of the field from all samples in the view.

The field will remain in the dataset's schema, and all samples in the view will have the value None for the field.

You can use dot notation (embedded.field.name) to clear embedded fields.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If the field name you specify is an embedded field, be aware that this operation will save the entire top-level field after clearing the field, which may result in data modification/loss if this view modifies the field in any other ways.

Parameters
field_namethe field name or embedded.field.name
def clear_sample_fields(self, field_names): (source)

Clears the values of the fields from all samples in the view.

The fields will remain in the dataset's schema, and all samples in the view will have the value None for the fields.

You can use dot notation (embedded.field.name) to clear embedded fields.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If any of the field names you specify are embedded fields, be aware that this operation will save the entire top-level field after clearing the fields, which may result in data modification/loss if this view modifies these fields in any other ways.

Parameters
field_namesthe field name or iterable of field names
def clone(self, name=None, persistent=False): (source)

Creates a new dataset containing a copy of the contents of the view.

Dataset clones contain deep copies of all samples and dataset-level information in the source collection. The source media files, however, are not copied.

Parameters
name:Nonea name for the cloned dataset. By default, get_default_dataset_name is used
persistent:Falsewhether the cloned dataset should be persistent
Returns
the new fiftyone.core.dataset.Dataset
def clone_frame_field(self, field_name, new_field_name): (source)

Clones the frame-level field of the view into a new field.

You can use dot notation (embedded.field.name) to clone embedded frame fields.

Only applicable to views that contain videos.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If new_field_name is an embedded field, be aware that this operation will save the entire top-level field of new_field_name after performing the clone, which may result in data modification/loss if this view modifies this field in any other ways.

Parameters
field_namethe field name or embedded.field.name
new_field_namethe new field name or embedded.field.name
def clone_frame_fields(self, field_mapping): (source)

Clones the frame-level fields of the view into new frame-level fields of the dataset.

You can use dot notation (embedded.field.name) to clone embedded frame fields.

Only applicable to views that contain videos.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If any of the new field names to specify are embedded fields, be aware that this operation will save the entire top-level new fields after performing the clone, which may result in data modification/loss if this view modifies these fields in any other ways.

Parameters
field_mappinga dict mapping field names to new field names into which to clone each field
def clone_sample_field(self, field_name, new_field_name): (source)

Clones the given sample field of the view into a new field of the dataset.

You can use dot notation (embedded.field.name) to clone embedded fields.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If new_field_name is an embedded field, be aware that this operation will save the entire top-level field of new_field_name after performing the clone, which may result in data modification/loss if this view modifies this field in any other ways.

Parameters
field_namethe field name or embedded.field.name
new_field_namethe new field name or embedded.field.name
def clone_sample_fields(self, field_mapping): (source)

Clones the given sample fields of the view into new fields of the dataset.

You can use dot notation (embedded.field.name) to clone embedded fields.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If any of the new field names to specify are embedded fields, be aware that this operation will save the entire top-level new fields after performing the clone, which may result in data modification/loss if this view modifies these fields in any other ways.

Parameters
field_mappinga dict mapping field names to new field names into which to clone each field
@default_classes.setter
def default_classes(self, classes): (source)

Undocumented

@default_mask_targets.setter
def default_mask_targets(self, targets): (source)

Undocumented

@default_skeleton.setter
def default_skeleton(self, skeleton): (source)

Undocumented

def ensure_frames(self): (source)

Ensures that the video view contains frame instances for every frame of each sample's source video.

Empty frames will be inserted for missing frames, and already existing frames are left unchanged.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

def get_dynamic_group(self, group_value): (source)

Returns a view containing the samples from a dynamic grouped view with the given group value.

Examples:

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("cifar10", split="test")

view = dataset.take(1000).group_by("ground_truth.label")

group = view.get_dynamic_group("cat")
print(len(group))  # 104
Parameters
group_valuethe group value
Returns
a DatasetView
def get_field_schema(self, ftype=None, embedded_doc_type=None, read_only=None, info_keys=None, created_after=None, include_private=False, flat=False, mode=None): (source)

Returns a schema dictionary describing the fields of the samples in the view.

Parameters
ftype:Nonean optional field type or iterable of types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.fields.Field
embedded_doc_type:Nonean optional embedded document type or iterable of types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.odm.BaseEmbeddedDocument
read_only:Nonewhether to restrict to (True) or exclude (False) read-only fields. By default, all fields are included
info_keys:Nonean optional key or list of keys that must be in the field's info dict
created_after:Nonean optional datetime specifying a minimum creation date
include_private:Falsewhether to include fields that start with _ in the returned schema
flat:Falsewhether to return a flattened schema where all embedded document fields are included as top-level keys
mode:Nonewhether to apply the above constraints before and/or after flattening the schema. Only applicable when flat is True. Supported values are ("before", "after", "both"). The default is "after"
Returns
a dict mapping field names to fiftyone.core.fields.Field instances
def get_frame_field_schema(self, ftype=None, embedded_doc_type=None, read_only=None, info_keys=None, created_after=None, include_private=False, flat=False, mode=None): (source)

Returns a schema dictionary describing the fields of the frames of the samples in the view.

Only applicable for views that contain videos.

Parameters
ftype:Nonean optional field type or iterable of types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.fields.Field
embedded_doc_type:Nonean optional embedded document type or iterable of types to which to restrict the returned schema. Must be subclass(es) of fiftyone.core.odm.BaseEmbeddedDocument
read_only:Nonewhether to restrict to (True) or exclude (False) read-only fields. By default, all fields are included
info_keys:Nonean optional key or list of keys that must be in the field's info dict
created_after:Nonean optional datetime specifying a minimum creation date
include_private:Falsewhether to include fields that start with _ in the returned schema
flat:Falsewhether to return a flattened schema where all embedded document fields are included as top-level keys
mode:Nonewhether to apply the above constraints before and/or after flattening the schema. Only applicable when flat is True. Supported values are ("before", "after", "both"). The default is "after"
Returns
a dict mapping field names to fiftyone.core.fields.Field instances, or None if the view does not contain videos
def get_group(self, group_id, group_slices=None): (source)

Returns a dict containing the samples for the given group ID.

Examples:

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart-groups")
view = dataset.select_fields()

group_id = view.take(1).first().group.id
group = view.get_group(group_id)

print(group.keys())
# ['left', 'right', 'pcd']
Parameters
group_ida group ID
group_slices:Nonean optional subset of group slices to load
Returns
a dict mapping group names to fiftyone.core.sample.SampleView instances
Raises
KeyErrorif the group ID is not found
@group_slice.setter
def group_slice(self, slice_name): (source)

Undocumented

@info.setter
def info(self, info): (source)

Undocumented

def iter_dynamic_groups(self, progress=False): (source)

Returns an iterator over the dynamic groups in the view.

Examples:

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("cifar10", split="test")

view = dataset.take(1000).group_by("ground_truth.label")

for group in view.iter_dynamic_groups():
    group_value = group.first().ground_truth.label
    print("%s: %d" % (group_value, len(group)))
Parameters
progress:Falsewhether 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
an iterator that emits DatasetView instances, one per group
def iter_groups(self, group_slices=None, progress=False, autosave=False, batch_size=None, batching_strategy=None): (source)

Returns an iterator over the groups in the view.

Examples:

import random as r
import string as s

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart-groups")
view = dataset.select_fields()

def make_label():
    return "".join(r.choice(s.ascii_letters) for i in range(10))

# No save context
for group in view.iter_groups(progress=True):
    for sample in group.values():
        sample["test"] = make_label()
        sample.save()

# Save using default batching strategy
for group in view.iter_groups(progress=True, autosave=True):
    for sample in group.values():
        sample["test"] = make_label()

# Save in batches of 10
for group in view.iter_groups(
    progress=True, autosave=True, batch_size=10
):
    for sample in group.values():
        sample["test"] = make_label()

# Save every 0.5 seconds
for group in view.iter_groups(
    progress=True, autosave=True, batch_size=0.5
):
    for sample in group.values():
        sample["test"] = make_label()
Parameters
group_slices:Nonean optional subset of group slices to load
progress:Falsewhether 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
autosave:Falsewhether to automatically save changes to samples emitted by this iterator
batch_size:Nonethe batch size to use when autosaving samples. If a batching_strategy is provided, this parameter configures the strategy as described below. If no batching_strategy is provided, this can either be an integer specifying the number of samples to save in a batch (in which case batching_strategy is implicitly set to "static") or a float number of seconds between batched saves (in which case batching_strategy is implicitly set to "latency")
batching_strategy:None

the batching strategy to use for each save operation when autosaving samples. Supported values are:

  • "static": a fixed sample batch size for each save
  • "size": a target batch size, in bytes, for each save
  • "latency": a target latency, in seconds, between saves

By default, fo.config.default_batcher is used

Returns
an iterator that emits dicts mapping slice names to fiftyone.core.sample.SampleView instances, one per group
def iter_samples(self, progress=False, autosave=False, batch_size=None, batching_strategy=None): (source)

Returns an iterator over the samples in the view.

Examples:

import random as r
import string as s

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("cifar10", split="test")
view = dataset.shuffle().limit(5000)

def make_label():
    return "".join(r.choice(s.ascii_letters) for i in range(10))

# No save context
for sample in view.iter_samples(progress=True):
    sample.ground_truth.label = make_label()
    sample.save()

# Save using default batching strategy
for sample in view.iter_samples(progress=True, autosave=True):
    sample.ground_truth.label = make_label()

# Save in batches of 10
for sample in view.iter_samples(
    progress=True, autosave=True, batch_size=10
):
    sample.ground_truth.label = make_label()

# Save every 0.5 seconds
for sample in view.iter_samples(
    progress=True, autosave=True, batch_size=0.5
):
    sample.ground_truth.label = make_label()
Parameters
progress:Falsewhether 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
autosave:Falsewhether to automatically save changes to samples emitted by this iterator
batch_size:Nonethe batch size to use when autosaving samples. If a batching_strategy is provided, this parameter configures the strategy as described below. If no batching_strategy is provided, this can either be an integer specifying the number of samples to save in a batch (in which case batching_strategy is implicitly set to "static") or a float number of seconds between batched saves (in which case batching_strategy is implicitly set to "latency")
batching_strategy:None

the batching strategy to use for each save operation when autosaving samples. Supported values are:

  • "static": a fixed sample batch size for each save
  • "size": a target batch size, in bytes, for each save
  • "latency": a target latency, in seconds, between saves

By default, fo.config.default_batcher is used

Returns
an iterator over fiftyone.core.sample.SampleView instances
def keep(self): (source)

Deletes all samples that are not in the view from the underlying dataset.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

def keep_fields(self): (source)

Deletes all fields that are excluded from the view from the underlying dataset.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

def keep_frames(self): (source)

For each sample in the view, deletes all frames labels that are not in the view from the underlying dataset.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

@mask_targets.setter
def mask_targets(self, targets): (source)

Undocumented

def reload(self): (source)

Reloads the view.

Note that fiftyone.core.sample.SampleView instances are not singletons, so any in-memory samples extracted from this view will not be updated by calling this method.

def save(self, fields=None): (source)

Saves the contents of the view to the database.

This method does not delete samples or frames from the underlying dataset that this view excludes.

Note

This method is not a fiftyone.core.stages.ViewStage; it immediately writes the requested changes to the underlying dataset.

Warning

If a view has excluded fields or filtered list values, this method will permanently delete this data from the dataset, unless fields is used to omit such fields from the save.

Parameters
fields:Nonean optional field or iterable of fields to save. If specified, only these field's contents are modified
@skeletons.setter
def skeletons(self, skeletons): (source)

Undocumented

def summary(self): (source)

Returns a string summary of the view.

Returns
a string summary
def to_dict(self, rel_dir=None, include_private=False, include_frames=False, frame_labels_dir=None, pretty_print=False): (source)

Returns a JSON dictionary representation of the view.

Parameters
rel_dir:Nonea relative directory to remove from the filepath of each sample, if possible. The path is converted to an absolute path (if necessary) via fiftyone.core.storage.normalize_path. The typical use case for this argument is that your source data lives in a single directory and you wish to serialize relative, rather than absolute, paths to the data within that directory
include_private:Falsewhether to include private fields
include_frames:Falsewhether to include the frame labels for video samples
frame_labels_dir:Nonea directory in which to write per-sample JSON files containing the frame labels for video samples. If omitted, frame labels will be included directly in the returned JSON dict (which can be quite quite large for video datasets containing many frames). Only applicable to datasets that contain videos when include_frames is True
pretty_print:Falsewhether to render frame labels JSON in human readable format with newlines and indentations. Only applicable to datasets that contain videos when a frame_labels_dir is provided
Returns
a JSON dict
def view(self): (source)

Returns a copy of this view.

Returns
a DatasetView

Dataset-specific settings that customize how this collection is visualized in the :ref:`FiftyOne App <fiftyone-app>`.

The classes of the underlying dataset.

See fiftyone.core.dataset.Dataset.classes for more information.

@property
dataset_name = (source)

The name of the underlying dataset.

@property
default_classes = (source)

The default classes of the underlying dataset.

See fiftyone.core.dataset.Dataset.default_classes for more information.

@property
default_group_slice = (source)

The default group slice of the view, or None if the view is not grouped.

@property
default_mask_targets = (source)

The default mask targets of the underlying dataset.

See fiftyone.core.dataset.Dataset.default_mask_targets for more information.

@property
default_skeleton = (source)

The default keypoint skeleton of the underlying dataset.

See fiftyone.core.dataset.Dataset.default_skeleton for more information.

@property
description = (source)

A description of the underlying dataset.

See fiftyone.core.dataset.Dataset.description for more information.

@property
group_field = (source)

The group field of the view, or None if the view is not grouped.

@property
group_media_types = (source)

A dict mapping group slices to media types, or None if the view is not grouped.

@property
group_slice = (source)

The current group slice of the view, or None if the view is not grouped.

@property
group_slices = (source)

The list of group slices of the view, or None if the view is not grouped.

The info dict of the underlying dataset.

See fiftyone.core.dataset.Dataset.info for more information.

@property
mask_targets = (source)

The mask targets of the underlying dataset.

See fiftyone.core.dataset.Dataset.mask_targets for more information.

The keypoint skeletons of the underlying dataset.

See fiftyone.core.dataset.Dataset.skeletons for more information.

The list of tags of the underlying dataset.

See fiftyone.core.dataset.Dataset.tags for more information.

@staticmethod
def _build(dataset, stage_dicts): (source)

Undocumented

def _add_view_stage(self, stage, validate=True): (source)

Returns a fiftyone.core.view.DatasetView containing the contents of the collection with the given fiftyone.core.stages.ViewStage` appended to its aggregation pipeline.

Subclasses are responsible for performing any validation on the view stage to ensure that it is a valid stage to add to this collection.

Parameters
stagea fiftyone.core.stages.ViewStage`
validateUndocumented
Returns
a fiftyone.core.view.DatasetView
def _aggregate(self, pipeline=None, media_type=None, attach_frames=False, detach_frames=False, frames_only=False, support=None, group_slice=None, group_slices=None, detach_groups=False, groups_only=False, manual_group_select=False, post_pipeline=None): (source)

Runs the MongoDB aggregation pipeline on the collection and returns the result.

Parameters
pipeline:Nonea MongoDB aggregation pipeline (list of dicts) to append to the current pipeline
media_type:Nonethe media type of the collection, if different than the source dataset's media type
attach_frames:Falsewhether to attach the frame documents immediately prior to executing pipeline. Only applicable to datasets that contain videos
detach_frames:Falsewhether to detach the frame documents at the end of the pipeline. Only applicable to datasets that contain videos
frames_only:Falsewhether to generate a pipeline that contains only the frames in the collection
support:Nonean optional [first, last] range of frames to attach. Only applicable when attaching frames
group_slice:Nonethe current group slice of the collection, if different than the source dataset's group slice. Only applicable for grouped collections
group_slices:Nonean optional list of group slices to attach when groups_only is True
detach_groups:Falsewhether to detach the group documents at the end of the pipeline. Only applicable to grouped collections
groups_only:Falsewhether to generate a pipeline that contains only the flattened group documents for the collection
manual_group_select:Falsewhether the pipeline has manually handled the initial group selection. Only applicable to grouped collections
post_pipeline:Nonea MongoDB aggregation pipeline (list of dicts) to append to the very end of the pipeline, after all other arguments are applied
Returns
the aggregation result dict
def _dynamic_groups_pipeline(self, group_value=None, group_pipeline=None): (source)

Undocumented

def _get_edited_fields(self, frames=False): (source)

Undocumented

def _get_filtered_fields(self, frames=False): (source)

Undocumented

def _get_filtered_schema(self, schema, frames=False): (source)

Undocumented

def _get_group_media_types(self): (source)
def _get_missing_fields(self, frames=False): (source)

Undocumented

def _get_selected_excluded_fields(self, frames=False, roots_only=False): (source)

Undocumented

def _init_make_frame(self): (source)

Undocumented

def _init_make_sample(self): (source)

Undocumented

def _iter_dynamic_groups(self): (source)

Undocumented

def _iter_groups(self, group_slices=None): (source)

Undocumented

def _iter_samples(self): (source)

Undocumented

def _make_frame(self, d): (source)

Undocumented

def _make_sample(self, d): (source)

Undocumented

def _make_view_stages_str(self): (source)

Undocumented

def _needs_frames(self): (source)

Undocumented

def _outputs_dynamic_groups(self): (source)

Undocumented

def _parse_dynamic_groups(self): (source)

Undocumented

def _pipeline(self, pipeline=None, media_type=None, attach_frames=False, detach_frames=False, frames_only=False, support=None, group_slice=None, group_slices=None, detach_groups=False, groups_only=False, manual_group_select=False, post_pipeline=None): (source)

Returns the MongoDB aggregation pipeline for the collection.

Parameters
pipeline:Nonea MongoDB aggregation pipeline (list of dicts) to append to the current pipeline
media_type:Nonethe media type of the collection, if different than the source dataset's media type
attach_frames:Falsewhether to attach the frame documents immediately prior to executing pipeline. Only applicable to datasets that contain videos
detach_frames:Falsewhether to detach the frame documents at the end of the pipeline. Only applicable to datasets that contain videos
frames_only:Falsewhether to generate a pipeline that contains only the frames in the collection
support:Nonean optional [first, last] range of frames to attach. Only applicable when attaching frames
group_slice:Nonethe current group slice of the collection, if different than the source dataset's group slice. Only applicable for grouped collections
group_slices:Nonean optional list of group slices to attach when groups_only is True
detach_groups:Falsewhether to detach the group documents at the end of the pipeline. Only applicable to grouped collections
groups_only:Falsewhether to generate a pipeline that contains only the flattened group documents for the collection
manual_group_select:Falsewhether the pipeline has manually handled the initial group selection. Only applicable to grouped collections
post_pipeline:Nonea MongoDB aggregation pipeline (list of dicts) to append to the very end of the pipeline, after all other arguments are applied
Returns
the aggregation pipeline
def _serialize(self, include_uuids=True): (source)
def _slice(self, s): (source)

Undocumented

__dataset = (source)

Undocumented

__group_slice = (source)

Undocumented

_make_frame_fcn = (source)

Undocumented

_make_sample_fcn = (source)

Undocumented

Undocumented

@property
_has_slices = (source)

Undocumented

Whether this collection contains clips.

@property
_is_dynamic_groups = (source)

Whether this collection contains dynamic groups.

Whether this collection contains frames of a video dataset.

@property
_is_generated = (source)

Whether this collection's contents is generated from another collection.

@property
_is_patches = (source)

Whether this collection contains patches.

@property
_parent_media_type = (source)

Undocumented

@property
_root_dataset = (source)

The root fiftyone.core.dataset.Dataset from which this collection is derived.

This is typically the same as _dataset but may differ in cases such as patches views.