Snearec commited on
Commit
0d6b2e0
1 Parent(s): b3bf7fa

Salida con texto e imagen

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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 mostrar los resultados
 
13
  for r in results:
14
  im_array = r.plot() # plot a BGR numpy array of predictions
15
- im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
16
- return im # retornar la imagen con los objetos detectados
 
 
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()