Kaushik Bar
commited on
Commit
·
1c348f1
1
Parent(s):
a1c2ab5
adding yoloxl
Browse files
app.py
CHANGED
@@ -21,12 +21,14 @@ COLORS = [
|
|
21 |
]
|
22 |
|
23 |
def make_prediction(img, feature_extractor, model, model_name):
|
24 |
-
inputs = feature_extractor(img, return_tensors="pt")
|
25 |
-
outputs = model(**inputs)
|
26 |
if 'yolox' in model_name:
|
|
|
|
|
27 |
processed_outputs = {}
|
28 |
processed_outputs['boxes'], processed_outputs['labels'], processed_outputs['scores'] = model.decode_predictions(outputs)[0]
|
29 |
else:
|
|
|
|
|
30 |
img_size = torch.tensor([tuple(reversed(img.size))])
|
31 |
processed_outputs = feature_extractor.post_process(outputs, img_size)[0]
|
32 |
return processed_outputs
|
@@ -112,7 +114,7 @@ demo = gr.Blocks(css=css)
|
|
112 |
|
113 |
with demo:
|
114 |
gr.Markdown(title)
|
115 |
-
gr.Markdown(description)
|
116 |
options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
|
117 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,label='Prediction Threshold')
|
118 |
|
|
|
21 |
]
|
22 |
|
23 |
def make_prediction(img, feature_extractor, model, model_name):
|
|
|
|
|
24 |
if 'yolox' in model_name:
|
25 |
+
inputs = feature_extractor(img)
|
26 |
+
outputs = model(**inputs)
|
27 |
processed_outputs = {}
|
28 |
processed_outputs['boxes'], processed_outputs['labels'], processed_outputs['scores'] = model.decode_predictions(outputs)[0]
|
29 |
else:
|
30 |
+
inputs = feature_extractor(img, return_tensors="pt")
|
31 |
+
outputs = model(**inputs)
|
32 |
img_size = torch.tensor([tuple(reversed(img.size))])
|
33 |
processed_outputs = feature_extractor.post_process(outputs, img_size)[0]
|
34 |
return processed_outputs
|
|
|
114 |
|
115 |
with demo:
|
116 |
gr.Markdown(title)
|
117 |
+
#gr.Markdown(description)
|
118 |
options = gr.Dropdown(choices=models,label='Select Object Detection Model',show_label=True)
|
119 |
slider_input = gr.Slider(minimum=0.2,maximum=1,value=0.5,label='Prediction Threshold')
|
120 |
|