tom-b974 commited on
Commit
289d26d
·
verified ·
1 Parent(s): 09359e3

Update tasks/image.py

Browse files
Files changed (1) hide show
  1. 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
- if len(results[0].boxes): # If predictions exist
123
- pred_box = results[0].boxes.xywh[0].cpu().numpy().tolist() # First box in YOLO format
124
- pred_boxes.append(pred_box)
 
125
  else:
126
- pred_boxes.append([]) # No prediction for this image
127
  else:
128
  true_boxes_list.append([])
129
- pred_boxes.append([])
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