Я использую библиотеку face_recognition для распознавания людей на изображениях.Согласно документации библиотеки , он поддерживает два формата входного изображения для дальнейшей обработки: RGB (8 бит, 3 канала) и L (черно-белый).
Я пытался использовать
<code>face_recognition.api.load_image_file(file, mode='RGB')
и все в порядке.Но мне нужно использовать L-режим, и в этом все дело.Проблема в том, что mode = 'RGB' генерирует numpy.array (x, y, 3), а mode = 'L' генерирует numpy.array (x, y).
Массив должен быть введен позже в face_recognition.face_locationsи face_recognition.face_encodings функции.
Если мы поместим массив, сгенерированный в L-режиме, в face_encodings, мы получим следующую ошибку:
<code>
TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:
1. (self: dlib.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),uint8], face: dlib.full_object_detection, num_jitters: int=0) -> dlib.vector
2. (self: dlib.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),uint8], faces: dlib.full_object_detections, num_jitters: int=0) -> dlib.vectors
3. (self: dlib.face_recognition_model_v1, batch_img: List[numpy.ndarray[(rows,cols,3),uint8]], batch_faces: List[dlib.full_object_detections], num_jitters: int=0) -> dlib.vectorss
Любые идеи, как следуетЯ использую эту библиотеку для черно-белых изображений для получения 128-мерных карт лица?
Полный список, который выдает ошибку (вы можете использовать изображение любого человека как image.jpg):
<code>
import face_recognition
image = face_recognition.load_image_file('image.jpg', mode='L')
face_locations = face_recognition.face_locations(image)
face_encodings = face_recognition.face_encodings(image, face_locations)
Traceback:
<code></p>
<p>File "D:/PythonProjects/face_recognition_grayscale_test.py", line 18, in
face_encodings = face_recognition.face_encodings(image, face_locations)</p>
<p>File "C:\ProgramData\Anaconda3\lib\site-packages\face_recognition\api.py", line 200, in face_encodings
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]</p>
<p>File "C:\ProgramData\Anaconda3\lib\site-packages\face_recognition\api.py", line 200, in
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]</p>
<p>TypeError: compute_face_descriptor(): incompatible function arguments. The following argument types are supported:
1. (self: dlib.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),uint8], face: dlib.full_object_detection, num_jitters: int=0) -> dlib.vector
2. (self: dlib.face_recognition_model_v1, img: numpy.ndarray[(rows,cols,3),uint8], faces: dlib.full_object_detections, num_jitters: int=0) -> dlib.vectors
3. (self: dlib.face_recognition_model_v1, batch_img: List[numpy.ndarray[(rows,cols,3),uint8]], batch_faces: List[dlib.full_object_detections], num_jitters: int=0) -> dlib.vectorss</p>
<p>Invoked with: , array([[167, 167, 167, ..., 172, 172, 170],
[167, 167, 167, ..., 172, 172, 170],
[167, 167, 167, ..., 172, 172, 170],
...,
[188, 186, 181, ..., 201, 201, 198],
[193, 189, 184, ..., 201, 201, 198],
[181, 180, 178, ..., 201, 201, 198]], dtype=uint8), , 1