From b308a517c72ce10e3c6b6caf73e34de494d39eb4 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 6 Sep 2021 16:47:27 +0300 Subject: [PATCH] Iter instead of dump --- image_classifier/image_classifier.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/image_classifier/image_classifier.py b/image_classifier/image_classifier.py index 7c6ef65..fef9d99 100755 --- a/image_classifier/image_classifier.py +++ b/image_classifier/image_classifier.py @@ -67,10 +67,12 @@ class image_classifier: self._log.debug(f"Processing file '{file}'...") people = self.find_faces(file) if people: + self._log.debug(f"Found {len(people)} known people in the image.") with open(file, 'rb') as image_file: exif_info = exif.Image(image_file) if exif_info.has_exif: - print(json.dumps(exif_info, indent=2)) + for key in exif_info.list_all(): + print(f"{key}: {exif_info[key]}") # get date # move to destination @@ -91,7 +93,7 @@ class image_classifier: def find_faces(self, file): ''' Find faces in an image/video file ''' - names = list() + people = list() try: image = face_recognition.load_image_file(file) encodings = face_recognition.face_encodings(image) @@ -99,11 +101,11 @@ class image_classifier: for known_person in self.known_people: for encoding in encodings: if face_recognition.compare_faces([known_person['encoding']], encoding)[0]: - names.append(known_person['name']) + people.append(known_person['name']) except PIL.UnidentifiedImageError as error: self._log.debug(f"File '{file}' don't seem to be an image.") return False - return names + return people def _init_log(self): ''' Initialize log object '''