You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I fixed it by changing the embedding_ontology.py in the following way:
defcosine_similarity(a: np.array, b: np.array) ->np.array:
""" Calculate the cosine similarity between two vectors. Args: a: The first vector. b: The second vector. Returns: The cosine similarity between the two vectors. """returnfloat(np.dot(a, b) / (np.linalg.norm(a) *np.linalg.norm(b)))
defcompare_embeddings(
image_embedding: np.array,
comparison_embeddings: List[np.array],
distance_metric="cosine",
):
""" Calculate the similarity between an image embedding and all embeddings in a list. Args: image_embedding: The embedding of the image to compare. comparison_embeddings: A list of embeddings to compare against. distance_metric: The distance metric to use. Currently only supports "cosine". Returns: A list of similarity scores. """ifdistance_metric=="cosine":
comparisons= []
forcomparison_embeddingincomparison_embeddings:
comparisons.append(
cosine_similarity(
image_embedding.reshape(-1), comparison_embedding.reshape(-1)
)
)
returnsv.Classifications(
class_id=np.array([iforiinrange(len(comparisons))]),
confidence=np.array(comparisons).flatten(),
)
else:
raiseNotImplementedError(
f"Distance metric {distance_metric} is not supported."
)
....
Search before asking
Bug
I want to use composed model:
But I'm getting:
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: