Photomongo requires Python 3. I recommend configured a virtualenv, and install requirements.
For my setup the directory structure is a bit backwards for now. I created a directory structure like this
mkdir -p $HOME/proj/face_detect/ cd $HOME/proj/face_detect/ git clone [email protected]:anielsen001/photomongo.git git clone https://github.com/davisking/dlib.git git clone [email protected]:anielsen001/face_recognition.git virtualenv --python=python3 $HOME/proj/face_detect/
Follow the instructions for dlib, essentially this:
cd dlib mkdir build; cd build; cmake .. -DUSE_AVX_INSTRUCTIONS=1; cmake --build .
To compile with CUDA support, you have to specify the path to CUDA and the path to the CUDA library. The path to the nvcc executable must be set on the PATH environment variable also:
export PATH="/usr/lib/cuda-10.0/bin":$PATH export LD_LIBRARY_PATH="/usr/lib/cuda-10.0/lib64":${LD_LIBRARY_PATH} cmake .. -DUSE_AVX_INSTRUCTIONS=1 -DDLIB_USE_CUDA=1 -DCMAKE_PREFIX_PATH=/usr/lib/cuda-10.0 -DCUDA_TOOLKIT_ROOT_DIR=/usr/lib/cuda-10.0 -DCUDA_CUDA_LIBRARY= -DCUDA_NVCC_EXECUTABLE=/usr/lib/cuda-10.0/bin/nvcc -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_PREFIX=$HOME/sw cmake --build .
To build the python bindings, run
python setup.py install
Test if CUDA’s available in the dlib python bindings
apn@baby-bubbles:~/proj/face_detect/dlib$ python3 Python 3.7.2 (default, Feb 24 2019, 11:30:14) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import dlib >>> import dlib.cuda as cuda >>> dlib.DLIB_USE_CUDA True >>> print(cuda.get_num_devices()) 2 >>>
Should see “True” and the number of GPUs available.
python setup.py install
This may also install dlib. If it does, then it cannot find the dlib installed earlier and it may break the CUDA compatibility.
pip install -r requirements.txt
This is optional. If you don’t want to do it, leave this section out of the configuration file.
Before running, the client_secret.json file needs to be save from the google developers site https://console.developers.google.com/ select “credentials” either select existing credentials or create new credentials, download the json file and save as client_secret.json in the current working directory.
python quickstart.py --noauth_local_webserver
You will have to cut and paste between the terminal and the web browser to configure things.
mkdir -p $HOME/data/photos/known
Put known photos with a single face per file into the ‘known’ directory.
mkdir -p $HOME/data/photos/match
Edit the configuration file as needed:
emacs mongo.conf
python photomongo.py mongo.conf --since=1 --progress-bar
Because I used a virtual environment for python, I created a wrapper shell script that could be run independently as a single command and used this as my command to crontab.
photomongo_cron.sh
I added this line to my crontab to run every night at 2am
0 2 * * * /home/me/proj/face_detect/photomongo/photomongo_cron.sh
To save the python environment into a requirements.txt file, use pipreqs which can be installed via pip. pipreqs will save just what’s needed based on the import lines in the python code.
pipreqs . --force