NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Quick fix for face rec (#16226)
Nicolas Mowenfb316874ef91
diff --git a/frigate/api/classification.py b/frigate/api/classification.pyindex 65a85a0568..b42e3ed8ba 100644--- a/frigate/api/classification.py+++ b/frigate/api/classification.py@@ -41,19 +41,36 @@ def get_faces():return JSONResponse(status_code=200, content=face_dict)[email protected]("/faces/{name}")-async def register_face(request: Request, name: str, file: UploadFile):[email protected]("/faces/reprocess")+def reclassify_face(request: Request, body: dict = None):if not request.app.frigate_config.face_recognition.enabled:return JSONResponse(status_code=400,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- result = context.register_face(name, await file.read())+ response = context.reprocess_face(training_file)+return JSONResponse(- status_code=200 if result.get("success", True) else 400,- content=result,+ content=response,+ status_code=200,)@@ -100,36 +117,19 @@ def train_face(request: Request, name: str, body: dict = None):)[email protected]("/faces/reprocess")-def reclassify_face(request: Request, name: str, body: dict = None):[email protected]("/faces/{name}")+async def register_face(request: Request, name: str, file: UploadFile):if not request.app.frigate_config.face_recognition.enabled:return JSONResponse(status_code=400,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- response = context.reprocess_face(training_file)-+ result = context.register_face(name, await file.read())return JSONResponse(- content=response,- status_code=200,+ status_code=200 if result.get("success", True) else 400,+ content=result,)diff --git a/frigate/data_processing/real_time/face_processor.py b/frigate/data_processing/real_time/face_processor.pyindex ee981f5ecc..086c596586 100644--- a/frigate/data_processing/real_time/face_processor.py+++ b/frigate/data_processing/real_time/face_processor.py@@ -215,7 +215,7 @@ class FaceProcessor(RealTimeProcessorApi):if not self.landmark_detector:return None- if not self.recognizer:+ if not self.label_map or not self.recognizer:self.__build_classifier()if not self.recognizer: