Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,14 +13,13 @@ if img is not None:
|
|
| 13 |
img = Image.open(img).resize((416,416)).convert('RGB')
|
| 14 |
results = model(img)
|
| 15 |
for result in results:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
draw.text(text_position, f'{cls} {lbl}', fill="red", font=font)
|
| 25 |
|
| 26 |
st.image(img,'Detected')
|
|
|
|
| 13 |
img = Image.open(img).resize((416,416)).convert('RGB')
|
| 14 |
results = model(img)
|
| 15 |
for result in results:
|
| 16 |
+
cls = result.boxes.cls[i]
|
| 17 |
+
cls = arr[int(cls)]
|
| 18 |
+
lbl = result.boxes.conf[i]
|
| 19 |
+
boxes = result.boxes.xyxy[i]
|
| 20 |
+
draw = ImageDraw.Draw(img)
|
| 21 |
+
draw.rectangle([boxes[0], boxes[1], boxes[2], boxes[3]], outline="black", width=5)
|
| 22 |
+
text_position = (boxes[0]+boxes[2])/2, boxes[1]-10
|
| 23 |
+
draw.text(text_position, f'{cls} {lbl}', fill="red", font=font)
|
|
|
|
| 24 |
|
| 25 |
st.image(img,'Detected')
|