I am loading images into all_images variable and later I'm saving it into all_encodings to use it later in my code, check the code below:
all_images = glob.glob('images/*.jpg')
all_encodings = []
for images in all_images:
image = fr.load_image_file(images)
face_encode = fr.face_encodings(image)[0]
print(face_encode)
all_encodings = list(face_encode)
all_encodings = list.append(face_encode)
print(all_encodings)
But it is throwing below error
TypeError: descriptor 'append' requires a 'list' object but received a 'numpy.ndarray'..
Please give me the precise answer to my question. Thanks in Advance.
You are overwriting all_encodings
in each iteration, guess you'd want:
all_images = glob.glob('images/*.jpg')
all_encodings = []
for images in all_images:
image = fr.load_image_file(images)
face_encode = fr.face_encodings(image)[0]
print(face_encode)
all_encodings.append(list(face_encode))
print(all_encodings)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.