Spaces:
Sleeping
Sleeping
Update tasks/image.py
Browse files- tasks/image.py +7 -4
tasks/image.py
CHANGED
@@ -5,7 +5,6 @@ import numpy as np
|
|
5 |
from sklearn.metrics import accuracy_score
|
6 |
import random
|
7 |
import os
|
8 |
-
from tqdm import tqdm
|
9 |
|
10 |
from ultralytics import YOLO # Import YOLO
|
11 |
from .utils.evaluation import ImageEvaluationRequest
|
@@ -108,8 +107,9 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
108 |
pred_boxes = [] # Flattened list of predicted boxes
|
109 |
true_boxes_list = [] # Flattened list of ground truth boxes
|
110 |
|
111 |
-
|
112 |
-
for example in
|
|
|
113 |
# Extract image and annotations
|
114 |
image = example["image"]
|
115 |
annotation = example.get("annotations", "").strip()
|
@@ -140,7 +140,10 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
140 |
predictions.append(0) # No smoke predicted
|
141 |
pred_boxes.append([]) # Add empty list if no prediction
|
142 |
|
143 |
-
|
|
|
|
|
|
|
144 |
# Filter out entries with empty boxes
|
145 |
filtered_true_boxes_list = []
|
146 |
filtered_pred_boxes = []
|
|
|
5 |
from sklearn.metrics import accuracy_score
|
6 |
import random
|
7 |
import os
|
|
|
8 |
|
9 |
from ultralytics import YOLO # Import YOLO
|
10 |
from .utils.evaluation import ImageEvaluationRequest
|
|
|
107 |
pred_boxes = [] # Flattened list of predicted boxes
|
108 |
true_boxes_list = [] # Flattened list of ground truth boxes
|
109 |
|
110 |
+
i = 0
|
111 |
+
for example in test_dataset:
|
112 |
+
i += 1
|
113 |
# Extract image and annotations
|
114 |
image = example["image"]
|
115 |
annotation = example.get("annotations", "").strip()
|
|
|
140 |
predictions.append(0) # No smoke predicted
|
141 |
pred_boxes.append([]) # Add empty list if no prediction
|
142 |
|
143 |
+
if i == 10:
|
144 |
+
break
|
145 |
+
|
146 |
+
|
147 |
# Filter out entries with empty boxes
|
148 |
filtered_true_boxes_list = []
|
149 |
filtered_pred_boxes = []
|