mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-08 15:52:48 +03:00
Classification Model UI (#18571)
* Setup basic training structure * Build out route * Handle model configs * Add image fetch APIs * Implement model training screen with dataset selection * Implement viewing of training images * Adjust directories * Implement viewing of images * Add support for deleting images * Implement full deletion * Implement classification model training * Improve naming * More renaming * Improve layout * Reduce logging * Cleanup
This commit is contained in:
committed by
Blake Blackshear
parent
ac7fb29b32
commit
1c75ff59f1
@@ -1,5 +1,6 @@
|
||||
"""Util for classification models."""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import cv2
|
||||
@@ -9,6 +10,8 @@ from tensorflow.keras import layers, models, optimizers
|
||||
from tensorflow.keras.applications import MobileNetV2
|
||||
from tensorflow.keras.preprocessing.image import ImageDataGenerator
|
||||
|
||||
from frigate.const import CLIPS_DIR, MODEL_CACHE_DIR
|
||||
|
||||
BATCH_SIZE = 16
|
||||
EPOCHS = 50
|
||||
LEARNING_RATE = 0.001
|
||||
@@ -35,9 +38,10 @@ def generate_representative_dataset_factory(dataset_dir: str):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def train_classification_model(model_dir: str) -> bool:
|
||||
def train_classification_model(model_name: str) -> bool:
|
||||
"""Train a classification model."""
|
||||
dataset_dir = os.path.join(model_dir, "dataset")
|
||||
dataset_dir = os.path.join(CLIPS_DIR, model_name, "dataset")
|
||||
model_dir = os.path.join(MODEL_CACHE_DIR, model_name)
|
||||
num_classes = len(
|
||||
[
|
||||
d
|
||||
@@ -46,6 +50,8 @@ def train_classification_model(model_dir: str) -> bool:
|
||||
]
|
||||
)
|
||||
|
||||
tf.get_logger().setLevel(logging.ERROR)
|
||||
|
||||
# Start with imagenet base model with 35% of channels in each layer
|
||||
base_model = MobileNetV2(
|
||||
input_shape=(224, 224, 3),
|
||||
|
||||
Reference in New Issue
Block a user