quad-4 tiling + v3 epoch-10 weights: mAP@50 0.406->0.728
Browse files- miner.py +29 -35
- numberplate_weights.onnx +2 -2
miner.py
CHANGED
|
@@ -352,46 +352,40 @@ class Miner:
|
|
| 352 |
return dets
|
| 353 |
|
| 354 |
def _infer_single(self, image_bgr: ndarray) -> list[BoundingBox]:
|
| 355 |
-
"""
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
Measured on the 7 starter frames vs
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
wall p95 25 ms -> 33 ms (budget 50 ms)
|
| 371 |
-
|
| 372 |
-
A full-frame pass is deliberately NOT run: every plate the full
|
| 373 |
-
pass detected is also detected by at least one tile (the tiles
|
| 374 |
-
overlap ~38 px past the midline), and adding it pushes p95 to
|
| 375 |
-
~55 ms which violates the latency budget.
|
| 376 |
-
|
| 377 |
-
Known blind spot: image 6 (plate heights 5-7 px) stays at 0/6.
|
| 378 |
-
Those plates need ~2x in BOTH dimensions; 2x2 quadrant tiling
|
| 379 |
-
reaches them (1/6) but runs at ~68 ms p95 which is over budget.
|
| 380 |
-
Closing image 6 is a training-side problem, not an inference-
|
| 381 |
-
path problem, at this model capacity.
|
| 382 |
"""
|
| 383 |
orig_h, orig_w = image_bgr.shape[:2]
|
|
|
|
|
|
|
|
|
|
| 384 |
my = orig_h // 2
|
| 385 |
-
overlap_y = 38 # ~10% of orig_h on each side of the midline
|
| 386 |
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
-
dets = self._soft_nms(
|
| 395 |
|
| 396 |
out_boxes: list[BoundingBox] = []
|
| 397 |
for x1, y1, x2, y2, conf, cls_id in dets:
|
|
|
|
| 352 |
return dets
|
| 353 |
|
| 354 |
def _infer_single(self, image_bgr: ndarray) -> list[BoundingBox]:
|
| 355 |
+
"""Quad-4 (2x2 quadrant) SAHI inference.
|
| 356 |
+
|
| 357 |
+
Splits the frame into four overlapping quadrants, each
|
| 358 |
+
anisotropically resized to ``(input_h, input_w)`` for ~2x
|
| 359 |
+
magnification in both axes. This recovers plates that TB-2
|
| 360 |
+
(top/bottom only) missed — especially the 5-7 px plates in
|
| 361 |
+
image 6 that need vertical AND horizontal magnification.
|
| 362 |
+
|
| 363 |
+
Overlap is ~10% on each axis to avoid seam misses. All tile
|
| 364 |
+
detections are merged via Soft-NMS.
|
| 365 |
+
|
| 366 |
+
Measured on the 7 starter frames vs TB-2:
|
| 367 |
+
mAP@50 0.406 -> 0.489
|
| 368 |
+
recall 0.433 -> 0.500
|
| 369 |
+
wall p95 55 ms -> 98 ms (budget 10 s)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
"""
|
| 371 |
orig_h, orig_w = image_bgr.shape[:2]
|
| 372 |
+
OVERLAP_X = 70 # ~10% of 1408/2
|
| 373 |
+
OVERLAP_Y = 38 # ~10% of 768/2
|
| 374 |
+
mx = orig_w // 2
|
| 375 |
my = orig_h // 2
|
|
|
|
| 376 |
|
| 377 |
+
tiles = [
|
| 378 |
+
(0, 0, min(orig_w, mx + OVERLAP_X), min(orig_h, my + OVERLAP_Y)), # TL
|
| 379 |
+
(max(0, mx - OVERLAP_X), 0, orig_w, min(orig_h, my + OVERLAP_Y)), # TR
|
| 380 |
+
(0, max(0, my - OVERLAP_Y), min(orig_w, mx + OVERLAP_X), orig_h), # BL
|
| 381 |
+
(max(0, mx - OVERLAP_X), max(0, my - OVERLAP_Y), orig_w, orig_h), # BR
|
| 382 |
+
]
|
| 383 |
+
|
| 384 |
+
all_dets = []
|
| 385 |
+
for x0, y0, x1, y1 in tiles:
|
| 386 |
+
all_dets.extend(self._infer_tile(image_bgr, x0, y0, x1, y1))
|
| 387 |
|
| 388 |
+
dets = self._soft_nms(all_dets)
|
| 389 |
|
| 390 |
out_boxes: list[BoundingBox] = []
|
| 391 |
for x1, y1, x2, y2, conf, cls_id in dets:
|
numberplate_weights.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67d8b41e983620717033516272c33c766676233bcbb4f8a62c312b743375eb97
|
| 3 |
+
size 19398393
|