Spaces:
Runtime error
Runtime error
Commit
·
ad4e573
1
Parent(s):
26aedd3
Update main.py
Browse files
main.py
CHANGED
|
@@ -5,13 +5,15 @@ from PIL import Image
|
|
| 5 |
import io
|
| 6 |
import base64
|
| 7 |
from sentence_transformers import SentenceTransformer, util
|
| 8 |
-
import json
|
| 9 |
|
| 10 |
class Item(BaseModel):
|
| 11 |
name: str
|
| 12 |
image1: bytes
|
| 13 |
image2: bytes
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
app = FastAPI()
|
| 16 |
|
| 17 |
@app.get("/")
|
|
@@ -74,8 +76,7 @@ def predict(item: Item):
|
|
| 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 |
-
|
| 78 |
-
return score_json
|
| 79 |
|
| 80 |
#return "Score: {:.3f}%".format(score * 100)
|
| 81 |
|
|
|
|
| 5 |
import io
|
| 6 |
import base64
|
| 7 |
from sentence_transformers import SentenceTransformer, util
|
|
|
|
| 8 |
|
| 9 |
class Item(BaseModel):
|
| 10 |
name: str
|
| 11 |
image1: bytes
|
| 12 |
image2: bytes
|
| 13 |
|
| 14 |
+
class ScoreResponse(BaseModel):
|
| 15 |
+
score: float
|
| 16 |
+
|
| 17 |
app = FastAPI()
|
| 18 |
|
| 19 |
@app.get("/")
|
|
|
|
| 76 |
print("\nScore: {:.3f}%".format(score * 100))
|
| 77 |
|
| 78 |
formatted_score = round(score * 100, 3) # Multiplies by 100 and rounds to three decimal places
|
| 79 |
+
return ScoreResponse(score=formatted_score)
|
|
|
|
| 80 |
|
| 81 |
#return "Score: {:.3f}%".format(score * 100)
|
| 82 |
|