0
I had the following error when working with the face_recognition library, when using the code:
face1 = face_recognition.load_image_file('face1.jpg')
face2 = face_recognition.load_image_file('face2.jpg')
face3 = face_recognition.load_image_file('face3.jpg')
face_recognition.batch_face_locations(images=[face1,face2,face3], number_of_times_to_upsample=1, batch_size=128)
Made the following mistake:
Traceback (most recent call last):
File "C:\Users\Samuel\OneDrive\PythonProjects\ident_facial.py", line 32, in <module>
face_recognition.batch_face_locations(images=[face1,face2,face3], number_of_times_to_upsample=1, batch_size=128)
File "C:\Users\Samuel\OneDrive\PythonProjects\venv\lib\site-packages\face_recognition\api.py", line 149, in batch_face_locations
raw_detections_batched = _raw_face_locations_batched(images, number_of_times_to_upsample, batch_size)
File "C:\Users\Samuel\OneDrive\PythonProjects\venv\lib\site-packages\face_recognition\api.py", line 132, in _raw_face_locations_batched
return cnn_face_detector(images, number_of_times_to_upsample, batch_size=batch_size)
RuntimeError: Images in list must all have the same dimensions.
Even though I leave the size of the photos the same, it’s still the same. Follow the whole code :
import face_recognition
import numpy as np
import cv2
import matplotlib.pyplot as plt
def show_img(img):
plt.axis('off')
plt.imshow(img)
plt.show()
# CARREGAR IMAGEM
face1 = face_recognition.load_image_file('face1.jpg')
face2 = face_recognition.load_image_file('face2.jpg')
face3 = face_recognition.load_image_file('face3.jpg')
face_recognition.batch_face_locations(images=[face1,face2,face3], number_of_times_to_upsample=1, batch_size=128)
what your program returns if you print
imagem.shape
for each image (face1, face2, face3)?– Flavio Moraes
Hello Samuel, I believe the mistake is clear: Images in list must all have the same Dimensions. That is, the images have different dimensions between them. In other words, different sizes of width and/or height.
– Paulo Marques