Spaces:
Sleeping
Sleeping
Salida con texto e imagen
Browse files
app.py
CHANGED
|
@@ -8,12 +8,15 @@ model = YOLO('best.pt')
|
|
| 8 |
def detect_objects(image: Image.Image):
|
| 9 |
# Realizar la inferencia
|
| 10 |
results = model.predict(image)
|
| 11 |
-
|
| 12 |
-
# Obtener y
|
|
|
|
| 13 |
for r in results:
|
| 14 |
im_array = r.plot() # plot a BGR numpy array of predictions
|
| 15 |
-
im = Image.fromarray(im_array[..., ::-1]) #
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Crear la interfaz de Gradio
|
| 19 |
-
gr.Interface(fn=detect_objects, inputs="image", outputs="image").launch()
|
|
|
|
| 8 |
def detect_objects(image: Image.Image):
|
| 9 |
# Realizar la inferencia
|
| 10 |
results = model.predict(image)
|
| 11 |
+
|
| 12 |
+
# Obtener los resultados y el texto de descripci贸n
|
| 13 |
+
description = ""
|
| 14 |
for r in results:
|
| 15 |
im_array = r.plot() # plot a BGR numpy array of predictions
|
| 16 |
+
im = Image.fromarray(im_array[..., ::-1]) # Convertir a imagen RGB
|
| 17 |
+
description += r.print() # Obtener la descripci贸n de los objetos detectados
|
| 18 |
+
|
| 19 |
+
return im, description # Retornar la imagen y la descripci贸n
|
| 20 |
|
| 21 |
# Crear la interfaz de Gradio
|
| 22 |
+
gr.Interface(fn=detect_objects, inputs="image", outputs=["image", "text"]).launch()
|