Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,21 +33,34 @@ def process_img(image):
|
|
33 |
for element in boxes:
|
34 |
box=np.array(element.xyxy.cpu()).flatten()
|
35 |
if element.cls[0].cpu().numpy()==2.0:
|
36 |
-
|
|
|
|
|
37 |
if element.cls[0].cpu().numpy()==0.0:
|
38 |
-
|
|
|
|
|
39 |
if element.cls[0].cpu().numpy()==1.0:
|
40 |
-
|
|
|
|
|
41 |
if element.cls[0].cpu().numpy()==3.0:
|
42 |
-
|
|
|
|
|
43 |
if element.cls[0].cpu().numpy()==4.0:
|
44 |
-
|
|
|
|
|
45 |
if element.cls[0].cpu().numpy()==5.0:
|
46 |
-
|
|
|
|
|
47 |
if element.cls[0].cpu().numpy()==6.0:
|
48 |
-
|
|
|
49 |
|
50 |
-
ann.box_label(box=box, label=lbel, color=
|
51 |
vis=ann.result()
|
52 |
else:
|
53 |
vis = image
|
|
|
33 |
for element in boxes:
|
34 |
box=np.array(element.xyxy.cpu()).flatten()
|
35 |
if element.cls[0].cpu().numpy()==2.0:
|
36 |
+
lbel='car'
|
37 |
+
clr=(0,255,0)
|
38 |
+
|
39 |
if element.cls[0].cpu().numpy()==0.0:
|
40 |
+
lbel='bicycle'
|
41 |
+
clr=(255,0,0)
|
42 |
+
|
43 |
if element.cls[0].cpu().numpy()==1.0:
|
44 |
+
lbel='bus'
|
45 |
+
clr=(0,0,255)
|
46 |
+
|
47 |
if element.cls[0].cpu().numpy()==3.0:
|
48 |
+
lbel='motorcycle'
|
49 |
+
clr=(255,0,255)
|
50 |
+
|
51 |
if element.cls[0].cpu().numpy()==4.0:
|
52 |
+
lbel='person'
|
53 |
+
clr=(255,128,0)
|
54 |
+
|
55 |
if element.cls[0].cpu().numpy()==5.0:
|
56 |
+
lbel='train'
|
57 |
+
clr=(255,0,128)
|
58 |
+
|
59 |
if element.cls[0].cpu().numpy()==6.0:
|
60 |
+
lbel='truck'
|
61 |
+
clr=(0,255,255)
|
62 |
|
63 |
+
ann.box_label(box=box, label=lbel, color=clr)
|
64 |
vis=ann.result()
|
65 |
else:
|
66 |
vis = image
|