Spaces:
Sleeping
Sleeping
Update app_front.py
Browse files- app_front.py +4 -1
app_front.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
|
|
|
| 5 |
|
| 6 |
# URL interna de la API
|
| 7 |
API_URL = "http://127.0.0.1:8000"
|
|
@@ -59,8 +60,10 @@ def analizar_foto(token, imagen):
|
|
| 59 |
det = res.headers.get("X-Detection", "Desconocido")
|
| 60 |
|
| 61 |
msg_formateado = msg_crudo.replace("|", "\n\n")
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
msg_formateado = msg_formateado.replace("\n\n\n", "\n
|
| 64 |
|
| 65 |
img_res = Image.open(io.BytesIO(res.content))
|
| 66 |
return f"## 🤖 ReciclIA Dice:\n{msg_formateado}\n\n**Objeto:** {det}", img_res, gr.update()
|
|
|
|
| 2 |
import requests
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
| 5 |
+
import re
|
| 6 |
|
| 7 |
# URL interna de la API
|
| 8 |
API_URL = "http://127.0.0.1:8000"
|
|
|
|
| 60 |
det = res.headers.get("X-Detection", "Desconocido")
|
| 61 |
|
| 62 |
msg_formateado = msg_crudo.replace("|", "\n\n")
|
| 63 |
+
|
| 64 |
+
msg_formateado = re.sub(r' +', ' ', msg_formateado)
|
| 65 |
|
| 66 |
+
msg_formateado = msg_formateado.replace(" \n", "\n").replace("\n ", "\n").strip()
|
| 67 |
|
| 68 |
img_res = Image.open(io.BytesIO(res.content))
|
| 69 |
return f"## 🤖 ReciclIA Dice:\n{msg_formateado}\n\n**Objeto:** {det}", img_res, gr.update()
|