Skip to content

Commit

Permalink
Fix rename operation 2
Browse files Browse the repository at this point in the history
  • Loading branch information
weitheng01 committed Jan 28, 2025
1 parent ff55faf commit 0ccf512
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 9 additions & 0 deletions frigate/api/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions web/src/pages/FaceLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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']
});
}

Expand Down

0 comments on commit 0ccf512

Please sign in to comment.