2 ///////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation. //
7 // This program is distributed in the hope that it will be useful, but //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
10 // General Public License for more details. //
12 // You should have received a copy of the GNU General Public License //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
15 // Written by Francois Fleuret //
16 // (C) Idiap Research Institute //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
19 ///////////////////////////////////////////////////////////////////////////
35 void Global::init_parser(ParamParser *parser) {
36 // The nice level of the process
37 parser->add_association("niceness", "15", false);
39 // Seed to initialize the random generator
40 parser->add_association("random-seed", "0", false);
42 // Should the pictures be b&w
43 parser->add_association("pictures-for-article", "no", false);
45 // The name of the image pool to use
46 parser->add_association("pool-name", "", false);
47 // The name of the test image pool to use
48 parser->add_association("test-pool-name", "", false);
49 // From where to load or where to save the detector
50 parser->add_association("detector-name", "default.det", false);
51 // Where to put the generated files
52 parser->add_association("result-path", "/tmp/", false);
54 // What kind of loss for the boosting
55 parser->add_association("loss-type", "exponential", false);
57 // How many images to produce/process
58 parser->add_association("nb-images", "-1", false);
59 // What is the number of the feature to show in the images
60 parser->add_association("material-feature-nb", "-1", false);
62 // What is the maximum tree depth
63 parser->add_association("tree-depth-max", "1", false);
64 // What is the proportion of negative cells we actually use during training
65 parser->add_association("proportion-negative-cells-for-training", "0.025", false);
66 // How many negative samples to sub-sample for boosting every classifier
67 parser->add_association("nb-negative-samples-per-positive", "10", false);
68 // How many features we will look at for boosting optimization
69 parser->add_association("nb-features-for-boosting-optimization", "10000", false);
70 // Do we allow head-belly registration
71 parser->add_association("force-head-belly-independence", "no", false);
72 // How many weak-learners in every classifier
73 parser->add_association("nb-weak-learners-per-classifier", "100", false);
74 // How many classifiers per level
75 parser->add_association("nb-classifiers-per-level", "25", false);
77 parser->add_association("nb-levels", "2", false);
79 // Proportion of images from the pool to use for training
80 parser->add_association("proportion-for-train", "0.5", false);
81 // Proportion of images from the pool to use for validation
82 parser->add_association("proportion-for-validation", "0.25", false);
83 // Proportion of images from the pool to use for test (negative
84 // means everything else)
85 parser->add_association("proportion-for-test", "0.25", false);
86 // During training, should we write the ROC curve estimated on the
87 // validation set (which cost a bit of computation)
88 parser->add_association("write-validation-rocs", "no", false);
90 // Should we write down the PNGs for the results of the parsing
91 parser->add_association("write-parse-images", "no", false);
93 // Should we write down the PNGs for the tags
94 parser->add_association("write-tag-images", "no", false);
96 // What is the wanted true overall positive rate
97 parser->add_association("wanted-true-positive-rate", "0.75", false);
98 // How many rates to try for the sequence of tests
99 parser->add_association("nb-wanted-true-positive-rates", "10", false);
101 // What is the minimum radius of the heads to detect. This is used
102 // as the reference size.
103 parser->add_association("min-head-radius", "25", false);
104 // What is the maximum size of the heads to detect.
105 parser->add_association("max-head-radius", "200", false);
106 // How many translation cell for one scale when generating the "top
107 // level" cells for an image.
108 parser->add_association("root-cell-nb-xy-per-radius", "5", false);
110 // What is the minimum size of the windows
111 parser->add_association("pi-feature-window-min-size", "0.1", false);
113 // How many scales between two powers of two for the multi-scale
115 parser->add_association("nb-scales-per-power-of-two", "5", false);
117 // Should we display a progress bar for lengthy operations
118 parser->add_association("progress-bar", "yes", false);
121 void Global::read_parser(ParamParser *parser) {
122 niceness = parser->get_association_int("niceness");
123 random_seed = parser->get_association_int("random-seed");
124 pictures_for_article = parser->get_association_bool("pictures-for-article");
126 strncpy(pool_name, parser->get_association("pool-name"), buffer_size);
127 strncpy(test_pool_name, parser->get_association("test-pool-name"), buffer_size);
128 strncpy(detector_name, parser->get_association("detector-name"), buffer_size);
129 strncpy(result_path, parser->get_association("result-path"), buffer_size);
131 char buffer[buffer_size];
132 sprintf(buffer, "%s/log", result_path);
133 log_stream = new ofstream(buffer);
135 char *l = parser->get_association("loss-type");
136 if(strcmp(l, "exponential") == 0)
137 loss_type = LOSS_EXPONENTIAL;
138 else if(strcmp(l, "ev-regularized") == 0)
139 loss_type = LOSS_EV_REGULARIZED;
140 else if(strcmp(l, "hinge") == 0)
141 loss_type = LOSS_HINGE;
142 else if(strcmp(l, "logistic") == 0)
143 loss_type = LOSS_LOGISTIC;
145 cerr << "Unknown loss type." << endl;
149 nb_images = parser->get_association_int("nb-images");
150 material_feature_nb = parser->get_association_int("material-feature-nb");
151 tree_depth_max = parser->get_association_int("tree-depth-max");
152 nb_weak_learners_per_classifier = parser->get_association_int("nb-weak-learners-per-classifier");
153 nb_classifiers_per_level = parser->get_association_int("nb-classifiers-per-level");
154 nb_levels = parser->get_association_int("nb-levels");
155 proportion_negative_cells_for_training = parser->get_association_scalar("proportion-negative-cells-for-training");
156 nb_negative_samples_per_positive = parser->get_association_int("nb-negative-samples-per-positive");
157 nb_features_for_boosting_optimization = parser->get_association_int("nb-features-for-boosting-optimization");
158 force_head_belly_independence = parser->get_association_bool("force-head-belly-independence");
159 proportion_for_train = parser->get_association_scalar("proportion-for-train");
160 proportion_for_validation = parser->get_association_scalar("proportion-for-validation");
161 proportion_for_test = parser->get_association_scalar("proportion-for-test");
162 write_validation_rocs = parser->get_association_bool("write-validation-rocs");
163 write_parse_images = parser->get_association_bool("write-parse-images");
164 write_tag_images = parser->get_association_bool("write-tag-images");
165 wanted_true_positive_rate = parser->get_association_scalar("wanted-true-positive-rate");
166 nb_wanted_true_positive_rates = parser->get_association_int("nb-wanted-true-positive-rates");
168 min_head_radius = parser->get_association_scalar("min-head-radius");
169 max_head_radius = parser->get_association_scalar("max-head-radius");
170 root_cell_nb_xy_per_radius = parser->get_association_int("root-cell-nb-xy-per-radius");
172 pi_feature_window_min_size = parser->get_association_scalar("pi-feature-window-min-size");
174 nb_scales_per_power_of_two = parser->get_association_int("nb-scales-per-power-of-two");
176 bar.set_visible(parser->get_association_bool("progress-bar"));