automatic commit
[folded-ctf.git] / global.h
1
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.                         //
6 //                                                                       //
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.                              //
11 //                                                                       //
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/>.  //
14 //                                                                       //
15 // Written by Francois Fleuret                                           //
16 // (C) Idiap Research Institute                                          //
17 //                                                                       //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
19 ///////////////////////////////////////////////////////////////////////////
20
21 /*
22
23   We stuff all the global values in there.
24
25  */
26
27 #ifndef GLOBAL_H
28 #define GLOBAL_H
29
30 #include <iostream>
31
32 using namespace std;
33
34 #include "misc.h"
35 #include "param_parser.h"
36 #include "progress_bar.h"
37
38 enum { LOSS_EXPONENTIAL,
39        LOSS_HINGE,
40        LOSS_LOGISTIC };
41
42 class Global {
43 public:
44   int niceness;
45   int random_seed;
46   int pictures_for_article;
47
48   char pool_name[buffer_size];
49   char test_pool_name[buffer_size];
50   char detector_name[buffer_size];
51   char result_path[buffer_size];
52
53   int loss_type;
54
55   int nb_images;
56   int material_feature_nb;
57
58   int tree_depth_max;
59
60   int nb_weak_learners_per_classifier;
61   int nb_classifiers_per_level;
62   int nb_levels;
63
64   scalar_t proportion_negative_cells_for_training;
65   int nb_negative_samples_per_positive;
66   int nb_features_for_boosting_optimization;
67   int force_head_belly_independence;
68
69   scalar_t proportion_for_train;
70   scalar_t proportion_for_validation;
71   scalar_t proportion_for_test;
72   bool write_validation_rocs;
73   bool write_parse_images;
74   bool write_tag_images;
75   scalar_t wanted_true_positive_rate;
76   int nb_wanted_true_positive_rates;
77
78   int nb_scales_per_power_of_two;
79   scalar_t min_head_radius;
80   scalar_t max_head_radius;
81   int root_cell_nb_xy_per_radius;
82
83   scalar_t pi_feature_window_min_size;
84
85   ProgressBar bar;
86
87   Global();
88   ~Global();
89
90   void init_parser(ParamParser *parser);
91   void read_parser(ParamParser *parser);
92
93   ostream *log_stream;
94
95   inline int scale_to_discrete_log_scale(scalar_t scale_ratio) {
96     return int(floor(log(scale_ratio) / log(2.0) * nb_scales_per_power_of_two));
97   }
98
99   inline scalar_t discrete_log_scale_to_scale(int discrete_scale) {
100     return exp( - scalar_t(discrete_scale) * log(2.0) / scalar_t(nb_scales_per_power_of_two));
101   }
102 };
103
104 extern Global global;
105
106 #endif