Skip to content

Instantly share code, notes, and snippets.

@kaikuehne
Last active February 22, 2020 17:50
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kaikuehne/d027a0ff3aa353a7322a to your computer and use it in GitHub Desktop.
Save kaikuehne/d027a0ff3aa353a7322a to your computer and use it in GitHub Desktop.
Installation and using openface to create and use your own classifier

Installation

Installation instructions are basically notes that I took while installing openface on MacOSX El Capitan.

System packages

brew install bash coreutils curl findutils opencv
brew install python --framework --universal --with-brewed-openssl
brew install boost-python --universal

Python & packages

git clone --recursive https://github.com/cmusatyalab/openface.git
cd openface
virtualenv env
source env/bin/activate
pip install dlib numpy scipy pandas scikit-learn scikit-image
cp /usr/local/lib/python2.7/site-packages/cv* env/lib/python2.7/site-packages
deactivate

Torch

curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
git clone https://github.com/torch/distro.git torch --recursive
cd torch
./install.sh
source install/bin/torch-activate
luarocks install csvigo
luarocks install dpnn
luarocks install nn
cd ..
source env/bin/activate

Creating your own classifier

Put images (structured by subdirectory) into e.g. data/mydataset/raw:

  • data/mydataset/raw/person-1 * 1.jpg * ...
  • data/mydataset/raw/person-2 * ...
for N in {1..8}; do ./util/align-dlib.py data/mydataset/raw align affine data/mydataset/aligned --size 96 &; done
luajit batch-represent/main.lua -data data/mydataset/aligned -outDir data/mydataset/reps -model models/openface/nn4.v1.t7
./demos/classifier.py train data/mydataset/reps

Using your classifier

./demos/classifier.py infer data/mydataset/reps/classifier.pkl <image>
@bninopaul
Copy link

Hi @kaikuehne, I've been following your steps in installing openface, thanks for this helpful installation guide! The setup documentation in openface api seems not dummy-friendly. I did all the installation steps and to know if its working, I also create my own classifier, but after running the first line:

for N in {1..8}; do ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96 & done

I tried to look at the folder data/lfw_aligned by cd, I get this:

[1]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[2]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[3]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[4]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[5]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[6]   Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[7]-  Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)
[8]+  Segmentation fault: 11  ./util/align-dlib.py data/lfw/ align affine data/lfw_aligned/ --size 96  (wd: ~/git-repos/openface)
(wd now: ~/git-repos/openface/data/lfw_aligned)

Also, if I do simple importing of openface, that is:

>>>>import openface
Segmentation fault: 11

How do I fix this? What might be the reason for this?

@yactouat
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment