From fee3209ede0f1716a761ba41af08b0c67ba6bb06 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 29 Jan 2025 07:30:49 -0700 Subject: [PATCH] Simplify --- frigate/api/classification.py | 2 +- web/src/pages/FaceLibrary.tsx | 51 +++++++++++++++++------------------ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/frigate/api/classification.py b/frigate/api/classification.py index 4dcada0a4..65a85a056 100644 --- a/frigate/api/classification.py +++ b/frigate/api/classification.py @@ -100,7 +100,7 @@ def train_face(request: Request, name: str, body: dict = None): ) -@router.post("/faces/train/{name}/reprocess") +@router.post("/faces/reprocess") def reclassify_face(request: Request, name: str, body: dict = None): if not request.app.frigate_config.face_recognition.enabled: return JSONResponse( diff --git a/web/src/pages/FaceLibrary.tsx b/web/src/pages/FaceLibrary.tsx index f69591916..610f3b5c4 100644 --- a/web/src/pages/FaceLibrary.tsx +++ b/web/src/pages/FaceLibrary.tsx @@ -274,32 +274,29 @@ function FaceAttempt({ [image, onRefresh], ); - const onReprocess = useCallback( - (trainName: string) => { - axios - .post(`/faces/train/${trainName}/reprocess`, { training_file: image }) - .then((resp) => { - if (resp.status == 200) { - toast.success(`Successfully trained face.`, { - position: "top-center", - }); - onRefresh(); - } - }) - .catch((error) => { - if (error.response?.data?.message) { - toast.error(`Failed to train: ${error.response.data.message}`, { - position: "top-center", - }); - } else { - toast.error(`Failed to train: ${error.message}`, { - position: "top-center", - }); - } - }); - }, - [image, onRefresh], - ); + const onReprocess = useCallback(() => { + axios + .post(`/faces/reprocess`, { training_file: image }) + .then((resp) => { + if (resp.status == 200) { + toast.success(`Successfully trained face.`, { + position: "top-center", + }); + onRefresh(); + } + }) + .catch((error) => { + if (error.response?.data?.message) { + toast.error(`Failed to train: ${error.response.data.message}`, { + position: "top-center", + }); + } else { + toast.error(`Failed to train: ${error.message}`, { + position: "top-center", + }); + } + }); + }, [image, onRefresh]); const onDelete = useCallback(() => { axios @@ -371,7 +368,7 @@ function FaceAttempt({ onReprocess()} /> Delete Face Attempt