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