Add function to download weigths if do no exist, for each test. Add some controls in map demo.

Signed-off-by: Francesco Gatti <gattifrancesco@hotmail.it>
This commit is contained in:
Francesco Gatti
2020-03-14 17:02:07 +01:00
parent 5e0c1879bc
commit cf7fbadcd2
16 changed files with 51 additions and 2 deletions
+10
View File
@@ -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;
+1
View File
@@ -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);
+2 -2
View File
@@ -3,8 +3,8 @@
#include "CenternetDetection.h"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/cudawarping.hpp>
#include <opencv2/cudaarithm.hpp>
// #include <opencv2/cudawarping.hpp>
// #include <opencv2/cudaarithm.hpp>
+13
View File
@@ -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)
{
@@ -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);
+2
View File
@@ -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);
+3
View File
@@ -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
+1
View File
@@ -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);
+2
View File
@@ -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);
+2
View File
@@ -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"};
+2
View File
@@ -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"};
+2
View File
@@ -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;
+2
View File
@@ -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++) {
+3
View File
@@ -1,4 +1,5 @@
#include<iostream>
// #include<cstdlib>
#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
+2
View File
@@ -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);
+2
View File
@@ -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);