class documentation
class PromptMixin(object): (source)
Known subclasses: fiftyone.utils.clip.zoo.TorchCLIPModel
, fiftyone.utils.open_clip.TorchOpenClipModel
, fiftyone.utils.transformers.ZeroShotTransformerPromptMixin
Mixin for Model
classes that can generate prompt embeddings.
This mixin allows for the possibility that only some instances of a class
are capable of generating prompt embeddings, per the value of the
can_embed_prompts
property.
Method | embed |
Generates an embedding for the given prompt. |
Method | embed |
Generates embeddings for the given prompts. |
Property | can |
Whether this instance can generate prompt embeddings. |
overridden in
fiftyone.utils.clip.zoo.TorchCLIPModel
, fiftyone.utils.open_clip.TorchOpenClipModel
, fiftyone.utils.transformers.ZeroShotTransformerPromptMixin
Generates an embedding for the given prompt.
Parameters | |
arg | the prompt |
Returns | |
a numpy array containing the embedding |
overridden in
fiftyone.utils.clip.zoo.TorchCLIPModel
, fiftyone.utils.open_clip.TorchOpenClipModel
, fiftyone.utils.transformers.ZeroShotTransformerPromptMixin
Generates embeddings for the given prompts.
Subclasses can override this method to increase efficiency, but, by
default, this method simply iterates over the data and applies
embed_prompt
to each.
Parameters | |
args | an iterable of prompts |
Returns | |
a numpy array containing the embeddings stacked along axis 0 |
overridden in
fiftyone.utils.clip.zoo.TorchCLIPModel
, fiftyone.utils.open_clip.TorchOpenClipModel
, fiftyone.utils.transformers.ZeroShotTransformerPromptMixin
Whether this instance can generate prompt embeddings.