Iter instead of dump
This commit is contained in:
parent
c971382270
commit
b308a517c7
1 changed files with 6 additions and 4 deletions
|
@ -67,10 +67,12 @@ class image_classifier:
|
||||||
self._log.debug(f"Processing file '{file}'...")
|
self._log.debug(f"Processing file '{file}'...")
|
||||||
people = self.find_faces(file)
|
people = self.find_faces(file)
|
||||||
if people:
|
if people:
|
||||||
|
self._log.debug(f"Found {len(people)} known people in the image.")
|
||||||
with open(file, 'rb') as image_file:
|
with open(file, 'rb') as image_file:
|
||||||
exif_info = exif.Image(image_file)
|
exif_info = exif.Image(image_file)
|
||||||
if exif_info.has_exif:
|
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
|
# get date
|
||||||
# move to destination
|
# move to destination
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ class image_classifier:
|
||||||
|
|
||||||
def find_faces(self, file):
|
def find_faces(self, file):
|
||||||
''' Find faces in an image/video file '''
|
''' Find faces in an image/video file '''
|
||||||
names = list()
|
people = list()
|
||||||
try:
|
try:
|
||||||
image = face_recognition.load_image_file(file)
|
image = face_recognition.load_image_file(file)
|
||||||
encodings = face_recognition.face_encodings(image)
|
encodings = face_recognition.face_encodings(image)
|
||||||
|
@ -99,11 +101,11 @@ class image_classifier:
|
||||||
for known_person in self.known_people:
|
for known_person in self.known_people:
|
||||||
for encoding in encodings:
|
for encoding in encodings:
|
||||||
if face_recognition.compare_faces([known_person['encoding']], encoding)[0]:
|
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:
|
except PIL.UnidentifiedImageError as error:
|
||||||
self._log.debug(f"File '{file}' don't seem to be an image.")
|
self._log.debug(f"File '{file}' don't seem to be an image.")
|
||||||
return False
|
return False
|
||||||
return names
|
return people
|
||||||
|
|
||||||
def _init_log(self):
|
def _init_log(self):
|
||||||
''' Initialize log object '''
|
''' Initialize log object '''
|
||||||
|
|
Loading…
Reference in a new issue