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:
Nicolas Mowen
2025-08-16 10:20:33 -05:00
committed by Blake Blackshear
parent 1c75ff59f1
commit 765a28d812
10 changed files with 168 additions and 22 deletions
+12 -2
View File
@@ -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