Face_recognition: missing pybind11 dependencies when trying to use model="cnn"

Created on 7 Mar 2018  路  5Comments  路  Source: ageitgey/face_recognition

  • face_recognition version: 0.1.0
  • Python version: 2.7.13
  • Operating System: OSX 10.12.5

Description

Traceback when trying to use face detection with model="cnn":

File "brains.py", line 104, in detect_face
    face_locations = face_recognition.face_locations(frame, number_of_times_to_upsample="0", model="cnn")
  File "/Users/cjoseph/anaconda/lib/python2.7/site-packages/face_recognition/api.py", line 114, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/Users/cjoseph/anaconda/lib/python2.7/site-packages/face_recognition/api.py", line 98, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
    1. (self: dlib.cnn_face_detection_model_v1, img: object, upsample_num_times: int=0) -> std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >
    2. (self: dlib.cnn_face_detection_model_v1, imgs: list, upsample_num_times: int=0, batch_size: int=128) -> std::__1::vector<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >, std::__1::allocator<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> > > >

Invoked with: <dlib.cnn_face_detection_model_v1 object at 0x11b6ef8f0>, array([[[  4,   4,   4],
        [150, 150, 150],
        [148, 148, 148],
        ..., 
        [ 44,  44,  44],
        [  0,   0,   0],
        [  0,   0,   0]],

       [[150, 150, 150],
        [151, 151, 151],
        [148, 148, 148],
        ..., 
        [ 44,  44,  44],
        [  0,   0,   0],
        [  0,   0,   0]],

       [[149, 149, 149],
        [147, 147, 147],
        [146, 146, 146],
        ..., 
        [ 44,  44,  44],
        [  0,   0,   0],
        [  0,   0,   0]],

       ..., 
       [[ 99,  99,  99],
        [ 94,  94,  94],
        [ 92,  92,  92],
        ..., 
        [ 42,  42,  42],
        [  0,   0,   0],
        [  0,   0,   0]],

       [[ 98,  98,  98],
        [ 93,  93,  93],
        [ 94,  94,  94],
        ..., 
        [ 40,  40,  40],
        [  0,   0,   0],
        [  0,   0,   0]],

       [[ 93,  93,  93],
        [ 91,  91,  91],
        [ 97,  97,  97],
        ..., 
        [ 40,  40,  40],
        [  0,   0,   0],
        [  0,   0,   0]]], dtype=uint8), '0'

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

Most helpful comment

Help me, I ran into a similar error but this this I do pass a 0 not "0"

Traceback (most recent call last):
  File "/Users/huynhphuminh/PycharmProjects/GenderDetection_Facenet_MS_1M/test_face_modules.py", line 30, in <module>
    batch_of_face_locations = face.batch_face_locations(curbatch, number_of_times_to_upsample=0)
  File "/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 146, in batch_face_locations
    raw_detections_batched = _raw_face_locations_batched(images, number_of_times_to_upsample, batch_size)
  File "/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 129, in _raw_face_locations_batched
    return cnn_face_detector(images, number_of_times_to_upsample, batch_size=batch_size)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
    1. (self: dlib.cnn_face_detection_model_v1, imgs: list, upsample_num_times: int=0, batch_size: int=128) -> std::__1::vector<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >, std::__1::allocator<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> > > >
    2. (self: dlib.cnn_face_detection_model_v1, img: array, upsample_num_times: int=0) -> std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >

Invoked with: <dlib.cnn_face_detection_model_v1 object at 0x109771768>, array([[[[ 15.,  12.,   3.],
         [ 18.,  15.,   6.],
         [ 23.,  16.,   6.],
         ...,
         [ 12.,   8.,   9.],
         [ 12.,   7.,  11.],
         [  9.,   7.,  10.]],

        [[ 15.,  12.,   3.],
         [ 18.,  14.,   5.],
         [ 23.,  16.,   6.],
         ...,

        [[ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         ...,
         [201., 174., 157.],
         [207., 181., 164.],
         [211., 185., 168.]],

        [[ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         ...,
         [206., 179., 162.],
         [213., 187., 172.],
         [217., 191., 176.]]]]), 0; kwargs: batch_size=128

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

All 5 comments

The parameter number_of_times_to_upsample needs to be an integer value. It looks like you are passing it in as a string.

Just change:

    face_locations = face_recognition.face_locations(frame, number_of_times_to_upsample="0", model="cnn")

To:

    face_locations = face_recognition.face_locations(frame, number_of_times_to_upsample=0, model="cnn")

(I.e. Remove the quotes around 0. That's making the value a string instead of an integer)

Hopefully that's all it is :)

Yup, derp!

Help me, I ran into a similar error but this this I do pass a 0 not "0"

Traceback (most recent call last):
  File "/Users/huynhphuminh/PycharmProjects/GenderDetection_Facenet_MS_1M/test_face_modules.py", line 30, in <module>
    batch_of_face_locations = face.batch_face_locations(curbatch, number_of_times_to_upsample=0)
  File "/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 146, in batch_face_locations
    raw_detections_batched = _raw_face_locations_batched(images, number_of_times_to_upsample, batch_size)
  File "/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 129, in _raw_face_locations_batched
    return cnn_face_detector(images, number_of_times_to_upsample, batch_size=batch_size)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
    1. (self: dlib.cnn_face_detection_model_v1, imgs: list, upsample_num_times: int=0, batch_size: int=128) -> std::__1::vector<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >, std::__1::allocator<std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> > > >
    2. (self: dlib.cnn_face_detection_model_v1, img: array, upsample_num_times: int=0) -> std::__1::vector<dlib::mmod_rect, std::__1::allocator<dlib::mmod_rect> >

Invoked with: <dlib.cnn_face_detection_model_v1 object at 0x109771768>, array([[[[ 15.,  12.,   3.],
         [ 18.,  15.,   6.],
         [ 23.,  16.,   6.],
         ...,
         [ 12.,   8.,   9.],
         [ 12.,   7.,  11.],
         [  9.,   7.,  10.]],

        [[ 15.,  12.,   3.],
         [ 18.,  14.,   5.],
         [ 23.,  16.,   6.],
         ...,

        [[ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         ...,
         [201., 174., 157.],
         [207., 181., 164.],
         [211., 185., 168.]],

        [[ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         [ 24.,  12.,  12.],
         ...,
         [206., 179., 162.],
         [213., 187., 172.],
         [217., 191., 176.]]]]), 0; kwargs: batch_size=128

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

I managed to fix this by opening the image with cv2 instead of PIL.

I managed to fix this by opening the image with cv2 instead of PIL.

I am opening the image with cv2 and still get the same error.

Was this page helpful?
0 / 5 - 0 ratings