人脸识别框架 openface学习(一) openface的安装

1)openface 地址:
官网地址: http://cmusatyalab.github.io/openface/
Git地址 : https://github.com/cmusatyalab/openface/
2)开发环境:
2.1 系统环境:
OSX 10.10 以及 Ubuntu 14.04 我用的是ubuntu 14.04
2.2 开发工具
因为opencv和dlib的原因,最后选择python2 现使用python 2.7.6

3)openface安装方式
3.1) 通过docker 这种方式比较简单, 方便快捷
3.2) 利用平台anaconda 安装
3.3) 手动安装

3.1)docker安装
现把安装过程贴出来
apt-get -y install docker.io
docker pull bamos/openface

docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
cd /root/openface
./demos/compare.py images/examples/{lennon*,clapton*}
./demos/classifier.py infer models/openface/celeb-classifier.nn4.small2.v1.pkl ./images/examples/carell.jpg
./demos/web/start-servers.sh

说明:
我自己运行的时候在 docker pull 镜像的时候就出错, 所以这种方法就没继续研究下来, 错误是 FATA[0150] Tag latest not found in repository bamos/openface 网络查找原因是境外的源可能被墙。

3.2) 利用平台anaconda 安装
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
conda create --name openface python=2.7
source activate openface

conda config --add channels conda-forge
conda install opencv numpy pandas scipy scikit-learn scikit-image dlib txaio twisted autobahn OpenSSL pyopenssl imagehash service_identity
安装torch
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh
for NAME in dpnn nn optim optnet csvigo cutorch cunn fblualib torchx tds; do luarocks install $NAME; done
安装openface
source activate openface
git clone https://github.com/cmusatyalab/openface.git ~/openface
cd openface
python setup.py install
这样,openface就安装完成了

3.3) 手动安装

  1. pip install numpy
  2. pip install pandas
  3. pip install scipy
  4. pip install scikit-learn
  5. pip install scikit-image

安装opencv
下载地址 https://codeload.github.com/opencv/opencv/zip/2.4.11
安装说明 https://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

apt-get install build-essential

apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local …
make && make install
安装dlib
下载地址:
https://github-production-release-asset-2e65be.s3.amazonaws.com/16331291/6b3c6d7a-0c2d-11e5-8267-d2dbbc62e0ba?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190411%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190411T052755Z&X-Amz-Expires=300&X-Amz-Signature=f115a57f70eb1702f79dd906a398493dc15ed547a17d887170eb67c5feed3de5&X-Amz-SignedHeaders=host&actor_id=7464871&response-content-disposition=attachment%3B filename%3Ddlib-18.16.tar.bz2&response-content-type=application%2Foctet-stream
apt-get install cmake
apt-get install libopenblas-dev liblapack-dev
sudo apt-get install libboost-dev
apt-get install --no-install-recommends libboost-all-dev
tar xf dlib-18.16.tar.bz2
cd dlib-18.16/python_examples
mkdir build
cd build
cmake …/…/tools/python
cmake --build . --config Release
sudo cp dlib.so /usr/local/lib/python2.7/dist-packages

注意 dlib 编译时内存至少占用1.4G

安装torch
sudo apt-get update
sudo apt-get install luarocks
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
bash install-deps
./install.sh
source ~/.profile
for NAME in dpnn nn optim optnet csvigo cutorch cunn fblualib torchx tds; do luarocks install $NAME; done

Openface安装
在主目录执行 sudo python2 setup.py install.
说明:
此次安装我安装openface时没有安装torch ,只是引用import openface不报错,没有执行训练,后在重新安装的torch,没再安装其他, 不过这么安装应该没得什么问题

手动安装也最是麻烦, pip install 的时候就遇到不少问题,最后将记录的一些问题记录下来 以下是踩过的坑

Pip install numpy 出现错误
SystemError: Cannot compile ‘Python.h’. Perhaps you need to install python-dev|python-devel.

而在执行apt-get install python-devel时也出错

解决:
是因为源不一样的原因
• sudo apt-get update
• sudo apt-get install python2.7-dev
• sudo apt-get install python-dev

Pip install scipy 失败
解决:
apt-get install python-scipy
pip install scikit-image失败
apt-get install python-matplotlib
install scikit-image==0.13.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

virtual memory exhausted: Cannot allocate memory
手动编译dlib时报出的问题, 我的云主机为1c1g, 至少内存要2G

一些必要的依赖可以如此安装
sudo apt-get install python-nose

sudo apt-get install python-scipy

sudo apt-get install python-numpy

sudo apt-get install python-matplotlib

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章