Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,7 +65,7 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
| 65 |
|
| 66 |
model = YolosForObjectDetection.from_pretrained(model_name)
|
| 67 |
|
| 68 |
-
if
|
| 69 |
image = Image.open(requests.get(url_input, stream=True).raw)
|
| 70 |
|
| 71 |
elif image_input:
|
|
@@ -98,6 +98,8 @@ Links to HuggingFace Models:
|
|
| 98 |
"""
|
| 99 |
|
| 100 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small']
|
|
|
|
|
|
|
| 101 |
|
| 102 |
css = '''
|
| 103 |
h1#title {
|
|
@@ -115,14 +117,11 @@ with demo:
|
|
| 115 |
with gr.Tabs():
|
| 116 |
with gr.TabItem('Image URL'):
|
| 117 |
with gr.Row():
|
| 118 |
-
url_input = gr.Textbox(lines=
|
| 119 |
img_output_from_url = gr.Image(shape=(450,450))
|
| 120 |
|
| 121 |
with gr.Row():
|
| 122 |
-
|
| 123 |
-
example_url = gr.Dataset(components=[url_input],
|
| 124 |
-
samples=[[url]
|
| 125 |
-
for url in urls])
|
| 126 |
|
| 127 |
url_but = gr.Button('Detect')
|
| 128 |
|
|
|
|
| 65 |
|
| 66 |
model = YolosForObjectDetection.from_pretrained(model_name)
|
| 67 |
|
| 68 |
+
if validators.url(url_input):
|
| 69 |
image = Image.open(requests.get(url_input, stream=True).raw)
|
| 70 |
|
| 71 |
elif image_input:
|
|
|
|
| 98 |
"""
|
| 99 |
|
| 100 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small']
|
| 101 |
+
urls = ["https://media-cldnry.s-nbcnews.com/image/upload/t_fit-1500w,f_auto,q_auto:best/newscms/2020_14/3290756/200331-wall-street-ew-#343p.jpg"]
|
| 102 |
+
|
| 103 |
|
| 104 |
css = '''
|
| 105 |
h1#title {
|
|
|
|
| 117 |
with gr.Tabs():
|
| 118 |
with gr.TabItem('Image URL'):
|
| 119 |
with gr.Row():
|
| 120 |
+
url_input = gr.Textbox(lines=2,label='Enter valid image URL here..')
|
| 121 |
img_output_from_url = gr.Image(shape=(450,450))
|
| 122 |
|
| 123 |
with gr.Row():
|
| 124 |
+
example_url = gr.Dataset(components=[url_input],samples=[[str(url)] for url in urls])
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
url_but = gr.Button('Detect')
|
| 127 |
|