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 = {