class documentation

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_fields.setter Undocumented
Method predict Performs prediction on the given data.
Method predict_all Performs prediction on the given iterable of data.
Property needs_fields A dict mapping model-specific keys to sample field names.
Instance Variable _fields Undocumented
@needs_fields.setter
def needs_fields(self, fields): (source)

Undocumented

def predict(self, arg, sample=None): (source)

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
argthe data
sample:Nonethe 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
def predict_all(self, args, samples=None): (source)

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
argsan iterable of data
samples:Nonean 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
@property
needs_fields = (source)

A dict mapping model-specific keys to sample field names.