Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,13 +25,13 @@ def find_similarity(image, text_input):
|
|
25 |
|
26 |
|
27 |
with torch.no_grad():
|
28 |
-
image_features = model.encode_image(image)
|
29 |
-
text_features = model.encode_text(text_tokens)
|
30 |
|
31 |
# Normalize features and calculate similarity
|
32 |
image_features /= image_features.norm(dim=-1, keepdim=True)
|
33 |
text_features /= text_features.norm(dim=-1, keepdim=True)
|
34 |
-
similarity = (text_features @ image_features.T).cpu().numpy()
|
35 |
|
36 |
return similarity[0, 0]
|
37 |
|
|
|
25 |
|
26 |
|
27 |
with torch.no_grad():
|
28 |
+
image_features = model.encode_image(image)
|
29 |
+
text_features = model.encode_text(text_tokens)
|
30 |
|
31 |
# Normalize features and calculate similarity
|
32 |
image_features /= image_features.norm(dim=-1, keepdim=True)
|
33 |
text_features /= text_features.norm(dim=-1, keepdim=True)
|
34 |
+
similarity = (text_features @ image_features.T).squeeze(0).cpu().numpy()
|
35 |
|
36 |
return similarity[0, 0]
|
37 |
|