scorevision: push artifact
Browse files- chute_config.yml +1 -0
- miner.py +65 -30
- vehicle_weights.onnx +2 -2
chute_config.yml
CHANGED
|
@@ -13,3 +13,4 @@ Chute:
|
|
| 13 |
concurrency: 4
|
| 14 |
max_instances: 5
|
| 15 |
scaling_threshold: 0.5
|
|
|
|
|
|
| 13 |
concurrency: 4
|
| 14 |
max_instances: 5
|
| 15 |
scaling_threshold: 0.5
|
| 16 |
+
shutdown_after_seconds: 288000
|
miner.py
CHANGED
|
@@ -178,10 +178,12 @@ VEH_CONF_DEFAULT = 0.35
|
|
| 178 |
VEH_TTA_CONF = 0.10
|
| 179 |
VEH_WBF_IOU = 0.40
|
| 180 |
|
| 181 |
-
# ββ Person config βββββββββββββββββββββββββββββββββββββββββββ
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
| 185 |
|
| 186 |
# ββ Shared ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 187 |
WBF_SKIP_THR = 0.0001
|
|
@@ -508,36 +510,71 @@ class Miner:
|
|
| 508 |
|
| 509 |
def _infer_person(self, image_bgr):
|
| 510 |
oh, ow = image_bgr.shape[:2]
|
| 511 |
-
all_b, all_s = [], []
|
| 512 |
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
norm[:, [0, 2]] /= ow
|
| 518 |
-
norm[:, [1, 3]] /= oh
|
| 519 |
-
norm = np.clip(norm, 0, 1)
|
| 520 |
-
all_b.append(norm)
|
| 521 |
-
all_s.append(confs)
|
| 522 |
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
# Pass 2: hflip
|
| 527 |
flipped = cv2.flip(image_bgr, 1)
|
| 528 |
-
|
| 529 |
-
if len(
|
| 530 |
-
|
| 531 |
-
|
| 532 |
else:
|
| 533 |
-
|
| 534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
|
| 536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
return []
|
| 538 |
|
| 539 |
-
#
|
| 540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
|
| 542 |
if len(fb) == 0:
|
| 543 |
return []
|
|
@@ -545,9 +582,6 @@ class Miner:
|
|
| 545 |
fb[:, [0, 2]] *= ow
|
| 546 |
fb[:, [1, 3]] *= oh
|
| 547 |
|
| 548 |
-
keep = fs >= PER_CONF
|
| 549 |
-
fb, fs = fb[keep], fs[keep]
|
| 550 |
-
|
| 551 |
out = []
|
| 552 |
for i in range(len(fb)):
|
| 553 |
b = fb[i]
|
|
@@ -561,6 +595,7 @@ class Miner:
|
|
| 561 |
))
|
| 562 |
return out
|
| 563 |
|
|
|
|
| 564 |
# ββ Unified inference βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 565 |
|
| 566 |
def _infer_single(self, image_bgr: ndarray) -> list[BoundingBox]:
|
|
|
|
| 178 |
VEH_TTA_CONF = 0.10
|
| 179 |
VEH_WBF_IOU = 0.40
|
| 180 |
|
| 181 |
+
# ββ Person config (TTA consensus) βββββββββββββββββββββββββββββββββββββββββββ
|
| 182 |
+
PER_CONF_LOW = 0.32 # Detection threshold (both passes)
|
| 183 |
+
PER_CONF_HIGH = 0.55 # Above this = unconditionally kept
|
| 184 |
+
PER_CONSENSUS_IOU = 0.50 # Cross-view IoU to confirm low-conf box
|
| 185 |
+
PER_WBF_IOU = 0.40 # Final WBF dedup (unchanged)
|
| 186 |
+
PER_RTF_BUDGET = 8.0 # Conservative RTF budget (gate is 10s)
|
| 187 |
|
| 188 |
# ββ Shared ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 189 |
WBF_SKIP_THR = 0.0001
|
|
|
|
| 510 |
|
| 511 |
def _infer_person(self, image_bgr):
|
| 512 |
oh, ow = image_bgr.shape[:2]
|
|
|
|
| 513 |
|
| 514 |
+
# Pass 1: original
|
| 515 |
+
t_start = time.monotonic()
|
| 516 |
+
boxes_orig, confs_orig = self._per_run_pass(image_bgr, PER_CONF_LOW)
|
| 517 |
+
elapsed = time.monotonic() - t_start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
|
| 519 |
+
# Pass 2: hflip β only if RTF budget allows
|
| 520 |
+
has_flip = False
|
| 521 |
+
if elapsed < PER_RTF_BUDGET / 2:
|
|
|
|
| 522 |
flipped = cv2.flip(image_bgr, 1)
|
| 523 |
+
boxes_flip, confs_flip = self._per_run_pass(flipped, PER_CONF_LOW)
|
| 524 |
+
if len(boxes_flip):
|
| 525 |
+
boxes_flip[:, 0], boxes_flip[:, 2] = ow - boxes_flip[:, 2], ow - boxes_flip[:, 0]
|
| 526 |
+
has_flip = True
|
| 527 |
else:
|
| 528 |
+
logger.warning(f"[person TTA] skipping flip β pass1 took {elapsed*1000:.0f}ms")
|
| 529 |
+
|
| 530 |
+
# ββ Consensus filtering βββββββββββββββββββββββββββββββββββββββββ
|
| 531 |
+
kept_b, kept_s = [], []
|
| 532 |
+
|
| 533 |
+
if has_flip:
|
| 534 |
+
# High-conf (>=0.55): keep unconditionally from both views
|
| 535 |
+
# Low-conf (0.32-0.55): keep only if confirmed in other view
|
| 536 |
+
|
| 537 |
+
def _has_match(box, others):
|
| 538 |
+
if len(others) == 0:
|
| 539 |
+
return False
|
| 540 |
+
xx1 = np.maximum(box[0], others[:, 0])
|
| 541 |
+
yy1 = np.maximum(box[1], others[:, 1])
|
| 542 |
+
xx2 = np.minimum(box[2], others[:, 2])
|
| 543 |
+
yy2 = np.minimum(box[3], others[:, 3])
|
| 544 |
+
inter = np.maximum(0, xx2 - xx1) * np.maximum(0, yy2 - yy1)
|
| 545 |
+
a1 = (box[2] - box[0]) * (box[3] - box[1])
|
| 546 |
+
a2 = (others[:, 2] - others[:, 0]) * (others[:, 3] - others[:, 1])
|
| 547 |
+
iou = inter / (a1 + a2 - inter + 1e-9)
|
| 548 |
+
return bool(np.any(iou > PER_CONSENSUS_IOU))
|
| 549 |
|
| 550 |
+
for i in range(len(boxes_orig)):
|
| 551 |
+
if confs_orig[i] >= PER_CONF_HIGH or _has_match(boxes_orig[i], boxes_flip):
|
| 552 |
+
kept_b.append(boxes_orig[i])
|
| 553 |
+
kept_s.append(confs_orig[i])
|
| 554 |
+
|
| 555 |
+
for i in range(len(boxes_flip)):
|
| 556 |
+
if confs_flip[i] >= PER_CONF_HIGH or _has_match(boxes_flip[i], boxes_orig):
|
| 557 |
+
kept_b.append(boxes_flip[i])
|
| 558 |
+
kept_s.append(confs_flip[i])
|
| 559 |
+
else:
|
| 560 |
+
# No flip β just use original boxes (same as v6 single-pass)
|
| 561 |
+
for i in range(len(boxes_orig)):
|
| 562 |
+
if confs_orig[i] >= PER_CONF_LOW:
|
| 563 |
+
kept_b.append(boxes_orig[i])
|
| 564 |
+
kept_s.append(confs_orig[i])
|
| 565 |
+
|
| 566 |
+
if not kept_b:
|
| 567 |
return []
|
| 568 |
|
| 569 |
+
# ββ WBF dedup (merges near-duplicate detections) ββββββββββββββββ
|
| 570 |
+
kept_b = np.array(kept_b)
|
| 571 |
+
kept_s = np.array(kept_s)
|
| 572 |
+
norm = kept_b.copy()
|
| 573 |
+
norm[:, [0, 2]] /= ow
|
| 574 |
+
norm[:, [1, 3]] /= oh
|
| 575 |
+
norm = np.clip(norm, 0, 1)
|
| 576 |
+
|
| 577 |
+
fb, fs = _wbf_single([norm], [kept_s], iou_thr=PER_WBF_IOU, skip_thr=WBF_SKIP_THR)
|
| 578 |
|
| 579 |
if len(fb) == 0:
|
| 580 |
return []
|
|
|
|
| 582 |
fb[:, [0, 2]] *= ow
|
| 583 |
fb[:, [1, 3]] *= oh
|
| 584 |
|
|
|
|
|
|
|
|
|
|
| 585 |
out = []
|
| 586 |
for i in range(len(fb)):
|
| 587 |
b = fb[i]
|
|
|
|
| 595 |
))
|
| 596 |
return out
|
| 597 |
|
| 598 |
+
|
| 599 |
# ββ Unified inference βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 600 |
|
| 601 |
def _infer_single(self, image_bgr: ndarray) -> list[BoundingBox]:
|
vehicle_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:00bae032cee689d04b3b9131cd80134d03c17972490190f45a5f2aa96f9b703a
|
| 3 |
+
size 21244589
|