VietCat commited on
Commit
9b96f24
·
1 Parent(s): 6998ed6
Files changed (2) hide show
  1. config.yaml +1 -1
  2. model.py +7 -9
config.yaml CHANGED
@@ -1,6 +1,6 @@
1
  model:
2
  path: 'VietCat/GTSRB-Model/models/GTSRB.pt' # Path to the YOLO model on Hugging Face Hub (will be downloaded automatically)
3
- confidence_threshold: 0.01 # Minimum confidence for detections (lowered for debugging)
4
 
5
  inference:
6
  box_color: (128, 0, 128) # Purple color for bounding boxes (BGR format)
 
1
  model:
2
  path: 'VietCat/GTSRB-Model/models/GTSRB.pt' # Path to the YOLO model on Hugging Face Hub (will be downloaded automatically)
3
+ confidence_threshold: 0.25 # Minimum confidence for detections
4
 
5
  inference:
6
  box_color: (128, 0, 128) # Purple color for bounding boxes (BGR format)
model.py CHANGED
@@ -114,8 +114,8 @@ class TrafficSignDetector:
114
  image = self._preprocess(image)
115
 
116
  # Use imgsz=640 to match training size
117
- # Run with conf=0.0 to get ALL detections
118
- results = self.model(image, conf=0.0, imgsz=640)
119
  print(f"Number of results: {len(results)}")
120
 
121
  # Get original dimensions for coordinate transformation
@@ -123,16 +123,14 @@ class TrafficSignDetector:
123
 
124
  for result in results:
125
  boxes = result.boxes
126
- print(f"Total boxes detected (all confidences): {len(boxes)}")
127
 
128
- # Debug: print all detection confidences
129
  if len(boxes) > 0:
130
- all_confidences = [float(box.conf[0]) for box in boxes]
131
- print(f"All detected confidences: {all_confidences}")
132
- print(f"Max confidence: {max(all_confidences):.4f}, Min: {min(all_confidences):.4f}")
133
  else:
134
- print(f"No detections at all (even with conf=0.0)")
135
- print(f"Model may not have detected any objects. Check if model was trained correctly.")
136
 
137
  for box in boxes:
138
  # Get bounding box coordinates from letterboxed image
 
114
  image = self._preprocess(image)
115
 
116
  # Use imgsz=640 to match training size
117
+ # Use iou_threshold for NMS (Non-Maximum Suppression) to remove overlapping boxes
118
+ results = self.model(image, conf=self.conf_threshold, imgsz=640, iou=0.45)
119
  print(f"Number of results: {len(results)}")
120
 
121
  # Get original dimensions for coordinate transformation
 
123
 
124
  for result in results:
125
  boxes = result.boxes
126
+ print(f"Total boxes detected (confidence >= {self.conf_threshold}): {len(boxes)}")
127
 
128
+ # Debug: print summary
129
  if len(boxes) > 0:
130
+ confidences = [float(box.conf[0]) for box in boxes]
131
+ print(f"Confidence range: {min(confidences):.4f} - {max(confidences):.4f}")
 
132
  else:
133
+ print(f"No detections above threshold {self.conf_threshold}")
 
134
 
135
  for box in boxes:
136
  # Get bounding box coordinates from letterboxed image