mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
adjust SharedMemory size to largest detector model shape
This commit is contained in:
parent
bbadb70365
commit
f5ff975530
@ -186,10 +186,11 @@ class FrigateApp:
|
||||
self.detection_out_events[name] = mp.Event()
|
||||
|
||||
try:
|
||||
size = max([det.model.height * det.model.width * 3 for (name, det) in self.config.detectors.items()])
|
||||
shm_in = mp.shared_memory.SharedMemory(
|
||||
name=name,
|
||||
create=True,
|
||||
size=self.config.model.height * self.config.model.width * 3,
|
||||
size=size,
|
||||
)
|
||||
except FileExistsError:
|
||||
shm_in = mp.shared_memory.SharedMemory(name=name)
|
||||
@ -204,15 +205,12 @@ class FrigateApp:
|
||||
self.detection_shms.append(shm_in)
|
||||
self.detection_shms.append(shm_out)
|
||||
|
||||
for name, detector in self.config.detectors.items():
|
||||
for name, detector_config in self.config.detectors.items():
|
||||
self.detectors[name] = ObjectDetectProcess(
|
||||
name,
|
||||
self.detection_queue,
|
||||
self.detection_out_events,
|
||||
self.config.model,
|
||||
detector.type,
|
||||
detector.device,
|
||||
detector.num_threads,
|
||||
detector_config,
|
||||
)
|
||||
|
||||
def start_detected_frames_processor(self) -> None:
|
||||
|
||||
@ -79,10 +79,7 @@ def run_detector(
|
||||
out_events: dict[str, mp.Event],
|
||||
avg_speed,
|
||||
start,
|
||||
model_config,
|
||||
det_type,
|
||||
det_device,
|
||||
num_threads,
|
||||
detector_config,
|
||||
):
|
||||
threading.current_thread().name = f"detector:{name}"
|
||||
logger = logging.getLogger(f"detector.{name}")
|
||||
@ -100,10 +97,7 @@ def run_detector(
|
||||
|
||||
frame_manager = SharedMemoryFrameManager()
|
||||
object_detector = LocalObjectDetector(
|
||||
det_type=det_type,
|
||||
det_device=det_device,
|
||||
model_config=model_config,
|
||||
num_threads=num_threads,
|
||||
detector_config=detector_config
|
||||
)
|
||||
|
||||
outputs = {}
|
||||
@ -118,7 +112,7 @@ def run_detector(
|
||||
except queue.Empty:
|
||||
continue
|
||||
input_frame = frame_manager.get(
|
||||
connection_id, (1, model_config.height, model_config.width, 3)
|
||||
connection_id, (1, detector_config.model.height, detector_config.model.width, 3)
|
||||
)
|
||||
|
||||
if input_frame is None:
|
||||
@ -141,10 +135,7 @@ class ObjectDetectProcess:
|
||||
name,
|
||||
detection_queue,
|
||||
out_events,
|
||||
model_config,
|
||||
det_type=None,
|
||||
det_device=None,
|
||||
num_threads=3,
|
||||
detector_config,
|
||||
):
|
||||
self.name = name
|
||||
self.out_events = out_events
|
||||
@ -152,10 +143,7 @@ class ObjectDetectProcess:
|
||||
self.avg_inference_speed = mp.Value("d", 0.01)
|
||||
self.detection_start = mp.Value("d", 0.0)
|
||||
self.detect_process = None
|
||||
self.model_config = model_config
|
||||
self.det_type = det_type
|
||||
self.det_device = det_device
|
||||
self.num_threads = num_threads
|
||||
self.detector_config = detector_config
|
||||
self.start_or_restart()
|
||||
|
||||
def stop(self):
|
||||
@ -180,10 +168,7 @@ class ObjectDetectProcess:
|
||||
self.out_events,
|
||||
self.avg_inference_speed,
|
||||
self.detection_start,
|
||||
self.model_config,
|
||||
self.det_type,
|
||||
self.det_device,
|
||||
self.num_threads,
|
||||
self.detector_config,
|
||||
),
|
||||
)
|
||||
self.detect_process.daemon = True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user