class SamplesMixin(object): (source)
Known subclasses: fiftyone.utils.sam2.SegmentAnything2VideoModel
, fiftyone.utils.torch.TorchSamplesMixin
Mixin for Model
classes that need samples for prediction.
Models can implement this mixin to declare that they require one or more fields of the current sample when performing inference on its media.
The fields are get/set via needs_fields
, which is a dict that maps
model-specific keys to sample field names:
model.needs_fields = {"key1": "field1", "key2": "field2", ...}
Method | __init__ |
Undocumented |
Method | needs |
Undocumented |
Method | predict |
Performs prediction on the given data. |
Method | predict |
Performs prediction on the given iterable of data. |
Property | needs |
A dict mapping model-specific keys to sample field names. |
Instance Variable | _fields |
Undocumented |
fiftyone.utils.sam.SegmentAnythingModel
, fiftyone.utils.sam2.SegmentAnything2VideoModel
Undocumented
fiftyone.utils.sam2.SegmentAnything2VideoModel
, fiftyone.utils.torch.TorchSamplesMixin
Performs prediction on the given data.
Image models should support, at minimum, processing arg values that are uint8 numpy arrays (HWC).
Video models should support, at minimum, processing arg values that are eta.core.video.VideoReader instances.
Parameters | |
arg | the data |
sample:None | the fiftyone.core.sample.Sample associated
with the data |
Returns | |
a fiftyone.core.labels.Label instance or dict of
fiftyone.core.labels.Label instances containing the
predictions |
fiftyone.utils.sam.SegmentAnythingModel
Performs prediction on the given iterable of data.
Image models should support, at minimum, processing args values that are either lists of uint8 numpy arrays (HWC) or numpy array tensors (NHWC).
Video models should support, at minimum, processing args values that are lists of eta.core.video.VideoReader instances.
Subclasses can override this method to increase efficiency, but, by
default, this method simply iterates over the data and applies
predict
to each.
Parameters | |
args | an iterable of data |
samples:None | an iterable of fiftyone.core.sample.Sample
instances associated with the data |
Returns | |
a list of fiftyone.core.labels.Label instances or a list
of dicts of fiftyone.core.labels.Label instances
containing the predictions |