-
Notifications
You must be signed in to change notification settings - Fork 0
/
EvalErrorGMIM_train.m
executable file
·75 lines (56 loc) · 1.81 KB
/
EvalErrorGMIM_train.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
clear;
ImageDir = 'd:\MATLAB\im_parser\LabelMeDataSet\Images\';
DescriptorsDir = 'd:\MATLAB\im_parser\LabelMeDataSet\Data\Descriptors\SP_Desc_k200\';
GtDir = 'd:\MATLAB\im_parser\LabelMe\SemanticLabels\';
TestSetDir = 'd:\MATLAB\im_parser\LabelMe\TestSet\';
load IndexTest
load LabelsTest
file_list = dir(ImageDir);
ResultsDir = 'ERHF';
%feature_names = cell(1);
features_name = 'super_pixels';
load (['ResultsTest_' ResultsDir '.mat']);
%load ('BaselineLabels.mat');
%%
PredLabels = zeros(size(idx_tst));
PredLabels(idx_tst) = labels_tst'+1;
PredLabels(~idx_tst) = labels_train+1;
%%
tot_pp = 0;
tot_p = 0;
cm = zeros(33,33);
for image_i = train_idx;%test_idx
%image_i
curr_name = Index{image_i}.name;
load( [GtDir curr_name '.mat']);
Image = imread([ImageDir curr_name '.jpg']);
features = load( [ DescriptorsDir features_name '\' curr_name '.mat']);
SP = features.superPixels;
GT = double(S);
Prediction = GT;
cur_offset = Index{image_i}.offset;
limit = length(Labels);
if(image_i + 1 <= length(Index))
limit = Index{image_i+1}.offset;
end
for node = Index{image_i}.offset+1 : limit
idx = SP == node - cur_offset;
GT(idx) = Labels(node);
Prediction(idx) = PredLabels(node);
end
GT = double(S(:));
Prediction = Prediction(:);
for i = find(GT ~= 0)'
cm(Prediction(i), GT(i)) = cm(Prediction(i), GT(i)) + 1;
end
tot_pp = tot_pp + sum(Prediction(GT ~= 0) ~= GT(GT ~= 0));
tot_p = tot_p + sum(GT ~= 0);
end
for i = 1 : size(cm,1)
if( sum(cm(:,i)) > 0)
cm(:,i) = cm(:,i) / sum(cm(:,i));
end
end
mean(diag(cm))
1 - tot_pp / tot_p
save(['CM_' ResultsDir, '_train.mat'], 'cm', 'tot_p', 'tot_pp');