mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
parent
9236898a9d
commit
fb316874ef
@ -41,19 +41,36 @@ def get_faces():
|
|||||||
return JSONResponse(status_code=200, content=face_dict)
|
return JSONResponse(status_code=200, content=face_dict)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/faces/{name}")
|
@router.post("/faces/reprocess")
|
||||||
async def register_face(request: Request, name: str, file: UploadFile):
|
def reclassify_face(request: Request, body: dict = None):
|
||||||
if not request.app.frigate_config.face_recognition.enabled:
|
if not request.app.frigate_config.face_recognition.enabled:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
content={"message": "Face recognition is not enabled.", "success": False},
|
content={"message": "Face recognition is not enabled.", "success": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
context: EmbeddingsContext = request.app.embeddings
|
json: dict[str, any] = body or {}
|
||||||
result = context.register_face(name, await file.read())
|
training_file = os.path.join(
|
||||||
|
FACE_DIR, f"train/{sanitize_filename(json.get('training_file', ''))}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not training_file or not os.path.isfile(training_file):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=200 if result.get("success", True) else 400,
|
content=(
|
||||||
content=result,
|
{
|
||||||
|
"success": False,
|
||||||
|
"message": f"Invalid filename or no file exists: {training_file}",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
status_code=404,
|
||||||
|
)
|
||||||
|
|
||||||
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
|
response = context.reprocess_face(training_file)
|
||||||
|
|
||||||
|
return JSONResponse(
|
||||||
|
content=response,
|
||||||
|
status_code=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -100,36 +117,19 @@ def train_face(request: Request, name: str, body: dict = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/faces/reprocess")
|
@router.post("/faces/{name}")
|
||||||
def reclassify_face(request: Request, name: str, body: dict = None):
|
async def register_face(request: Request, name: str, file: UploadFile):
|
||||||
if not request.app.frigate_config.face_recognition.enabled:
|
if not request.app.frigate_config.face_recognition.enabled:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
content={"message": "Face recognition is not enabled.", "success": False},
|
content={"message": "Face recognition is not enabled.", "success": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
json: dict[str, any] = body or {}
|
|
||||||
training_file = os.path.join(
|
|
||||||
FACE_DIR, f"train/{sanitize_filename(json.get('training_file', ''))}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not training_file or not os.path.isfile(training_file):
|
|
||||||
return JSONResponse(
|
|
||||||
content=(
|
|
||||||
{
|
|
||||||
"success": False,
|
|
||||||
"message": f"Invalid filename or no file exists: {training_file}",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
status_code=404,
|
|
||||||
)
|
|
||||||
|
|
||||||
context: EmbeddingsContext = request.app.embeddings
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
response = context.reprocess_face(training_file)
|
result = context.register_face(name, await file.read())
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=response,
|
status_code=200 if result.get("success", True) else 400,
|
||||||
status_code=200,
|
content=result,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
if not self.landmark_detector:
|
if not self.landmark_detector:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not self.recognizer:
|
if not self.label_map or not self.recognizer:
|
||||||
self.__build_classifier()
|
self.__build_classifier()
|
||||||
|
|
||||||
if not self.recognizer:
|
if not self.recognizer:
|
||||||
|
Loading…
Reference in New Issue
Block a user