earthboypirl commited on
Commit
0d266c7
·
verified ·
1 Parent(s): c38b5c2

scorevision: push artifact

Browse files
Files changed (1) hide show
  1. miner.py +10 -20
miner.py CHANGED
@@ -27,27 +27,21 @@ class TVFrameResult(BaseModel):
27
  keypoints: list[tuple[int, int]] | None = None
28
 
29
 
30
- # Element: manak0/Detect-fire — objects order: 0=fire, 1=smoke, 2=fire extinguisher.
31
- # Model trained with identical class order; ids pass through unmapped.
32
- # Tuned by replicating the element's own scorer
33
- # (0.6*mAP50 + 0.4*(1-FP_per_image/10)) across a threshold sweep on held-out
34
- # data. For the 3-class v2 model 0.10 maximised composite (0.782); below that
35
- # false positives grow faster than recall, above it mAP drops off sharply.
36
- CONF_THRESHOLD = 0.10
37
  IMGSZ = 1280 # matches element preproc resize_long
38
 
39
 
40
  class Miner:
41
  def __init__(self, path_hf_repo: Path) -> None:
42
- self.model = YOLO(str(path_hf_repo / "fire-detection.pt"))
43
- try:
44
- self.half = self.model.device is not None and "cuda" in str(self.model.device)
45
- except Exception:
46
- self.half = False
47
- print("✅ Fire/Smoke/Extinguisher model loaded")
48
 
49
  def __repr__(self) -> str:
50
- return f"Detect-fire miner: {type(self.model).__name__} @ imgsz={IMGSZ}, conf={CONF_THRESHOLD}"
51
 
52
  def predict_batch(
53
  self,
@@ -70,12 +64,8 @@ class Miner:
70
  x1, y1, x2, y2, conf, cls_id = box.tolist()
71
  boxes.append(
72
  BoundingBox(
73
- x1=int(x1),
74
- y1=int(y1),
75
- x2=int(x2),
76
- y2=int(y2),
77
- cls_id=int(cls_id),
78
- conf=float(conf),
79
  )
80
  )
81
  out.append(TVFrameResult(frame_id=offset + i, boxes=boxes))
 
27
  keypoints: list[tuple[int, int]] | None = None
28
 
29
 
30
+ # Element: manak0/Detect-road-signs — objects: ["road sign"] (single class, id 0).
31
+ # Trained on LVIS street_sign + signboard + stop_sign, all mapped to class 0.
32
+ # CONF_THRESHOLD is set by the sweep that replicates the element's own scorer
33
+ # (0.6*mAP50 + 0.4*(1 - FP_per_image/10)).
34
+ CONF_THRESHOLD = 0.40
 
 
35
  IMGSZ = 1280 # matches element preproc resize_long
36
 
37
 
38
  class Miner:
39
  def __init__(self, path_hf_repo: Path) -> None:
40
+ self.model = YOLO(str(path_hf_repo / "road-sign-detection.pt"))
41
+ print("✅ Road-sign model loaded")
 
 
 
 
42
 
43
  def __repr__(self) -> str:
44
+ return f"Detect-road-signs miner: {type(self.model).__name__} @ imgsz={IMGSZ}, conf={CONF_THRESHOLD}"
45
 
46
  def predict_batch(
47
  self,
 
64
  x1, y1, x2, y2, conf, cls_id = box.tolist()
65
  boxes.append(
66
  BoundingBox(
67
+ x1=int(x1), y1=int(y1), x2=int(x2), y2=int(y2),
68
+ cls_id=int(cls_id), conf=float(conf),
 
 
 
 
69
  )
70
  )
71
  out.append(TVFrameResult(frame_id=offset + i, boxes=boxes))