MCPcopy Create free account
hub / github.com/davisking/dlib / main

Function main

examples/dnn_yolo_train_ex.cpp:147–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147int main(const int argc, const char** argv)
148try
149{
150 command_line_parser parser;
151 parser.add_option("size", "image size for training (default: 416)", 1);
152 parser.add_option("learning-rate", "initial learning rate (default: 0.001)", 1);
153 parser.add_option("batch-size", "mini batch size (default: 8)", 1);
154 parser.add_option("burnin", "learning rate burnin steps (default: 1000)", 1);
155 parser.add_option("patience", "number of steps without progress (default: 10000)", 1);
156 parser.add_option("workers", "number of worker threads to load data (default: 4)", 1);
157 parser.add_option("gpus", "number of GPUs to run the training on (default: 1)", 1);
158 parser.add_option("test", "test the detector with a threshold (default: 0.01)", 1);
159 parser.add_option("visualize", "visualize data augmentation instead of training");
160 parser.add_option("map", "compute the mean average precision");
161 parser.add_option("anchors", "Do nothing but compute <arg1> anchor boxes using K-Means and print their shapes.", 1);
162 parser.set_group_name("Help Options");
163 parser.add_option("h", "alias of --help");
164 parser.add_option("help", "display this message and exit");
165 parser.parse(argc, argv);
166 if (parser.number_of_arguments() == 0 || parser.option("h") || parser.option("help"))
167 {
168 parser.print_options();
169 cout << "Give the path to a folder containing the training.xml file." << endl;
170 return 0;
171 }
172 const double learning_rate = get_option(parser, "learning-rate", 0.001);
173 const size_t patience = get_option(parser, "patience", 10000);
174 const size_t batch_size = get_option(parser, "batch-size", 8);
175 const size_t burnin = get_option(parser, "burnin", 1000);
176 const size_t image_size = get_option(parser, "size", 416);
177 const size_t num_workers = get_option(parser, "workers", 4);
178 const size_t num_gpus = get_option(parser, "gpus", 1);
179
180 const string data_directory = parser[0];
181 const string sync_file_name = "yolov3_sync";
182
183 image_dataset_metadata::dataset dataset;
184 image_dataset_metadata::load_image_dataset_metadata(dataset, data_directory + "/training.xml");
185 cout << "# images: " << dataset.images.size() << endl;
186 std::map<string, size_t> labels;
187 size_t num_objects = 0;
188 for (const auto& im : dataset.images)
189 {
190 for (const auto& b : im.boxes)
191 {
192 labels[b.label]++;
193 ++num_objects;
194 }
195 }
196 cout << "# labels: " << labels.size() << endl;
197
198 yolo_options options;
199 color_mapper string_to_color;
200 for (const auto& label : labels)
201 {
202 cout << " - " << label.first << ": " << label.second;
203 cout << " (" << (100.0*label.second)/num_objects << "%)\n";
204 options.labels.push_back(label.first);

Callers

nothing calls this directly

Calls 15

get_optionFunction · 0.85
randomize_samplesFunction · 0.85
pick_initial_centersFunction · 0.85
prodFunction · 0.85
roundFunction · 0.85
centered_drectFunction · 0.85
setup_detectorFunction · 0.85
linspaceFunction · 0.85
file_existsFunction · 0.85

Tested by

no test coverage detected