From 6fa005fd56542e5acd502deeebf3f9f93cbb5d3d Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 16 May 2026 18:24:30 -0500 Subject: [PATCH] sync top-level model with default detector's resolved model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when the user doesn't define a top-level `model:` block, `FrigateConfig.model` stayed at pydantic field defaults (320×320, /labelmap.txt) while the per-detector model picked up `DEFAULT_MODEL` for openvino on cpu (300×300, coco_91cl_bkgr.txt introduced in #23127), causing `RemoteObjectDetector` to fail with "buffer is too small for requested array" because the SHM was sized from the per-detector model but mapped using the top-level one. After the detector loop, copy the first detector's resolved model up to `self.model` so both sides agree on dimensions and labelmap --- frigate/config/config.py | 8 ++++++++ frigate/test/test_config.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frigate/config/config.py b/frigate/config/config.py index 6873e6b880..db450ffcf3 100644 --- a/frigate/config/config.py +++ b/frigate/config/config.py @@ -708,6 +708,14 @@ class FrigateConfig(FrigateBaseModel): detector_config.model = model self.detectors[key] = detector_config + # If the top-level model is unset, adopt the first detector's resolved + # model so worker processes (which receive self.model) agree with the + # dimensions used to size the detection shared memory in start_detectors. + if not self.model.model_dump(exclude_unset=True, warnings="none") and self.detectors: + first_detector = next(iter(self.detectors.values())) + if first_detector.model is not None: + self.model = first_detector.model + for name, camera in self.cameras.items(): modified_global_config = global_config.copy() diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index c63f27430a..1469924b9c 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -964,8 +964,11 @@ class TestConfig(unittest.TestCase): }, } + # With no model defined, the top-level model adopts the default + # detector's resolved model (openvino + ssdlite_mobilenet_v2 with the + # coco_91cl_bkgr labelmap, which has __background__ at index 0). frigate_config = FrigateConfig(**config) - assert frigate_config.model.merged_labelmap[0] == "person" + assert frigate_config.model.merged_labelmap[1] == "person" def test_default_labelmap(self): config = {