hello.fiftyone.view module¶
- hello.fiftyone.view.exclude_labels(dataset, labels=None, ids=None, tags=None, fields=None, omit_empty=True)[source]¶
Excludes the specified labels from the collection.
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionlabels (None) – a list of dicts specifying the labels to exclude in the format returned by
fiftyone.core.session.Session.selected_labels()ids (None) – an ID or iterable of IDs of the labels to exclude
tags (None) – a tag or iterable of tags of labels to exclude
fields (None) – a field or iterable of fields from which to exclude
omit_empty (True) – whether to omit samples that have no labels after filtering
- Returns:
a
fiftyone.core.view.DatasetView
- hello.fiftyone.view.filter_duplicate_labels(dataset, label_field, iou_thresh=0.999, method='simple', iscrowd=None, classwise=False)[source]¶
Delete duplicate labels in the given field of the dataset, as defined as labels with an IoU greater than a chosen threshold with another label in the field.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetlabel_field – a label field of type
fiftyone.core.labels.Detectionsorfiftyone.core.labels.Polylinesiou_thresh (0.999) – the IoU threshold to use to determine whether labels are duplicates
method ("simple") – supported values are
("simple", "greedy")iscrowd (None) – an optional name of a boolean attribute
classwise (False) – different label values as always non-overlapping
- hello.fiftyone.view.filter_field(dataset, field, a, op, b, only_matches=True)[source]¶
Filters the values of a field or embedded field of each sample in the collection.
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionfield – the label field to filter
only_matches (True) – whether to only include samples with at least one label after filtering (True) or include all samples (False)
- hello.fiftyone.view.filter_labels(dataset, field, expression, only_matches=True)[source]¶
Filters the
fiftyone.core.labels.Labelfield of each sample in the collection.>>> from fiftyone import ViewField as F >>> filter_labels(dataset, "ground_truth", F("label") == "house") >>> filter_labels(dataset, "ground_truth", F("label").is_in(["cat", "dog"])) >>> filter_labels(dataset, "ground_truth", ~F("label").is_in(["cat", "dog"]), only_matches=False) >>> filter_labels(dataset, "predictions", F("confidence") > 0.8)
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionfield – the label field to filter
expression – a
fiftyone.core.expressions.ViewExpressiononly_matches (True) – whether to only include samples with at least one label after filtering (True) or include all samples (False)
- hello.fiftyone.view.filter_samples(dataset, expression)[source]¶
Filters the samples in the collection by the given filter.
>>> from fiftyone import ViewField as F >>> filter_samples(dataset, F("filepath").ends_with(".jpg")) >>> filter_samples(dataset, F("predictions.detections").length() >= 2) >>> # Only include samples whose `predictions` field contains at least >>> # one object with area smaller than 0.2 >>> bbox = F("bounding_box") >>> bbox_area = bbox[2] * bbox[3] >>> small_boxes = F("predictions.detections").filter(bbox_area < 0.2) >>> view = dataset.match(small_boxes.length() > 0)
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetexpression – a
fiftyone.core.expressions.ViewExpression
- hello.fiftyone.view.match_labels(dataset, labels=None, ids=None, tags=None, filter=None, fields=None, bool=None)[source]¶
Selects the samples from the collection that contain (or do not contain) at least one label that matches the specified criteria.
Note that, unlike
select_labels()andfilter_labels(), this stage will not filter the labels themselves; it only selects the corresponding samples.- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionlabels (None) – by
fiftyone.core.session.Session.selected_labels()ids (None) – an ID or iterable of IDs of the labels to select
tags (None) – a tag or iterable of tags of labels to select
filter (None) – a
fiftyone.core.expressions.ViewExpressionfields (None) – a field or iterable of fields from which to select
bool (None) – have (None or True) or do not have (False) at least one label
- Returns:
a
fiftyone.core.view.DatasetView
- hello.fiftyone.view.match_tags(dataset, tags, bool=None)[source]¶
Returns a view containing the samples in the collection that have (or do not have) any of the given tag(s).
- Parameters:
dataset – a
fiftyone.core.dataset.Datasettags – the tag or iterable of tags to match
bool (None) – whether to match samples that have (None or True) or do not have (False) the given tags
- Returns:
a
DatasetView
- hello.fiftyone.view.select_labels(dataset, labels=None, ids=None, tags=None, fields=None, omit_empty=True)[source]¶
Selects only the specified labels from the collection.
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionlabels (None) – a list of dicts specifying the labels to select in the format returned by
fiftyone.core.session.Session.selected_labels()ids (None) – an ID or iterable of IDs of the labels to select
tags (None) – a tag or iterable of tags of labels to select
fields (None) – a field or iterable of fields from which to select
omit_empty (True) – whether to omit samples that have no labels after filtering
- Returns:
a
fiftyone.core.view.DatasetView
- hello.fiftyone.view.set_label_values(dataset, field_name, values, **kwargs)[source]¶
Sets the fields of the specified labels in the collection to the given values.
Examples:
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)
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionfield_name – a field or
embedded.field.namevalues – a dict mapping label IDs to values
- hello.fiftyone.view.set_values(dataset, field_name, values, **kwargs)[source]¶
Sets the field or embedded field on each sample or frame in the collection to the given values.
- Parameters:
dataset – a
fiftyone.core.collections.SampleCollectionfield_name – a field or
embedded.field.namevalues – an iterable of values, one for each sample in the collection
- hello.fiftyone.view.uniqueness(dataset, count, brain_key='img_sim', model=None)[source]¶
The uniqueness of a Dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetcount (int, float) – specific int value or percentage
model (None) – a
fiftyone.core.models.Modelor the name of a model
Examples:
>>> model: 'clip-vit-base32-torch' # pip install ftfy regex >>> model: 'mobilenet-v2-imagenet-torch' >>> model: 'resnet50-imagenet-torch', 'resnet101-imagenet-torch', 'resnet152-imagenet-torch' >>> model: 'resnext50-32x4d-imagenet-torch', 'resnext101-32x8d-imagenet-torch' >>> model: 'wide-resnet50-2-imagenet-torch', 'wide-resnet101-2-imagenet-torch'
- Returns:
a
DatasetView