人臉識別框架 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

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