silver-A commited on
Commit
03c0240
1 Parent(s): 43ae077

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -28,7 +28,6 @@ category_dict = {
28
  77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'
29
  }
30
 
31
-
32
  @spaces.GPU(duration=200)
33
  def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
34
  model_path = download_models(model_id)
@@ -44,6 +43,11 @@ def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold
44
 
45
  return annotated_image
46
 
 
 
 
 
 
47
  def app():
48
  with gr.Blocks():
49
  with gr.Row():
@@ -87,6 +91,8 @@ def app():
87
 
88
  with gr.Column():
89
  output_image = gr.Image(type="pil", label="Annotated Image")
 
 
90
 
91
  yolov10_infer.click(
92
  fn=yolov10_inference,
@@ -100,6 +106,17 @@ def app():
100
  outputs=[output_image],
101
  )
102
 
 
 
 
 
 
 
 
 
 
 
 
103
  gr.Examples(
104
  examples=[
105
  [
@@ -148,4 +165,4 @@ with gradio_app:
148
  with gr.Column():
149
  app()
150
 
151
- gradio_app.launch(debug=True)
 
28
  77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'
29
  }
30
 
 
31
  @spaces.GPU(duration=200)
32
  def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold):
33
  model_path = download_models(model_id)
 
43
 
44
  return annotated_image
45
 
46
+ def yolov10_inference_multi(image, image_size, conf_threshold, iou_threshold):
47
+ yolov10s_image = yolov10_inference(image, "yolov10s.pt", image_size, conf_threshold, iou_threshold)
48
+ yolov10m_image = yolov10_inference(image, "yolov10m.pt", image_size, conf_threshold, iou_threshold)
49
+ return yolov10s_image, yolov10m_image
50
+
51
  def app():
52
  with gr.Blocks():
53
  with gr.Row():
 
91
 
92
  with gr.Column():
93
  output_image = gr.Image(type="pil", label="Annotated Image")
94
+ output_image_s = gr.Image(type="pil", label="Annotated Image yolov10s")
95
+ output_image_m = gr.Image(type="pil", label="Annotated Image yolov10m")
96
 
97
  yolov10_infer.click(
98
  fn=yolov10_inference,
 
106
  outputs=[output_image],
107
  )
108
 
109
+ yolov10_infer.click(
110
+ fn=yolov10_inference_multi,
111
+ inputs=[
112
+ image,
113
+ image_size,
114
+ conf_threshold,
115
+ iou_threshold,
116
+ ],
117
+ outputs=[output_image_s, output_image_m],
118
+ )
119
+
120
  gr.Examples(
121
  examples=[
122
  [
 
165
  with gr.Column():
166
  app()
167
 
168
+ gradio_app.launch(debug=True)