Change README.md, add config.yaml, refactoring

Signed-off-by: xavier <micaelaverucchi@gmail.com>
This commit is contained in:
xavier
2020-02-11 11:25:42 +01:00
parent e01d7c6b13
commit d0026ff235
6 changed files with 73 additions and 42 deletions
+22 -39
View File
@@ -17,7 +17,7 @@
#include "evaluation.h"
#include <map>
#include <yaml-cpp/yaml.h>
void convertFilename(std::string &filename,const std::string l_folder, const std::string i_folder, const std::string l_ext,const std::string i_ext)
@@ -26,49 +26,24 @@ void convertFilename(std::string &filename,const std::string l_folder, const std
filename.replace(filename.find(l_ext),l_ext.length(),i_ext);
}
void readParams(char* config_filename, std::string& net, char &ntype, std::string& labels_path,
bool &show, bool& write_dets, int& classes, int& n_images,
int& map_points, int& map_levels, float& map_step,
float& IoU_thresh, float& conf_thresh, bool& verbose)
{
YAML::Node config = YAML::LoadFile(config_filename);
net = config["net"].as<std::string>();
ntype = config["ntype"].as<char>();
labels_path = config["labels_path"].as<std::string>();
show = config["show"].as<bool>();
write_dets = config["write_dets"].as<bool>();
classes = config["classes"].as<int>();
n_images = config["n_images"].as<int>();
map_points = config["map_points"].as<int>();
map_levels = config["map_levels"].as<int>();
map_step = config["map_step"].as<float>();
IoU_thresh = config["IoU_thresh"].as<float>();
conf_thresh = config["conf_thresh"].as<float>();
verbose = config["verbose"].as<bool>();
}
int main(int argc, char *argv[])
{
char *config_filename = "config.yaml";
char ntype = 'y';
char *config_filename = "../demo/config.yaml";
char * net = "yolo3.rt";
char * labels_path = "/media/887E650E7E64F67A/val2017/all_labels2017.txt";
bool show = false;
bool write_dets = false;
int n_images = 1000;
if(argc > 1)
config_filename = argv[1];
char ntype;
std::string net, labels_path;
bool show, write_dets, verbose;
int classes, map_points, map_levels, n_images;
float map_step, IoU_thresh, conf_thresh;
readParams( config_filename, net, ntype, labels_path, show, write_dets,
classes, n_images, map_points, map_levels, map_step,
IoU_thresh, conf_thresh, verbose);
net = argv[1];
if(argc > 2)
net = argv[2];
ntype = argv[2][0];
if(argc > 3)
ntype = argv[3][0];
labels_path = argv[3];
if(argc > 3)
config_filename = argv[4];
tk::dnn::Yolo3Detection yolo;
tk::dnn::CenternetDetection cnet;
@@ -183,6 +158,14 @@ int main(int argc, char *argv[])
}
std::cout<<"Done."<<std::endl;
bool verbose;
int classes, map_points, map_levels;
float map_step, IoU_thresh, conf_thresh;
//read mAP parameters
readParams( config_filename, classes, map_points, map_levels, map_step,
IoU_thresh, conf_thresh, verbose);
//compute mAP
double AP = computeMapNIoULevels(images,classes,IoU_thresh,conf_thresh, map_points, map_step, map_levels, verbose);