Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,20 +51,15 @@ def visualize_prediction(pil_img, output_dict, threshold=0.7, id2label=None):
|
|
51 |
plt.axis("off")
|
52 |
return fig2img(plt.gcf())
|
53 |
|
54 |
-
def detect_objects(model_name,
|
55 |
|
56 |
#Extract model and feature extractor
|
57 |
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
58 |
|
59 |
-
if 'detr' in model_name:
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
if validators.url(url_input):
|
65 |
-
image = Image.open(requests.get(url_input, stream=True).raw)
|
66 |
-
|
67 |
-
elif image_input:
|
68 |
image = image_input
|
69 |
|
70 |
#Make prediction
|
@@ -89,8 +84,6 @@ Links to HuggingFace Models:
|
|
89 |
"""
|
90 |
|
91 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101"]
|
92 |
-
urls = ["https://c8.alamy.com/comp/J2AB4K/the-new-york-stock-exchange-on-the-wall-street-in-new-york-J2AB4K.jpg"]
|
93 |
-
|
94 |
|
95 |
css = '''
|
96 |
h1#title {
|
@@ -120,8 +113,7 @@ with demo:
|
|
120 |
img_but = gr.Button('Detect')
|
121 |
|
122 |
|
123 |
-
|
124 |
-
img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
125 |
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
|
126 |
|
127 |
|
|
|
51 |
plt.axis("off")
|
52 |
return fig2img(plt.gcf())
|
53 |
|
54 |
+
def detect_objects(model_name,image_input,threshold):
|
55 |
|
56 |
#Extract model and feature extractor
|
57 |
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
58 |
|
59 |
+
if 'detr' in model_name:
|
60 |
+
model = DetrForObjectDetection.from_pretrained(model_name)
|
61 |
|
62 |
+
if image_input:
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
image = image_input
|
64 |
|
65 |
#Make prediction
|
|
|
84 |
"""
|
85 |
|
86 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101"]
|
|
|
|
|
87 |
|
88 |
css = '''
|
89 |
h1#title {
|
|
|
113 |
img_but = gr.Button('Detect')
|
114 |
|
115 |
|
116 |
+
img_but.click(detect_objects,inputs=[options,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
|
|
117 |
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
|
118 |
|
119 |
|