mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-19 23:08:08 +02:00
Correctly remove classification model from config (#20772)
* Correctly remove classification model from config * Undo * fix * Use existing config update API and dynamically remove models that were running * Set update message for face
This commit is contained in:
@@ -34,12 +34,10 @@ from frigate.config.camera import DetectConfig
|
||||
from frigate.const import CLIPS_DIR, FACE_DIR, MODEL_CACHE_DIR
|
||||
from frigate.embeddings import EmbeddingsContext
|
||||
from frigate.models import Event
|
||||
from frigate.util.builtin import update_yaml_file_bulk
|
||||
from frigate.util.classification import (
|
||||
collect_object_classification_examples,
|
||||
collect_state_classification_examples,
|
||||
)
|
||||
from frigate.util.config import find_config_file
|
||||
from frigate.util.path import get_event_snapshot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -840,24 +838,6 @@ def delete_classification_model(request: Request, name: str):
|
||||
if os.path.exists(model_dir):
|
||||
shutil.rmtree(model_dir)
|
||||
|
||||
# Remove the model from the config file
|
||||
config_file = find_config_file()
|
||||
try:
|
||||
# Setting value to empty string deletes the key
|
||||
updates = {f"classification.custom.{name}": None}
|
||||
update_yaml_file_bulk(config_file, updates)
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating config file: {e}")
|
||||
return JSONResponse(
|
||||
content=(
|
||||
{
|
||||
"success": False,
|
||||
"message": "Failed to update config file.",
|
||||
}
|
||||
),
|
||||
status_code=500,
|
||||
)
|
||||
|
||||
return JSONResponse(
|
||||
content=(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user