Update app.py
Browse files
app.py
CHANGED
@@ -79,7 +79,7 @@ def detect(img,thr=0.2,trained_dataset='aitod'):
|
|
79 |
t_img = transformer(img).unsqueeze(0)#.unsqueeze(0) #[1,1,640,640]
|
80 |
size = torch.tensor([[t_img.shape[2], t_img.shape[3]]])
|
81 |
#print(t_img.shape)
|
82 |
-
if
|
83 |
labels, boxes, scores=model(t_img,size)
|
84 |
elif cope == 'cope12':
|
85 |
labels, boxes, scores=model2(t_img,size)
|
@@ -110,7 +110,7 @@ def detect(img,thr=0.2,trained_dataset='aitod'):
|
|
110 |
90: 'toothbrush'} #coco
|
111 |
|
112 |
label_color_dict = {8:'burlyWood',7:'red',6:'blue',5:'green',4:'yellow',3:'cyan',2:'magenta',1:'orange'}
|
113 |
-
if
|
114 |
for idx,b in enumerate(box):
|
115 |
label_i = lab[idx].item()
|
116 |
draw.rectangle(list(b), outline=label_color_dict[label_i], )
|
@@ -124,6 +124,6 @@ def detect(img,thr=0.2,trained_dataset='aitod'):
|
|
124 |
#save_path = Path('./output') / img_path.name
|
125 |
return img
|
126 |
|
127 |
-
interface = gr.Interface(fn=detect,inputs=["image",gr.Slider(label="thr", value=0.2, maximum=1, minimum=0),gr.Radio(['aitod','ten_classes','COCO'])],outputs="image",title="rt-cope detect")
|
128 |
|
129 |
interface.launch()
|
|
|
79 |
t_img = transformer(img).unsqueeze(0)#.unsqueeze(0) #[1,1,640,640]
|
80 |
size = torch.tensor([[t_img.shape[2], t_img.shape[3]]])
|
81 |
#print(t_img.shape)
|
82 |
+
if trained_dataset == 'aitod':
|
83 |
labels, boxes, scores=model(t_img,size)
|
84 |
elif cope == 'cope12':
|
85 |
labels, boxes, scores=model2(t_img,size)
|
|
|
110 |
90: 'toothbrush'} #coco
|
111 |
|
112 |
label_color_dict = {8:'burlyWood',7:'red',6:'blue',5:'green',4:'yellow',3:'cyan',2:'magenta',1:'orange'}
|
113 |
+
if trained_dataset == 'coco':
|
114 |
for idx,b in enumerate(box):
|
115 |
label_i = lab[idx].item()
|
116 |
draw.rectangle(list(b), outline=label_color_dict[label_i], )
|
|
|
124 |
#save_path = Path('./output') / img_path.name
|
125 |
return img
|
126 |
|
127 |
+
interface = gr.Interface(fn=detect,inputs=["image",gr.Slider(label="thr", value=0.2, maximum=1, minimum=0),gr.Radio(['aitod','ten_classes','COCO'],value='aitod')],outputs="image",title="rt-cope detect")
|
128 |
|
129 |
interface.launch()
|