DPM(Deformable Parts Model)可变部件模型
DPM(Deformable Parts Model):DPM是一个非常成功的目标检测算法,连续获得VOC(Visual Object Class)07,08,09年的检测冠军。目前已成为众多分类器、分割、人体姿态和行为分类的重要部分。DPM源码版本:voc-release4.01
VOC开发包版本:VOC2007_devkit_08-Jun
Matlab版本:MatlabR2014a
c++编译器:VS2013
系统:Win7 32位
learn.exe迭代次数:5万次
数据集:INRIA 人体数据集
使用时应注意:
【1】当重新修改了数据集后,例如改为train_ysw.txt和trainval_ysw.txt,此时应该清空临时文件夹dmp_tmp的.mat、.log等文件
【2】在pascal_train.m中,索引超过矩阵维度,修改:globals;
= pascal_data(cls, true, VOCyear);
% split data by aspect ratio into n groups
spos = split(cls, pos, n);
cachesize = 24000;
maxneg = 20; % 不能超过neg的长度【3】提示:错误使用 movefile 另一个程序正在使用此文件,进程无法访问。在MATLAB2011b和VS2012、WIN64bit环境下,是没有这个错误提示的。目前我遇到的MATLAB2014a、VS2013、WIN32bit和MATLAB2016b、VS2012、WIN64bit,均会出现这个错误提示。
产生原因:在global.m文件中,我修改的是相对路径:% directory for LARGE temporary files created during training
tmpdir = ['./dpm_tmp/dat/' VOCyear '/'];在使用movefile(datfile, oldfile)时,输出相应的datfile和oldfile:datfile =./dpm_tmp/dat/2007/person.dat
oldfile =./dpm_tmp/dat/2007/person.dat_tmp为什么会报错呢?查看matlab帮助文档,doc movefile,我们可以知道,movefile('source','destination') moves the file or folder named source to the location destination, where source and destination are the absolute or relative paths for the folder or file.
因此,在此处需要用绝对路径。
解决方法:在global.m文件中,修改为绝对路径:
% directory for LARGE temporary files created during training
tmpdir = ['C:/Users/ysw/Desktop/VOC/dpm-master/dpm-master/dpm_tmp/dat/' VOCyear '/'];关闭MATLAB后,再打开运行即可。
刚开始时,我还以为是并行计算造成的,把train.m文件中所有的parfor全部改为for,没想到是global.m的路径设置问题。
如果中途还有这个问题存在,就需要你把你的临时文件夹(C:/Users/ysw/Desktop/VOC/dpm-master/dpm-master/dpm_tmp/)的生成内容全部清理掉,将train.m文件中所有的parfor全部改为for,关闭MATLAB,删除,再启动MATLAB。
【4】在运行pascal('person', 1);代码时,记得还要把测试的.txt拷贝到相对应的文件夹C:\Users\ysw\Desktop\VOC\VOCtest_06-Nov-2007\VOCdevkit\VOC2007\ImageSets\Main --->C:\Users\ysw\Desktop\VOC\dpm-master\dpm-master\VOCdevkit\VOC2007\ImageSets\Main
DPM代码解释:
我调试的DPM代码分享:http://pan.baidu.com/s/1nuBCOYX
DPM代码调试视频分享:**** Hidden Message *****
DPM数据集、程序包分享:http://pan.baidu.com/s/1qYmK1C4
代码分析:
1、pascal('person', 1);进行人模型训练测试;
2、model = pascal_train(cls, n, note);模型的训练
1) = pascal_data(cls, true, VOCyear);提取正负样本,一张图像上存在多个正样本和多个负样本,crop_part
2)spos = split(cls, pos, n);根据长宽比进行正负样本分类;
3)模型的训练:models{i} = train(cls, models{i}, spos{i}(inds), neg, i, 1, 1, 1, cachesize, true, 0.7, false, ['lrsplit1_' num2str(i)]);模型的训练过程中,
hdrfile = ;
datfile = ; % 样本的分类过程中间数据,内容最为丰富
modfile = ;
inffile = ;
lobfile = ;
cmpfile = ;
objfile = ;
通过这些文件的缓存,进行learn.exe学习,得到model。得到model后,我们就可以像SVM工具箱一样,直接对model结果进行调用即可,可重点关注模型的测试。
3、boxes1 = pascal_test(cls, model, 'test_ysw', testyear, testyear);模型的测试(重点关注)
1) = imgdetect(im, model, model.thresh);图像上目标part检测;
2)
参考:
【1】http://blog.csdn.net/masibuaa/article/details/25221103
【2】http://blog.csdn.net/carson2005/article/details/22499565
【3】http://blog.csdn.net/qq_14845119/article/details/52625426
【4】http://blog.csdn.net/ttransposition/article/details/12966521
【5】PASCAL VOC数据集:http://host.robots.ox.ac.uk/pascal/VOC/index.html
【6】镜像文件:Pascal VOC Dataset Mirror
【7】源码下载:http://www.rossgirshick.info/latent/
【8】SVM-light:http://sourceforge.net/projects/mex-svm/
【9】VOC数据集及dpm代码分享
学习了,谢谢分享
页:
[1]