Beasto commited on
Commit
3f9cfc7
·
verified ·
1 Parent(s): 2500880

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
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
- for i in range(len(result.boxes.cls)):
17
- cls = result.boxes.cls[i]
18
- cls = arr[int(cls)]
19
- lbl = result.boxes.conf[i]
20
- boxes = result.boxes.xyxy[i]
21
- draw = ImageDraw.Draw(img)
22
- draw.rectangle([boxes[0], boxes[1], boxes[2], boxes[3]], outline="white", width=5)
23
- text_position = (boxes[0]+boxes[2])/2, boxes[1]-10
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')