deploy push for crime (deploy)
Browse files
miner.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# build-marker:
|
| 2 |
"""SN44 crime detection miner — ENSEMBLE of alfred yolo26n + RF-DETR base.
|
| 3 |
|
| 4 |
Composes two internal miners with different preprocess/inference pipelines:
|
|
@@ -8,10 +8,10 @@ Composes two internal miners with different preprocess/inference pipelines:
|
|
| 8 |
Class routing (final union after per-class NMS@IoU=0.5, alfred wins conflicts):
|
| 9 |
cls0 balaclava : BOTH (alfred priority on conflicts)
|
| 10 |
cls1 hoodie : BOTH (alfred priority on conflicts)
|
| 11 |
-
cls2 glove :
|
| 12 |
-
cls3 bat :
|
| 13 |
-
cls4 spray paint:
|
| 14 |
-
cls5 graffiti : alfred only
|
| 15 |
|
| 16 |
Conf threshold 0.52 is applied INSIDE each internal miner; the union is the
|
| 17 |
already-thresholded boxes from each. This matches alfred's existing per-class
|
|
@@ -321,7 +321,13 @@ class Miner:
|
|
| 321 |
pass
|
| 322 |
self.alfred = _AlfredMiner(self.path_hf_repo)
|
| 323 |
self.rfdetr = _RFDETRMiner(self.path_hf_repo)
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
self.rfdetr_classes = {0, 1, 2, 3, 4}
|
| 326 |
self.merge_iou = 0.5
|
| 327 |
# Warmup
|
|
@@ -334,8 +340,9 @@ class Miner:
|
|
| 334 |
except Exception: break
|
| 335 |
|
| 336 |
def __repr__(self):
|
| 337 |
-
return (f"CrimeEnsembleMiner
|
| 338 |
-
f"rfdetr(base@1288) conf>=0.52 merge_iou={self.merge_iou}"
|
|
|
|
| 339 |
|
| 340 |
@staticmethod
|
| 341 |
def _box_iou(a: BoundingBox, b: BoundingBox) -> float:
|
|
@@ -348,9 +355,8 @@ class Miner:
|
|
| 348 |
|
| 349 |
def _merge(self, alfred_boxes: list, rfdetr_boxes: list) -> list:
|
| 350 |
"""Per-class union: alfred always kept; rfdetr kept ONLY if not overlapping
|
| 351 |
-
an alfred same-class box at IoU >= merge_iou. cls
|
| 352 |
-
|
| 353 |
-
cls 0/1 see both — alfred priority."""
|
| 354 |
kept = list(alfred_boxes)
|
| 355 |
for rb in rfdetr_boxes:
|
| 356 |
collide = False
|
|
|
|
| 1 |
+
# build-marker: v3-ensemble-alfred-priority-all
|
| 2 |
"""SN44 crime detection miner — ENSEMBLE of alfred yolo26n + RF-DETR base.
|
| 3 |
|
| 4 |
Composes two internal miners with different preprocess/inference pipelines:
|
|
|
|
| 8 |
Class routing (final union after per-class NMS@IoU=0.5, alfred wins conflicts):
|
| 9 |
cls0 balaclava : BOTH (alfred priority on conflicts)
|
| 10 |
cls1 hoodie : BOTH (alfred priority on conflicts)
|
| 11 |
+
cls2 glove : BOTH (alfred priority on conflicts)
|
| 12 |
+
cls3 bat : BOTH (alfred priority on conflicts)
|
| 13 |
+
cls4 spray paint: BOTH (alfred priority on conflicts)
|
| 14 |
+
cls5 graffiti : alfred only (RF-DETR can't read static walls)
|
| 15 |
|
| 16 |
Conf threshold 0.52 is applied INSIDE each internal miner; the union is the
|
| 17 |
already-thresholded boxes from each. This matches alfred's existing per-class
|
|
|
|
| 321 |
pass
|
| 322 |
self.alfred = _AlfredMiner(self.path_hf_repo)
|
| 323 |
self.rfdetr = _RFDETRMiner(self.path_hf_repo)
|
| 324 |
+
# v3 (2026-05-04): all classes go through alfred (was {0,1,5}).
|
| 325 |
+
# cid 61709 post-mortem showed alfred returning correct gloves at
|
| 326 |
+
# conf 0.79/0.89 that the prior {0,1,5} filter dropped, costing the
|
| 327 |
+
# full validator score on that frame. RF-DETR remains additive on
|
| 328 |
+
# cls 0..4; cls 5 (graffiti) stays alfred-only since RF-DETR can't
|
| 329 |
+
# read static walls.
|
| 330 |
+
self.alfred_classes = {0, 1, 2, 3, 4, 5}
|
| 331 |
self.rfdetr_classes = {0, 1, 2, 3, 4}
|
| 332 |
self.merge_iou = 0.5
|
| 333 |
# Warmup
|
|
|
|
| 340 |
except Exception: break
|
| 341 |
|
| 342 |
def __repr__(self):
|
| 343 |
+
return (f"CrimeEnsembleMiner v3 alfred(yolo26n@1280, TTA) + "
|
| 344 |
+
f"rfdetr(base@1288) conf>=0.52 merge_iou={self.merge_iou} "
|
| 345 |
+
f"alfred_priority_all_classes")
|
| 346 |
|
| 347 |
@staticmethod
|
| 348 |
def _box_iou(a: BoundingBox, b: BoundingBox) -> float:
|
|
|
|
| 355 |
|
| 356 |
def _merge(self, alfred_boxes: list, rfdetr_boxes: list) -> list:
|
| 357 |
"""Per-class union: alfred always kept; rfdetr kept ONLY if not overlapping
|
| 358 |
+
an alfred same-class box at IoU >= merge_iou. cls 0..4 see both — alfred
|
| 359 |
+
priority on conflicts; cls 5 is alfred-only (no rfdetr boxes there)."""
|
|
|
|
| 360 |
kept = list(alfred_boxes)
|
| 361 |
for rb in rfdetr_boxes:
|
| 362 |
collide = False
|