-
Notifications
You must be signed in to change notification settings - Fork 27
/
win_siz_selection.m
69 lines (56 loc) · 1.86 KB
/
win_siz_selection.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
function win_siz_selection()
nselect = 50;
load(['siz_hist_all_ov_' 'VOC07' '.mat'], 'siz_win_all', 'siz_hist_all')
hist00 = siz_hist_all;
hist0 = hist00;
hist0 = hist0>0;
AR_op = 1;
%%%AR objective: greedly select windows that at the same time cover AND fit to the ground-truth as much as possible
if AR_op==1
%wght=repmat([1 1 1 1 1], size(hist0,1),1); %[.06 0.12 0.25 0.5 1]
x = mean(hist0,3);
prob = mean(x,1);
[~,bb] = sort(prob,'descend');
best =[];
best(1) = bb(1);
for i=2:nselect %TODO %size(hist0,2)
interBest = sum(hist0(:,best,:),2);
interBest = interBest>0;
interBest = permute(interBest,[1 3 2]);
x = mean(mean(interBest,1));
%x = interBest.*wght; x=mean(sum(x,2));
r70 = mean(interBest(:,3));
fprintf('Recall@.7=%3.2f AR=%3.2f nbox=%d\n', r70, x, length(best));
count=1;
for j=1:size(hist0,2)
if ismember(bb(j),best(:))
continue;
end
interBest = sum(hist0(:,[best bb(j)],:),2);
interBest = interBest>0;
interBest = permute(interBest,[1 3 2]);
x = mean(mean(interBest,1));
%x = interBest.*wght; x=mean(sum(x,2));
if count==1
best_xorr = x;
best_idx = j;
count = 2;
elseif x > best_xorr
best_xorr = x;
best_idx = j;
end
end
best(i) = bb(best_idx);
end
%recall for IoU of [0.5 0.6 0.7 0.8 0.9]
for ss=1:5
win_ix=best(1:nselect);
a=hist0(:,win_ix,ss)>0;
all_obj=sum(a,2)>0;
xx(ss)=sum(all_obj)./length(all_obj);
end
best_win = siz_win_all(best)';
siz_win = best_win;
fname = ['./best_siz_win_AR_' 'VOC07' '.mat'];
save(fname,'siz_win');
end