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