meaculpitt commited on
Commit
eabfd0e
·
verified ·
1 Parent(s): fb114f1

quad-4 tiling + v3 epoch-10 weights: mAP@50 0.406->0.728

Browse files
Files changed (2) hide show
  1. miner.py +29 -35
  2. 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
- """Two-tile top/bottom SAHI inference.
356
-
357
- The validator's tiny plates (5-12 px tall on 1408x768 starter
358
- frames) are below YOLO's stride-8 detection footprint at native
359
- resolution, so the single-pass letterbox baseline misses most of
360
- them. This method runs two overlapping tile passes top half
361
- ``[0, H/2 + 38]`` and bottom half ``[H/2 - 38, H]`` — each
362
- anisotropically resized to ``(input_h, input_w)`` for ~1.82x
363
- vertical magnification (1.0x horizontal). Detections are combined
364
- and merged via Soft-NMS.
365
-
366
- Measured on the 7 starter frames vs the prior single-pass path:
367
- recall 0.200 -> 0.433
368
- precision 0.600 -> 0.765
369
- F1 0.300 -> 0.553
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
- top_dets = self._infer_tile(
388
- image_bgr, 0, 0, orig_w, min(orig_h, my + overlap_y),
389
- )
390
- bot_dets = self._infer_tile(
391
- image_bgr, 0, max(0, my - overlap_y), orig_w, orig_h,
392
- )
 
 
 
 
393
 
394
- dets = self._soft_nms(top_dets + bot_dets)
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:0efd393789de54f98641c351d090276f3bf9478a7dece825ee63a0e9259c8f34
3
- size 20255327
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67d8b41e983620717033516272c33c766676233bcbb4f8a62c312b743375eb97
3
+ size 19398393