Dlib: Unable to cast Python instance to C++ type

Created on 30 Apr 2019  路  4Comments  路  Source: davisking/dlib

I'm trying to implement face clustering in Python. Unfortunately function dlib.chinese_whispers_clustering(descriptors,0.5) triggers a Runtime error: Unable to cast Python instance to C++ type (compile in debug mode for details). I can't get it to install in debug mode with python setup.py build --debug. It fails near the end with an error: c++: internal compiler error: Killed (program cc1plus). Although it installs fine with command python setup.py install.
Function dlib.chinese_whispers() works fine, however I don't know how to cluster faces using this function. So alternatively I'd appreciate any outline on how to cluster faces using chinese_whispers() instead of chinese_whispers_clustering(). I couldn't find any details on how the latter one works.

Expected Behavior

Cluster descriptors of faces and return list of labels of those faces. By getting the length of the labels I could find out how many faces there are in the dataset.

Current Behavior

Triggers a runtime error Unable to cast Python instance to C++ type (compile in debug mode for details)

Steps to Reproduce

  1. Install dlib on Ubuntu with python setup.py install
  2. Import dlib and try to run function dlib.chinese_whispers_clustering(descriptors, 0.5).

Thank you very much.

  • Version: 19.17
  • Where did you get dlib: dlib.net
  • Platform: Ubuntu 18.04
  • Compiler: gcc 7.3

Most helpful comment

I stumbled into this aswell and solved it by printing the descriptors from the example script and noticed that they are of type dlib.vector. Converted all my python lists to dlib.vectors and now its works.

descriptor = dlib.vector([0.1, 0.2, 0.3, ...])

All 4 comments

Please post a small python program that runs and illustrates the issue.

Hello, I've just sorted it out. I was converting descriptors to a numpy array, and it apparently isn't accepted by dlib. I didn't imagine that it could be a problem with the code. I was thinking only about dlib installation.
Thank you again

@maromcik, What did you do to solve this problem. I tried to converting the embeddings into a list, but the problem is not solved.

I stumbled into this aswell and solved it by printing the descriptors from the example script and noticed that they are of type dlib.vector. Converted all my python lists to dlib.vectors and now its works.

descriptor = dlib.vector([0.1, 0.2, 0.3, ...])
Was this page helpful?
0 / 5 - 0 ratings

Related issues

AeroClassics picture AeroClassics  路  4Comments

yourmailhacked picture yourmailhacked  路  3Comments

unicorn7t picture unicorn7t  路  3Comments

mohsin512 picture mohsin512  路  5Comments

reunanen picture reunanen  路  3Comments