Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,22 +29,22 @@ def process_img(image):
|
|
| 29 |
lbel=''
|
| 30 |
if len(result[0].boxes)>0:
|
| 31 |
ann=Annotator(im=image)
|
| 32 |
-
boxes=result[0].boxes
|
| 33 |
for element in boxes:
|
| 34 |
-
box=np.array(element.cpu()).flatten()
|
| 35 |
-
if
|
| 36 |
lbel='car'
|
| 37 |
-
if
|
| 38 |
lbel='bicycle'
|
| 39 |
-
if
|
| 40 |
lbel='bus'
|
| 41 |
-
if
|
| 42 |
lbel='motorcycle'
|
| 43 |
-
if
|
| 44 |
lbel='person'
|
| 45 |
-
if
|
| 46 |
lbel='train'
|
| 47 |
-
if
|
| 48 |
lbel='truck'
|
| 49 |
|
| 50 |
ann.box_label(box=box, label=lbel, color=(0,128,0))
|
|
|
|
| 29 |
lbel=''
|
| 30 |
if len(result[0].boxes)>0:
|
| 31 |
ann=Annotator(im=image)
|
| 32 |
+
boxes=result[0].boxes
|
| 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 |
+
if element.cls[0].cpu().numpy()==0.0:
|
| 38 |
lbel='bicycle'
|
| 39 |
+
if element.cls[0].cpu().numpy()==1.0:
|
| 40 |
lbel='bus'
|
| 41 |
+
if element.cls[0].cpu().numpy()==3.0:
|
| 42 |
lbel='motorcycle'
|
| 43 |
+
if element.cls[0].cpu().numpy()==4.0:
|
| 44 |
lbel='person'
|
| 45 |
+
if element.cls[0].cpu().numpy()==5.0:
|
| 46 |
lbel='train'
|
| 47 |
+
if element.cls[0].cpu().numpy()==6.0:
|
| 48 |
lbel='truck'
|
| 49 |
|
| 50 |
ann.box_label(box=box, label=lbel, color=(0,128,0))
|