"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:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
ageitgeycommented, Aug 2, 2017

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.

1reaction
ageitgeycommented, Aug 2, 2017

No problem 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

dlib face detection error : Unsupported image type, must be ...
i am trying to crop out the faces from instagram avatars by first detecting the faces and then resizing the image.
Read more >
RGB error python edit - OpenCV Q&A Forum
Well your problem is in the error message "Unsupported image type, must be 8bit gray or RGB image. " So either supply a...
Read more >
Face Recognition Documentation - Read the Docs
Issue: RuntimeError: Unsupported image type, must be 8bit gray or RGB image. when running the webcam examples.
Read more >
Image Menu - SalsaJ - EU-HOU
Converts to 32-bit RGB colour. The active image must be grayscale, 8-bit Colour, or an RGB (red, green, blue) or HSB (hue, saturation...
Read more >
face-recognition - Python Package Health Analysis - Snyk
you do face recognition on a folder of images from the command line! ... Issue: RuntimeError: Unsupported image type, must be 8bit gray...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found