Spaces:
Runtime error
Runtime error
Commit
·
26aedd3
1
Parent(s):
24ea268
Update main.py
Browse files
main.py
CHANGED
|
@@ -5,6 +5,7 @@ from PIL import Image
|
|
| 5 |
import io
|
| 6 |
import base64
|
| 7 |
from sentence_transformers import SentenceTransformer, util
|
|
|
|
| 8 |
|
| 9 |
class Item(BaseModel):
|
| 10 |
name: str
|
|
@@ -72,7 +73,11 @@ def predict(item: Item):
|
|
| 72 |
for score, image_id1, image_id2 in near_duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 73 |
print("\nScore: {:.3f}%".format(score * 100))
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
#def update_item(item: Item):
|
| 78 |
# return item
|
|
|
|
| 5 |
import io
|
| 6 |
import base64
|
| 7 |
from sentence_transformers import SentenceTransformer, util
|
| 8 |
+
import json
|
| 9 |
|
| 10 |
class Item(BaseModel):
|
| 11 |
name: str
|
|
|
|
| 73 |
for score, image_id1, image_id2 in near_duplicates[0:NUM_SIMILAR_IMAGES]:
|
| 74 |
print("\nScore: {:.3f}%".format(score * 100))
|
| 75 |
|
| 76 |
+
formatted_score = round(score * 100, 3) # Multiplies by 100 and rounds to three decimal places
|
| 77 |
+
score_json = json.dumps({"score": formatted_score})
|
| 78 |
+
return score_json
|
| 79 |
+
|
| 80 |
+
#return "Score: {:.3f}%".format(score * 100)
|
| 81 |
|
| 82 |
#def update_item(item: Item):
|
| 83 |
# return item
|