class _PatchesView(fov.DatasetView): (source)
Known subclasses: fiftyone.core.patches.EvaluationPatchesView
, fiftyone.core.patches.PatchesView
Constructor: _PatchesView(source_collection, patches_stage, patches_dataset, _stages, ...)
Undocumented
Method | __copy__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | keep |
Deletes all patches that are not in this view from the underlying dataset. |
Method | keep |
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 |
Sets the fields of the specified labels in the collection to the given values. |
Method | set |
Sets the field or embedded field on each sample or frame in the collection to the given values. |
Class Variable | __slots__ |
Undocumented |
Property | is |
Whether the view is a saved view or not. |
Property | media |
The media type of the view. |
Property | name |
The name of the view if it is a saved view; otherwise None. |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _tag |
Undocumented |
Method | _to |
Undocumented |
Method | _untag |
Undocumented |
Instance Variable | __media |
Undocumented |
Instance Variable | __name |
Undocumented |
Instance Variable | __stages |
Undocumented |
Instance Variable | _patches |
Undocumented |
Instance Variable | _patches |
Undocumented |
Instance Variable | _source |
Undocumented |
Property | _all |
Undocumented |
Property | _base |
Undocumented |
Property | _dataset |
The fiftyone.core.dataset.Dataset that serves the samples in this collection. |
Property | _id |
Undocumented |
Property | _label |
Undocumented |
Property | _root |
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 |
Undocumented |
Method | classes |
Undocumented |
Method | clear |
Deletes all samples in the view from the underlying dataset. |
Method | clear |
Clears the values of the frame-level field from all samples in the view. |
Method | clear |
Clears the values of the frame-level fields from all samples in the view. |
Method | clear |
Deletes all frame labels from the samples in the view from the underlying dataset. |
Method | clear |
Clears the values of the field from all samples in the view. |
Method | clear |
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 |
Clones the frame-level field of the view into a new field. |
Method | clone |
Clones the frame-level fields of the view into new frame-level fields of the dataset. |
Method | clone |
Clones the given sample field of the view into a new field of the dataset. |
Method | clone |
Clones the given sample fields of the view into new fields of the dataset. |
Method | default |
Undocumented |
Method | default |
Undocumented |
Method | default |
Undocumented |
Method | description |
Undocumented |
Method | ensure |
Ensures that the video view contains frame instances for every frame of each sample's source video. |
Method | get |
Returns a view containing the samples from a dynamic grouped view with the given group value. |
Method | get |
Returns a schema dictionary describing the fields of the samples in the view. |
Method | get |
Returns a schema dictionary describing the fields of the frames of the samples in the view. |
Method | get |
Returns a dict containing the samples for the given group ID. |
Method | group |
Undocumented |
Method | info |
Undocumented |
Method | iter |
Returns an iterator over the dynamic groups in the view. |
Method | iter |
Returns an iterator over the groups in the view. |
Method | iter |
Returns an iterator over the samples in the view. |
Method | keep |
For each sample in the view, deletes all frames labels that are not in the view from the underlying dataset. |
Method | mask |
Undocumented |
Method | skeletons |
Undocumented |
Method | summary |
Returns a string summary of the view. |
Method | tags |
Undocumented |
Method | to |
Returns a JSON dictionary representation of the view. |
Method | view |
Returns a copy of this view. |
Property | app |
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 |
The name of the underlying dataset. |
Property | default |
The default classes of the underlying dataset. |
Property | default |
The default group slice of the view, or None if the view is not grouped. |
Property | default |
The default mask targets of the underlying dataset. |
Property | default |
The default keypoint skeleton of the underlying dataset. |
Property | description |
A description of the underlying dataset. |
Property | group |
The group field of the view, or None if the view is not grouped. |
Property | group |
A dict mapping group slices to media types, or None if the view is not grouped. |
Property | group |
The current group slice of the view, or None if the view is not grouped. |
Property | group |
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 |
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 |
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 |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _init |
Undocumented |
Method | _init |
Undocumented |
Method | _iter |
Undocumented |
Method | _iter |
Undocumented |
Method | _iter |
Undocumented |
Method | _make |
Undocumented |
Method | _make |
Undocumented |
Method | _make |
Undocumented |
Method | _needs |
Undocumented |
Method | _outputs |
Undocumented |
Method | _parse |
Undocumented |
Method | _pipeline |
Returns the MongoDB aggregation pipeline for the collection. |
Method | _serialize |
Undocumented |
Method | _slice |
Undocumented |
Instance Variable | __dataset |
Undocumented |
Instance Variable | __group |
Undocumented |
Instance Variable | _make |
Undocumented |
Instance Variable | _make |
Undocumented |
Property | _frame |
Undocumented |
Property | _has |
Undocumented |
Property | _is |
Whether this collection contains clips. |
Property | _is |
Whether this collection contains dynamic groups. |
Property | _is |
Whether this collection contains frames of a video dataset. |
Property | _is |
Whether this collection's contents is generated from another collection. |
Property | _is |
Whether this collection contains patches. |
Property | _parent |
Undocumented |
Property | _sample |
Undocumented |
Inherited from SampleCollection
(via DatasetView
):
Class Method | list |
Returns a list of all available methods on this collection that apply fiftyone.core.aggregations.Aggregation operations to this collection. |
Class Method | list |
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 |
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 |
Applies the model to the samples in the collection. |
Method | bounds |
Computes the bounds of a numeric field of the collection. |
Method | compute |
Computes embeddings for the samples in the collection using the given model. |
Method | compute |
Populates the metadata field of all samples in the collection. |
Method | compute |
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 |
Counts the occurrences of all label tags in the specified label field(s) of this collection. |
Method | count |
Counts the occurrences of sample tags in this collection. |
Method | count |
Counts the occurrences of field values in the collection. |
Method | create |
Creates an index on the given field or with the given specification, if necessary. |
Method | delete |
Deletes the annotation run with the given key from this collection. |
Method | delete |
Deletes all annotation runs from this collection. |
Method | delete |
Deletes the brain method run with the given key from this collection. |
Method | delete |
Deletes all brain method runs from this collection. |
Method | delete |
Deletes the evaluation results associated with the given evaluation key from this collection. |
Method | delete |
Deletes all evaluation results from this collection. |
Method | delete |
Deletes the run with the given key from this collection. |
Method | delete |
Deletes all runs from this collection. |
Method | distinct |
Computes the distinct values of a field in the collection. |
Method | draw |
Renders annotated versions of the media in the collection with the specified label data overlaid to the given directory. |
Method | drop |
Drops the index for the given field or name, if necessary. |
Method | evaluate |
Evaluates the classification predictions in this collection with respect to the specified ground truth labels. |
Method | evaluate |
Evaluates the specified predicted detections in this collection with respect to the specified ground truth detections. |
Method | evaluate |
Evaluates the regression predictions in this collection with respect to the specified ground truth values. |
Method | evaluate |
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 |
Excludes the samples with the given field values from the collection. |
Method | exclude |
Excludes the fields with the given names from the samples in the collection. |
Method | exclude |
Excludes the frames with the given IDs from the video collection. |
Method | exclude |
Excludes the groups with the given IDs from the grouped collection. |
Method | exclude |
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 |
Filters the values of a field or embedded field of each sample in the collection. |
Method | filter |
Filters the individual fiftyone.core.labels.Keypoint.points elements in the specified keypoints field of each sample in the collection. |
Method | filter |
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 |
Sorts the samples in the collection by their proximity to a specified geolocation. |
Method | geo |
Filters the samples in this collection to only include samples whose geolocation is within a specified boundary. |
Method | get |
Returns information about the annotation run with the given key on this collection. |
Method | get |
Returns information about the brain method run with the given key on this collection. |
Method | get |
Gets the classes list for the given field, or None if no classes are available. |
Method | get |
Returns a schema dictionary describing the dynamic fields of the samples in the collection. |
Method | get |
Returns a schema dictionary describing the dynamic fields of the frames in the collection. |
Method | get |
Returns information about the evaluation with the given key on this collection. |
Method | get |
Returns the field instance of the provided path, or None if one does not exist. |
Method | get |
Returns a dictionary of information about the indexes on this collection. |
Method | get |
Gets the mask targets for the given field, or None if no mask targets are available. |
Method | get |
Returns information about the run with the given key on this collection. |
Method | get |
Gets the keypoint skeleton for the given field, or None if no skeleton is available. |
Method | group |
Creates a view that groups the samples in the collection by a specified field or expression. |
Method | has |
Whether this collection has an annotation run with the given key. |
Method | has |
Whether this collection has a brain method run with the given key. |
Method | has |
Determines whether this collection has a classes list for the given field. |
Method | has |
Whether this collection has an evaluation with the given key. |
Method | has |
Determines whether the collection has a field with the given name. |
Method | has |
Determines whether the collection has a frame-level field with the given name. |
Method | has |
Determines whether this collection has mask targets for the given field. |
Method | has |
Whether this collection has a run with the given key. |
Method | has |
Determines whether the collection has a sample field with the given name. |
Method | has |
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 |
Computes a histogram of the field values in the collection. |
Method | init |
Initializes a config instance for a new run. |
Method | init |
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 |
Limits the number of fiftyone.core.labels.Label instances in the specified labels list field of each sample in the collection. |
Method | list |
Returns a list of annotation keys on this collection. |
Method | list |
Returns a list of brain keys on this collection. |
Method | list |
Returns a list of evaluation keys on this collection. |
Method | list |
Returns the list of index names on this collection. |
Method | list |
Returns a list of run keys on this collection. |
Method | list |
Extracts the value type(s) in a specified list field across all samples in the collection. |
Method | load |
Loads the results for the annotation run with the given key on this collection. |
Method | load |
Loads the fiftyone.core.view.DatasetView on which the specified annotation run was performed on this collection. |
Method | load |
Downloads the labels from the given annotation run from the annotation backend and merges them into this collection. |
Method | load |
Loads the results for the brain method run with the given key on this collection. |
Method | load |
Loads the fiftyone.core.view.DatasetView on which the specified brain method run was performed on this collection. |
Method | load |
Loads the results for the evaluation with the given key on this collection. |
Method | load |
Loads the fiftyone.core.view.DatasetView on which the specified evaluation was performed on this collection. |
Method | load |
Loads the results for the run with the given key on this collection. |
Method | load |
Loads the fiftyone.core.view.DatasetView on which the specified run was performed on this collection. |
Method | make |
Makes a unique field name with the given root name for the collection. |
Method | map |
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 |
Filters the frames in the video collection by the given filter. |
Method | match |
Selects the samples from the collection that contain (or do not contain) at least one label that matches the specified criteria. |
Method | match |
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 |
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 |
Registers a run under the given key on this collection. |
Method | rename |
Replaces the key for the given annotation run with a new key. |
Method | rename |
Replaces the key for the given brain run with a new key. |
Method | rename |
Replaces the key for the given evaluation with a new key. |
Method | rename |
Replaces the key for the given run with a new key. |
Method | save |
Returns a context that can be used to save samples from this collection according to a configurable batching strategy. |
Method | save |
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 |
Selects the samples with the given field values from the collection. |
Method | select |
Selects only the fields with the given names from the samples in the collection. All other fields are excluded. |
Method | select |
Selects the frames with the given IDs from the video collection. |
Method | select |
Selects the samples in the group collection from the given slice(s). |
Method | select |
Selects the groups with the given IDs from the grouped collection. |
Method | select |
Selects only the specified labels from the collection. |
Method | set |
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 |
Sorts the samples in the collection by the given field(s) or expression(s). |
Method | sort |
Sorts the collection by similarity to a specified query. |
Method | split |
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 |
Syncs the last_modified_at property(s) of the dataset. |
Method | tag |
Adds the tag(s) to all labels in the specified label field(s) of this collection, if necessary. |
Method | tag |
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 |
Creates a view that contains one sample per clip defined by the given field or expression in the video collection. |
Method | to |
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 |
Creates a view that contains one sample per frame in the video collection. |
Method | to |
Returns a JSON string representation of the collection. |
Method | to |
Creates a view that contains one sample per object patch in the specified field of the collection. |
Method | to |
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 |
Removes the tag from all labels in the specified label field(s) of this collection, if necessary. |
Method | untag |
Removes the tag(s) from all samples in this collection, if necessary. |
Method | update |
Updates the run config for the run with the given key. |
Method | validate |
Validates that the collection has a field of the given type. |
Method | validate |
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 |
Writes the colllection to disk in JSON format. |
Property | has |
Whether this collection has any annotation runs. |
Property | has |
Whether this collection has any brain runs. |
Property | has |
Whether this collection has any evaluation results. |
Property | has |
Whether this collection has any runs. |
Async Method | _async |
Undocumented |
Method | _build |
Undocumented |
Method | _build |
Undocumented |
Method | _build |
Undocumented |
Method | _build |
Undocumented |
Method | _contains |
Undocumented |
Method | _contains |
Undocumented |
Method | _delete |
Undocumented |
Method | _do |
Undocumented |
Method | _edit |
Undocumented |
Method | _edit |
Undocumented |
Method | _expand |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Computes the total size of the frame documents in the collection. |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Returns a dictionary mapping frame IDs to document sizes (in bytes) for each frame in the video collection. |
Method | _get |
Returns a dictionary mapping sample IDs to document sizes (in bytes) for each sample in the collection. |
Method | _get |
Returns a dictionary mapping sample IDs to total frame document sizes (in bytes) for each sample in the video collection. |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Computes the total size of the sample documents in the collection. |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _handle |
Undocumented |
Method | _handle |
Undocumented |
Method | _handle |
Undocumented |
Method | _handle |
Undocumented |
Method | _handle |
Undocumented |
Method | _has |
Undocumented |
Method | _has |
Undocumented |
Method | _has |
Undocumented |
Method | _is |
Undocumented |
Method | _is |
Undocumented |
Method | _is |
Undocumented |
Method | _is |
Undocumented |
Method | _is |
Undocumented |
Method | _is |
Undocumented |
Method | _list |
Undocumented |
Method | _make |
Undocumented |
Method | _make |
Undocumented |
Method | _max |
Undocumented |
Method | _min |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _parse |
Undocumented |
Method | _process |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _serialize |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _split |
Undocumented |
Method | _sync |
Undocumented |
Method | _sync |
Undocumented |
Method | _to |
Undocumented |
Method | _unwind |
Undocumented |
Method | _validate |
Undocumented |
Constant | _FRAMES |
Undocumented |
Constant | _GROUPS |
Undocumented |
Property | _element |
Undocumented |
Property | _elements |
Undocumented |
fiftyone.core.view.DatasetView.__init__
Undocumented
fiftyone.core.view.DatasetView.keep
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.
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.
fiftyone.core.view.DatasetView.reload
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.
fiftyone.core.view.DatasetView.save
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:None | an optional field or list of fields to save. If specified, only these fields are overwritten |
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 | a field or embedded.field.name |
*args | Undocumented |
skipFalse | whether to treat None data in values as missing data that should not be set |
dynamic:False | whether to declare dynamic attributes of embedded document fields that are encountered |
validate:True | whether to validate that the values are compliant with the dataset schema before adding them |
progress:False | whether 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 |
values | a dict mapping label IDs to values |
**kwargs | Undocumented |
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 | a field or embedded.field.name |
*args | Undocumented |
keyNone | a key field to use when choosing which samples to update when values is a dict |
skipFalse | whether to treat None data in values as missing data that should not be set |
expandTrue | whether 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:False | whether to declare dynamic attributes of embedded document fields that are encountered |
validate:True | whether to validate that the values are compliant with the dataset schema before adding them |
progress:False | whether 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 |
values | an 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 |
**kwargs | Undocumented |
fiftyone.core.view.DatasetView.name
The name of the view if it is a saved view; otherwise None.
fiftyone.core.view.DatasetView._dataset
The fiftyone.core.dataset.Dataset
that serves the samples
in this collection.
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.