Spaces:
Build error
Build error
Update main.py
Browse files
main.py
CHANGED
|
@@ -516,12 +516,21 @@ def base64_in_immagine(dati_base64):
|
|
| 516 |
@app.post("/Image_To_Text")
|
| 517 |
def image_to_text(request: Request, input_data: InputImageToText):
|
| 518 |
base64_in_immagine(input_data.base64)
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
LoggaTesto("IMMAGINE", {"response": result}, False)
|
| 526 |
return {"response": result}
|
| 527 |
|
|
|
|
| 516 |
@app.post("/Image_To_Text")
|
| 517 |
def image_to_text(request: Request, input_data: InputImageToText):
|
| 518 |
base64_in_immagine(input_data.base64)
|
| 519 |
+
Version = 1
|
| 520 |
+
if Version == 1:
|
| 521 |
+
client = Client("https://vikhyatk-moondream1.hf.space/--replicas/av7ct/")
|
| 522 |
+
result = client.predict(
|
| 523 |
+
"/tmp/img.jpg",
|
| 524 |
+
input_data.input,
|
| 525 |
+
api_name="/answer_question"
|
| 526 |
+
)
|
| 527 |
+
else:
|
| 528 |
+
client = Client("vikhyatk/moondream2")
|
| 529 |
+
result = client.predict(
|
| 530 |
+
"/tmp/img.jpg",
|
| 531 |
+
input_data.input,
|
| 532 |
+
api_name="/answer_question_1"
|
| 533 |
+
)
|
| 534 |
LoggaTesto("IMMAGINE", {"response": result}, False)
|
| 535 |
return {"response": result}
|
| 536 |
|