Spaces:
Runtime error
Runtime error
Update app.py
Browse filesTrying to get the list working
app.py
CHANGED
|
@@ -66,12 +66,15 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
| 66 |
elif 'yolos' in model_name:
|
| 67 |
|
| 68 |
model = YolosForObjectDetection.from_pretrained(model_name)
|
| 69 |
-
|
|
|
|
| 70 |
if validators.url(url_input):
|
| 71 |
image = Image.open(requests.get(url_input, stream=True).raw)
|
|
|
|
| 72 |
|
| 73 |
elif image_input:
|
| 74 |
image = image_input
|
|
|
|
| 75 |
|
| 76 |
#Make prediction
|
| 77 |
processed_output_list = make_prediction(image, feature_extractor, model)
|
|
@@ -82,8 +85,8 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
| 82 |
viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
|
| 83 |
|
| 84 |
# return [viz_img, processed_outputs]
|
| 85 |
-
print(type(viz_img))
|
| 86 |
-
return viz_img
|
| 87 |
|
| 88 |
def set_example_image(example: list) -> dict:
|
| 89 |
return gr.Image.update(value=example[0])
|
|
@@ -150,16 +153,15 @@ with demo:
|
|
| 150 |
|
| 151 |
img_but = gr.Button('Detect')
|
| 152 |
|
| 153 |
-
output_text1 = gr.Textbox(value="", label="Confidence Values
|
| 154 |
-
output_text2 = gr.Textbox(value="", label="Confidence Values Upload")
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
# url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_url, _],queue=True)
|
| 159 |
# img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_upload, _],queue=True)
|
| 160 |
|
| 161 |
-
url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
|
| 162 |
-
img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
| 163 |
|
| 164 |
|
| 165 |
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
|
|
|
|
| 66 |
elif 'yolos' in model_name:
|
| 67 |
|
| 68 |
model = YolosForObjectDetection.from_pretrained(model_name)
|
| 69 |
+
|
| 70 |
+
tb_label = ""
|
| 71 |
if validators.url(url_input):
|
| 72 |
image = Image.open(requests.get(url_input, stream=True).raw)
|
| 73 |
+
tb_label = "Confidence Values URL"
|
| 74 |
|
| 75 |
elif image_input:
|
| 76 |
image = image_input
|
| 77 |
+
tb_label = "Confidence Values Upload"
|
| 78 |
|
| 79 |
#Make prediction
|
| 80 |
processed_output_list = make_prediction(image, feature_extractor, model)
|
|
|
|
| 85 |
viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
|
| 86 |
|
| 87 |
# return [viz_img, processed_outputs]
|
| 88 |
+
# print(type(viz_img))
|
| 89 |
+
return viz_img, gr.Textbox(value=str(processed_outputs),label=tb_label)
|
| 90 |
|
| 91 |
def set_example_image(example: list) -> dict:
|
| 92 |
return gr.Image.update(value=example[0])
|
|
|
|
| 153 |
|
| 154 |
img_but = gr.Button('Detect')
|
| 155 |
|
| 156 |
+
output_text1 = gr.Textbox(value="", label="Confidence Values")
|
|
|
|
| 157 |
|
| 158 |
+
url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_url, output_text1],queue=True)
|
| 159 |
+
img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=[img_output_from_upload, output_text1],queue=True)
|
| 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 |
+
# url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
|
| 164 |
+
# img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
| 165 |
|
| 166 |
|
| 167 |
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
|