-
Notifications
You must be signed in to change notification settings - Fork 26
/
getAccuracyNYU.m
77 lines (55 loc) · 1.69 KB
/
getAccuracyNYU.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
76
function getAccuracyNYU
voidClass=0
numClasses = 13;
globalacc = 0;
totalpoints = 0;
voidpoints = 0;
num_imgs = 653;
cf = zeros(numClasses);
for i = 0 : num_imgs
i
NYU_TEST_ANNOTATION = sprintf('/scratch/NYU_TEST/labels/Ordered/new_nyu_test_class13_%04d.png',i);
Ia = imread(NYU_TEST_ANNOTATION);
Ia = imresize(Ia,[224 224],'nearest');
%Ia = Ia .* sum(segImg,3);%to ignore all zero annotations.
Ivoid = Ia == voidClass;% NYU
voidpoints = voidpoints + sum(sum(Ivoid));
Ia = Ia .* uint8(not(Ivoid));%ignore computing accuracy at void indices
totalpoints = totalpoints + sum(Ia(:)>0);
%Use your predictions here
NYU_TEST_PREDICTION = sprintf('/scratch/DeconvNetFloat/evaluation/new_nyu_class13_eigen_acc/new_nyu_class13_eigen_%04d.png',i);
Ip = imread(NYU_TEST_PREDICTION);
if ( size(Ip,3) > 1 )
Ip = rgb2gray(Ip);
end
%Ip = Ip .* sum(annot,3);%to ignore all zero annotations.
Ip(Ivoid) = voidClass;
% CamVid type accuracy
for j = 1:numClasses
for k = 1:numClasses
if k ~= voidClass
c1 = Ia == j;
c1p = Ip == k;
index = c1 .* c1p;
cf(j,k) = cf(j,k) + sum(index(:));
end
end
if j ~= voidClass
c1 = Ia == j;
c1p = Ip == j;
index = c1 .* c1p;
globalacc = globalacc + sum(index(:));
end
end
end
% confusion matrix
conf = zeros(numClasses);
for i = 1:numClasses
if i ~= voidClass && sum(cf(i,:)) > 0
conf(i,:) = cf(i,:)/sum(cf(i,:));
end
end
conf
diag(conf)
globalacc = globalacc/totalpoints
classavg = sum(diag(conf))/(numClasses)