From d90f2397474b3c89dbefc53c599e6f6a47f0138b Mon Sep 17 00:00:00 2001 From: YS Date: Wed, 15 Dec 2021 22:44:03 +0300 Subject: [PATCH] downgrade to python3.6 --- frigate/app.py | 11 ++++++----- frigate/config.py | 4 +--- frigate/edgetpu.py | 8 +++++--- frigate/http.py | 3 ++- frigate/output.py | 3 +-- frigate/record.py | 3 ++- frigate/util.py | 3 ++- process_clip.py | 2 +- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 051c845e1..6e18e06c3 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -1,6 +1,7 @@ import json import logging import multiprocessing as mp +import shared_memory import os import signal import sys @@ -41,7 +42,7 @@ class FrigateApp: self.detection_queue = mp.Queue() self.detectors: Dict[str, EdgeTPUProcess] = {} self.detection_out_events: Dict[str, mp.Event] = {} - self.detection_shms: List[mp.shared_memory.SharedMemory] = [] + self.detection_shms: List[shared_memory.SharedMemory] = [] self.log_queue = mp.Queue() self.camera_metrics = {} @@ -163,20 +164,20 @@ class FrigateApp: self.detection_out_events[name] = mp.Event() try: - shm_in = mp.shared_memory.SharedMemory( + shm_in = shared_memory.SharedMemory( name=name, create=True, size=self.config.model.height * self.config.model.width * 3, ) except FileExistsError: - shm_in = mp.shared_memory.SharedMemory(name=name) + shm_in = shared_memory.SharedMemory(name=name) try: - shm_out = mp.shared_memory.SharedMemory( + shm_out = shared_memory.SharedMemory( name=f"out-{name}", create=True, size=20 * 6 * 4 ) except FileExistsError: - shm_out = mp.shared_memory.SharedMemory(name=f"out-{name}") + shm_out = shared_memory.SharedMemory(name=f"out-{name}") self.detection_shms.append(shm_in) self.detection_shms.append(shm_out) diff --git a/frigate/config.py b/frigate/config.py index a433ca694..3dbf4614c 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import json import logging import os @@ -868,7 +866,7 @@ class FrigateConfig(FrigateBaseModel): ) @property - def runtime_config(self) -> FrigateConfig: + def runtime_config(self): """Merge camera config with globals.""" config = self.copy(deep=True) diff --git a/frigate/edgetpu.py b/frigate/edgetpu.py index 9849f8afc..5bcf561df 100644 --- a/frigate/edgetpu.py +++ b/frigate/edgetpu.py @@ -7,8 +7,10 @@ import signal import threading from abc import ABC, abstractmethod from typing import Dict +import shared_memory import numpy as np +# TensorRT https://github.com/NobuoTsukamoto/tensorrt-examples/blob/main/python/detection/README.md import tflite_runtime.interpreter as tflite from setproctitle import setproctitle from tflite_runtime.interpreter import load_delegate @@ -139,7 +141,7 @@ def run_detector( outputs = {} for name in out_events.keys(): - out_shm = mp.shared_memory.SharedMemory(name=f"out-{name}", create=False) + out_shm = shared_memory.SharedMemory(name=f"out-{name}", create=False) out_np = np.ndarray((20, 6), dtype=np.float32, buffer=out_shm.buf) outputs[name] = {"shm": out_shm, "np": out_np} @@ -228,11 +230,11 @@ class RemoteObjectDetector: self.fps = EventsPerSecond() self.detection_queue = detection_queue self.event = event - self.shm = mp.shared_memory.SharedMemory(name=self.name, create=False) + self.shm = shared_memory.SharedMemory(name=self.name, create=False) self.np_shm = np.ndarray( (1, model_shape[0], model_shape[1], 3), dtype=np.uint8, buffer=self.shm.buf ) - self.out_shm = mp.shared_memory.SharedMemory( + self.out_shm = shared_memory.SharedMemory( name=f"out-{self.name}", create=False ) self.out_np_shm = np.ndarray((20, 6), dtype=np.float32, buffer=self.out_shm.buf) diff --git a/frigate/http.py b/frigate/http.py index c2c86e7c4..ed9818a11 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -610,7 +610,8 @@ def recording_clip(camera, start_ts, end_ts): ffmpeg_cmd, input="\n".join(playlist_lines), encoding="ascii", - capture_output=True, + stdout=sp.PIPE, + stderr=sp.PIPE, ) if p.returncode != 0: logger.error(p.stderr) diff --git a/frigate/output.py b/frigate/output.py index d950ceb07..f86ff6ae5 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -7,7 +7,6 @@ import queue import signal import subprocess as sp import threading -from multiprocessing import shared_memory from wsgiref.simple_server import make_server from frigate.log import LogPipe @@ -37,7 +36,7 @@ class FFMpegConverter: # ffmpeg_cmd = f"gst-launch-1.0 fdsrc ! video/x-raw, width={in_width}, height={in_height}, format=I420 ! nvvideoconvert ! omxh264enc ! h264parse ! mpegtsmux ! fdsink".split( # " " # ) - + self.logpipe = LogPipe( "ffmpeg.converter", logging.ERROR) diff --git a/frigate/record.py b/frigate/record.py index 3d6c0bd01..8836776ca 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -502,7 +502,8 @@ class RecordingCleanup(threading.Thread): logger.debug(f"Oldest recording in the db: {oldest_timestamp}") process = sp.run( ["find", RECORD_DIR, "-type", "f", "!", "-newermt", f"@{oldest_timestamp}"], - capture_output=True, + stdout=sp.PIPE, + stderr=sp.PIPE, text=True, ) files_to_check = process.stdout.splitlines() diff --git a/frigate/util.py b/frigate/util.py index 85835e933..f3ca2ccad 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -11,7 +11,8 @@ import threading import time import traceback from abc import ABC, abstractmethod -from multiprocessing import shared_memory +#from multiprocessing import shared_memory +import shared_memory from typing import AnyStr import cv2 diff --git a/process_clip.py b/process_clip.py index f6f046820..9c4dfd274 100644 --- a/process_clip.py +++ b/process_clip.py @@ -44,7 +44,7 @@ def get_frame_shape(source): "json", source, ] - p = sp.run(ffprobe_cmd, capture_output=True) + p = sp.run(ffprobe_cmd, stdout=sp.PIPE, stderr=sp.PIPE) info = json.loads(p.stdout) video_info = [s for s in info["streams"] if s["codec_type"] == "video"][0]