NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Fix sanitized api causing issues (#16433)
Nicolas Mowen81bd956ae830
diff --git a/frigate/api/classification.py b/frigate/api/classification.pyindex df0d3b45e9..7cd127d070 100644--- a/frigate/api/classification.py+++ b/frigate/api/classification.py@@ -98,9 +98,10 @@ def train_face(request: Request, name: str, body: dict = None):status_code=404,)+ sanitized_name = sanitize_filename(name)rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))- new_name = f"{name}-{rand_id}.webp"- new_file = sanitize_filename(os.path.join(FACE_DIR, f"{name}/{new_name}"))+ new_name = f"{sanitized_name}-{rand_id}.webp"+ new_file = os.path.join(FACE_DIR, f"{sanitized_name}/{new_name}")shutil.move(training_file, new_file)context: EmbeddingsContext = request.app.embeddings@@ -118,7 +119,7 @@ def train_face(request: Request, name: str, body: dict = None):@router.post("/faces/{name}/create")-async def create_face(request: Request, name: str, file: UploadFile):+async def create_face(request: Request, name: str):if not request.app.frigate_config.face_recognition.enabled:return JSONResponse(status_code=400,@@ -126,7 +127,7 @@ async def create_face(request: Request, name: str, file: UploadFile):)os.makedirs(- sanitize_filename(os.path.join(FACE_DIR, name.replace(" ", "_"))), exist_ok=True+ os.path.join(FACE_DIR, sanitize_filename(name.replace(" ", "_"))), exist_ok=True)return JSONResponse(status_code=200,diff --git a/web/src/pages/FaceLibrary.tsx b/web/src/pages/FaceLibrary.tsxindex a096bb28c8..4bb6b39ffc 100644--- a/web/src/pages/FaceLibrary.tsx+++ b/web/src/pages/FaceLibrary.tsx@@ -93,10 +93,9 @@ export default function FaceLibrary() {if (resp.status == 200) {setUpload(false);refreshFaces();- toast.success(- "Successfully uploaded image. View the file in the /exports folder.",- { position: "top-center" },- );+ toast.success("Successfully uploaded image.", {+ position: "top-center",+ });}}).catch((error) => {@@ -125,22 +124,21 @@ export default function FaceLibrary() {}).then((resp) => {if (resp.status == 200) {- setUpload(false);+ setAddFace(false);refreshFaces();- toast.success(- "Successfully uploaded image. View the file in the /exports folder.",- { position: "top-center" },- );+ toast.success("Successfully add face library.", {+ position: "top-center",+ });}}).catch((error) => {if (error.response?.data?.message) {toast.error(- `Failed to upload image: ${error.response.data.message}`,+ `Failed to set face name: ${error.response.data.message}`,{ position: "top-center" },);} else {- toast.error(`Failed to upload image: ${error.message}`, {+ toast.error(`Failed to set face name: ${error.message}`, {position: "top-center",});}