popped face recog load_image_fil into a try block as it clearly has/can fail
This commit is contained in:
17
shared.py
17
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
|
||||
|
||||
Reference in New Issue
Block a user