在Linux 中build 开源人脸识别引擎 openface

来源:互联网 发布:郑州知名软件企业排名 编辑:程序博客网 时间:2024/05/22 04:52

参考 Openface 官方安装文档
需要安装的内容有以下几项
1. CUDA 编译器 NVCC
2. Torch7
3. OpenCV 参见另一文章《在Linux 中 build 开源人脸识别引擎SeetaFace》
4. dlib 采用最新版本 19.2 下载链接,另外dlib依赖Boost C++库所以需要安装Boost
5. cuDNN(NVIDIA公司提供的)该部分看个人需求,在dlib中有用到。

一. 安装NVCC

安装Nvidia显卡的驱动程序

安装的方法有两种:
1. 去官网下载最新的依据显卡信息获取的官方驱动
2. 直接使用源下载
本人使用第二种(注意安装符合自己显卡的版本)

$ sudo aptitude install nvidia-367$ sudo reboot # 重启系统,使驱动生效#重启成功之后查看驱动安装情况,注意打印信息中的configuration 行!$ lshw -c display    WARNING: you should run this program as super-user.      *-display           description: VGA compatible controller           product: GK106 [GeForce GTX 650 Ti]           vendor: NVIDIA Corporation           physical id: 0           bus info: pci@0000:01:00.0           version: a1           width: 64 bits           clock: 33MHz           capabilities: vga_controller bus_master cap_list rom           configuration: driver=nvidia latency=0           resources: irq:50 memory:fd000000-fdffffff 

安装cuda

1.直接从官网下载cuda安装(选择合适的版本)
2.第二种使用源进行下载安装

$ sudo aptitude install nvidia-cuda-toolkit#安装完成后,使用nvcc命令来检查是否安装成功

二. Install Torch7

1.安装基础Torch

git clone https://github.com/torch/distro.git ~/torch --recursivecd ~/torch; bash install-deps;./install.sh

第一个脚本安装了LuaJit和Torch的基本依赖。
第二个脚本则安装了LuaJit和LuaRocks,然后领LuaRocks这个包管理工具去安装torch的核心包如torch,nn和paths等其他包。

该脚本将torch添加到你的PATH路径中,需要执行source命令使得env环境变量及时更新。相关执行代码如下

# On Linux with bashsource ~/.bashrc# On Linux with zshsource ~/.zshrc# On OSX or in Linux with none of the above.source ~/.profile
  1. 利用LuaRocks 安装Openface需要的其它库
    需要的库如下:
    dpnn
    nn
    optim
    csvigo
    cutorch and cunn (only with CUDA)
    fblualib (only for training a DNN)
    tds (only for training a DNN)
    torchx (only for training a DNN)
    optnet (optional, only for training a DNN)

安装的shell语言脚本如下:

for NAME in dpnn nn optim optnet csvigo cutorch cunn fblualib torchx tds; do luarocks install $NAME; done

可能出现的问题

  1. 运行bash install-deps 时出现**cannot find -lgfortran,这是安装OpenBLAS中需要的库

解决方法:

$ sudo apt-get install gfortran$ sudo ln -s /usr/lib/x86-64-liunx-gnu/libgfortran.so.3 /usr/lib/libgfortran.so

2 . 有些库下载不下来,直接gitclone 相关库,然后安装。
比如安装nn库

$ git clone https://github.com/torch/nn$ luarocks install dpnn-master/rocks/nn-scm-1.rockspec

3 . fblualib 没有办法用LuaRocks安装,这个问题至今没有解决,但是如果不用训练模型的话问题不大。如果广大网友有解决方法,可以欢迎评论共享。

三. 安装Boost

  1. 在官网 www.boost.org 下载最新的boost库,并解压
  2. 在目录中执行下面语句:
$./bootstrap.sh --with-libraries=python$./b2$ sudo ./b2 install
  1. 测试Boost
#include <iostream>#include <boost/bind.hpp>using namespace std;using namespace boost;int fun(int x,int y){return x+y;}int main(){    int m=1,n=2;    cout << boost::bind(fun,_1,_2)(m,n)<<endl;    return 0;   }

编译运行:

$ g++ test.cpp -o test $ ./test

四. Install Dlib

(1)从https://sourceforge.net/projects/dclib/files/dlib/中下载你需要的版本
(2)执行下面语句:

$ tar xf dlib-19.2.zip$ cd dlib-19.2/python_examples$ mkdir build$ cd build$ cmake ../../tools/python$ cmake --build . --config Release$ sudo cp dlib.so /usr/local/lib/python2.7/dist-packages

测试Opencv 和dlib是否安装成功
在python2环境下输入import dlib;import cv2,查看是否成功导入

五. Install Openface

1 clone Openface源代码

git clone --recursive https://github.com/cmusatyalab/openface.git

2 在Openface文件夹下,进行安装

sudo python2 setup.py install

3 安装完成之后,运行model/get-models.sh来相关模型库

0 0
原创粉丝点击