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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -18
app.py CHANGED
@@ -60,7 +60,7 @@ def yolov8_img_inference(
60
  object_counts = {x: 0 for x in names}
61
  for r in results:
62
  for c in r.boxes.cls:
63
- c = c.add(names[int(c)])
64
  if c in names:
65
  object_counts[c] += 1
66
  elif c not in names:
@@ -108,23 +108,7 @@ def yolov8_img_inference(
108
  # output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
109
  # return output_image['image']
110
  # render = render_result(model=model, image=image, result=results[0])
111
- def count_objects(predictions, target_classes):
112
- object_counts = {x: 0 for x in target_classes}
113
- for prediction in predictions:
114
- for c in prediction.boxes.cls:
115
- c = int(c)
116
- if c in target_classes:
117
- object_counts[c] += 1
118
- elif c not in target_classes:
119
- object_counts[c] = 1
120
-
121
- present_objects = object_counts.copy()
122
-
123
- for i in object_counts:
124
- if object_counts[i] < 1:
125
- present_objects.pop(i)
126
-
127
- return present_objects
128
 
129
 
130
 
 
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:
 
108
  # output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
109
  # return output_image['image']
110
  # render = render_result(model=model, image=image, result=results[0])
111
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
 
114