class documentation

Undocumented

Method __copy__ Undocumented
Method __init__ Undocumented
Method keep Deletes all patches that are not in this view from the underlying dataset.
Method keep_fields Deletes all patch field(s) that have been excluded from this view from the underlying dataset.
Method reload Reloads the view.
Method save Saves the patches in this view to the underlying dataset.
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.
Class Variable __slots__ Undocumented
Property is_saved Whether the view is a saved view or not.
Property media_type The media type of the view.
Property name The name of the view if it is a saved view; otherwise None.
Method _set_media_type Undocumented
Method _set_name Undocumented
Method _sync_source Undocumented
Method _sync_source_field Undocumented
Method _sync_source_field_schema Undocumented
Method _sync_source_keep_fields Undocumented
Method _sync_source_sample Undocumented
Method _sync_source_sample_field Undocumented
Method _tag_labels Undocumented
Method _to_source_ids Undocumented
Method _untag_labels Undocumented
Instance Variable __media_type Undocumented
Instance Variable __name Undocumented
Instance Variable __stages Undocumented
Instance Variable _patches_dataset Undocumented
Instance Variable _patches_stage Undocumented
Instance Variable _source_collection Undocumented
Property _all_stages Undocumented
Property _base_view Undocumented
Property _dataset The fiftyone.core.dataset.Dataset that serves the samples in this collection.
Property _id_field Undocumented
Property _label_fields Undocumented
Property _root_dataset The root fiftyone.core.dataset.Dataset from which this collection is derived.
Property _stages Undocumented

Inherited from DatasetView:

Method __eq__ Undocumented
Method __getitem__ 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_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 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.
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 mask_targets The mask targets of the underlying dataset.
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 _slice Undocumented
Instance Variable __dataset Undocumented
Instance Variable __group_slice Undocumented
Instance Variable _make_frame_fcn Undocumented
Instance Variable _make_sample_fcn Undocumented
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 _sample_cls Undocumented

Inherited from SampleCollection (via DatasetView):

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 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 _to_fields_str 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 __copy__(self): (source)
def __init__(self, source_collection, patches_stage, patches_dataset, _stages=None, _media_type=None, _name=None): (source)
def keep(self): (source)

Deletes all patches that are not in this 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 patch field(s) that have been excluded from this 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 reload(self): (source)

Reloads the view.

Note that PatchView instances are not singletons, so any in-memory patches extracted from this view will not be updated by calling this method.

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

Saves the patches in this view to the underlying dataset.

If this view contains any additional fields that were not extracted from the underlying dataset, these fields are not saved.

This method does not delete patches 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.

Parameters
fields:Nonean optional field or list of fields to save. If specified, only these fields are overwritten
def set_label_values(self, field_name, *args, **kwargs): (source)

Sets the fields of the specified labels in the collection to the given values.

Note

This method is appropriate when you have the IDs of the labels you wish to modify. See set_values and set_field if your updates are not keyed by label ID.

Examples:

import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone import ViewField as F

dataset = foz.load_zoo_dataset("quickstart")

#
# Populate a new boolean attribute on all high confidence labels
#

view = dataset.filter_labels("predictions", F("confidence") > 0.99)

label_ids = view.values("predictions.detections.id", unwind=True)
values = {_id: True for _id in label_ids}

dataset.set_label_values("predictions.detections.high_conf", values)

print(dataset.count("predictions.detections"))
print(len(label_ids))
print(dataset.count_values("predictions.detections.high_conf"))
Parameters
field_namea field or embedded.field.name
*argsUndocumented
skip_none:Falsewhether to treat None data in values as missing data that should not be set
dynamic:Falsewhether to declare dynamic attributes of embedded document fields that are encountered
validate:Truewhether to validate that the values are compliant with the dataset schema before adding them
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
valuesa dict mapping label IDs to values
**kwargsUndocumented
def set_values(self, field_name, *args, **kwargs): (source)

Sets the field or embedded field on each sample or frame in the collection to the given values.

When setting a sample field embedded.field.name, this function is an efficient implementation of the following loop:

for sample, value in zip(sample_collection, values):
    sample.embedded.field.name = value
    sample.save()

When setting an embedded field that contains an array, say embedded.array.field.name, this function is an efficient implementation of the following loop:

for sample, array_values in zip(sample_collection, values):
    for doc, value in zip(sample.embedded.array, array_values):
        doc.field.name = value

    sample.save()

When setting a frame field frames.embedded.field.name, this function is an efficient implementation of the following loop:

for sample, frame_values in zip(sample_collection, values):
    for frame, value in zip(sample.frames.values(), frame_values):
        frame.embedded.field.name = value

    sample.save()

When setting an embedded frame field that contains an array, say frames.embedded.array.field.name, this function is an efficient implementation of the following loop:

for sample, frame_values in zip(sample_collection, values):
    for frame, array_values in zip(sample.frames.values(), frame_values):
        for doc, value in zip(frame.embedded.array, array_values):
            doc.field.name = value

    sample.save()

When values is a dict mapping keys in key_field to values, then this function is an efficient implementation of the following loop:

for key, value in values.items():
    sample = sample_collection.one(F(key_field) == key)
    sample.embedded.field.name = value
    sample.save()

When setting frame fields using the dict values syntax, each value in values may either be a list corresponding to the frames of the sample matching the given key, or each value may itself be a dict mapping frame numbers to values. In the latter case, this function is an efficient implementation of the following loop:

for key, frame_values in values.items():
    sample = sample_collection.one(F(key_field) == key)
    for frame_number, value in frame_values.items():
        frame = sample[frame_number]
        frame.embedded.field.name = value

    sample.save()

You can also update list fields using the dict values syntax, in which case this method is an efficient implementation of the natural nested list modifications of the above sample/frame loops.

The dual function of set_values is values, which can be used to efficiently extract the values of a field or embedded field of all samples in a collection as lists of values in the same structure expected by this method.

Note

If the values you are setting can be described by a fiftyone.core.expressions.ViewExpression applied to the existing dataset contents, then consider using set_field + save for an even more efficient alternative to explicitly iterating over the dataset or calling values + set_values to perform the update in-memory.

Examples:

import random

import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone import ViewField as F

dataset = foz.load_zoo_dataset("quickstart")

#
# Create a new sample field
#

values = [random.random() for _ in range(len(dataset))]
dataset.set_values("random", values)

print(dataset.bounds("random"))

#
# Add a tag to all low confidence labels
#

view = dataset.filter_labels("predictions", F("confidence") < 0.06)

detections = view.values("predictions.detections")
for sample_detections in detections:
    for detection in sample_detections:
        detection.tags.append("low_confidence")

view.set_values("predictions.detections", detections)

print(dataset.count_label_tags())
Parameters
field_namea field or embedded.field.name
*argsUndocumented
key_field:Nonea key field to use when choosing which samples to update when values is a dict
skip_none:Falsewhether to treat None data in values as missing data that should not be set
expand_schema:Truewhether to dynamically add new sample/frame fields encountered to the dataset schema. If False, an error is raised if the root field_name does not exist
dynamic:Falsewhether to declare dynamic attributes of embedded document fields that are encountered
validate:Truewhether to validate that the values are compliant with the dataset schema before adding them
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
valuesan iterable of values, one for each sample in the collection. When setting frame fields, each element can either be an iterable of values (one for each existing frame of the sample) or a dict mapping frame numbers to values. If field_name contains array fields, the corresponding elements of values must be arrays of the same lengths. This argument can also be a dict mapping keys to values (each value as described previously), in which case the keys are used to match samples by their key_field
**kwargsUndocumented

Whether the view is a saved view or not.

The media type of the view.

The name of the view if it is a saved view; otherwise None.

def _set_media_type(self, media_type): (source)
def _set_name(self, name): (source)
def _sync_source(self, fields=None, ids=None, update=True, delete=False): (source)

Undocumented

def _sync_source_field(self, field, ids=None, update=True, delete=False): (source)

Undocumented

def _sync_source_field_schema(self, path): (source)

Undocumented

def _sync_source_keep_fields(self): (source)

Undocumented

def _sync_source_sample(self, sample): (source)

Undocumented

def _sync_source_sample_field(self, sample, field): (source)

Undocumented

def _tag_labels(self, tags, label_field, ids=None, label_ids=None): (source)
def _to_source_ids(self, label_field, ids, label_ids): (source)

Undocumented

def _untag_labels(self, tags, label_field, ids=None, label_ids=None): (source)
_patches_dataset = (source)

Undocumented

_patches_stage = (source)

Undocumented

_source_collection = (source)

Undocumented

The fiftyone.core.dataset.Dataset that serves the samples in this collection.

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.