Attention: This MediaPipe Solutions Preview is an early release. Learn more.

mp.tasks.components.utils.cosine_similarity.cosine_similarity

Stay organized with collections Save and categorize content based on your preferences.

Utility function to compute cosine similarity between two embedding.

May return an InvalidArgumentError if e.g. the feature vectors are of different types (quantized vs. float), have different sizes, or have an L2-norm of 0.

u An embedding.
v An embedding.

Cosine similarity value.