-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathcascade_thresh.m
36 lines (28 loc) · 939 Bytes
/
cascade_thresh.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
function [prec, recall, thresh] = cascade_thresh(model, year, p)
% [prec, recall, thresh] = cascade_thresh(model, year, p)
%
% if p is empty, select the min threshold such that precision >= recall.
% otherwise, select the min threshold such that precision >= p
setVOCyear = year;
globals;
if nargin < 3
p = [];
end
% Find the index that satisfies the requested precision constraint.
% load: prec, recall
load([cachedir model.class '_pr_test_' year]);
if isempty(p)
I = find((prec >= recall) == 1, 1, 'last');
else
I = find(prec >= p, 1, 'last');
end
prec = prec(I);
recall = recall(I);
% Find the corresponding threshold.
% load detection boxes and extract sorted confidence scores
load([cachedir model.class '_boxes_test_' year]);
sc = cat(1, boxes1{:});
sc = sort(sc(:,end), 'descend');
thresh = sc(I);
fprintf('Selected cascade thresholds for\n prec = %f\n recall = %f\n thresh = %f\n', ...
prec, recall, thresh);