Skip to content

Commit

Permalink
detector/: acfTrain: nicer logging, acfTest: option to modify detecto…
Browse files Browse the repository at this point in the history
…r prior to applying to test set, acfDemo*: updated demos and model files (retrained on Linux)
  • Loading branch information
pdollar committed Oct 30, 2014
1 parent ee438dc commit 8c81f93
Show file tree
Hide file tree
Showing 14 changed files with 9,978 additions and 46,333 deletions.
10 changes: 6 additions & 4 deletions detector/acfDemoCal.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
% Note: pre-trained model files are provided (delete to re-train).
% Re-training may give slightly variable results on different machines.
%
% Piotr's Computer Vision Matlab Toolbox Version 3.23
% Piotr's Computer Vision Matlab Toolbox Version NEW
% Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
% Licensed under the Simplified BSD License [see external/bsd.txt]

%% extract training and testing images and ground truth
dataDir = 'D:\code\research\detectorAcf\data\Caltech\';
cd(fileparts(which('acfDemoCal.m'))); dataDir='../../data/Caltech/';
for s=1:2
if(s==1), type='train'; else type='test'; end
if(exist([dataDir type '/annotations'],'dir')), continue; end
Expand All @@ -37,7 +37,8 @@
detector = acfTrain( opts );

%% modify detector (see acfModify)
detector = acfModify(detector,'cascThr',-1,'cascCal',-.005);
pModify=struct('cascThr',-1,'cascCal',-.005);
detector=acfModify(detector,pModify);

%% run detector on a sample image (see acfDetect)
imgNms=bbGt('getFiles',{[dataDir 'test/images']});
Expand All @@ -47,7 +48,8 @@
%% test detector and plot roc (see acfTest)
[~,~,gt,dt]=acfTest('name',opts.name,'imgDir',[dataDir 'test/images'],...
'gtDir',[dataDir 'test/annotations'],'pLoad',[pLoad, 'hRng',[50 inf],...
'vRng',[.65 1],'xRng',[5 635],'yRng',[5 475]],'show',2);
'vRng',[.65 1],'xRng',[5 635],'yRng',[5 475]],...
'pModify',pModify,'reapply',0,'show',2);

%% optionally show top false positives ('type' can be 'fp','fn','tp','dt')
if( 0 ), bbGt('cropRes',gt,dt,imgNms,'type','fn','n',50,...
Expand Down
10 changes: 6 additions & 4 deletions detector/acfDemoInria.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
% Note: pre-trained model files are provided (delete to re-train).
% Re-training may give slightly variable results on different machines.
%
% Piotr's Computer Vision Matlab Toolbox Version 3.22
% Piotr's Computer Vision Matlab Toolbox Version NEW
% Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
% Licensed under the Simplified BSD License [see external/bsd.txt]

%% extract training and testing images and ground truth
dataDir = 'D:\code\research\detectorAcf\data\Inria\';
cd(fileparts(which('acfDemoInria.m'))); dataDir='../../data/Inria/';
for s=1:2
if(s==1), set='00'; type='train'; else set='01'; type='test'; end
if(exist([dataDir type '/posGt'],'dir')), continue; end
Expand All @@ -38,7 +38,8 @@
detector = acfTrain( opts );

%% modify detector (see acfModify)
detector = acfModify(detector,'cascThr',-1,'cascCal',0);
pModify=struct('cascThr',-1,'cascCal',0);
detector=acfModify(detector,pModify);

%% run detector on a sample image (see acfDetect)
imgNms=bbGt('getFiles',{[dataDir 'test/pos']});
Expand All @@ -47,7 +48,8 @@

%% test detector and plot roc (see acfTest)
[miss,~,gt,dt]=acfTest('name',opts.name,'imgDir',[dataDir 'test/pos'],...
'gtDir',[dataDir 'test/posGt'],'pLoad',opts.pLoad,'show',2);
'gtDir',[dataDir 'test/posGt'],'pLoad',opts.pLoad,...
'pModify',pModify,'reapply',0,'show',2);

%% optional timing test for detector (should be ~30 fps)
if( 0 )
Expand Down
10 changes: 6 additions & 4 deletions detector/acfTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
% .imgDir - ['REQ'] dir containing test images
% .gtDir - ['REQ'] dir containing test ground truth
% .pLoad - [] params for bbGt>bbLoad for test data (see bbGt>bbLoad)
% .pModify - [] params for acfModify for modifying detector
% .thr - [.5] threshold on overlap area for comparing two bbs
% .mul - [0] if true allow multiple matches to each gt
% .reapply - [0] if true re-apply detector even if bbs already computed
Expand All @@ -25,17 +26,17 @@
%
% EXAMPLE
%
% See also acfTrain, acfDetect, acfDemoInria, bbGt
% See also acfTrain, acfDetect, acfModify, acfDemoInria, bbGt
%
% Piotr's Computer Vision Matlab Toolbox Version 3.22
% Piotr's Computer Vision Matlab Toolbox Version NEW
% Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
% Licensed under the Simplified BSD License [see external/bsd.txt]

