Update app.py
Browse files
app.py
CHANGED
@@ -56,9 +56,13 @@ def match_image():
|
|
56 |
results = []
|
57 |
for b64_img in data["images"]:
|
58 |
try:
|
59 |
-
|
60 |
-
|
61 |
|
|
|
|
|
|
|
|
|
62 |
sims = cosine_similarity(query_embed, image_embeds)[0]
|
63 |
best_idx = np.argmax(sims)
|
64 |
|
|
|
56 |
results = []
|
57 |
for b64_img in data["images"]:
|
58 |
try:
|
59 |
+
# Convert Base64 → BytesIO
|
60 |
+
b_io = BytesIO(base64.b64decode(b64_img))
|
61 |
|
62 |
+
# Embed the query image
|
63 |
+
query_embed = np.array(clip_embd.embed_image([b_io]))
|
64 |
+
|
65 |
+
# Cosine similarity with stored embeddings
|
66 |
sims = cosine_similarity(query_embed, image_embeds)[0]
|
67 |
best_idx = np.argmax(sims)
|
68 |
|