mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 17:12:16 +03:00
Live classification model training (#18583)
* Implement model training via ZMQ and add model states to represent training * Get model updates working * Improve toasts and model state * Clean up logging * Add back in
This commit is contained in:
committed by
Blake Blackshear
parent
1c75ff59f1
commit
765a28d812
@@ -1,7 +1,7 @@
|
||||
"""Util for classification models."""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
@@ -50,7 +50,13 @@ def train_classification_model(model_name: str) -> bool:
|
||||
]
|
||||
)
|
||||
|
||||
tf.get_logger().setLevel(logging.ERROR)
|
||||
# TF and Keras are very loud with logging
|
||||
# we want to avoid these logs so we
|
||||
# temporarily redirect stdout / stderr
|
||||
original_stdout = sys.stdout
|
||||
original_stderr = sys.stderr
|
||||
sys.stdout = open(os.devnull, "w")
|
||||
sys.stderr = open(os.devnull, "w")
|
||||
|
||||
# Start with imagenet base model with 35% of channels in each layer
|
||||
base_model = MobileNetV2(
|
||||
@@ -112,3 +118,7 @@ def train_classification_model(model_name: str) -> bool:
|
||||
# write model
|
||||
with open(os.path.join(model_dir, "model.tflite"), "wb") as f:
|
||||
f.write(tflite_model)
|
||||
|
||||
# restore original stdout / stderr
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
|
||||
Reference in New Issue
Block a user