gatesla commited on
Commit
7e429a8
1 Parent(s): f5fb975

Update app.py

Browse files

Trying it with returning lists

Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -81,8 +81,8 @@ def detect_objects(model_name,url_input,image_input,threshold):
81
  #Visualize prediction
82
  viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
83
 
84
- # return [viz_img, processed_outputs]
85
- return viz_img
86
 
87
  def set_example_image(example: list) -> dict:
88
  return gr.Image.update(value=example[0])
@@ -124,8 +124,7 @@ with demo:
124
  options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
125
  slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.7,label='Prediction Threshold')
126
 
127
- output_text1 = gr.Textbox(value="", label="Confidence Values URL")
128
- output_text2 = gr.Textbox(value="", label="Confidence Values Upload")
129
 
130
  with gr.Tabs():
131
  with gr.TabItem('Image URL'):
@@ -149,12 +148,19 @@ with demo:
149
  for path in sorted(pathlib.Path('images').rglob('*.JPG'))])
150
 
151
  img_but = gr.Button('Detect')
152
-
 
 
153
 
154
  # url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_url, output_text1],queue=True)
155
  # img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_upload, output_text2],queue=True)
156
- url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
157
- img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
 
 
 
 
 
158
  example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
159
  example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
160
 
 
81
  #Visualize prediction
82
  viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
83
 
84
+ return [viz_img, processed_outputs]
85
+ # return viz_img
86
 
87
  def set_example_image(example: list) -> dict:
88
  return gr.Image.update(value=example[0])
 
124
  options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
125
  slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.7,label='Prediction Threshold')
126
 
127
+
 
128
 
129
  with gr.Tabs():
130
  with gr.TabItem('Image URL'):
 
148
  for path in sorted(pathlib.Path('images').rglob('*.JPG'))])
149
 
150
  img_but = gr.Button('Detect')
151
+
152
+ output_text1 = gr.Textbox(value="", label="Confidence Values URL")
153
+ output_text2 = gr.Textbox(value="", label="Confidence Values Upload")
154
 
155
  # url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_url, output_text1],queue=True)
156
  # img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_upload, output_text2],queue=True)
157
+ url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_url, _],queue=True)
158
+ img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_upload, _],queue=True)
159
+
160
+ # url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
161
+ # img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
162
+
163
+
164
  example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
165
  example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
166