scorevision: push artifact
Browse files11234528 unmodified lines3435363637383839404142125 unmodified lines16816917017017117217337 unmodified lines2112122132142142152165 unmodified lines22222322422622522622722823122923023123223323723423523621 unmodified lines258259260265261262263"""ScoreVision crime detector — YOLOv11s with flip TTA + per-class conf + cross-class NMS.""""""ScoreVision crime detector v24 — YOLOv11s trained on rival-consensus labels.Per-class conf thresholds tuned vs validator-PGT proxy; flip TTA; cross-class NMS."""from pathlib import Pathimport math
28 unmodified lines cross_iou_thresh = 0.50 max_aspect_ratio = 10.0 max_det = 150 # tuned on held-out SAM3-labeled crime set # per-class thresholds — tuned on rival-consensus GT (proxy for validator PGT) _conf_thres_array = np.array( [0.50, 0.50, 0.30, 0.30, 0.40, 0.40], dtype=np.float32 [0.30, 0.70, 0.60, 0.50, 0.40, 0.40], dtype=np.float32 )
def __init__(self, path_hf_repo: Path) -> None:125 unmodified lines return np.array(keep_all, dtype=np.intp)
def _cross_class_dedup(self, boxes, scores, cls_ids, iou_thr): """If two boxes (any class) heavily overlap, keep only the higher-scoring one.""" n = len(boxes) if n == 0: return np.array([], dtype=np.intp)37 unmodified lines
def _decode(self, preds: ndarray, ratio: float, pad: tuple[float, float], orig_size: tuple[int, int]) -> tuple[np.ndarray, np.ndarray, np.ndarray]: """ONNX output is [1,300,6]: x1,y1,x2,y2,conf,cls in letterboxed coords.""" if preds.ndim == 3 and preds.shape[0] == 1: preds = preds[0] if preds.ndim != 2 or preds.shape[1] < 6:5 unmodified lines boxes = preds[:, :4].astype(np.float32) scores = preds[:, 4].astype(np.float32) cls_ids = preds[:, 5].astype(np.int32) # drop padded rows keep = (scores > 0) & (cls_ids >= 0) & (cls_ids < len(self.class_names)) boxes, scores, cls_ids = boxes[keep], scores[keep], cls_ids[keep] if len(boxes) == 0: return boxes, scores, cls_ids # per-class confidence thr = self._conf_thres_array[cls_ids] keep = scores >= thr boxes, scores, cls_ids = boxes[keep], scores[keep], cls_ids[keep] if len(boxes) == 0: return boxes, scores, cls_ids # untransform: subtract pad, divide ratio pad_w, pad_h = pad boxes[:, [0, 2]] -= pad_w boxes[:, [1, 3]] -= pad_h21 unmodified lines cls_ids = np.concatenate([c0, cf], axis=0) if len(b0) or len(bf) else c0 if len(boxes) == 0: return [] # filter + per-class NMS + cross-class dedup boxes, scores, cls_ids = self._filter_sane( boxes, scores, cls_ids, (image.shape[1], image.shape[0]) )miner.py+4-9