sing Caffe and python to reproduce the results of MTCNN on FDDB dataset.
References
- The implementation ofMTCNNusing python & caffe,thank the authorDuinoDu/mtcnn.
- (alternatively) We can convert the ellipse annotations into the rectangle annotations for better visualization. Thank the author@L_404_3@.
Better visualization
We can use theconvertEllipseToRectangle.pyto convert the FDDB-folds/FDDB-fold-01-ellipseList.txt into FDDB-folds/FDDB-fold-01-rectList.txt and show the converted bounding Boxes on the images.
Run MTCNN on general image
We can use thedemo.pyto run mtcnn framwork on general images. This file comes fromDuinoDu/mtcnn/demo.py.
Run MTCNN on FDDB dataset
We can use therunFDDB.pyto run mtcnn framwork onFDDB dataset.
The official evaluation of your results
Download the officialevaluation codeand use the commond 'make' in the evaluation folder. To evaluate the results/preditions of your framework,just use the following codes.
./evaluate -a ../data/FDDB-folds/ellipseList.txt -d ../data/FDDB-folds/predict.txt -l ../data/FDDB-folds/foldList.txt -f 0
Then tempContROC.txt and tempDiscROC.txt will be generated in the /data/FDDB-folds/.
@H_403_39@注明添加:然后就要进行到本文的重点了:运行评估程序,生成ROC曲线
在FDDB官网上下载评估程序:http://vis-www.cs.umass.edu/fddb/evaluation.tgz
尽管FDDB官网上FAQ做了说明,虽然我用mingw成功编译了evaluation,但是后续用perl生成ROC曲线脚本仍然有非windows的命令,所以这里我放弃了mingw的方法。
转而使用了我最熟悉的vs。
建立VS工程FDDBEvaluation,将evaluation中的源码添加到工程,配置OPENCV等,修改main函数里以下内容:
string baseDir = "F:/Data/FDDB/";
string listFile = "D:/fold_all.txt";
string detFile = "D:/output.txt";
string annotFile = "D:/Elsp_all.txt";
还要注意 detFormat = DET_RECTANGLE; 如果你的检测输出是椭圆,这里就要改成椭圆。
编译通过,运行。
DiscRoc.txt和ContRoc.txt,这就是最终要画图ROC的数据。
4. 生成ROC图数据
安装perl,我装的是strawberry-perl-5.22.0.1-64bit,网上搜索下载就行。
然后,修改官网提供的runEvaluate.pl,否则有些命令执行不了。。。
我修改后是这样的:
#!/usr/bin/perl -w
use strict;
#### VARIABLES TO EDIT ####
# where gnuplot is
my $GNUPLOT = "D:/Program Files (x86)/gnuplot/bin/gnuplot";
# where the binary is
my $evaluateBin = "evaluate";
# where the images are
my $imDir = "F:/Data/FDDB";
# where the folds are
my $fddbDir = "F:/Data/FDDB/FDDB-folds";
# where the detections are
my $detDir = "D:/";
###########################
my $detFormat = 0; # 0: rectangle,1: ellipse 2: pixels
sub makeGNUplotFile
{
my $rocFile = shift;
my $gnuplotFile = shift;
my $title = shift;
my $pngFile = shift;
open(GF,">$gnuplotFile") or die "Can not open $gnuplotFile for writing\n";
#print GF "$GNUPLOT\n";
print GF "set term png\n";
print GF "set size .75,1\n";
print GF "set output \"$pngFile\"\n";
#print GF "set xtics 100\n";
#print GF "set logscale x\n";
print GF "set ytics .1\n";
print GF "set grid\n";
#print GF "set size ratio -1\n";
print GF "set ylabel \"True positive rate\"\n";
print GF "set xlabel \"False positives\"\n";
#print GF "set xr [0:500]\n";
print GF "set yr [0:1]\n";
print GF "set key right bottom\n";
print GF "plot \"$rocFile\" using 2:1 title \"$title\" with lines lw 2 \n";
close(GF);
}
my $gpFile = "D:/ContROC.p";
my $gpFile1 = "D:/DiscROC.p";
my $title = "zhouzhou";
# plot the two ROC curves using GNUplot
makeGNUplotFile("D:/ContROC.txt",$gpFile,$title,$detDir."ContROC.png");
makeGNUplotFile("D:/DiscROC.txt",$gpFile1,$detDir."DiscROC.png");
然后,cmd->perlrunEvaluate.pl
酱紫地:
5. 画ROC曲线
安装GUNPLOT
Draw the ROC curves
gnuplot contROC.p gnuplot discROC.p
We will get the tempContROC-MTCNN.png(tempDiscROC-MTCNN.png) and the ROC curves like this: