mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-08 22:35:42 +03:00
Correctly return response for reprocess
This commit is contained in:
parent
e5dc39f1fd
commit
142bc2078a
@ -112,9 +112,18 @@ def reclassify_face(request: Request, body: dict = None):
|
|||||||
context: EmbeddingsContext = request.app.embeddings
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
response = context.reprocess_face(training_file)
|
response = context.reprocess_face(training_file)
|
||||||
|
|
||||||
|
if not isinstance(response, dict):
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=500,
|
||||||
|
content={
|
||||||
|
"success": False,
|
||||||
|
"message": "Could not process request.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
status_code=200 if response.get("success", True) else 400,
|
||||||
content=response,
|
content=response,
|
||||||
status_code=200,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -423,7 +423,10 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
res = self.recognizer.classify(img)
|
res = self.recognizer.classify(img)
|
||||||
|
|
||||||
if not res:
|
if not res:
|
||||||
return
|
return {
|
||||||
|
"message": "No face was recognized.",
|
||||||
|
"success": False,
|
||||||
|
}
|
||||||
|
|
||||||
sub_label, score = res
|
sub_label, score = res
|
||||||
|
|
||||||
@ -442,6 +445,13 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
)
|
)
|
||||||
shutil.move(current_file, new_file)
|
shutil.move(current_file, new_file)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": f"Successfully reprocessed face. Result: {sub_label} (score: {score:.2f})",
|
||||||
|
"success": True,
|
||||||
|
"face_name": sub_label,
|
||||||
|
"score": score,
|
||||||
|
}
|
||||||
|
|
||||||
def expire_object(self, object_id: str, camera: str):
|
def expire_object(self, object_id: str, camera: str):
|
||||||
if object_id in self.person_face_history:
|
if object_id in self.person_face_history:
|
||||||
self.person_face_history.pop(object_id)
|
self.person_face_history.pop(object_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user