kiurtis commited on
Commit
268c989
·
1 Parent(s): da0fa8e

changed batch size

Browse files
Files changed (1) hide show
  1. tasks/image.py +5 -6
tasks/image.py CHANGED
@@ -16,7 +16,7 @@ load_dotenv()
16
  router = APIRouter()
17
 
18
  #MODEL_TYPE = "YOLOv11n"
19
- DESCRIPTION = f"YOLOv11n model 1280 with batch 64 inference"
20
  ROUTE = "/image"
21
 
22
  def parse_boxes(annotation_string):
@@ -123,7 +123,7 @@ async def evaluate_image(request: ImageEvaluationRequest):
123
  INFERENCE_ENGINE_TYPE = 'pt'
124
  INPUT_SIZE = 1280
125
  N_TEST_BATCHES = 2
126
- BATCH_SIZE = 64 # Can be adjusted as needed
127
 
128
  def preprocessor(frame):
129
  #frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # Only when read from file
@@ -301,21 +301,20 @@ async def evaluate_image(request: ImageEvaluationRequest):
301
  emissions_data = tracker.stop_task()
302
  predictions = all_binary_classifications
303
  # Calculate classification metrics
304
- print("true_labels", true_labels)
305
- print("predictions", predictions)
306
  classification_accuracy = accuracy_score(true_labels, predictions)
307
  classification_precision = precision_score(true_labels, predictions)
308
  classification_recall = recall_score(true_labels, predictions)
309
 
310
  # Calculate mean IoU for object detection (only for images with smoke)
311
  # For each image, we compute the max IoU between the predicted box and all true boxes
 
312
  ious = []
313
  for true_boxes, pred_box in zip(true_boxes_list, pred_boxes):
314
  max_iou = compute_max_iou(true_boxes, pred_box)
315
  ious.append(max_iou)
316
 
317
  mean_iou = float(np.mean(ious)) if ious else 0.0
318
-
319
  # Prepare results dictionary
320
  results = {
321
  "username": username,
@@ -336,5 +335,5 @@ async def evaluate_image(request: ImageEvaluationRequest):
336
  "test_seed": request.test_seed
337
  }
338
  }
339
-
340
  return results
 
16
  router = APIRouter()
17
 
18
  #MODEL_TYPE = "YOLOv11n"
19
+ DESCRIPTION = f"YOLOv11n model 1280 with batch 16 inference"
20
  ROUTE = "/image"
21
 
22
  def parse_boxes(annotation_string):
 
123
  INFERENCE_ENGINE_TYPE = 'pt'
124
  INPUT_SIZE = 1280
125
  N_TEST_BATCHES = 2
126
+ BATCH_SIZE = 16 # Can be adjusted as needed
127
 
128
  def preprocessor(frame):
129
  #frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # Only when read from file
 
301
  emissions_data = tracker.stop_task()
302
  predictions = all_binary_classifications
303
  # Calculate classification metrics
 
 
304
  classification_accuracy = accuracy_score(true_labels, predictions)
305
  classification_precision = precision_score(true_labels, predictions)
306
  classification_recall = recall_score(true_labels, predictions)
307
 
308
  # Calculate mean IoU for object detection (only for images with smoke)
309
  # For each image, we compute the max IoU between the predicted box and all true boxes
310
+ print("Calculating mean IoU")
311
  ious = []
312
  for true_boxes, pred_box in zip(true_boxes_list, pred_boxes):
313
  max_iou = compute_max_iou(true_boxes, pred_box)
314
  ious.append(max_iou)
315
 
316
  mean_iou = float(np.mean(ious)) if ious else 0.0
317
+ print("Mean IoU calculated")
318
  # Prepare results dictionary
319
  results = {
320
  "username": username,
 
335
  "test_seed": request.test_seed
336
  }
337
  }
338
+ print("Result returned")
339
  return results