diff --git a/demo/demo/map.cpp b/demo/demo/map.cpp index 7e24141..e1e3840 100644 --- a/demo/demo/map.cpp +++ b/demo/demo/map.cpp @@ -46,6 +46,13 @@ int main(int argc, char *argv[]) if(argc > 4) config_filename = argv[4]; + if(!fileExist(config_filename)) + FatalError("Wrong config file path."); + if(!fileExist(net)) + FatalError("Wrong net file path."); + if(!fileExist(labels_path)) + FatalError("Wrong labels file path."); + std::ofstream times; if(write_res_on_file) @@ -90,6 +97,9 @@ int main(int argc, char *argv[]) convertFilename(f.i_filename, "labels", "images", ".txt", ".jpg"); // read frame + if(!fileExist(f.i_filename.c_str())) + FatalError("Wrong image file path."); + cv::Mat frame = cv::imread(f.i_filename.c_str(), cv::IMREAD_COLOR); int height = frame.rows; int width = frame.cols; diff --git a/include/tkDNN/utils.h b/include/tkDNN/utils.h index f0503cd..5da6e81 100644 --- a/include/tkDNN/utils.h +++ b/include/tkDNN/utils.h @@ -90,6 +90,7 @@ void printCenteredTitle(const char *title, char fill, int dim); bool fileExist(const char *fname); +void downloadWeightsifDoNotExist(const std::string& input_bin, const std::string& test_folder, const std::string& weights_url); void readBinaryFile(std::string fname, int size, dnnType** data_h, dnnType** data_d, int seek = 0, bool skipLoad = false); int checkResult(int size, dnnType *data_d, dnnType *correct_d, bool device = true); void printDeviceVector(int size, dnnType* vec_d, bool device = true); diff --git a/src/CenternetDetection.cpp b/src/CenternetDetection.cpp index 5165535..4560015 100644 --- a/src/CenternetDetection.cpp +++ b/src/CenternetDetection.cpp @@ -3,8 +3,8 @@ #include "CenternetDetection.h" #include "opencv2/imgproc/imgproc.hpp" -#include -#include +// #include +// #include diff --git a/src/utils.cpp b/src/utils.cpp index deb4def..142e85f 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -20,6 +20,19 @@ bool fileExist(const char *fname) { return true; } +void downloadWeightsifDoNotExist(const std::string& input_bin, const std::string& test_folder, const std::string& weights_url) +{ + if(!fileExist(input_bin.c_str())) + { + std::string wget_cmd = "wget " + weights_url + " -O " + test_folder + "/weights.zip"; + std::string unzip_cmd = "unzip " + test_folder + "/weights.zip -d" + test_folder; + std::string rm_cmd = "rm " + test_folder + "/weights.zip"; + system(wget_cmd.c_str()); + system(unzip_cmd.c_str()); + system(rm_cmd.c_str()); + } +} + void readBinaryFile(std::string fname, int size, dnnType** data_h, dnnType** data_d, int seek, bool skipLoad) { diff --git a/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp b/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp index 087fd71..eda09f5 100644 --- a/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp +++ b/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp @@ -121,6 +121,8 @@ int main() std::string g126_bin = bin_path + "/layers/g126.bin"; std::string g137_bin = bin_path + "/layers/g137.bin"; + downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/Kcs4xBozwY4wFx8/download"); + tk::dnn::Conv2d c0(&net, 64, 7, 7, 2, 2, 3, 3, c0_bin, true); tk::dnn::Activation a0(&net, tk::dnn::ACTIVATION_LEAKY); tk::dnn::Pooling p1(&net, 2, 2, 2, 2, 0,0, tk::dnn::POOLING_MAX); diff --git a/tests/dla34_cnet/dla34_cnet.cpp b/tests/dla34_cnet/dla34_cnet.cpp index b73bb1d..0bb822b 100644 --- a/tests/dla34_cnet/dla34_cnet.cpp +++ b/tests/dla34_cnet/dla34_cnet.cpp @@ -103,6 +103,8 @@ const char *output_bin[]={ int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/dla34_cnet", "https://cloud.hipert.unimore.it/s/8AjXdgCeRzCa5AF/download"); + // Network layout tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); tk::dnn::Network net(dim); diff --git a/tests/mobilenetv2ssd/mobilenetv2ssd.cpp b/tests/mobilenetv2ssd/mobilenetv2ssd.cpp index cec97e2..851ffa9 100644 --- a/tests/mobilenetv2ssd/mobilenetv2ssd.cpp +++ b/tests/mobilenetv2ssd/mobilenetv2ssd.cpp @@ -133,6 +133,9 @@ const char *regression_header5 = "../tests/mobilenetv2ssd/layers/regression_head int main() { + + downloadWeightsifDoNotExist(input_bin, "./tests/mobilenetv2ssd", "https://cloud.hipert.unimore.it/s/B6mj33k7beECXsY/download"); + int classes = 21; // Network layout diff --git a/tests/resnet101_cnet/resnet101_cnet.cpp b/tests/resnet101_cnet/resnet101_cnet.cpp index 35cd857..9467f18 100644 --- a/tests/resnet101_cnet/resnet101_cnet.cpp +++ b/tests/resnet101_cnet/resnet101_cnet.cpp @@ -185,6 +185,7 @@ const char *output_bin[]={ int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/resnet101_cnet", "https://cloud.hipert.unimore.it/s/B6mj33k7beECXsY/download"); // Network layout tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); diff --git a/tests/yolo/yolo.cpp b/tests/yolo/yolo.cpp index 05404b0..6e1ce17 100644 --- a/tests/yolo/yolo.cpp +++ b/tests/yolo/yolo.cpp @@ -30,6 +30,8 @@ const char *output_bin = "../tests/yolo/layers/output.bin"; int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/yolo", "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download"); + // Network layout tk::dnn::dataDim_t dim(1, 3, 608, 608, 1); tk::dnn::Network net(dim); diff --git a/tests/yolo3/yolo3.cpp b/tests/yolo3/yolo3.cpp index a3772e5..b3b2f0f 100644 --- a/tests/yolo3/yolo3.cpp +++ b/tests/yolo3/yolo3.cpp @@ -14,6 +14,8 @@ int main() { tk::dnn::Yolo *yolo [3]; #include "models/Yolo3.h" + downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download"); + // fill classes names for(int i=0; i<3; i++) { yolo[i]->classesNames = {"person" , "bicycle" , "car" , "motorbike" , "aeroplane" , "bus" , "train" , "truck" , "boat" , "traffic light" , "fire hydrant" , "stop sign" , "parking meter" , "bench" , "bird" , "cat" , "dog" , "horse" , "sheep" , "cow" , "elephant" , "bear" , "zebra" , "giraffe" , "backpack" , "umbrella" , "handbag" , "tie" , "suitcase" , "frisbee" , "skis" , "snowboard" , "sports ball" , "kite" , "baseball bat" , "baseball glove" , "skateboard" , "surfboard" , "tennis racket" , "bottle" , "wine glass" , "cup" , "fork" , "knife" , "spoon" , "bowl" , "banana" , "apple" , "sandwich" , "orange" , "broccoli" , "carrot" , "hot dog" , "pizza" , "donut" , "cake" , "chair" , "sofa" , "pottedplant" , "bed" , "diningtable" , "toilet" , "tvmonitor" , "laptop" , "mouse" , "remote" , "keyboard" , "cell phone" , "microwave" , "oven" , "toaster" , "sink" , "refrigerator" , "book" , "clock" , "vase" , "scissors" , "teddy bear" , "hair drier" , "toothbrush"}; diff --git a/tests/yolo3_berkeley/yolo3_berkeley.cpp b/tests/yolo3_berkeley/yolo3_berkeley.cpp index 70e8b60..4c62f8e 100644 --- a/tests/yolo3_berkeley/yolo3_berkeley.cpp +++ b/tests/yolo3_berkeley/yolo3_berkeley.cpp @@ -14,6 +14,8 @@ int main() { tk::dnn::Yolo *yolo [3]; #include "models/Yolo3.h" + downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download"); + // fill classes names for(int i=0; i<3; i++) { yolo[i]->classesNames = {"person", "car", "truck", "bus", "motor", "bike", "rider", "traffic light", "traffic sign", "train"}; diff --git a/tests/yolo3_coco4/yolo3_coco4.cpp b/tests/yolo3_coco4/yolo3_coco4.cpp index 67790e9..61274b3 100644 --- a/tests/yolo3_coco4/yolo3_coco4.cpp +++ b/tests/yolo3_coco4/yolo3_coco4.cpp @@ -14,6 +14,8 @@ int main() { tk::dnn::Yolo *yolo [3]; #include "models/Yolo3.h" + downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/o27NDzSAartbyc4/download"); + // Load input dnnType *data; dnnType *input_h; diff --git a/tests/yolo3_flir/yolo3_flir.cpp b/tests/yolo3_flir/yolo3_flir.cpp index 83b53af..fcb2ce5 100644 --- a/tests/yolo3_flir/yolo3_flir.cpp +++ b/tests/yolo3_flir/yolo3_flir.cpp @@ -14,6 +14,8 @@ int main() { int classes = 3; tk::dnn::Yolo *yolo [3]; #include "models/Yolo3.h" + + downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/62DECncmF6bMMiH/download"); // fill classes names for(int i=0; i<3; i++) { diff --git a/tests/yolo3_tiny/yolo3_tiny.cpp b/tests/yolo3_tiny/yolo3_tiny.cpp index 7c8a382..f06fab0 100644 --- a/tests/yolo3_tiny/yolo3_tiny.cpp +++ b/tests/yolo3_tiny/yolo3_tiny.cpp @@ -1,4 +1,5 @@ #include +// #include #include "tkdnn.h" const char *input_bin = "../tests/yolo3_tiny/layers/input.bin"; @@ -23,6 +24,8 @@ const char *output_bin = "../tests/yolo3_tiny/debug/layer23_out.bin"; int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/yolo3_tiny", "https://cloud.hipert.unimore.it/s/LMcSHtWaLeps8yN/download"); + int classes = 80; // Network layout diff --git a/tests/yolo_tiny/yolo_tiny.cpp b/tests/yolo_tiny/yolo_tiny.cpp index 0255108..08c504d 100644 --- a/tests/yolo_tiny/yolo_tiny.cpp +++ b/tests/yolo_tiny/yolo_tiny.cpp @@ -17,6 +17,8 @@ const char *output_bin = "../tests/yolo_tiny/layers/output.bin"; int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/yolo_tiny", "https://cloud.hipert.unimore.it/s/m3orfJr8pGrN5mQ/download"); + // Network layout tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); tk::dnn::Network net(dim); diff --git a/tests/yolo_voc/yolo_voc.cpp b/tests/yolo_voc/yolo_voc.cpp index d0b9456..9d2609c 100644 --- a/tests/yolo_voc/yolo_voc.cpp +++ b/tests/yolo_voc/yolo_voc.cpp @@ -30,6 +30,8 @@ const char *output_bin = "../tests/yolo_voc/layers/output.bin"; int main() { + downloadWeightsifDoNotExist(input_bin, "../tests/yolo_voc", "https://cloud.hipert.unimore.it/s/DJC5Fi2pEjfNDP9/download"); + // Network layout tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); tk::dnn::Network net(dim);