darknet parser tested
This commit is contained in:
@@ -22,6 +22,7 @@ namespace tk { namespace dnn {
|
|||||||
int classes = 20;
|
int classes = 20;
|
||||||
int num = 1;
|
int num = 1;
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
|
int coords = 4;
|
||||||
float scale_xy = 1;
|
float scale_xy = 1;
|
||||||
std::vector<int> layers;
|
std::vector<int> layers;
|
||||||
std::string activation = "linear";
|
std::string activation = "linear";
|
||||||
@@ -102,9 +103,11 @@ namespace tk { namespace dnn {
|
|||||||
fields.classes = std::stoi(value);
|
fields.classes = std::stoi(value);
|
||||||
else if(name.find("num") != std::string::npos)
|
else if(name.find("num") != std::string::npos)
|
||||||
fields.num = std::stoi(value);
|
fields.num = std::stoi(value);
|
||||||
|
else if(name.find("coords") != std::string::npos)
|
||||||
|
fields.coords = std::stoi(value);
|
||||||
else if(name.find("groups") != std::string::npos)
|
else if(name.find("groups") != std::string::npos)
|
||||||
fields.groups = std::stoi(value);
|
fields.groups = std::stoi(value);
|
||||||
else if(name.find("scale_xy") != std::string::npos)
|
else if(name.find("scale_x_y") != std::string::npos)
|
||||||
fields.scale_xy = std::stof(value);
|
fields.scale_xy = std::stof(value);
|
||||||
else if(name.find("from") != std::string::npos)
|
else if(name.find("from") != std::string::npos)
|
||||||
fields.layers.push_back(std::stof(value));
|
fields.layers.push_back(std::stof(value));
|
||||||
@@ -135,23 +138,25 @@ namespace tk { namespace dnn {
|
|||||||
if(f.pad == 1) {
|
if(f.pad == 1) {
|
||||||
f.padding_x = f.padding_y = f.size_x /2;
|
f.padding_x = f.padding_y = f.size_x /2;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<"Add layer: "<<f.type<<"\n";
|
std::cout<<"Add layer: "<<f.type<<"\n";
|
||||||
if(f.type == "convolutional") {
|
if(f.type == "convolutional") {
|
||||||
std::string wgs = wgs_path + "/c" + std::to_string(netLayers.size()) + ".bin";
|
std::string wgs = wgs_path + "/c" + std::to_string(netLayers.size()) + ".bin";
|
||||||
printf("%d (%d,%d) (%d,%d) (%d,%d) %s %d %d\n", f.filters, f.size_x, f.size_y, f.stride_x, f.stride_y, f.padding_x, f.padding_y, wgs.c_str(), f.batch_normalize, f.groups);
|
printf("%d (%d,%d) (%d,%d) (%d,%d) %s %d %d\n", f.filters, f.size_x, f.size_y, f.stride_x, f.stride_y, f.padding_x, f.padding_y, wgs.c_str(), f.batch_normalize, f.groups);
|
||||||
tk::dnn::Conv2d *l= new tk::dnn::Conv2d(net, f.filters, f.size_x, f.size_y, f.stride_x,
|
tk::dnn::Conv2d *l= new tk::dnn::Conv2d(net, f.filters, f.size_x, f.size_y, f.stride_x,
|
||||||
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups);
|
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups);
|
||||||
if(f.activation != "linear") {
|
netLayers.push_back(l);
|
||||||
tkdnnActivationMode_t act;
|
} else if(f.type == "maxpool") {
|
||||||
if(f.activation == "relu") act = tkdnnActivationMode_t(CUDNN_ACTIVATION_RELU);
|
if(f.stride_x == 1 && f.stride_y == 1)
|
||||||
else if(f.activation == "leaky") act = tk::dnn::ACTIVATION_LEAKY;
|
netLayers.push_back(new tk::dnn::Pooling(net, f.size_x, f.size_y, f.stride_x, f.stride_y,
|
||||||
else if(f.activation == "mish") act = tk::dnn::ACTIVATION_MISH;
|
f.padding_x, f.padding_y, tk::dnn::POOLING_MAX_FIXEDSIZE));
|
||||||
else { FatalError("activation not supported: " + f.activation); }
|
else
|
||||||
netLayers.push_back(new tk::dnn::Activation(net, act));
|
netLayers.push_back(new tk::dnn::Pooling(net, f.size_x, f.size_y, f.stride_x, f.stride_y,
|
||||||
} else {
|
f.padding_x, f.padding_y, tk::dnn::POOLING_MAX));
|
||||||
netLayers.push_back(l);
|
|
||||||
}
|
} else if(f.type == "avgpool") {
|
||||||
|
netLayers.push_back(new tk::dnn::Pooling(net, f.size_x, f.size_y, f.stride_x, f.stride_y,
|
||||||
|
f.padding_x, f.padding_y, tk::dnn::POOLING_AVERAGE));
|
||||||
|
|
||||||
} else if(f.type == "shortcut") {
|
} else if(f.type == "shortcut") {
|
||||||
if(f.layers.size() != 1) FatalError("no layers to shortcut\n");
|
if(f.layers.size() != 1) FatalError("no layers to shortcut\n");
|
||||||
int layerIdx = f.layers[0];
|
int layerIdx = f.layers[0];
|
||||||
@@ -177,6 +182,12 @@ namespace tk { namespace dnn {
|
|||||||
}
|
}
|
||||||
netLayers.push_back(new tk::dnn::Route(net, layers.data(), layers.size()));
|
netLayers.push_back(new tk::dnn::Route(net, layers.data(), layers.size()));
|
||||||
|
|
||||||
|
} else if(f.type == "reorg") {
|
||||||
|
netLayers.push_back(new tk::dnn::Reorg(net, f.stride_x));
|
||||||
|
|
||||||
|
} else if(f.type == "region") {
|
||||||
|
netLayers.push_back(new tk::dnn::Region(net, f.classes, f.coords, f.num));
|
||||||
|
|
||||||
} else if(f.type == "yolo") {
|
} else if(f.type == "yolo") {
|
||||||
std::string wgs = wgs_path + "/g" + std::to_string(netLayers.size()) + ".bin";
|
std::string wgs = wgs_path + "/g" + std::to_string(netLayers.size()) + ".bin";
|
||||||
printf("%d %d %s %d %f\n", f.classes, f.num/f.n_mask, wgs.c_str(), f.n_mask, f.scale_xy);
|
printf("%d %d %s %d %f\n", f.classes, f.num/f.n_mask, wgs.c_str(), f.n_mask, f.scale_xy);
|
||||||
@@ -189,6 +200,16 @@ namespace tk { namespace dnn {
|
|||||||
} else{
|
} else{
|
||||||
FatalError("layer not supported: " + f.type);
|
FatalError("layer not supported: " + f.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add activation
|
||||||
|
if(netLayers.size() > 0 && f.activation != "linear") {
|
||||||
|
tkdnnActivationMode_t act;
|
||||||
|
if(f.activation == "relu") act = tkdnnActivationMode_t(CUDNN_ACTIVATION_RELU);
|
||||||
|
else if(f.activation == "leaky") act = tk::dnn::ACTIVATION_LEAKY;
|
||||||
|
else if(f.activation == "mish") act = tk::dnn::ACTIVATION_MISH;
|
||||||
|
else { FatalError("activation not supported: " + f.activation); }
|
||||||
|
netLayers[netLayers.size()-1] = new tk::dnn::Activation(net, act);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> darknetReadNames(const std::string& names_file){
|
std::vector<std::string> darknetReadNames(const std::string& names_file){
|
||||||
@@ -244,7 +265,7 @@ namespace tk { namespace dnn {
|
|||||||
|
|
||||||
// new type
|
// new type
|
||||||
//std::cout<<"type: "<<type<<"\n";
|
//std::cout<<"type: "<<type<<"\n";
|
||||||
fields = darknetFields_t();
|
fields = darknetFields_t(); // reset to default
|
||||||
fields.type = type;
|
fields.type = type;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Network {
|
|||||||
public:
|
public:
|
||||||
Network(dataDim_t input_dim);
|
Network(dataDim_t input_dim);
|
||||||
virtual ~Network();
|
virtual ~Network();
|
||||||
|
void releaseLayers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Do inferece for every added layer
|
Do inferece for every added layer
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ int testInference(std::vector<std::string> input_bins, std::vector<std::string>
|
|||||||
if(net->layers[i]->final)
|
if(net->layers[i]->final)
|
||||||
outputs.push_back(net->layers[i]);
|
outputs.push_back(net->layers[i]);
|
||||||
}
|
}
|
||||||
|
// no final layers, set last as output
|
||||||
|
if(outputs.size() == 0) {
|
||||||
|
outputs.push_back(net->layers[net->num_layers-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// check input
|
// check input
|
||||||
if(input_bins.size() != 1) {
|
if(input_bins.size() != 1) {
|
||||||
|
|||||||
@@ -78,9 +78,10 @@ do
|
|||||||
test_net yolo3_512
|
test_net yolo3_512
|
||||||
test_net yolo3tiny
|
test_net yolo3tiny
|
||||||
test_net csresnext50-panet-spp
|
test_net csresnext50-panet-spp
|
||||||
|
#test_net csresnext50-panet-spp_berkeley
|
||||||
test_net mobilenetv2ssd
|
test_net mobilenetv2ssd
|
||||||
test_net yolo3tiny_512
|
test_net yolo3tiny_512
|
||||||
test_net yolo2tiny
|
#test_net yolo2tiny
|
||||||
test_net mobilenetv2ssd512
|
test_net mobilenetv2ssd512
|
||||||
test_net mnist
|
test_net mnist
|
||||||
test_net yolo2
|
test_net yolo2
|
||||||
|
|||||||
+6
-2
@@ -59,12 +59,16 @@ Network::Network(dataDim_t input_dim) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Network::~Network() {
|
Network::~Network() {
|
||||||
for(int i=0; i<num_layers; i++)
|
|
||||||
delete layers[i];
|
|
||||||
checkCUDNN( cudnnDestroy(cudnnHandle) );
|
checkCUDNN( cudnnDestroy(cudnnHandle) );
|
||||||
checkERROR( cublasDestroy(cublasHandle) );
|
checkERROR( cublasDestroy(cublasHandle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::releaseLayers() {
|
||||||
|
for(int i=0; i<num_layers; i++)
|
||||||
|
delete layers[i];
|
||||||
|
num_layers = 0;
|
||||||
|
}
|
||||||
|
|
||||||
dnnType* Network::infer(dataDim_t &dim, dnnType* data) {
|
dnnType* Network::infer(dataDim_t &dim, dnnType* data) {
|
||||||
|
|
||||||
//do infer for every layer
|
//do infer for every layer
|
||||||
|
|||||||
+1
-2
@@ -12,8 +12,7 @@
|
|||||||
namespace tk { namespace dnn {
|
namespace tk { namespace dnn {
|
||||||
|
|
||||||
Region::Region(Network *net, int classes, int coords, int num) :
|
Region::Region(Network *net, int classes, int coords, int num) :
|
||||||
Layer(net) {
|
Layer(net) {
|
||||||
|
|
||||||
this->classes = classes;
|
this->classes = classes;
|
||||||
this->coords = coords;
|
this->coords = coords;
|
||||||
this->num = num;
|
this->num = num;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[net]
|
[net]
|
||||||
Training
|
# Training
|
||||||
batch=64
|
batch=64
|
||||||
subdivisions=8
|
subdivisions=8
|
||||||
# Testing
|
# Testing
|
||||||
@@ -90,9 +90,9 @@ stride=1
|
|||||||
pad=1
|
pad=1
|
||||||
activation=leaky
|
activation=leaky
|
||||||
|
|
||||||
#[maxpool]
|
[maxpool]
|
||||||
#size=2
|
size=2
|
||||||
#stride=1
|
stride=1
|
||||||
|
|
||||||
[convolutional]
|
[convolutional]
|
||||||
batch_normalize=1
|
batch_normalize=1
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "DarknetParser.h"
|
#include "DarknetParser.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::string bin_path = "bdd-csresnext50-panet-spp";
|
std::string bin_path = "csresnext50-panet-spp_berkeley";
|
||||||
std::vector<std::string> input_bins = {
|
std::vector<std::string> input_bins = {
|
||||||
bin_path + "/layers/input.bin"
|
bin_path + "/layers/input.bin"
|
||||||
};
|
};
|
||||||
@@ -17,6 +17,7 @@ int main() {
|
|||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg";
|
||||||
std::string name_path = "../tests/darknet/names/berkeley.names";
|
std::string name_path = "../tests/darknet/names/berkeley.names";
|
||||||
|
// FIXME: wrong weights
|
||||||
// downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
// downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
||||||
|
|
||||||
// parse darknet network
|
// parse darknet network
|
||||||
@@ -27,6 +28,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ int main() {
|
|||||||
bin_path + "/layers/input.bin"
|
bin_path + "/layers/input.bin"
|
||||||
};
|
};
|
||||||
std::vector<std::string> output_bins = {
|
std::vector<std::string> output_bins = {
|
||||||
bin_path + "layers/output.bin"
|
bin_path + "/layers/output.bin"
|
||||||
};
|
};
|
||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/yolo2.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/yolo2.cfg";
|
||||||
@@ -25,6 +25,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ int main() {
|
|||||||
bin_path + "/layers/input.bin"
|
bin_path + "/layers/input.bin"
|
||||||
};
|
};
|
||||||
std::vector<std::string> output_bins = {
|
std::vector<std::string> output_bins = {
|
||||||
bin_path + "layers/output.bin"
|
bin_path + "/layers/output.bin"
|
||||||
};
|
};
|
||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/yolo2tiny.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/yolo2tiny.cfg";
|
||||||
std::string name_path = "../tests/darknet/names/coco.names";
|
std::string name_path = "../tests/darknet/names/coco.names";
|
||||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download");
|
// FIXME: wrong weights
|
||||||
|
//downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
||||||
|
|
||||||
// parse darknet network
|
// parse darknet network
|
||||||
tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path);
|
tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path);
|
||||||
@@ -25,6 +26,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ int main() {
|
|||||||
//convert network to tensorRT
|
//convert network to tensorRT
|
||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ int main() {
|
|||||||
};
|
};
|
||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/yolo3_berkeley.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/yolo3_berkeley.cfg";
|
||||||
std::string name_path = "../tests/darknet/names/barkeley.names";
|
std::string name_path = "../tests/darknet/names/berkeley.names";
|
||||||
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download");
|
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download");
|
||||||
|
|
||||||
// parse darknet network
|
// parse darknet network
|
||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ int main() {
|
|||||||
bin_path + "/layers/input.bin"
|
bin_path + "/layers/input.bin"
|
||||||
};
|
};
|
||||||
std::vector<std::string> output_bins = {
|
std::vector<std::string> output_bins = {
|
||||||
bin_path + "debug/layer23_out.bin",
|
bin_path + "/debug/layer16_out.bin",
|
||||||
|
bin_path + "/debug/layer23_out.bin",
|
||||||
};
|
};
|
||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny.cfg";
|
||||||
@@ -25,6 +26,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ int main() {
|
|||||||
bin_path + "/layers/input.bin"
|
bin_path + "/layers/input.bin"
|
||||||
};
|
};
|
||||||
std::vector<std::string> output_bins = {
|
std::vector<std::string> output_bins = {
|
||||||
bin_path + "debug/layer23_out.bin",
|
bin_path + "/debug/layer16_out.bin",
|
||||||
|
bin_path + "/debug/layer23_out.bin",
|
||||||
};
|
};
|
||||||
std::string wgs_path = bin_path + "/layers";
|
std::string wgs_path = bin_path + "/layers";
|
||||||
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny_512.cfg";
|
std::string cfg_path = "../tests/darknet/cfg/yolo3tiny_512.cfg";
|
||||||
@@ -25,6 +26,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -27,6 +27,7 @@ int main() {
|
|||||||
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
int ret = testInference(input_bins, output_bins, net, netRT);
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
delete net;
|
delete net;
|
||||||
delete netRT;
|
delete netRT;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#include<iostream>
|
||||||
|
#include<vector>
|
||||||
|
#include "tkdnn.h"
|
||||||
|
#include "test.h"
|
||||||
|
#include "DarknetParser.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::string bin_path = "yolo4_berkeley";
|
||||||
|
std::vector<std::string> input_bins = {
|
||||||
|
bin_path + "/layers/input.bin"
|
||||||
|
};
|
||||||
|
std::vector<std::string> output_bins = {
|
||||||
|
bin_path + "/debug/layer139_out.bin",
|
||||||
|
bin_path + "/debug/layer150_out.bin",
|
||||||
|
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";
|
||||||
|
downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download");
|
||||||
|
|
||||||
|
// parse darknet network
|
||||||
|
tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path);
|
||||||
|
net->print();
|
||||||
|
|
||||||
|
//convert network to tensorRT
|
||||||
|
tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str()));
|
||||||
|
|
||||||
|
int ret = testInference(input_bins, output_bins, net, netRT);
|
||||||
|
net->releaseLayers();
|
||||||
|
delete net;
|
||||||
|
delete netRT;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user