nickmuchi commited on
Commit
b6842b7
·
1 Parent(s): 4a4185f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -75,13 +75,13 @@ def detect_objects(model_name,url_input,image_input,webcam_input,threshold):
75
  #Visualize prediction
76
  viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
77
 
78
- return viz_img
79
 
80
  def set_example_image(example: list) -> dict:
81
  return gr.Image.update(value=example[0])
82
 
83
  def set_example_url(example: list) -> dict:
84
- return gr.Textbox.update(value=example[0])
85
 
86
 
87
  title = """<h1 id="title">Face Mask Detection with YOLOS</h1>"""
@@ -124,6 +124,7 @@ with demo:
124
  with gr.TabItem('Image URL'):
125
  with gr.Row():
126
  url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
 
127
  img_output_from_url = gr.Image(shape=(750,750))
128
 
129
  with gr.Row():
@@ -150,9 +151,9 @@ with demo:
150
 
151
  cam_but = gr.Button('Detect')
152
 
153
- url_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=img_output_from_url,queue=True)
154
- img_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=img_output_from_upload,queue=True)
155
- cam_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=img_output_from_webcam,queue=True)
156
  example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
157
  example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
158
 
 
75
  #Visualize prediction
76
  viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
77
 
78
+ return viz_img, image
79
 
80
  def set_example_image(example: list) -> dict:
81
  return gr.Image.update(value=example[0])
82
 
83
  def set_example_url(example: list) -> dict:
84
+ return gr.Textbox.update(value=example[0]), display_url_input.update(image)
85
 
86
 
87
  title = """<h1 id="title">Face Mask Detection with YOLOS</h1>"""
 
124
  with gr.TabItem('Image URL'):
125
  with gr.Row():
126
  url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
127
+ orig_image = gr.Image(shape=(750,750))
128
  img_output_from_url = gr.Image(shape=(750,750))
129
 
130
  with gr.Row():
 
151
 
152
  cam_but = gr.Button('Detect')
153
 
154
+ url_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_url,orig_image],queue=True)
155
+ img_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_upload,orig_image],queue=True)
156
+ cam_but.click(detect_objects,inputs=[options,url_input,img_input,web_input,slider_input],outputs=[img_output_from_webcam,orig_image],queue=True)
157
  example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
158
  example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
159