Spaces:
Runtime error
Runtime error
Commit ·
af0c9d9
1
Parent(s): 0864ad4
Update main.py
Browse files
main.py
CHANGED
|
@@ -63,6 +63,13 @@ def predict(item: Item):
|
|
| 63 |
# Output the top X duplicate images
|
| 64 |
for score, image_id1, image_id2 in duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 65 |
print("\nScore: {:.3f}%".format(score * 100))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# =================
|
| 68 |
# NEAR DUPLICATES
|
|
@@ -75,11 +82,20 @@ def predict(item: Item):
|
|
| 75 |
threshold = 0.99
|
| 76 |
near_duplicates = [image for image in processed_images if image[0] < threshold]
|
| 77 |
|
| 78 |
-
for score, image_id1, image_id2 in near_duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 79 |
-
print("\nScore: {:.3f}%".format(score * 100))
|
| 80 |
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
return ScoreResponse(score=formatted_score)
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
#return "Score: {:.3f}%".format(score * 100)
|
| 85 |
|
|
|
|
| 63 |
# Output the top X duplicate images
|
| 64 |
for score, image_id1, image_id2 in duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 65 |
print("\nScore: {:.3f}%".format(score * 100))
|
| 66 |
+
|
| 67 |
+
# Check if there are any duplicates
|
| 68 |
+
if duplicates:
|
| 69 |
+
# Find the top score among duplicates
|
| 70 |
+
top_score = max(duplicates, key=lambda x: x[0])[0]
|
| 71 |
+
formatted_score = round(top_score * 100, 3) # Multiplies by 100 and rounds to three decimal places
|
| 72 |
+
return ScoreResponse(score=formatted_score)
|
| 73 |
|
| 74 |
# =================
|
| 75 |
# NEAR DUPLICATES
|
|
|
|
| 82 |
threshold = 0.99
|
| 83 |
near_duplicates = [image for image in processed_images if image[0] < threshold]
|
| 84 |
|
| 85 |
+
#for score, image_id1, image_id2 in near_duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 86 |
+
#print("\nScore: {:.3f}%".format(score * 100))
|
| 87 |
|
| 88 |
+
# Find the top score from near duplicates
|
| 89 |
+
if near_duplicates:
|
| 90 |
+
top_score = max(near_duplicates, key=lambda x: x[0])[0]
|
| 91 |
+
else:
|
| 92 |
+
top_score = 0 # Default score if there are no near duplicates
|
| 93 |
+
|
| 94 |
+
formatted_score = round(top_score * 100, 3) # Multiplies by 100 and rounds to three decimal places
|
| 95 |
return ScoreResponse(score=formatted_score)
|
| 96 |
+
|
| 97 |
+
#formatted_score = round(score * 100, 3) # Multiplies by 100 and rounds to three decimal places
|
| 98 |
+
#return ScoreResponse(score=formatted_score)
|
| 99 |
|
| 100 |
#return "Score: {:.3f}%".format(score * 100)
|
| 101 |
|