linhcuem commited on
Commit
cb31023
1 Parent(s): 72825f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -58,14 +58,21 @@ def yolov8_img_inference(
58
  # count_result = results[0].boxes.cls.tolist()
59
 
60
  object_counts = {x: 0 for x in names}
61
- for r in results:
62
- for c in r.boxes.cls:
63
- c = (names[int(c)])
64
- if c in names:
65
- object_counts[c] += 1
66
- elif c not in names:
67
- object_counts[c] = 1
68
-
 
 
 
 
 
 
 
69
  present_objects = object_counts.copy()
70
 
71
  for i in object_counts:
 
58
  # count_result = results[0].boxes.cls.tolist()
59
 
60
  object_counts = {x: 0 for x in names}
61
+ # for r in results:
62
+ # for c in r.boxes.cls:
63
+ # c = (names[int(c)])
64
+ # if c in names:
65
+ # object_counts[c] += 1
66
+ # elif c not in names:
67
+ # object_counts[c] = 1
68
+ clist = results[0].boxes.cls
69
+ cls = set()
70
+ for c in clist:
71
+ cls = cls.add(names[int(c)])
72
+ if c in names:
73
+ object_counts[c] += 1
74
+ elif c not in names:
75
+ object_counts[c] = 1
76
  present_objects = object_counts.copy()
77
 
78
  for i in object_counts: