Class that performs dense feature vector extraction on images.
tflite_support
.
task
.
vision
.
ImageEmbedder
(
options
:
tflite_support
.
task
.
vision
.
ImageEmbedderOptions
,
cpp_embedder
:
_CppImageEmbedder
)
->
None
Methods
cosine_similarity
cosine_similarity
(
u
:
tflite_support
.
task
.
processor
.
FeatureVector
,
v
:
tflite_support
.
task
.
processor
.
FeatureVector
)
->
float
Computes cosine similarity [1] between two feature vectors.
create_from_file
@classmethodcreate_from_file ( file_path : str ) -> 'ImageEmbedder'
Creates the ImageEmbedder
object from a TensorFlow Lite model.
file_path
ImageEmbedder
object that's created from the model file.
ValueError
ImageEmbedder
object from the provided
file such as invalid file.RuntimeError
create_from_options
@classmethodcreate_from_options ( options :tflite_support . task . vision . ImageEmbedderOptions) -> 'ImageEmbedder'
Creates the ImageEmbedder
object from image embedder options.
options
ImageEmbedder
object that's created from options
.
ValueError
ImageEmbdder
object from ImageEmbedderOptions
such as missing the model.RuntimeError
embed
embed
(
image
:
tflite_support
.
task
.
vision
.
TensorImage
,
bounding_box
:
Optional
[
tflite_support
.
task
.
processor
.
BoundingBox
]
=
None
)
->
tflite_support
.
task
.
processor
.
EmbeddingResult
Performs actual feature vector extraction on the provided TensorImage.
image
bounding_box
ValueError
RuntimeError
get_embedding_by_index
get_embedding_by_index
(
result
:
tflite_support
.
task
.
processor
.
EmbeddingResult
,
output_index
:
int
)
->
tflite_support
.
task
.
processor
.
Embedding
Gets the embedding in the embedding result by output_index
.
result
output_index
get_embedding_dimension
get_embedding_dimension
(
output_index
:
int
)
->
int
Gets the dimensionality of the embedding output.
output_index
output_index
is out of bounds.

