Update app.py
Browse filesTrying to see if I can get the json
app.py
CHANGED
@@ -24,7 +24,7 @@ def make_prediction(img, feature_extractor, model):
|
|
24 |
outputs = model(**inputs)
|
25 |
img_size = torch.tensor([tuple(reversed(img.size))])
|
26 |
processed_outputs = feature_extractor.post_process(outputs, img_size)
|
27 |
-
return processed_outputs
|
28 |
|
29 |
def fig2img(fig):
|
30 |
buf = io.BytesIO()
|
@@ -72,7 +72,9 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
72 |
image = image_input
|
73 |
|
74 |
#Make prediction
|
75 |
-
|
|
|
|
|
76 |
|
77 |
#Visualize prediction
|
78 |
viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
|
@@ -101,9 +103,9 @@ Links to HuggingFace Models:
|
|
101 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small','hustvl/yolos-tiny']
|
102 |
urls = ["https://c8.alamy.com/comp/J2AB4K/the-new-york-stock-exchange-on-the-wall-street-in-new-york-J2AB4K.jpg"]
|
103 |
|
104 |
-
twitter_link = """
|
105 |
-
[![](https://img.shields.io/twitter/follow/nickmuchi?label=@nickmuchi&style=social)](https://twitter.com/nickmuchi)
|
106 |
-
"""
|
107 |
|
108 |
css = '''
|
109 |
h1#title {
|
@@ -115,7 +117,7 @@ demo = gr.Blocks(css=css)
|
|
115 |
with demo:
|
116 |
gr.Markdown(title)
|
117 |
gr.Markdown(description)
|
118 |
-
gr.Markdown(twitter_link)
|
119 |
options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
|
120 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.7,label='Prediction Threshold')
|
121 |
|
|
|
24 |
outputs = model(**inputs)
|
25 |
img_size = torch.tensor([tuple(reversed(img.size))])
|
26 |
processed_outputs = feature_extractor.post_process(outputs, img_size)
|
27 |
+
return processed_outputs
|
28 |
|
29 |
def fig2img(fig):
|
30 |
buf = io.BytesIO()
|
|
|
72 |
image = image_input
|
73 |
|
74 |
#Make prediction
|
75 |
+
processed_output_list = make_prediction(image, feature_extractor, model)
|
76 |
+
print(processed_output_list[1:])
|
77 |
+
processed_output = processed_output_list[0]
|
78 |
|
79 |
#Visualize prediction
|
80 |
viz_img = visualize_prediction(image, processed_outputs, threshold, model.config.id2label)
|
|
|
103 |
models = ["facebook/detr-resnet-50","facebook/detr-resnet-101",'hustvl/yolos-small','hustvl/yolos-tiny']
|
104 |
urls = ["https://c8.alamy.com/comp/J2AB4K/the-new-york-stock-exchange-on-the-wall-street-in-new-york-J2AB4K.jpg"]
|
105 |
|
106 |
+
# twitter_link = """
|
107 |
+
# [![](https://img.shields.io/twitter/follow/nickmuchi?label=@nickmuchi&style=social)](https://twitter.com/nickmuchi)
|
108 |
+
# """
|
109 |
|
110 |
css = '''
|
111 |
h1#title {
|
|
|
117 |
with demo:
|
118 |
gr.Markdown(title)
|
119 |
gr.Markdown(description)
|
120 |
+
# gr.Markdown(twitter_link)
|
121 |
options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
|
122 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.7,label='Prediction Threshold')
|
123 |
|