From 3eb56a495c32165b103ba881aad6a03e0be558dd Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:57:57 -0600 Subject: [PATCH] Retain narrow sign reads meeting the original height and area floors --- .../starpilot/speed_limits/vision/model.py | 6 ++++- .../vision/tests/test_width_rounding.py | 22 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 openpilot/starpilot/speed_limits/vision/tests/test_width_rounding.py diff --git a/openpilot/starpilot/speed_limits/vision/model.py b/openpilot/starpilot/speed_limits/vision/model.py index 459d8ff0e6..f2d1664356 100644 --- a/openpilot/starpilot/speed_limits/vision/model.py +++ b/openpilot/starpilot/speed_limits/vision/model.py @@ -848,7 +848,11 @@ class VisionModelCore: box_height = y2 - y1 if box_width <= 0 or box_height <= 0: continue - is_small_box = box_width < DETECTOR_CLASSIFIER_MIN_ACCEPT_WIDTH or box_height < DETECTOR_CLASSIFIER_MIN_ACCEPT_HEIGHT + is_small_box = ( + box_width < DETECTOR_CLASSIFIER_MIN_ACCEPT_WIDTH - 1 or + box_height < DETECTOR_CLASSIFIER_MIN_ACCEPT_HEIGHT or + box_width * box_height < DETECTOR_CLASSIFIER_MIN_ACCEPT_WIDTH * DETECTOR_CLASSIFIER_MIN_ACCEPT_HEIGHT + ) # Tiny far-away proposals are the main nighttime false-positive source. # Keep a narrow rescue path for right-side high-confidence reads, # then let temporal confirmation decide whether they are real. diff --git a/openpilot/starpilot/speed_limits/vision/tests/test_width_rounding.py b/openpilot/starpilot/speed_limits/vision/tests/test_width_rounding.py new file mode 100644 index 0000000000..8a7656f7ef --- /dev/null +++ b/openpilot/starpilot/speed_limits/vision/tests/test_width_rounding.py @@ -0,0 +1,22 @@ +import unittest + +import numpy as np + +from openpilot.starpilot.speed_limits.vision.tests.test_retry_consistency import core_fixture, probabilities + + +class TestWidthRounding(unittest.TestCase): + def test_narrow_plate_needs_original_height_area_and_consistent_reads(self): + for width, height, confident in ((27, 43, True), (28, 40, True), (27, 41, False), (26, 44, False), (29, 39, False)): + with self.subTest(width=width, height=height): + values = [probabilities(30, .992), probabilities(30, .847), probabilities(70, .906)] + core = core_fixture([(value, value) for value in values], [False, False, False], + proposals=[(.447, 0, (770, 354, 770 + width, 354 + height))]) + result = core.infer(np.zeros((760, 1344, 3), np.uint8)) + self.assertIsNotNone(result) + self.assertEqual(result.speed_limit_mph, 30) + self.assertEqual(result.confidence >= .83, confident) + + +if __name__ == '__main__': + unittest.main() diff --git a/prebuilt.json b/prebuilt.json index 6e33ba1c67..0009c2a4db 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "aa609b4f7ebf67b41995bffbb8dab7edc8c2ef2139bb086d782447aa59cd1dcb", "schema_version": 1} +{"protected_inventory_sha256": "1ca3c74ab754614ad521b1c5937dae71b9de81db93571c3545586f804cd401fc", "schema_version": 1}