From 7c55dcb708fbd1c7a4a776503d5b948cce4db2fe Mon Sep 17 00:00:00 2001 From: Micaela Verucchi Date: Thu, 26 Mar 2020 15:06:49 +0100 Subject: [PATCH] Add tp tests for yolo3512 and yolo3tiny512 Signed-off-by: Micaela Verucchi --- CMakeLists.txt | 8 +- demo/config_tetra.yaml | 7 + demo/demo/map.cpp | 7 +- tests/yolo3_512tp/yolo3512.cfg | 787 ++++++++++++++++++++++ tests/yolo3_512tp/yolo3_512tp.cpp | 93 +++ tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp | 123 ++++ tests/yolo3_tiny512tp/yolo3tiny512.cfg | 182 +++++ 7 files changed, 1202 insertions(+), 5 deletions(-) create mode 100644 demo/config_tetra.yaml create mode 100644 tests/yolo3_512tp/yolo3512.cfg create mode 100644 tests/yolo3_512tp/yolo3_512tp.cpp create mode 100644 tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp create mode 100644 tests/yolo3_tiny512tp/yolo3tiny512.cfg diff --git a/CMakeLists.txt b/CMakeLists.txt index 88362f7..17b7e75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ find_package(yaml-cpp REQUIRED) file(GLOB tkdnn_SRC "src/*.cpp") set(tkdnn_LIBS kernels ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDNN_LIBRARIES} ${OpenCV_LIBS} yaml-cpp) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS} ${OPENCV_INCLUDE_DIRS} ${NVINFER_INCLUDES}) add_library(tkDNN SHARED ${tkdnn_SRC}) target_link_libraries(tkDNN ${tkdnn_LIBS} nvinfer_plugin) @@ -88,12 +88,18 @@ target_link_libraries(test_yolo3 tkDNN) add_executable(test_yolo3_512 tests/yolo3_512/yolo3_512.cpp) target_link_libraries(test_yolo3_512 tkDNN) +add_executable(test_yolo3_512tp tests/yolo3_512tp/yolo3_512tp.cpp) +target_link_libraries(test_yolo3_512tp tkDNN) + add_executable(test_yolo3_tiny tests/yolo3_tiny/yolo3_tiny.cpp) target_link_libraries(test_yolo3_tiny tkDNN) add_executable(test_yolo3_tiny512 tests/yolo3_tiny512/yolo3_tiny512.cpp) target_link_libraries(test_yolo3_tiny512 tkDNN) +add_executable(test_yolo3_tiny512tp tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp) +target_link_libraries(test_yolo3_tiny512tp tkDNN) + add_executable(test_yolo3_berkeley tests/yolo3_berkeley/yolo3_berkeley.cpp) target_link_libraries(test_yolo3_berkeley tkDNN) diff --git a/demo/config_tetra.yaml b/demo/config_tetra.yaml new file mode 100644 index 0000000..3bf56cc --- /dev/null +++ b/demo/config_tetra.yaml @@ -0,0 +1,7 @@ +classes : 3 #number of classes +map_points : 101 #number of recall points (0 for all, 101 for COCO, 11 PascalVOC) +map_levels : 10 #number of IoU step for the AP +map_step : 0.05 #step of IoU +IoU_thresh : 0.5 #starting IoU threshold +conf_thresh : 0.0 #threshold on the condifence of the bbox +verbose : false #print on screen information diff --git a/demo/demo/map.cpp b/demo/demo/map.cpp index 31ea821..69fc57b 100644 --- a/demo/demo/map.cpp +++ b/demo/demo/map.cpp @@ -42,10 +42,6 @@ int main(int argc, char *argv[]) int classes, map_points, map_levels; float map_step, IoU_thresh, conf_thresh; - //read mAP parameters - readParams( config_filename, classes, map_points, map_levels, map_step, - IoU_thresh, conf_thresh, verbose); - if(argc > 1) net = argv[1]; if(argc > 2) @@ -62,6 +58,9 @@ int main(int argc, char *argv[]) if(!fileExist(labels_path)) FatalError("Wrong labels file path."); + //read mAP parameters + readParams( config_filename, classes, map_points, map_levels, map_step, + IoU_thresh, conf_thresh, verbose); std::ofstream times; if(write_res_on_file) diff --git a/tests/yolo3_512tp/yolo3512.cfg b/tests/yolo3_512tp/yolo3512.cfg new file mode 100644 index 0000000..00ea6e9 --- /dev/null +++ b/tests/yolo3_512tp/yolo3512.cfg @@ -0,0 +1,787 @@ +[net] +# Testing +#batch=1 +#subdivisions=1 +# Training +batch=16 +subdivisions=1 +width=512 +height=512 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +# Downsample + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=32 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +# Downsample + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[shortcut] +from=-3 +activation=linear + +###################### + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=24 +activation=linear + + +[yolo] +mask = 6,7,8 +anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 +classes=3 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 61 + + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=512 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=24 +activation=linear + + +[yolo] +mask = 3,4,5 +anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 +classes=3 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + + + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 36 + + + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=256 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=24 +activation=linear + + +[yolo] +mask = 0,1,2 +anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 +classes=3 +num=9 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 diff --git a/tests/yolo3_512tp/yolo3_512tp.cpp b/tests/yolo3_512tp/yolo3_512tp.cpp new file mode 100644 index 0000000..935c03c --- /dev/null +++ b/tests/yolo3_512tp/yolo3_512tp.cpp @@ -0,0 +1,93 @@ +#include +#include +#include "tkdnn.h" + +int main() { + + // Network layout + tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); + tk::dnn::Network net(dim); + + // create yolo3 model + std::string bin_path = "../tests/yolo3_512tp"; + // downloadWeightsifDoNotExist("../tests/yolo3_512tp/layers/input.bin", bin_path, ); + int classes = 3; + tk::dnn::Yolo *yolo [3]; + #include "models/Yolo3.h" + + // fill classes names + for(int i=0; i<3; i++) { + yolo[i]->classesNames = {"Dent", "Wrinkle", "UnsealedFlaps"}; + } + + // Load input + dnnType *data; + dnnType *input_h; + readBinaryFile(input_bin, dim.tot(), &input_h, &data); + + //print network model + net.print(); + + //convert network to tensorRT + tk::dnn::NetworkRT netRT(&net, "yolo3_512tp.rt"); + + // the network have 3 outputs + tk::dnn::dataDim_t out_dim[3]; + for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; + dnnType *cudnn_out[3], *rt_out[3]; + + tk::dnn::dataDim_t dim1 = dim; //input dim + printCenteredTitle(" CUDNN inference ", '=', 30); { + dim1.print(); + TIMER_START + net.infer(dim1, data); + TIMER_STOP + dim1.print(); + } + for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; + + printCenteredTitle(" compute detections ", '=', 30); + TIMER_START + int ndets = 0; + tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); + for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); + tk::dnn::Yolo::mergeDetections(dets, ndets, classes); + + for(int j=0; j 0) + cl = c; + } + std::cout< +#include "tkdnn.h" + +const char *input_bin = "../tests/yolo3_tiny512tp/layers/input.bin"; +const char *c0_bin = "../tests/yolo3_tiny512tp/layers/c0.bin"; +const char *c2_bin = "../tests/yolo3_tiny512tp/layers/c2.bin"; +const char *c4_bin = "../tests/yolo3_tiny512tp/layers/c4.bin"; +const char *c6_bin = "../tests/yolo3_tiny512tp/layers/c6.bin"; +const char *c8_bin = "../tests/yolo3_tiny512tp/layers/c8.bin"; +const char *c10_bin = "../tests/yolo3_tiny512tp/layers/c10.bin"; +const char *c12_bin = "../tests/yolo3_tiny512tp/layers/c12.bin"; +const char *c13_bin = "../tests/yolo3_tiny512tp/layers/c13.bin"; +const char *c14_bin = "../tests/yolo3_tiny512tp/layers/c14.bin"; +const char *c15_bin = "../tests/yolo3_tiny512tp/layers/c15.bin"; +const char *c18_bin = "../tests/yolo3_tiny512tp/layers/c18.bin"; +const char *c21_bin = "../tests/yolo3_tiny512tp/layers/c21.bin"; +const char *c22_bin = "../tests/yolo3_tiny512tp/layers/c22.bin"; +const char *g16_bin = "../tests/yolo3_tiny512tp/layers/g16.bin"; +const char *g23_bin = "../tests/yolo3_tiny512tp/layers/g23.bin"; +// const char *output_bin = "../tests/yolo3_tiny512tp/layers/output.bin"; + +const char *output_bin = "../tests/yolo3_tiny512tp/debug/layer23_out.bin"; + +int main() { + + int classes = 3; + + // Network layout + tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); + tk::dnn::Network net(dim); + + + tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); + tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, tk::dnn::POOLING_MAX); + + tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); + tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, tk::dnn::POOLING_MAX); + + tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); + tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, tk::dnn::POOLING_MAX); + + tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); + tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p7(&net, 2, 2, 2, 2, tk::dnn::POOLING_MAX); + + tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); + tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p9(&net, 2, 2, 2, 2, tk::dnn::POOLING_MAX); + + tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); + tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Pooling p11(&net, 2, 2, 1, 1,0,0, tk::dnn::POOLING_MAX, false, true); + + tk::dnn::Conv2d c12(&net, 1024, 3, 3, 1, 1, 1, 1, c12_bin, true); + tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); + + tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); + tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); + tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Conv2d c15(&net, 24, 1, 1, 1, 1, 0, 0, c15_bin, false); + + tk::dnn::Yolo yolo0 (&net, classes, 2, g16_bin); + + tk::dnn::Layer *m17_layers[1] = { &a13 }; + tk::dnn::Route m17 (&net, m17_layers, 1); + tk::dnn::Conv2d c18(&net, 128, 1, 1, 1, 1, 0, 0, c18_bin, true); + tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Upsample u19 (&net, 2); + + tk::dnn::Layer *m20_layers[2] = { &u19, &a8 }; + tk::dnn::Route m20 (&net, m20_layers, 2); + + tk::dnn::Conv2d c21(&net, 256, 3, 3, 1, 1, 1, 1, c21_bin, true); + tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); + tk::dnn::Conv2d c22(&net, 24, 1, 1, 1, 1, 0, 0, c22_bin, false); + + tk::dnn::Yolo yolo1 (&net, classes, 2, g23_bin); + + // Load input + dnnType *data; + dnnType *input_h; + readBinaryFile(input_bin, dim.tot(), &input_h, &data); + + //print network model + net.print(); + + // convert network to tensorRT + tk::dnn::NetworkRT netRT(&net, "yolo3_tiny512tp.rt"); + + dnnType *out_data, *out_data2; // cudnn output, tensorRT output + + tk::dnn::dataDim_t dim1 = dim; //input dim + printCenteredTitle(" CUDNN inference ", '=', 30); { + dim1.print(); + TIMER_START + out_data = net.infer(dim1, data); + TIMER_STOP + dim1.print(); + } + + tk::dnn::dataDim_t dim2 = dim; + printCenteredTitle(" TENSORRT inference ", '=', 30); { + dim2.print(); + TIMER_START + out_data2 = netRT.infer(dim2, data); + TIMER_STOP + dim2.print(); + } + + printCenteredTitle(" CHECK RESULTS ", '=', 30); + dnnType *out, *out_h; + int out_dim = net.getOutputDim().tot(); + readBinaryFile(output_bin, out_dim, &out_h, &out); + std::cout<<"CUDNN vs correct"; checkResult(out_dim, out_data, out); + std::cout<<"TRT vs correct"; checkResult(out_dim, out_data2, out); + std::cout<<"CUDNN vs TRT "; checkResult(out_dim, out_data, out_data2); + + return 0; +} diff --git a/tests/yolo3_tiny512tp/yolo3tiny512.cfg b/tests/yolo3_tiny512tp/yolo3tiny512.cfg new file mode 100644 index 0000000..baecead --- /dev/null +++ b/tests/yolo3_tiny512tp/yolo3tiny512.cfg @@ -0,0 +1,182 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=2 +width=512 +height=512 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=16 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=1 + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +########### + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=24 +activation=linear + + + +[yolo] +mask = 3,4,5 +anchors = 10.638,16.801, 13.183,19.091, 24.568,12.24, 54.462,77.421, 29.199,210.49, 37.495,212.21 +classes=3 +num=6 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1 + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 8 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=24 +activation=linear + +[yolo] +mask = 0,1,2 +anchors = 10.638,16.801, 13.183,19.091, 24.568,12.24, 54.462,77.421, 29.199,210.49, 37.495,212.21 +classes=3 +num=6 +jitter=.3 +ignore_thresh = .7 +truth_thresh = 1 +random=1