Ensure doesn't fail due to missing dir

This commit is contained in:
Nicolas Mowen 2025-03-21 07:51:40 -06:00
parent 060659044e
commit 3d605b75a6
2 changed files with 4 additions and 0 deletions

View File

@ -30,6 +30,9 @@ router = APIRouter(tags=[Tags.events])
def get_faces():
face_dict: dict[str, list[str]] = {}
if not os.path.exists(FACE_DIR):
return JSONResponse(status_code=200, content={})
for name in os.listdir(FACE_DIR):
face_dir = os.path.join(FACE_DIR, name)

View File

@ -506,6 +506,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
if self.config.face_recognition.save_attempts:
# write face to library
folder = os.path.join(FACE_DIR, "train")
os.makedirs(folder, exist_ok=True)
new_file = os.path.join(
folder, f"{id}-{sub_label}-{score}-{face_score}.webp"
)