Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,10 +56,20 @@ def yolov8_img_inference(
|
|
56 |
# count 'car' objects in the results
|
57 |
# count_result = results[0].boxes.cls[0].item()
|
58 |
# count_result = results[0].boxes.cls.tolist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
|
64 |
# clist= results[0].boxes.cls.tolist()
|
65 |
# cls = set()
|
@@ -67,7 +77,7 @@ def yolov8_img_inference(
|
|
67 |
# cls.add(model.names[int(cno)])
|
68 |
|
69 |
# count_result = results.pandas().xyxy[0].value_counts('name')
|
70 |
-
return render,
|
71 |
# results = model.predict(image, imgsz=image_size, return_outputs=True)
|
72 |
# results = model.predict(image)
|
73 |
# object_prediction_list = []
|
|
|
56 |
# count 'car' objects in the results
|
57 |
# count_result = results[0].boxes.cls[0].item()
|
58 |
# count_result = results[0].boxes.cls.tolist()
|
59 |
+
object_counts = {x: 0 for x in names}
|
60 |
+
for prediction in predictions:
|
61 |
+
for c in prediction.boxes.cls:
|
62 |
+
c = int(c)
|
63 |
+
if c in names:
|
64 |
+
object_counts[c] += 1
|
65 |
+
elif c not in names:
|
66 |
+
object_counts[c] = 1
|
67 |
|
68 |
+
present_objects = object_counts.copy()
|
69 |
+
|
70 |
+
for i in object_counts:
|
71 |
+
if object_counts[i] < 1:
|
72 |
+
present_objects.pop(i)
|
73 |
|
74 |
# clist= results[0].boxes.cls.tolist()
|
75 |
# cls = set()
|
|
|
77 |
# cls.add(model.names[int(cno)])
|
78 |
|
79 |
# count_result = results.pandas().xyxy[0].value_counts('name')
|
80 |
+
return render, present_objects
|
81 |
# results = model.predict(image, imgsz=image_size, return_outputs=True)
|
82 |
# results = model.predict(image)
|
83 |
# object_prediction_list = []
|