just in case, if location or encoding is null when GenFace is run then return None, and catch this in person and show error on GUI -- for now uploading from a phone does odd things to the image format and fails to work in face_recognition.load_image()

This commit is contained in:
2022-07-10 16:22:35 +10:00
parent 6b7694f382
commit 9f2ecb1901
3 changed files with 10 additions and 2 deletions

5
BUGs
View File

@@ -27,3 +27,8 @@ BUG-89: refimg face_locn also got transformed -- some sequence of adding/removin
BUG-90: I added photo of mich as kid (ice-cream in paris) and then somehow it matches that photo to Cam's face, not the same img -- is this a bug in my code, or some weird quirk of face_recognition library???
- either lib. is weird; OR
- I should get a lower score for mich in that image, and somehow my order/face matching is not doing the right thing
BUG-91: uploading reference images from a phone, does soemthing to the format (they are uploaded as some sort of TIFF inside jpeg?:
"JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=12, height=3024, manufacturer=samsung, model=SM-G980F, orientation=upper-right, xresolution=210, yresolution=218, resolutionunit=2, software=G980FXXUEFVDB, datetime=2022:07:03 14:04:43, width=4032], baseline, precision 8, 4032x3024, components 3"
and then face_recognition.load_image cant find a face in it -- but, if I uplaod via a browser, its a more normal jpeg that I can find a face in... ODD)

View File

@@ -101,10 +101,13 @@ def AddRefimgToPerson( filename, person ):
settings = Settings.query.first()
model=AIModel.query.get(settings.default_refimg_model)
refimg.face, face_locn = GenFace( filename, model=model.name )
os.remove(filename)
if not face_locn:
raise Exception("Could not find face in uploaded reference image" )
return
refimg.face_locn = json.dumps(face_locn)
refimg.model_used = settings.default_refimg_model
refimg.created_on = time.time()
os.remove(filename)
person.refimg.append(refimg)
db.session.add(person)
db.session.add(refimg)

View File

@@ -141,7 +141,7 @@ 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):
if len(encodings) and len(location):
return encodings[0].tobytes(), location[0]
else:
return None, None