Spaces:
Sleeping
Sleeping
fix bug
Browse files- config.yaml +1 -1
- 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.
|
| 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 |
-
#
|
| 118 |
-
results = self.model(image, conf=
|
| 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 (
|
| 127 |
|
| 128 |
-
# Debug: print
|
| 129 |
if len(boxes) > 0:
|
| 130 |
-
|
| 131 |
-
print(f"
|
| 132 |
-
print(f"Max confidence: {max(all_confidences):.4f}, Min: {min(all_confidences):.4f}")
|
| 133 |
else:
|
| 134 |
-
print(f"No detections
|
| 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
|