parse line by line

This commit is contained in:
Francesco Gatti
2020-05-30 17:27:22 +02:00
parent 4e1c7a70b1
commit 548a3dd33c
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -4,12 +4,32 @@
namespace tk { namespace dnn {
tk::dnn::Network* DarknetParser(std::string cfg) {
tk::dnn::Network* DarknetParser(std::string cfg_file) {
tk::dnn::dataDim_t dim;
tk::dnn::Network *net = new tk::dnn::Network(dim);
std::ifstream if_cfg(cfg_file);
if(!if_cfg.is_open())
FatalError("cloud not open cfg file: " + cfg_file);
std::string line;
while(std::getline(if_cfg, line)) {
// remove comments
std::size_t found = line.find("#");
if ( found != std::string::npos ) {
line = line.substr(0, found);
}
// skip empty lines
if(line.size() == 0)
continue;
std::string type = parseType(line);
if(type.size() > 0) {
std::cout<<"type: "<<type<<"\n";
}
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
int main() {
tk::dnn::Network *net = tk::dnn::DarknetParser("../../tests/yolo3/yolo3.cfg");
tk::dnn::Network *net = tk::dnn::DarknetParser("../tests/yolo3/yolov3.cfg");
// Network layout
//tk::dnn::dataDim_t dim(1, 3, 416, 416, 1);