mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-27 17:17:40 +03:00
Use other logging redirect class
This commit is contained in:
parent
a490767f91
commit
4701bedde4
@ -38,7 +38,7 @@ class FaceRecognizer(ABC):
|
|||||||
def classify(self, face_image: np.ndarray) -> tuple[str, float] | None:
|
def classify(self, face_image: np.ndarray) -> tuple[str, float] | None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@redirect_stdout_to_logger(__name__, logging.DEBUG)
|
@redirect_stdout_to_logger(logger, logging.DEBUG)
|
||||||
def init_landmark_detector(self) -> None:
|
def init_landmark_detector(self) -> None:
|
||||||
landmark_model = os.path.join(MODEL_CACHE_DIR, "facedet/landmarkdet.yaml")
|
landmark_model = os.path.join(MODEL_CACHE_DIR, "facedet/landmarkdet.yaml")
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class CpuDetectorConfig(BaseDetectorConfig):
|
|||||||
class CpuTfl(DetectionApi):
|
class CpuTfl(DetectionApi):
|
||||||
type_key = DETECTOR_KEY
|
type_key = DETECTOR_KEY
|
||||||
|
|
||||||
@redirect_stdout_to_logger(__name__, logging.DEBUG)
|
@redirect_stdout_to_logger(logger, logging.DEBUG)
|
||||||
def __init__(self, detector_config: CpuDetectorConfig):
|
def __init__(self, detector_config: CpuDetectorConfig):
|
||||||
interpreter = Interpreter(
|
interpreter = Interpreter(
|
||||||
model_path=detector_config.model.path,
|
model_path=detector_config.model.path,
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class FaceNetEmbedding(BaseEmbedding):
|
|||||||
self._load_model_and_utils()
|
self._load_model_and_utils()
|
||||||
logger.debug(f"models are already downloaded for {self.model_name}")
|
logger.debug(f"models are already downloaded for {self.model_name}")
|
||||||
|
|
||||||
@redirect_stdout_to_logger(__name__, logging.DEBUG)
|
@redirect_stdout_to_logger(logger, logging.DEBUG)
|
||||||
def _load_model_and_utils(self):
|
def _load_model_and_utils(self):
|
||||||
if self.runner is None:
|
if self.runner is None:
|
||||||
if self.downloader:
|
if self.downloader:
|
||||||
|
|||||||
@ -49,6 +49,9 @@ except ModuleNotFoundError:
|
|||||||
from tensorflow.lite.python.interpreter import Interpreter
|
from tensorflow.lite.python.interpreter import Interpreter
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_ffmpeg_command(ffmpeg: FfmpegConfig) -> list[str]:
|
def get_ffmpeg_command(ffmpeg: FfmpegConfig) -> list[str]:
|
||||||
ffmpeg_input: CameraInput = [i for i in ffmpeg.inputs if "audio" in i.roles][0]
|
ffmpeg_input: CameraInput = [i for i in ffmpeg.inputs if "audio" in i.roles][0]
|
||||||
input_args = get_ffmpeg_arg_list(ffmpeg.global_args) + (
|
input_args = get_ffmpeg_arg_list(ffmpeg.global_args) + (
|
||||||
@ -423,7 +426,7 @@ class AudioEventMaintainer(threading.Thread):
|
|||||||
|
|
||||||
|
|
||||||
class AudioTfl:
|
class AudioTfl:
|
||||||
@redirect_stdout_to_logger(__name__, logging.DEBUG)
|
@redirect_stdout_to_logger(logger, logging.DEBUG)
|
||||||
def __init__(self, stop_event: threading.Event, num_threads=2):
|
def __init__(self, stop_event: threading.Event, num_threads=2):
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.num_threads = num_threads
|
self.num_threads = num_threads
|
||||||
|
|||||||
@ -189,11 +189,11 @@ class LogRedirect(io.StringIO):
|
|||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
|
||||||
def redirect_stdout_to_logger(log_name: str, level: int) -> Any:
|
def redirect_stdout_to_logger(logger: logging.Logger, level: int) -> Any:
|
||||||
def decorator(func: Callable):
|
def decorator(func: Callable):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
current_log_pipe = LogRedirect(log_name, logging.ERROR)
|
current_log_pipe = LogRedirect(logger, logging.ERROR)
|
||||||
|
|
||||||
old_stdout = sys.stdout
|
old_stdout = sys.stdout
|
||||||
old_stderr = sys.stderr
|
old_stderr = sys.stderr
|
||||||
|
|||||||
@ -17,6 +17,8 @@ BATCH_SIZE = 16
|
|||||||
EPOCHS = 50
|
EPOCHS = 50
|
||||||
LEARNING_RATE = 0.001
|
LEARNING_RATE = 0.001
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def __generate_representative_dataset_factory(dataset_dir: str):
|
def __generate_representative_dataset_factory(dataset_dir: str):
|
||||||
def generate_representative_dataset():
|
def generate_representative_dataset():
|
||||||
@ -37,7 +39,7 @@ def __generate_representative_dataset_factory(dataset_dir: str):
|
|||||||
return generate_representative_dataset
|
return generate_representative_dataset
|
||||||
|
|
||||||
|
|
||||||
@redirect_stdout_to_logger(__name__, logging.DEBUG)
|
@redirect_stdout_to_logger(logger, logging.DEBUG)
|
||||||
def __train_classification_model(model_name: str) -> bool:
|
def __train_classification_model(model_name: str) -> bool:
|
||||||
"""Train a classification model."""
|
"""Train a classification model."""
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user