-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathbaseline_evaluation_FACT_776.m
91 lines (84 loc) · 2.62 KB
/
baseline_evaluation_FACT_776.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
clc;clear all;close all;
%***********************************************%
% This code runs on the VeRi-776 dataset.
% This code uses post fuse the results of CNN + CN + SIFT.
% We use the mAP and hit-1/5 rate as evaluation
%***********************************************%
%% load query hist and test hist
CNN_featureLen = 431;
CN_featureLen = 5600;
SIFT_featureLen = 10000;
nQuery = 1678;
nTest = 11579;
dist_SIFT = zeros(nTest, nQuery, 'double');
dist_CN = zeros(nTest, nQuery, 'double');
dist_CNN = zeros(nTest, nQuery, 'double');
fidin = fopen('dist_SIFT_776.txt');
for i = 1:nTest
dist_line = fgetl(fidin);
dist_line = str2num(dist_line);
dist_SIFT(i, 1:length(dist_line)) = dist_line;
end
fclose(fidin);
fidin = fopen('dist_CN_776.txt');
for i = 1:nTest
dist_line = fgetl(fidin);
dist_line = str2num(dist_line);
dist_CN(i, 1:length(dist_line)) = dist_line;
end
fclose(fidin);
fidin = fopen('dist_CNN_776.txt');
for i = 1:nTest
dist_line = fgetl(fidin);
dist_line = str2num(dist_line);
dist_CNN(i, 1:length(dist_line)) = dist_line;
end
fclose(fidin);
dist = dist_CNN*0.7 + dist_CN*0.2 + dist_SIFT*0.1;
%% load ground truth index
maxgt = 256;
gt_index = zeros(nQuery, maxgt);
fidin = fopen('gt_index_776.txt');
for i = 1:nQuery
gt_index_line = fgetl(fidin);
gt_line = str2num(gt_index_line);
for j = 1:size(gt_line, 2)
gt_index(i, j) = gt_line(j);
end
end
maxjk = 256;
jk_index = zeros(nQuery, maxjk);
fidin = fopen('jk_index_776.txt');
for i = 1:nQuery
jk_index_line = fgetl(fidin);
jk_line = str2num(jk_index_line);
for j = 1:size(jk_line, 2)
jk_index(i, j) = jk_line(j);
end
end
%% search the database and calcuate re-id accuracy
ap = zeros(nQuery, 1); % average precision
CMC = zeros(nQuery, nTest);
r1 = 0; % rank 1 precision with single query
for k = 1:nQuery
k
% load groud truth for each query (good and junk)
good_index = reshape(gt_index(k,:), 1, []);
good_index = good_index(good_index ~= 0);
junk_index = reshape(jk_index(k,:), 1, []);
junk_index = junk_index(junk_index ~= 0);
tic
%score = dist(:, k);
%score = dist_null(:, k);
score = dist_LOMO(:, k);
[~, index] = sort(score, 'ascend'); % single query
[ap(k), CMC(k, :)] = compute_AP(good_index, junk_index, index);% compute AP for single query
end
CMC = mean(CMC);
%% print result
fprintf('single query: mAP = %f, r1 precision = %f, r5 precision = %f\r\n', mean(ap), CMC(1), CMC(5));
%% plot CMC curves
figure;
s = 50;
CMC_curve = CMC;
plot(1:s, CMC_curve(:, 1:s));