OpenFace自建CNN模型

OpenFace自建CNN模型

1.        OpenFace Home:

https://cmusatyalab.github.io/openface/

Setup: (This is not working for myenvironment. View on 2016/8/23)

https://cmusatyalab.github.io/openface/setup/

2.        Environment(环境):

Ubuntu16.04

Nvidia 940M

Cuda8.0

3.        Required Liabrary(必须环境):

Opencv2.4.11与cuda8.0具有一定的冲突性,可以安装opencv2.4.13,本机安装的是opencv3.10.

Opencv2.4.13官方安装(未测试):

http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

[compiler] sudo apt-get installbuild-essential

[required] sudo apt-get install cmake gitlibgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

[optional] sudo apt-get install python-devpython-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-devlibjasper-dev libdc1394-22-dev

cd ~/opencv

mkdir release

cd release

cmake -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..

make

sudo make install

4.        Dlib库以及torch的安装此处略过,查看之前的内容

5.        Openface的安装:

安装比较简单:

sudo python2 setup.py install

sh models/get-models.sh

配置好就可以跑一些简单的demo了(相关web的demo都没跑,感觉有点麻烦,~~):


 

跑demo运行

demo2:

./demos/compare.pyimages/examples/{lennon*,clapton*}

运行demo3:

./demos/classifier.py infermodels/openface/celeb-classifier.nn4.small2.v1.pkl ./images/examples/carell.jpg:

 

注意:官网的很多命令不带有前标,如python2,th等。

6.        训练DNN模型:

数据预处理:

 

for N in {1..8}; do ./util/align-dlib.pydata/casia-facescrub/raw align outerEyesAndNose data/casia-facescrub/dlib-affine-sz:96--size 96 & done

python2 ./util/prune-dataset.pydata/casia-facescrub/dlib-affine-sz:96 --numImagesThreshold 3

Train之前需要做的处理:

train.lua:

修正module和OpenFaceOptim模块:

local models = require 'model'

local openFaceOptim = require 'OpenFaceOptim'

改为

local models = require './model.lua'

local openFaceOptim = require'./OpenFaceOptim.lua'

由官网所知opt.lua为训练的参数,其中需要更改两个参数,减少对GPU的要求(容易out of memory):

 cmd:option('-peoplePerBatch', 15, 'Number of people to sample in eachmini-batch.')

   cmd:option('-imagesPerPerson',20, 'Number of images to sample per person in each mini-batch.')

改为:

 

 cmd:option('-peoplePerBatch', 1, 'Number of people to sample in eachmini-batch.')

  cmd:option('-imagesPerPerson', 2, 'Number of images to sample per personin each mini-batch.')

test.lua:运行时发生错误找不到文件,直接改成绝对目录了:

 

local batchRepresent ="../batch-represent/main.lua"

local lfwEval ="../evaluation/lfw.py"

改为:

local batchRepresent = "~/openface/batch-represent/main.lua"

local lfwEval = "~/openface/evaluation/lfw.py"

找不到/data/lfw/aligned文件:

修改opt.lua:

cmd:option('-lfwDir','../data/lfw/aligned', 'LFW aligned image directory for testing.')

改为:

cmd:option('-lfwDir', '~/openface/data/lfw/aligned','LFW aligned image directory for testing.')

改过之后,开始训练和测试的时候,还是溢出了,再改:
   cmd:option('-testBatchSize', 800,'Batch size for testing.')

改成

  cmd:option('-testBatchSize', 80, 'Batch size for testing.')

「必须!」为了要testing,改变在opts.lua中的lfwDir

cmd:option('-lfwDir','/media/tsunyi/0EF057F8F057E50D/codeDemo/openface-master/data/lfw/dlib-affine-sz:96','LFW aligned image directory for testing.'

更改openface/batch-represent下面的batch-represent和opts以减少GPU

更改/openface/evaluation下的lfw.py,相关文件路径

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值