-
Notifications
You must be signed in to change notification settings - Fork 28
/
pascal.m
86 lines (70 loc) · 2.62 KB
/
pascal.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
function pascal(cls, n, note, dotrainval, testyear)
% Train and evaluate a model.
% pascal(cls, n, note, dotrainval, testyear)
%
% The model will be a mixture of n star models, each of which
% has 2 latent orientations.
%
% Arguments
% cls Object class to train and evaluate
% n Number of aspect ratio clusters to use
% (The final model has 2*n components)
% note Save a note in the model.note field that describes this model
% dotrainval Also evaluate on the trainval dataset
% This is used to collect training data for context rescoring
% testyear Test set year (e.g., '2007', '2011')
% AUTORIGHTS
% -------------------------------------------------------
% Copyright (C) 2011-2012 Ross Girshick
% Copyright (C) 2008, 2009, 2010 Pedro Felzenszwalb, Ross Girshick
%
% This file is part of the voc-releaseX code
% (http://people.cs.uchicago.edu/~rbg/latent/)
% and is available under the terms of an MIT-like license
% provided in COPYING. Please retain this notice and
% COPYING if you use this file (or a portion of it) in
% your project.
% -------------------------------------------------------
startup;
%global VOC_CONFIG_OVERRIDE;
%VOC_CONFIG_OVERRIDE = @voc_config_new_exp;
conf = voc_config();
cachedir = conf.paths.model_dir;
testset = conf.eval.test_set;
% TODO: should save entire code used for this run
% Take the code, zip it into an archive named by date
% print the name of the code archive to the log file
% add the code name to the training note
timestamp = datestr(datevec(now()), 'dd.mmm.yyyy:HH.MM.SS');
% Set the note to the training time if none is given
if nargin < 3
note = timestamp;
end
% Don't evaluate trainval by default
if nargin < 4
dotrainval = false;
end
if nargin < 5
% which year to test on -- a string, e.g., '2007'.
testyear = conf.pascal.year;
end
% Record a log of the training and test procedure
diary(conf.training.log([cls '-' timestamp]));
% Train a model (and record how long it took)
th = tic;
%model = pascal_train_d_and_t(cls, note);
model = pascal_train_mixture(cls, n, note);
%model = pascal_train_parts(cls, n, note);
toc(th);
% Free the feature vector cache memory
fv_cache('free');
% Lower threshold to get high recall
model.thresh = min(conf.eval.max_thresh, model.thresh);
model.interval = conf.eval.interval;
suffix = testyear;
model = model_cnn_init(model);
% Collect detections on the test set
ds = pascal_test(model, testset, testyear, suffix);
% Evaluate the model without bounding box prediction
ap1 = pascal_eval(cls, ds, testset, testyear, suffix);
fprintf('AP = %.4f (without bounding box prediction)\n', ap1);