-
Notifications
You must be signed in to change notification settings - Fork 32
/
train_demo.m
84 lines (62 loc) · 2.09 KB
/
train_demo.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
function train_demo( model_type )
% TRAIN_DEMO trains the detection model from scratch (except for the CNN model training)
% CNN model training can be done by ./finetune_vgg16_on_voc2007.sh
%
% Usage:
%
% train_demo( model_type )
%
% Input:
%
% model_type: can be a string naming the classifier model type:
% 'struct' - (linear) structured SVM,
% use the models in ./models_svm_linear
% 'linear' - ordinary linear SVM
% use the models in ./models_svm_struct
%
% Output:
%
% The trained (intermediate) models and intermediate outputs are all in
% the cache folders (SPECIFIC_DIRS in the code)
%
if ~exist('model_type','var') || isempty( model_type )
model_type = 'struct';
end
%% Preparation
fprintf( '========== Preparation\n' );
switch model_type
case 'struct' % do initialization for structured svm model
trainInit_svmStruct;
case 'linear' % do initialization for linear svm model
trainInit_svmLinear
otherwise
error( 'Unknown model_type' );
end
% prepare dataset
trainCallStage('PrepDataset');
% do selective search (on trainval & test)
trainCallStage('RegionProposal');
%% Classifier & BBox regression model training
fprintf( '========== Classifier & BBox regression model training\n' );
% compute best iou with gt (on trainval)
trainCallStage('BestIoU4Train');
% extract features from proposed bboxes (on trainval & test)
trainCallStage('Features4Proposed');
% extract features from groundtruth bboxes (on trainval)
trainCallStage('Features4Groundtruth');
% compute mean feature norm (on trainval)
trainCallStage('FeatureNorm4Train');
% train classifier
trainCallStage('Train');
% train bbox regression model
trainCallStage('BBoxRegTrain');
%% GP model training
fprintf( '========== GP model training\n' );
% generate additional regions for GP training
trainCallStage('RegionProposal4GPTrain');
% extract features from the additional regions
trainCallStage('Features4GPTrain');
% test on the training set (observations for GP training)
trainCallStage('Test4GPTrain');
% gp training
trainCallStage('GPTrain');