updates
Browse files
app.py
CHANGED
|
@@ -728,8 +728,12 @@ async def attention_heatmap(file: UploadFile = File(...)):
|
|
| 728 |
most_similar_id, most_similar_score, most_similar_img = None, -1, None
|
| 729 |
if old_records:
|
| 730 |
same_label = [
|
|
|
|
|
|
|
| 731 |
rec for rec in old_records
|
| 732 |
-
if
|
|
|
|
|
|
|
| 733 |
]
|
| 734 |
print(f"[heatmap-match] Found {len(same_label)} old heatmaps under label '{current_label}'")
|
| 735 |
|
|
@@ -740,7 +744,7 @@ async def attention_heatmap(file: UploadFile = File(...)):
|
|
| 740 |
max_idx = int(np.argmax(sim_scores))
|
| 741 |
best_sim = float(sim_scores[max_idx])
|
| 742 |
best_rec = same_label[max_idx]
|
| 743 |
-
if best_sim <
|
| 744 |
most_similar_id = best_rec.get("source")
|
| 745 |
most_similar_score = best_sim
|
| 746 |
most_similar_img = best_rec.get("image_base64")
|
|
|
|
| 728 |
most_similar_id, most_similar_score, most_similar_img = None, -1, None
|
| 729 |
if old_records:
|
| 730 |
same_label = [
|
| 731 |
+
# rec for rec in old_records
|
| 732 |
+
# if str(rec.get("label", "")).strip() == current_label
|
| 733 |
rec for rec in old_records
|
| 734 |
+
if rec.get("label") == current_label
|
| 735 |
+
and rec.get("embedding")
|
| 736 |
+
and rec.get("source") != file.filename
|
| 737 |
]
|
| 738 |
print(f"[heatmap-match] Found {len(same_label)} old heatmaps under label '{current_label}'")
|
| 739 |
|
|
|
|
| 744 |
max_idx = int(np.argmax(sim_scores))
|
| 745 |
best_sim = float(sim_scores[max_idx])
|
| 746 |
best_rec = same_label[max_idx]
|
| 747 |
+
if best_sim < 1: # 排除完全相同
|
| 748 |
most_similar_id = best_rec.get("source")
|
| 749 |
most_similar_score = best_sim
|
| 750 |
most_similar_img = best_rec.get("image_base64")
|