Face recognition in Mxnet
Oct 15, 2017Install Dependencies
Most computer vision tasks would require dependencies such as dlib and opencv. We will walk through how to install the dependencies, and the problems we encountered and how we resolved them. Installing these dependencies is non-trivial task, it might vary for different system setups. We only show you the story on OSX El Captain, therefore can not guarantee this will work on other setups.
OpenCV
Dlib
dlib is a wellknown C++ library containing many useful machine learning routines. It is widely used in face related tasks. Mostly you would follow the instructions on their git repo to compile your own programs. In our case, we need compile the dlib python API by running,
|
In order to check if your CPU support AVX, on Mac you can run,
This will gives you output like,
See if you have AVX2 in your output, if yes, then you can compile your python API with the USE_AVX_INSTRUCTIONS
option, otherwise just leave it none. Unfortunately during the compiling we got the compile error complaining that Boost.Python is not found, then we realized that dlib relies on Boost Libraries which is another C++ libraries, so what is it?
Boost C++ Library
Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains over eighty individual libraries.
Install the headers and binaries of Boost for Python is actually pretty handy. After download the tarball (we are using version 1.65.1), just uncompress it in your own BOOST_ROOT_PATH
. All the headers are in the subfolder boost
. If you don’t need other binaries, you can just include the headers in your own C++ programs. However, since we need Python bindings, therefore there’s additional steps to do.
To compile the python extensions, you must follow the instruction by specifying the python binding using the script provided,
|
Since we only need python extensions, so only python is specified in --with-libraries
. The default installation path is /usr/local/
. After successfully compiled the python bindings, you can now go back to compile dlib Python binaries.
Face detection example in Dlib
After successfully compiled Dlib Python binaries, you can try out the Python examples in DLIB_ROOT/python_examples/
, e.g., cnn_face_detector.py
|
The result of face detections looks like following. The python code is self explanatory. Next, we will look into how to code your own recognition model using Mxnet.