all test ok
This commit is contained in:
@@ -124,7 +124,7 @@ namespace tk { namespace dnn {
|
||||
}
|
||||
|
||||
tk::dnn::Network *darknetAddNet(darknetFields_t &fields) {
|
||||
std::cout<<"Add Net: "<<fields.type<<"\n";
|
||||
//std::cout<<"Add Net: "<<fields.type<<"\n";
|
||||
dataDim_t dim(1, fields.channels, fields.height, fields.width);
|
||||
return new tk::dnn::Network(dim);
|
||||
}
|
||||
@@ -138,10 +138,10 @@ namespace tk { namespace dnn {
|
||||
if(f.pad == 1) {
|
||||
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") {
|
||||
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,
|
||||
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups);
|
||||
netLayers.push_back(l);
|
||||
@@ -163,7 +163,7 @@ namespace tk { namespace dnn {
|
||||
if(layerIdx < 0)
|
||||
layerIdx = netLayers.size() + layerIdx;
|
||||
if(layerIdx < 0 || layerIdx >= netLayers.size()) FatalError("impossible to shortcut\n");
|
||||
std::cout<<"shortcut to "<<layerIdx<<" "<<netLayers[layerIdx]->getLayerName()<<"\n";
|
||||
//std::cout<<"shortcut to "<<layerIdx<<" "<<netLayers[layerIdx]->getLayerName()<<"\n";
|
||||
netLayers.push_back(new tk::dnn::Shortcut(net, netLayers[layerIdx]));
|
||||
|
||||
} else if(f.type == "upsample") {
|
||||
@@ -177,7 +177,7 @@ namespace tk { namespace dnn {
|
||||
if(layerIdx < 0)
|
||||
layerIdx = netLayers.size() + layerIdx;
|
||||
if(layerIdx < 0 || layerIdx >= netLayers.size()) FatalError("impossible to route\n");
|
||||
std::cout<<"Route to "<<layerIdx<<" "<<netLayers[layerIdx]->getLayerName()<<"\n";
|
||||
//std::cout<<"Route to "<<layerIdx<<" "<<netLayers[layerIdx]->getLayerName()<<"\n";
|
||||
layers.push_back(netLayers[layerIdx]);
|
||||
}
|
||||
netLayers.push_back(new tk::dnn::Route(net, layers.data(), layers.size()));
|
||||
@@ -190,7 +190,7 @@ namespace tk { namespace dnn {
|
||||
|
||||
} else if(f.type == "yolo") {
|
||||
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);
|
||||
tk::dnn::Yolo *l = new tk::dnn::Yolo(net, f.classes, f.num/f.n_mask, wgs, f.n_mask, f.scale_xy);
|
||||
if(names.size() != f.classes)
|
||||
FatalError("Mismatch between number of classes and names");
|
||||
|
||||
@@ -106,14 +106,14 @@ class DetectionNN {
|
||||
originalSize.clear();
|
||||
if(TKDNN_VERBOSE) printCenteredTitle(" TENSORRT detection ", '=', 30);
|
||||
{
|
||||
TIMER_START
|
||||
TKDNN_TSTART
|
||||
for(int bi=0; bi<cur_batches;++bi){
|
||||
if(!frames[bi].data)
|
||||
FatalError("No image data feed to detection");
|
||||
originalSize.push_back(frames[bi].size());
|
||||
preprocess(frames[bi], bi);
|
||||
}
|
||||
TIMER_STOP
|
||||
TKDNN_TSTOP
|
||||
if(save_times) *times<<t_ns<<";";
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ class DetectionNN {
|
||||
dim.n = cur_batches;
|
||||
{
|
||||
if(TKDNN_VERBOSE) dim.print();
|
||||
TIMER_START
|
||||
TKDNN_TSTART
|
||||
netRT->infer(dim, input_d);
|
||||
TIMER_STOP
|
||||
TKDNN_TSTOP
|
||||
if(TKDNN_VERBOSE) dim.print();
|
||||
stats.push_back(t_ns);
|
||||
if(save_times) *times<<t_ns<<";";
|
||||
@@ -132,10 +132,10 @@ class DetectionNN {
|
||||
|
||||
batchDetected.clear();
|
||||
{
|
||||
TIMER_START
|
||||
TKDNN_TSTART
|
||||
for(int bi=0; bi<cur_batches;++bi)
|
||||
postprocess(bi, mAP);
|
||||
TIMER_STOP
|
||||
TKDNN_TSTOP
|
||||
if(save_times) *times<<t_ns<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ int testInference(std::vector<std::string> input_bins, std::vector<std::string>
|
||||
tk::dnn::dataDim_t dim1 = net->input_dim; //input dim
|
||||
printCenteredTitle(" CUDNN inference ", '=', 30); {
|
||||
dim1.print();
|
||||
TIMER_START
|
||||
TKDNN_TSTART
|
||||
net->infer(dim1, data);
|
||||
TIMER_STOP
|
||||
TKDNN_TSTOP
|
||||
dim1.print();
|
||||
}
|
||||
for(int i=0; i<outputs.size(); i++) cudnn_out[i] = outputs[i]->dstData;
|
||||
@@ -45,9 +45,9 @@ int testInference(std::vector<std::string> input_bins, std::vector<std::string>
|
||||
tk::dnn::dataDim_t dim2 = net->input_dim;
|
||||
printCenteredTitle(" TENSORRT inference ", '=', 30); {
|
||||
dim2.print();
|
||||
TIMER_START
|
||||
TKDNN_TSTART
|
||||
netRT->infer(dim2, data);
|
||||
TIMER_STOP
|
||||
TKDNN_TSTOP
|
||||
dim2.print();
|
||||
}
|
||||
for(int i=0; i<outputs.size(); i++) rt_out[i] = (dnnType*)netRT->buffersRT[i+1];
|
||||
|
||||
@@ -39,15 +39,15 @@
|
||||
#define TKDNN_VERBOSE 0
|
||||
|
||||
// Simple Timer
|
||||
#define TIMER_START timespec start, end; \
|
||||
#define TKDNN_TSTART timespec start, end; \
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
|
||||
#define TIMER_STOP_C(col, show) clock_gettime(CLOCK_MONOTONIC, &end); \
|
||||
#define TKDNN_TSTOP_C(col, show) clock_gettime(CLOCK_MONOTONIC, &end); \
|
||||
double t_ns = ((double)(end.tv_sec - start.tv_sec) * 1.0e9 + \
|
||||
(double)(end.tv_nsec - start.tv_nsec))/1.0e6; \
|
||||
if(show) std::cout<<col<<"Time:"<<std::setw(16)<<t_ns<<" ms\n"<<COL_END;
|
||||
|
||||
#define TIMER_STOP TIMER_STOP_C(COL_CYANB, TKDNN_VERBOSE)
|
||||
#define TKDNN_TSTOP TKDNN_TSTOP_C(COL_CYANB, TKDNN_VERBOSE)
|
||||
|
||||
/********************************************************
|
||||
* Prints the error message, and exits
|
||||
|
||||
Reference in New Issue
Block a user