hello.fiftyone.brain module¶
- hello.fiftyone.brain.classification_hardness(samples, label_field, hardness_field='hardness')[source]¶
Adds a hardness field to each sample scoring the difficulty that the specified label field observed in classifying the sample.
All classifications must have their
logitsattributes populated in order to use this method.- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionlabel_field – the
fiftyone.core.labels.Classificationorfiftyone.core.labels.Classificationsfield to use from each samplehardness_field ("hardness") – the field name to use to store the hardness value for each sample
- hello.fiftyone.brain.compute_similarity(samples, patches_field=None, brain_key='img_sim', model='clip-vit-base32-torch', **kwargs)[source]¶
Uses embeddings to index the samples or their patches so that you can query/sort by similarity.
>>> compute_similarity(dataset, model="clip-vit-base32-torch", brain_key="img_sim") >>> compute_similarity(dataset, patches_field="ground_truth", model="clip-vit-base32-torch", brain_key="gt_sim")
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionpatches_field (None) – a sample field defining the image patches in each sample
brain_key ("img_sim") – a brain key under which to store the results of this method
model ("clip-vit-base32-torch) – a
fiftyone.core.models.Modelor the name of a model from the Model Zoo
- hello.fiftyone.brain.detection_mistakenness(samples, pred_field, label_field='ground_truth', mistakenness_field='mistakenness', missing_field='possible_missing', spurious_field='possible_spurious', use_logits=False, copy_missing=False)[source]¶
Computes the mistakenness of the labels in the specified
label_field, scoring the chance that the labels are incorrect.Mistakenness is computed based on the predictions in the
pred_field, through either theirconfidenceorlogitsattributes. This measure can be used to detect things like annotation errors and unusually hard samples.This method supports both classifications and detections/polylines.
For classifications, a
mistakenness_fieldfield is populated on each sample that quantifies the likelihood that the label in thelabel_fieldof that sample is incorrect.For detections/polylines, the mistakenness of each object in
label_fieldis computed. Three types of mistakes are identified:(Mistakes) Objects in
label_fieldwith a match inpred_fieldare assigned a mistakenness value in theirmistakenness_fieldthat captures the likelihood that the class label of the detection inlabel_fieldis a mistake. Amistakenness_field + "_loc"field is also populated that captures the likelihood that the detection inlabel_fieldis a mistake due to its localization (bounding box).(Missing) Objects in
pred_fieldwith no matches inlabel_fieldbut which are likely to be correct will have theirmissing_fieldattribute set to True. In addition, ifcopy_missingis True, copies of these objects are added to the ground truthlabel_field.(Spurious) Objects in
label_fieldwith no matches inpred_fieldbut which are likely to be incorrect will have theirspurious_fieldattribute set to True.
In addition, for detections/polylines, the following sample-level fields are populated:
(Mistakes) The
mistakenness_fieldof each sample is populated with the maximum mistakenness of the objects inlabel_field(Missing) The
missing_fieldof each sample is populated with the number of missing objects that were deemed missing fromlabel_field.(Spurious) The
spurious_fieldof each sample is populated with the number of objects inlabel_fieldthat were given deemed spurious.
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionpred_field – the name of the predicted label field to use from each sample. Can be of type
fiftyone.core.labels.Classification,fiftyone.core.labels.Classifications, orfiftyone.core.labels.Detectionslabel_field ("ground_truth") – the name of the “ground truth” label field that you want to test for mistakes with respect to the predictions in
pred_field. Must have the same type aspred_fieldmistakenness_field ("mistakenness") – the field name to use to store the mistakenness value for each sample
missing_field ("possible_missing) – the field in which to store per-sample counts of potential missing detections/polylines
spurious_field ("possible_spurious) – the field in which to store per-sample counts of potential spurious detections/polylines
use_logits (False) – whether to use logits (True) or confidence (False) to compute mistakenness. Logits typically yield better results, when they are available
copy_missing (False) – whether to copy predicted detections/polylines that were deemed to be missing into
label_field
- hello.fiftyone.brain.mistakenness_view(samples, min_mistakenness=0.5)[source]¶
Create a view containing the currently selected samples.
The following sample-level fields:
(mistakenness) The mistakenness field, store the mistakenness value.
(possible_missing) The missing field, store per-sample counts of potential missing.
(possible_spurious) The spurious field, store per-sample counts of potential spurious.
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionmin_mistakenness (0.5) – the mistakenness field minimum value
- hello.fiftyone.brain.mistakenness_views(samples, pred_field='predictions', pred_filter=None, label_field='ground_truth', label_filter=None)[source]¶
Create a view containing the currently selected objects.
- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionpred_field ("predictions") – the label field to filter
pred_filter (None) – a
fiftyone.core.expressions.ViewExpressionlabel_field ("ground_truth") – the label field to filter
label_filter (None) – a
fiftyone.core.expressions.ViewExpression
- hello.fiftyone.brain.patches_view(samples, field, **kwargs)[source]¶
Creates a view that contains one sample per object patch in the specified field of the collection.
Fields other than
fieldand the default sample fields will not be included in the returned view. Asample_idfield will be added that records the sample ID from which each patch was taken.- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionfield – the patches field, which must be of type
fiftyone.core.labels.Detectionsorfiftyone.core.labels.Polylines
- Returns:
a
fiftyone.core.patches.PatchesView
- hello.fiftyone.brain.to_patches(samples, field, **kwargs)[source]¶
Creates a view that contains one sample per object patch in the specified field of the collection.
Fields other than
fieldand the default sample fields will not be included in the returned view. Asample_idfield will be added that records the sample ID from which each patch was taken.- Parameters:
samples – a
fiftyone.core.collections.SampleCollectionfield – the patches field, which must be of type
fiftyone.core.labels.Detectionsorfiftyone.core.labels.Polylines
- Returns:
a
fiftyone.core.patches.PatchesView