"Unsupported image type, must be 8bit gray or RGB image."
See original GitHub issue- face_recognition version: Latest, just installed today from pip3
- Python version: 3.5.2
- Operating System: Fresh install of Ubuntu
Description
I was just playing around with some of the example scripts, when I get this error:
sudo python3 main.py obama.jpg obama.jpg Traceback (most recent call last): File “main.py”, line 13, in <module> unkown_image_encoding = face_recognition.face_encodings(unknown_image)[0] File “/usr/local/lib/python3.5/dist-packages/face_recognition/api.py”, line 146, in face_encodings raw_landmarks = _raw_face_landmarks(face_image, known_face_locations) File “/usr/local/lib/python3.5/dist-packages/face_recognition/api.py”, line 105, in _raw_face_landmarks face_locations = _raw_face_locations(face_image) File “/usr/local/lib/python3.5/dist-packages/face_recognition/api.py”, line 89, in _raw_face_locations return face_detector(img, number_of_times_to_upsample) RuntimeError: Unsupported image type, must be 8bit gray or RGB image.
What I Did
import face_recognition
import sys
unknown_image = sys.argv[1]
print(sys.argv[1])
obama_image = face_recognition.load_image_file('obama.jpg')
obama_image_encoding = face_recognition.face_encodings(obama_image)[0]
biden_image = face_recognition.load_image_file('biden.jpg')
biden_image_encoding = face_recognition.face_encodings(biden_image)[0]
unkown_image_encoding = face_recognition.face_encodings(unknown_image)[0]
knownfaces = [
obama_image_encoding,
biden_image_encoding
]
results = face_recognition.compare_faces(knownfaces, unkown_image_encoding)
print(results)
if results[0] == True and results[1] == False:
print("It's Obama!")
elif results[1] == True and results[0] == False:
print("It's Biden!")
else:
print('Unknown person')
The weird thing is that I tried running it without the sys.argv and with the same files, it works.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Related StackOverflow Question
You need to call
face_recognition.load_image_file()on the file name you pass in via argv. argv is just a string file name, not an array of image data.No problem 😃