diff --git a/shared.py b/shared.py index 619ac19..681da5a 100644 --- a/shared.py +++ b/shared.py @@ -5,6 +5,7 @@ import io import base64 import subprocess from PIL import Image, ImageOps +import numpy as np class PA: def __repr__(self): @@ -167,10 +168,12 @@ def GenThumb(fname,auto_rotate): # generate Face data (and location) - wrapper func of face_recognition library # used to store refimg data into the DB def GenFace(fname, model): - img = face_recognition.load_image_file(fname) - location = face_recognition.face_locations(img, model=model) - encodings = face_recognition.face_encodings(img, known_face_locations=location) - if len(encodings) and len(location): - return encodings[0].tobytes(), location[0] - else: - return None, None + try: + img = face_recognition.load_image_file(fname) + location = face_recognition.face_locations(img, model=model) + encodings = face_recognition.face_encodings(img, known_face_locations=location) + if len(encodings) and len(location): + return encodings[0].tobytes(), location[0] + except Exception as e: + print( f"GenFace failed: {e}" ) + return None, None