-
Notifications
You must be signed in to change notification settings - Fork 71
/
run_training.m
68 lines (45 loc) · 1.92 KB
/
run_training.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
function run_training ( )
%% loading the setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
options = setup( );
%% learning other requirements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if options.learningShape == 1
disp('Learning shap model...');
do_learn_shape( options );
end
if options.learningVariation == 1
disp('Learning data variation...');
do_learn_variation( options );
end
load( ['model/' options.datasetName '_ShapeModel.mat'] );
load( ['model/' options.datasetName '_DataVariation.mat'] );
%% learn cascaded regression %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
imgDir = options.trainingImageDataPath;
ptsDir = options.trainingTruthDataPath;
%% loading data
disp('Loading training data...');
Data = load_all_data2( imgDir, ptsDir, options );
n_cascades = options.n_cascades;
LearnedCascadedModel{n_cascades}.R = [];
rms = zeros(n_cascades,1);
for icascade = 1 : n_cascades
options.current_cascade = icascade;
%% learning single regressors
if icascade == 1
new_init_shape = [];
[R,new_init_shape,rms(icascade)] = learn_single_regressor( ...
ShapeModel, DataVariation, Data, new_init_shape, options );
LearnedCascadedModel{icascade}.R = R;
%% save other parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LearnedCascadedModel{icascade}.n_cascades = n_cascades;
LearnedCascadedModel{icascade}.descSize = options.descSize;
LearnedCascadedModel{icascade}.descBins = options.descBins;
else
[R, new_init_shape,rms(icascade)] = learn_single_regressor( ...
ShapeModel, DataVariation, Data, new_init_shape, options );
LearnedCascadedModel{icascade}.R = R;
end
end
%save('result/Trained_RMS.mat' , 'rms');
save([options.modelPath options.slash ...
'LearnedCascadedModel.mat'],'LearnedCascadedModel');
clear;