Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,8 +79,11 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
| 79 |
|
| 80 |
return viz_img
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
|
|
|
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
title = """<h1 id="title">Object Detection App with DETR and YOLOS</h1>"""
|
|
@@ -96,7 +99,12 @@ Links to HuggingFace Models:
|
|
| 96 |
|
| 97 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small']
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
with demo:
|
| 102 |
gr.Markdown(title)
|
|
@@ -133,6 +141,7 @@ with demo:
|
|
| 133 |
|
| 134 |
url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
|
| 135 |
img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
| 136 |
-
|
|
|
|
| 137 |
|
| 138 |
demo.launch(enable_queue=True)
|
|
|
|
| 79 |
|
| 80 |
return viz_img
|
| 81 |
|
| 82 |
+
def set_example_image(example: list) -> dict:
|
| 83 |
+
return gr.Image.update(value=example[0])
|
| 84 |
|
| 85 |
+
def set_example_url(example: list) -> dict:
|
| 86 |
+
return gr.Textbox.update(value=example[0])
|
| 87 |
|
| 88 |
|
| 89 |
title = """<h1 id="title">Object Detection App with DETR and YOLOS</h1>"""
|
|
|
|
| 99 |
|
| 100 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small']
|
| 101 |
|
| 102 |
+
css = '''
|
| 103 |
+
h1#title {
|
| 104 |
+
text-align: center;
|
| 105 |
+
}
|
| 106 |
+
'''
|
| 107 |
+
demo = gr.Blocks(css=css)
|
| 108 |
|
| 109 |
with demo:
|
| 110 |
gr.Markdown(title)
|
|
|
|
| 141 |
|
| 142 |
url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
|
| 143 |
img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
| 144 |
+
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[image_input])
|
| 145 |
+
example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
|
| 146 |
|
| 147 |
demo.launch(enable_queue=True)
|