% get parameters
dfs={ 'name','REQ', 'imgDir','REQ', 'gtDir','REQ', 'pLoad',[], ...
'thr',.5,'mul',0, 'reapply',0, 'ref',10.^(-2:.25:0), ...
'pModify',[], 'thr',.5,'mul',0, 'reapply',0, 'ref',10.^(-2:.25:0), ...
'lims',[3.1e-3 1e1 .05 1], 'show',0 };
[name,imgDir,gtDir,pLoad,thr,mul,reapply,ref,lims,show] = ...
[name,imgDir,gtDir,pLoad,pModify,thr,mul,reapply,ref,lims,show] = ...
getPrmDflt(varargin,dfs,1);

% run detector on directory of images
Expand All @@ -44,6 +45,7 @@
if(reapply || ~exist(bbsNm,'file'))
detector = load([name 'Detector.mat']);
detector = detector.detector;
if(~isempty(pModify)), detector=acfModify(detector,pModify); end
imgNms = bbGt('getFiles',{imgDir});
acfDetect( imgNms, detector, bbsNm );
end
Expand Down
10 changes: 6 additions & 4 deletions detector/acfTrain.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
% See also acfDetect, acfDemoInria, acfModify, acfTest, chnsCompute,
% chnsPyramid, adaBoostTrain, bbGt, bbNms, jitterImage
%
% Piotr's Computer Vision Matlab Toolbox Version 3.25
% Piotr's Computer Vision Matlab Toolbox Version NEW
% Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
% Licensed under the Simplified BSD License [see external/bsd.txt]

Expand Down Expand Up @@ -202,7 +202,7 @@
opts.pNms=getPrmDflt(opts.pNms,dfs,-1);
dfs={ 'pTree',{}, 'nWeak',0, 'discrete',1, 'verbose',16 };
opts.pBoost=getPrmDflt(opts.pBoost,dfs,1);
dfs={'nBins',256,'maxDepth',2,'minWeight',.01,'fracFtrs',1,'nThreads',1e5};
dfs={'nBins',256,'maxDepth',2,'minWeight',.01,'fracFtrs',1,'nThreads',16};
opts.pBoost.pTree=getPrmDflt(opts.pBoost.pTree,dfs,1);
opts.pLoad=getPrmDflt(opts.pLoad,{'squarify',{0,1}},-1);
opts.pLoad.squarify{2}=opts.modelDs(2)/opts.modelDs(1);
Expand All @@ -225,7 +225,7 @@
if(hasGt), fs={opts.posImgDir,opts.posGtDir}; end
fs=bbGt('getFiles',fs); nImg=size(fs,2); assert(nImg>0);
if(~isinf(n)), fs=fs(:,randperm(nImg)); end; Is=cell(nImg*1000,1);
tid=ticStatus('Sampling windows',1,30); k=0; i=0; batch=64;
diary('off'); tid=ticStatus('Sampling windows',1,30); k=0; i=0; batch=64;
while( i<nImg && k<n )
batch=min(batch,nImg-i); Is1=cell(1,batch);
parfor j=1:batch, ij=i+j;
Expand All @@ -237,7 +237,8 @@
if(k>n), Is=Is(randSample(k,n)); k=n; end
i=i+batch; tocStatus(tid,max(i/nImg,k/n));
end
Is=Is(1:k); fprintf('Sampled %i windows from %i images.\n',k,i);
Is=Is(1:k); diary('on');
fprintf('Sampled %i windows from %i images.\n',k,i);
end
% optionally jitter positive windows
if(length(Is)<2), Is={}; return; end
Expand All @@ -254,6 +255,7 @@
nm=[opts.name 'Is' int2str(positive) 'Stage' int2str(stage)];
if( opts.winsSave ), save(nm,'Is','-v7.3'); end
fprintf('Done sampling windows (time=%.0fs).\n',etime(clock,start));
diary('off'); diary('on');
end

function Is = sampleWins1( I, gt, detector, stage, positive )
Expand Down
Binary file modified detector/models/AcfCaltechDetector.mat
Binary file not shown.
Loading

0 comments on commit 8c81f93

Please sign in to comment.