Improve speed sign recall while preserving confirmation boundaries

This commit is contained in:
firestar5683
2026-11-12 18:37:17 -06:00
parent d3c322e578
commit f8da463831
8 changed files with 142 additions and 10 deletions
@@ -1,10 +1,58 @@
## Current speed-head recall refinement (November 12, 2026)
The joint detector is 9,725,446 bytes, SHA-256
`fe54ea8d47cb89cd44697e0a7e85ce8814a12f285c811ccd89ac2bba341c4228`.
The preceding joint detector was
`52bb30f73bf0d166342f33d1b32b29b726bf036004e0359fef10ef7bf1f5556f`.
Training changes 4,161 existing speed-classification parameters across three
initializers. The backbone, box regression, STOP output dependency path, numeric
reader, independent identity model, graph operators, tensor shapes and output
ABI are unchanged. No inference pass or scheduling change is introduced by this
refinement. Existing contributor attribution and licensing are retained.
The training-only teacher cache contains all 1,190 original training images.
Thirty-nine augmented views of four newly reviewed physical speed signs and
four preservation views supplement that cache. These new drive views are
correlated training examples, not independent validation. The original 296
validation images receive no gradients and do not select either calibration
constant. Repeated qualification and error analysis informed iterations, so this
is not an untouched-test result. Source media, teacher outputs and fit receipts
are retained privately.
A training-selected 0.16 speed-logit intercept preserves the original training
strong-proposal scores at the existing proposal gate. Numeric published-score
arithmetic removes that intercept and applies a training-selected conservative
0.001 margin. Existing temporal confirmation thresholds are unchanged. A
near-tied, contained upper regulatory plate is preferred over a combined tall
regulatory/MINIMUM proposal, preserving the actual detector and identity
bindings rather than treating the lower plate as part of the posted limit.
Paired actual-network replay of 1,486 original images retains every correct
numeric result, introduces no new wrong-value or zero-ground-truth reads and
leaves every STOP result identical. Correct numeric results increase from 414
to 418; the same two wrong positive-image values and 26 zero-ground-truth reads
remain. Some zero-ground-truth entries are crop-rejection cases, so these counts
are not a whole-road false-positive rate. All 6,120 tested fresh-history
confirmation profiles retain accepted true readings without adding a false
acceptance. These controlled histories do not exhaust all mixed field histories.
Ten actual-network cases pass with Linux OpenCV 4.11, including the reviewed
clear 55/60/30 signs, retained median 65, later 20, conditional-board rejection,
and existing confidence-boundary regressions. Native producer, display and
control qualification has 715 passing tests and no skips. One unchanged
speed-source settings test fails because the secondary default is Dashboard
rather than its expected Maps; the same failure is reproduced on the unmodified
parent revision. That failure is not counted as a pass. No fresh device timing,
AGNOS raw-frame parity, deployment or closed-loop road qualification is claimed.
Difficult small signs and missed field scenes remain open limitations.
## Current numeric classifier asset
| File | Bytes | SHA-256 |
| --- | ---: | --- |
| `speed_limit_us_value_classifier.onnx` | 6,240,534 | `f70477aa34a5557b69103ed65066b5a7a678f5bc35dfb4ee19914aec3c108918` |
## Current STOP-head refinement (November 5, 2026)
## Previous STOP-head refinement (November 5, 2026)
The current joint detector is 9,725,049 bytes, SHA-256
`52bb30f73bf0d166342f33d1b32b29b726bf036004e0359fef10ef7bf1f5556f`.
@@ -830,6 +830,19 @@ class VisionModelCore:
if proposals is None:
proposals = self._collect_detector_classifier_proposals(frame_bgr)
if type(proposals) is list and len(proposals) > 1 and proposals[0][1] == 0:
confidence, _, (left, top, right, bottom) = proposals[0]
width, height = right - left, bottom - top
if height >= 1.8 * width:
for index, candidate in enumerate(proposals[1:], 1):
score, kind, (x1, y1, x2, y2) = candidate
w, h = x2 - x1, y2 - y1
if (kind == 0 and 0 <= confidence - score <= .005 and
left <= x1 < x2 <= right and top <= y1 <= top + .15 * width and
w >= .8 * width and .9 * w <= h <= 1.6 * w and h <= .75 * height):
# Prefer a near-tied upper plate over its combined MINIMUM-board proposal.
proposals = [candidate, *proposals[:index], *proposals[index + 1:]]
break
for proposal_index, (proposal_confidence, class_id, (x1, y1, x2, y2)) in enumerate(proposals):
if class_id == 1:
continue
@@ -844,6 +857,13 @@ class VisionModelCore:
if duplicate_advisory:
continue
score_confidence = proposal_confidence
score_margin = getattr(self, 'PUBLISHED_SCORE_MARGIN', 0.0)
calibration = getattr(self, 'PROPOSAL_LOGIT_CALIBRATION', 0.0)
if calibration:
# Admission calibration must not inflate the published numeric evidence.
score_confidence /= proposal_confidence + math.exp(calibration) * (1 - proposal_confidence)
box_width = x2 - x1
box_height = y2 - y1
if box_width <= 0 or box_height <= 0:
@@ -920,9 +940,9 @@ class VisionModelCore:
):
score = min(
read_confidence * 0.72 +
proposal_confidence * 0.22 +
score_confidence * 0.22 +
max(support_count - 1, 0) * SCHOOL_ZONE_SUPPORT_BONUS +
0.04,
0.04 - score_margin,
0.95,
)
if score >= SCHOOL_ZONE_SHORT_CIRCUIT_CONFIDENCE:
@@ -970,8 +990,8 @@ class VisionModelCore:
speed_regulatory_support.get(agreed_speed, 0) >= 1 and
speed_scores[agreed_speed] + DETECTOR_CLASSIFIER_SUPPORT_BONUS >
expansion_weight + DETECTOR_CLASSIFIER_REGULATORY_BONUS and
speed_best_confidences[agreed_speed] * .72 + proposal_confidence * .24 +
DETECTOR_CLASSIFIER_SUPPORT_BONUS >= .95):
speed_best_confidences[agreed_speed] * .72 + score_confidence * .24 +
DETECTOR_CLASSIFIER_SUPPORT_BONUS - score_margin >= .95):
break
face_filter = getattr(self, '_speed_face_filter', None)
@@ -1185,8 +1205,8 @@ class VisionModelCore:
)
score = min(
read_confidence * 0.72 +
proposal_confidence * 0.24 +
max(support_count - 1, 0) * DETECTOR_CLASSIFIER_SUPPORT_BONUS,
score_confidence * 0.24 +
max(support_count - 1, 0) * DETECTOR_CLASSIFIER_SUPPORT_BONUS - score_margin,
0.95,
)
selection_score = score
@@ -13,7 +13,7 @@ MAX_FRAME_AGE_NS = 250_000_000
# Bound sign-processing latency independently of raw camera admission.
MAX_RESULT_AGE_NS = 2_000_000_000
MAX_PAIR_SKEW_NS = 5_000_000
MODEL_ID = '19cc26a0e4169962c1965e27b7237301a50d83a8771dde565e26bd0a63e39033:f70477aa34a5557b69103ed65066b5a7a678f5bc35dfb4ee19914aec3c108918'
MODEL_ID = 'f5ca626f2e0775b7892b2a14b0bc1081560ed411370c7afd9db7909608f41f7b:f70477aa34a5557b69103ed65066b5a7a678f5bc35dfb4ee19914aec3c108918'
def clock_pair_ns() -> tuple[int, int] | None:
@@ -0,0 +1,33 @@
import unittest
import numpy as np
from openpilot.starpilot.speed_limits.vision.tests.test_retry_consistency import core_fixture
class TestPrimaryPlate(unittest.TestCase):
def infer(self, future, *, as_iterator=False):
proposals = [(.6335, 0, (1536, 436, 1612, 583)), future]
core = core_fixture([], [True], proposals)
if as_iterator:
core._collect_detector_classifier_proposals = lambda frame: iter(proposals)
core._classify_speed_limit_from_model = lambda crop: (70 if crop.shape[0] < 140 else 75, .999)
return core.infer(np.zeros((1208, 1928, 3), np.uint8))
def test_near_tied_upper_plate_excludes_minimum_context(self):
result = self.infer((.6334, 0, (1537, 438, 1609, 535)))
self.assertEqual(result.speed_limit_mph, 70)
def test_low_score_lower_plate_and_unrelated_boxes_keep_order(self):
for future in ((.60, 0, (1537, 438, 1609, 535)),
(.6334, 0, (1537, 535, 1609, 590)),
(.6334, 0, (1420, 438, 1492, 535))):
with self.subTest(future=future):
self.assertEqual(self.infer(future).speed_limit_mph, 75)
def test_iterator_input_keeps_existing_order(self):
self.assertEqual(self.infer((.6334, 0, (1537, 438, 1609, 535)), as_iterator=True).speed_limit_mph, 75)
if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,29 @@
import math
import unittest
import numpy as np
from openpilot.starpilot.speed_limits.vision.tests.test_retry_consistency import core_fixture, probabilities
class TestProposalCalibration(unittest.TestCase):
def infer(self, proposal, calibration):
values = [probabilities(30, .992), probabilities(30, .847), probabilities(70, .906)]
core = core_fixture([(value, value) for value in values], [True, True, True],
proposals=[(proposal, 0, (770, 354, 830, 434))])
core.PROPOSAL_LOGIT_CALIBRATION = calibration
return core.infer(np.zeros((760, 1344, 3), np.uint8))
def test_admission_intercept_does_not_inflate_numeric_confidence(self):
for raw in (.21, .3, .4):
with self.subTest(raw=raw):
calibrated = 1 / (1 + math.exp(-(math.log(raw / (1 - raw)) + .16)))
baseline = self.infer(raw, 0.)
candidate = self.infer(calibrated, .16)
self.assertEqual(candidate.speed_limit_mph, baseline.speed_limit_mph)
self.assertAlmostEqual(candidate.confidence, baseline.confidence, places=7)
self.assertEqual(candidate.strong_consensus, baseline.strong_consensus)
if __name__ == '__main__':
unittest.main()
@@ -59,7 +59,9 @@ class SignDetections:
class TrafficSignModelCore(model.VisionModelCore):
DETECTOR_SHA256 = '52bb30f73bf0d166342f33d1b32b29b726bf036004e0359fef10ef7bf1f5556f'
DETECTOR_SHA256 = 'fe54ea8d47cb89cd44697e0a7e85ce8814a12f285c811ccd89ac2bba341c4228'
PROPOSAL_LOGIT_CALIBRATION = .16
PUBLISHED_SCORE_MARGIN = .001
STOP_PROJECTION_SHA256 = "a744df1b585bfd80a2a983229509f52bf2f09714d9df011109ad1b8b875aaecc"
ASSET_MANIFEST = (DETECTOR_SHA256, model.VisionModelCore.CLASSIFIER_SHA256, MODEL_SHA256, STOP_PROJECTION_SHA256)
MODEL_ID = (hashlib.sha256(("vision_joint_stop_projection_identity_v1\n" + "\n".join(ASSET_MANIFEST) + "\n").encode()).hexdigest() +
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "8cb949e28a1e5c1d97b37270ff966c952c0024e9ca38593afa0cb60c11d89933", "schema_version": 1}
{"protected_inventory_sha256": "9988b9f48f5eb10adaa44bf68da9d2009f3c6a659f0dc6d17a7f427e0ea03e47", "schema_version": 1}