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 base64
|
||||||
import subprocess
|
import subprocess
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
class PA:
|
class PA:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@@ -167,10 +168,12 @@ def GenThumb(fname,auto_rotate):
|
|||||||
# generate Face data (and location) - wrapper func of face_recognition library
|
# generate Face data (and location) - wrapper func of face_recognition library
|
||||||
# used to store refimg data into the DB
|
# used to store refimg data into the DB
|
||||||
def GenFace(fname, model):
|
def GenFace(fname, model):
|
||||||
img = face_recognition.load_image_file(fname)
|
try:
|
||||||
location = face_recognition.face_locations(img, model=model)
|
img = face_recognition.load_image_file(fname)
|
||||||
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
location = face_recognition.face_locations(img, model=model)
|
||||||
if len(encodings) and len(location):
|
encodings = face_recognition.face_encodings(img, known_face_locations=location)
|
||||||
return encodings[0].tobytes(), location[0]
|
if len(encodings) and len(location):
|
||||||
else:
|
return encodings[0].tobytes(), location[0]
|
||||||
return None, None
|
except Exception as e:
|
||||||
|
print( f"GenFace failed: {e}" )
|
||||||
|
return None, None
|
||||||
|
|||||||
Reference in New Issue
Block a user