Error during face recognition: Unsupported image type, must be 8bit gray or RGB image.
BadOOOFra opened this issue · 3 comments
- face_recognition version: 1.3.0
- Python version: 3.12.4
- Operating System: MacOS Sonoma Version 14.5 (23F79)
Description
I am trying to implement a face recognition login system using the face_recognition library in a Flask web application. The image is captured from a webcam using JavaScript, converted to a data URL, and sent to the server. However, I am consistently encountering the error Unsupported image type, must be 8bit gray or RGB image despite ensuring the image is in the correct format.
What went wrong:
• The error occurs during the face_recognition.face_encodings function call.
• Debugging indicates that the image is converted to RGB and is an 8-bit image, but the error persists.
Expected:
• The function face_recognition.face_encodings should process the image and return face encodings if faces are detected.
What I Did
Traceback:
DEBUG: STREAM b'IHDR' 16 13
DEBUG: STREAM b'sRGB' 41 1
DEBUG: STREAM b'IDAT' 54 8192
DEBUG: Original image mode: RGBA
DEBUG: Converted image mode: RGB
DEBUG: Image shape: (480, 640, 3), dtype: uint8
ERROR: Error during face recognition: Unsupported image type, must be 8bit gray or RGB image.
INFO: 127.0.0.1 - - [27/Jun/2024 22:23:00] "POST /login HTTP/1.1" 200 -
version de reconnaissance faciale : 1.3.0
Version Python : 3.12.4
systeme d'exploitation :windows 10
j'essaie d'implementer un systeme de reconnaissaance faciale a l'aide de la bibliotheque face_recognition . Cependant, je rencontre systématiquement l'erreur Type d'image non pris en charge, doit être une image grise ou RVB 8 bits, même si je m'assure que l'image est au bon format.
Hello! I've run into this issue a lot of times, and what worked for me was downgrading to numpy 1.26.1. Numpy 2 seems to have changed some functionality which causes this issue. Once you've downgraded your numpy, make sure to change the line containing "rgb_small_frame" to be:
rgb_small_frame = np.ascontiguousarray(small_frame[:, :, ::-1])
instead.
Hello! I've run into this issue a lot of times, and what worked for me was downgrading to numpy 1.26.4. Numpy 2 seems to have changed some functionality which causes this issue. Once you've downgraded your numpy, it's working fine.