Spaces:
Sleeping
Sleeping
Update tasks/image.py
Browse files- tasks/image.py +11 -7
tasks/image.py
CHANGED
@@ -116,20 +116,24 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
116 |
if has_smoke:
|
117 |
image_true_boxes = parse_boxes(annotation)
|
118 |
true_boxes_list.append(image_true_boxes)
|
119 |
-
|
120 |
# Perform YOLO inference
|
121 |
results = yolo_model.predict(image)
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
125 |
else:
|
126 |
-
|
127 |
else:
|
128 |
true_boxes_list.append([])
|
129 |
-
|
130 |
-
|
|
|
|
|
131 |
# Classification: If predictions exist, assume smoke is present
|
132 |
predictions.append(1 if len(results[0].boxes) > 0 else 0)
|
|
|
133 |
|
134 |
#--------------------------------------------------------------------------------------------
|
135 |
# YOUR MODEL INFERENCE STOPS HERE
|
|
|
116 |
if has_smoke:
|
117 |
image_true_boxes = parse_boxes(annotation)
|
118 |
true_boxes_list.append(image_true_boxes)
|
119 |
+
|
120 |
# Perform YOLO inference
|
121 |
results = yolo_model.predict(image)
|
122 |
+
|
123 |
+
# Extract predicted box if it exists
|
124 |
+
if len(results[0].boxes): # Check if predictions exist
|
125 |
+
pred_box = results[0].boxes.xywh[0].cpu().numpy().tolist() # Take the first box
|
126 |
else:
|
127 |
+
pred_box = [] # No prediction for this image
|
128 |
else:
|
129 |
true_boxes_list.append([])
|
130 |
+
pred_box = [] # No ground truth or predictions for this image
|
131 |
+
|
132 |
+
pred_boxes.append(pred_box)
|
133 |
+
|
134 |
# Classification: If predictions exist, assume smoke is present
|
135 |
predictions.append(1 if len(results[0].boxes) > 0 else 0)
|
136 |
+
|
137 |
|
138 |
#--------------------------------------------------------------------------------------------
|
139 |
# YOUR MODEL INFERENCE STOPS HERE
|