Spaces:
Running
Running
Update app_main.py
Browse files- app_main.py +8 -1
app_main.py
CHANGED
@@ -373,7 +373,14 @@ def similarity_matching(input_json_path: str) -> str:
|
|
373 |
img_matrix = np.array([img["embeddings"] for img in embedding_json])
|
374 |
sprite_matrix = np.array(sprite_features)
|
375 |
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
most_similar_indices = np.argmax(similarity, axis=1)
|
378 |
|
379 |
# ============= Match and copy ================
|
|
|
373 |
img_matrix = np.array([img["embeddings"] for img in embedding_json])
|
374 |
sprite_matrix = np.array(sprite_features)
|
375 |
|
376 |
+
try:
|
377 |
+
similarity = np.matmul(sprite_matrix, img_matrix.T)
|
378 |
+
except ValueError as ve:
|
379 |
+
if "matmul" in str(ve) and "size" in str(ve):
|
380 |
+
logger.error("❌ Matrix multiplication failed due to shape mismatch. Likely due to empty or invalid embeddings.")
|
381 |
+
raise RuntimeError("Matrix shape mismatch: CLIP embedding input is invalid or empty.")
|
382 |
+
else:
|
383 |
+
raise
|
384 |
most_similar_indices = np.argmax(similarity, axis=1)
|
385 |
|
386 |
# ============= Match and copy ================
|