diff --git a/BUGs b/BUGs index 7e80a47..37e3e8d 100644 --- a/BUGs +++ b/BUGs @@ -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) diff --git a/person.py b/person.py index d22b5c2..acc4eb8 100644 --- a/person.py +++ b/person.py @@ -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) diff --git a/shared.py b/shared.py index 4baafcf..aa67238 100644 --- a/shared.py +++ b/shared.py @@ -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