-
Notifications
You must be signed in to change notification settings - Fork 0
/
NonsmoothPairwiseTest.m
53 lines (41 loc) · 2.28 KB
/
NonsmoothPairwiseTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function [] = NonsmoothPairwiseTest(SPdata,SPparam,LORparam)
pfig = ProgressBar('Parsing Images (Nonsmooth Pairwise Test)');
range = 1:length(SPdata.testFileList);
for i = range
fprintf('Test image number : %d ',i);
[folder,onlyName] = fileparts(SPdata.testFileList{i});
baseFileName = fullfile(folder,onlyName);
fprintf('filename : %s\n',baseFileName);
%% Get data term
[~,imSP,~] = GetSuperParsingDataCost(baseFileName,i,SPdata,SPparam);
%% Get nonsmooth pairwise term
objRelOutFileName = fullfile(SPparam.HOMEDATA,'SecondOrderObjRel',...
[baseFileName '_retSetSize_' num2str(LORparam.retSetSize) '_kNN_' num2str(LORparam.kNN)...
'_w_Q_' num2str(LORparam.w_Q) '_w_U_' num2str(LORparam.w_U)...
'_K_' num2str(SPparam.K) '_lambda_' num2str(LORparam.lambda) '_secondOrderObjRel_app.mat']);
if ~exist(objRelOutFileName,'file')
fprintf('%s does not exist..! exiting..\n',objRelOutFileName);
error('Error in OptimizationWithQPBO.m');
else
load(objRelOutFileName,'secondOrderObjRel');
end;
numLabels = length(SPdata.Labels{1,1}); % note: Labels{1,1} = Labels{labelType,Kndx}
[normSecondOrderObjRel, maxNormSecondOrderObjRel, minNormSecondOrderObjRel] =...
LogNormObjRel(secondOrderObjRel,numLabels);
testSuffix = '';
testName = ['_PwSOR' '_retSetSize_' num2str(LORparam.retSetSize)...
'_kNN_' num2str(LORparam.kNN) '_l_' num2str(LORparam.lambda)...
'_a_' num2str(LORparam.alpha) '_nIter_' num2str(LORparam.numQPBOIter)...
'_nStart_' num2str(LORparam.numMultiStart) '_' testSuffix];
for j = 1:LORparam.numMultiStart
[Lsp,EnergyVal] = mexLOROptUndirectedQPBO(normSecondOrderObjRel,[],...
[maxNormSecondOrderObjRel minNormSecondOrderObjRel LORparam.alpha LORparam.numQPBOIter 0]);
L = ProjectLabelToImage(imSP,Lsp);
[EnergyValStored] = GenOutFileComparingEnergy(baseFileName,L,Lsp,EnergyVal,LORparam.HOMETESTDATA,...
LORparam.outFileSuffix,testName,SPdata.Labels{1,1}); % note: Labels{1,1} = Labels{labelType,Kndx}
fprintf('Iter %d\t: Previous: %f\tAchieved.. %f\n',j,EnergyVal,EnergyValStored);
end;
ProgressBar(pfig,find(i==range),length(range));
end;
close(pfig);
return;