Before you start
Make sure you have python, OpenFace and dlib installed. You can either install them manually or use a preconfigured docker image that has everying already installed:
docker pull bamos/openface
docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
cd /root/openface
Step 1
Make a folder called /training-images/
somewhere on your computer.
Step 2
Make a subfolder for each person you want to recognize. For example:
/training-images/will-ferrell/
/training-images/chad-smith/
/training-images/jimmy-fallon/
Step 3
Copy all your images of each person into the correct sub-folders
Step 4
Run the openface scripts from inside the openface root directory:
First, do pose detection and alignment:
./util/align-dlib.py ./training-images/ align outerEyesAndNose ./aligned-images/ --size 96
Second, generate the representations from the aligned images:
./batch-represent/main.lua -outDir ./generated-embeddings/ -data ./aligned-images/
When you are done, the ./generated-embeddings/
folder will contain a csv file with the embeddings for each image.
Finally I solved my issue. I am writing for those who might face the same problem.
What's the actual problem is that when we install the openface , it gets installed in the root directory and the line
/util/align-dlib.py ./training-images/ align outerEyesAndNose ./aligned-images/ --size 96
doesn't give any error but doesn't form any /aligned-images in the given path.
I copied the openface in my user directory and just altered few lines of the "/util/align-dlib.py"
in the line
29 modelDir = os.path.join(fileDir, '..', 'models')
changed it to
29 modelDir = os.path.join(fileDir, 'models')
after this is done, copy the "training-images" folder into this openface folder
Now from the dlib directory copy the "shape_predictor_68_face_landmarks.dat" into the folder "openface"
Now run
/util/align-dlib.py ./training-images/ align outerEyesAndNose ./aligned-images/ --size 96
and now you will find a folder /aligned-images in openface folder
Now if you run the 2nd line
./batch-represent/main.lua -outDir ./generated-embeddings/ -data ./aligned-images/
you will get an error that you don't have torch installed in your system , so first install torch
to install torch type->
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh
after torch is installed, if you run
./batch-represent/main.lua -outDir ./generated-embeddings/ -data ./aligned-images/
again you will encounter the error like
to remove this type
luarocks install cutorch
luarocks install csvigo
luarocks install dnn
and you are done