-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo_full.m
94 lines (67 loc) · 2.51 KB
/
demo_full.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
87
88
89
90
91
92
%
% Demo learning, detection, evaluation and visualization
% ---------------
% Set basic and global settings, compile mex sources
clear all
close all
globals
compile
% ---------------
% Specify the model settings
n_local_mixture = 3; % Number of filters per part
n_global_mixture = 10; % Number of global mixtures for model
n_3d_basis = 5; % Number of 3D basis shapes
hog_sbin = 4;
experiment_name = '3DCars'; % Used to name temp files and results
experiment_name_suffix = ['n_local:' num2str(n_local_mixture) '_n_global:' num2str(n_global_mixture)];
%experiment_name_suffix = 'run1';
% ---------------
% Read data and prepare training and testing images and part bounding boxes
dataset_file_path = './data/3DCar.mat';
pascal_annotation_path = './data/2011PASCAL_CAR.mat';
[pos test neg] = read_data(dataset_file_path,VOC_images_path);
% visualize an example of 2D landmark annotation, good for debugging
% visualize_landmark_annotation(pos(1))
% ---------------
% Debug mode : use subset of images
run_debug = false;
n_train = 50;
n_test = 10;
if run_debug
n_local_mixture = 2;
n_global_mixture = 5;
pos = pos(1:n_train);
neg = neg(1:n_train);
test = test(1:n_test);
experiment_name_suffix = 'debug';
end
% ---------------
% Training
% Train 2D model
model_2d = train_model(pos, neg, hog_sbin, n_local_mixture, n_global_mixture,...
experiment_name, experiment_name_suffix);
% Train 3D model
[model_3d, pos, test] = train_3d_model(pos, test, n_3d_basis, experiment_name, experiment_name_suffix);
% ---------------
% Visualize model
% Visualize 2D model
visualize_model(model_2d)
% Visualize 3D model
wireframe = wireframe_car();
visualize_3D_basis_shapes(model_3d, wireframe)
% ---------------
% Testing
model_2d.thresh = -1.5;
% Detect bounding boxes - for AP evaluation
test_model_bbox(model_2d, model_3d, test, experiment_name, experiment_name_suffix);
% Detect landmarks given ground-truth boudning box - for landmark
% localization and viewpoint classification evaluation
test_model_landmark(model_2d, model_3d, test, experiment_name, experiment_name_suffix);
% ---------------
% Evaluation
% Evaluate 2D bounding bounding box detection using VOC PASCAL object
% detection challenge method
ap_result = evaluate_2D_box_detection(test, experiment_name, experiment_name_suffix);
% Evaluate 2D landmark localization and visibility prediction
lp_result = evaluate_Landmarks(test, model_2d, experiment_name, experiment_name_suffix);
% Evaluate viewpoint estimation