Merge branch 'master' of https://github.com/ceccocats/tkDNN into ceccocats-master
This commit is contained in:
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer137_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/csresnext50-panet-spp.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/Kcs4xBozwY4wFx8/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer137_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg";
|
||||
std::string name_path = "../tests/darknet/names/berkeley.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/berkeley.names";
|
||||
// FIXME: wrong weights
|
||||
// downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#include<iostream>
|
||||
#include<vector>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "tkdnn.h"
|
||||
#include "test.h"
|
||||
#include "DarknetParser.h"
|
||||
#include "NetworkViz.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc <2)
|
||||
FatalError("you must provide an input image");
|
||||
std::string input_image = argv[1];
|
||||
std::string bin_path = "yolo3";
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(wgs_path, bin_path, "https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download");
|
||||
|
||||
// parse darknet network
|
||||
tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path);
|
||||
net->print();
|
||||
|
||||
// input data
|
||||
dnnType *input_d;
|
||||
checkCuda( cudaMalloc(&input_d, sizeof(dnnType)*net->input_dim.tot()));
|
||||
|
||||
// load image
|
||||
cv::Mat frame, frameFloat;
|
||||
frame = cv::imread(input_image);
|
||||
cv::resize(frame, frame, cv::Size(net->input_dim.w, net->input_dim.h));
|
||||
frame.convertTo(frameFloat, CV_32FC3, 1/255.0);
|
||||
|
||||
//split channels
|
||||
cv::Mat bgr[3];
|
||||
cv::split(frameFloat,bgr);//split source
|
||||
|
||||
//write channels
|
||||
for(int i=0; i<net->input_dim.c; i++) {
|
||||
int idx = i*frameFloat.rows*frameFloat.cols;
|
||||
int ch = net->input_dim.c-1 -i;
|
||||
checkCuda( cudaMemcpy(input_d + idx, (void*)bgr[ch].data, frameFloat.rows*frameFloat.cols*sizeof(dnnType), cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
tk::dnn::dataDim_t dim = net->input_dim;
|
||||
dim.print();
|
||||
std::cout<<"infer\n";
|
||||
net->infer(dim, input_d);
|
||||
|
||||
// output directory
|
||||
std::string output_viz = "viz/";
|
||||
system( (std::string("mkdir -p ") + output_viz).c_str() );
|
||||
|
||||
for(int i=0; i<net->num_layers; i++) {
|
||||
std::string output_png = output_viz + "/layer" + std::to_string(i) + ".png";
|
||||
std::cout<<"saving "<<output_png<<"\n";
|
||||
cv::Mat viz = vizLayer2Mat(net, i);
|
||||
cv::imwrite(output_png, viz);
|
||||
//cv::imshow("layer", viz);
|
||||
//cv::waitKey(0);
|
||||
}
|
||||
|
||||
checkCuda(cudaFree(input_d));
|
||||
net->releaseLayers();
|
||||
delete net;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ int main() {
|
||||
bin_path + "/layers/output.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo2.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo2.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -13,8 +13,8 @@ int main() {
|
||||
bin_path + "/layers/output.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo2_voc.cfg";
|
||||
std::string name_path = "../tests/darknet/names/voc.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo2_voc.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/voc.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/DJC5Fi2pEjfNDP9/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -13,8 +13,8 @@ int main() {
|
||||
bin_path + "/layers/output.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo2tiny.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo2tiny.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
// FIXME: wrong weights
|
||||
//downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer106_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer106_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3_512.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3_512.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/RGecMeGLD4cXEWL/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer106_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3_berkeley.cfg";
|
||||
std::string name_path = "../tests/darknet/names/berkeley.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3_berkeley.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/berkeley.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer106_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3_coco4.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco4.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3_coco4.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco4.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o27NDzSAartbyc4/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer106_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3_flir.cfg";
|
||||
std::string name_path = "../tests/darknet/names/flir.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3_flir.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/flir.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/62DECncmF6bMMiH/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -14,8 +14,8 @@ int main() {
|
||||
bin_path + "/debug/layer23_out.bin",
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3tiny.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/LMcSHtWaLeps8yN/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -14,8 +14,8 @@ int main() {
|
||||
bin_path + "/debug/layer23_out.bin",
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny_512.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo3tiny_512.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/8Zt6bHwHADqP4JC/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer161_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo4.cfg";
|
||||
std::string name_path = "../tests/darknet/names/coco.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo4.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/coco.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/d97CFzYqCPCp5Hg/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
@@ -15,8 +15,8 @@ int main() {
|
||||
bin_path + "/debug/layer161_out.bin"
|
||||
};
|
||||
std::string wgs_path = bin_path + "/layers";
|
||||
std::string cfg_path = "../tests/darknet/cfg/yolo4_berkeley.cfg";
|
||||
std::string name_path = "../tests/darknet/names/berkeley.names";
|
||||
std::string cfg_path = std::string(TKDNN_PATH) + "/tests/darknet/cfg/yolo4_berkeley.cfg";
|
||||
std::string name_path = std::string(TKDNN_PATH) + "/tests/darknet/names/berkeley.names";
|
||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/nkWFa5fgb4NTdnB/download");
|
||||
|
||||
// parse darknet network
|
||||
|
||||
Reference in New Issue
Block a user