diff --git a/frigate/api/classification.py b/frigate/api/classification.py index 0dc3a9d57..a06408828 100644 --- a/frigate/api/classification.py +++ b/frigate/api/classification.py @@ -117,10 +117,19 @@ def deregister_faces(request: Request, name: str, body: dict = None): status_code=404, ) + face_dir = os.path.join(FACE_DIR, name) + context: EmbeddingsContext = request.app.embeddings context.delete_face_ids( name, map(lambda file: sanitize_filename(file), list_of_ids) ) + + try: + if os.path.exists(face_dir) and not os.listdir(face_dir): + os.rmdir(face_dir) + except Exception as e: + logger.error(f"Failed to remove directory {face_dir}: {str(e)}") + return JSONResponse( content=({"success": True, "message": "Successfully deleted faces."}), status_code=200, diff --git a/web/src/pages/FaceLibrary.tsx b/web/src/pages/FaceLibrary.tsx index 76a8025d5..81c71cd1d 100644 --- a/web/src/pages/FaceLibrary.tsx +++ b/web/src/pages/FaceLibrary.tsx @@ -172,8 +172,13 @@ export default function FaceLibrary() { const blob = await response.blob(); const formData = new FormData(); - formData.append('file', blob, image); - await axios.post(`/faces/${renameData.newName}`, formData); + formData.append('file', new File([blob], image)); + + await axios.post(`/faces/${renameData.newName}`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); } if (oldFaceImages.length > 0) { @@ -182,7 +187,7 @@ export default function FaceLibrary() { }); } else { await axios.post(`/faces/${renameData.oldName}/delete`, { - ids: ['dummy'] // Send a dummy ID to pass validation + ids: ['dummy'] }); }