Add bdd new tests, add BDD100K_val download, fix yolo3-512 link
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
@@ -115,6 +115,9 @@ target_link_libraries(test_yolo3_flir tkDNN)
|
||||
add_executable(test_mobilenetv2ssd tests/mobilenetv2ssd/mobilenetv2ssd.cpp)
|
||||
target_link_libraries(test_mobilenetv2ssd tkDNN)
|
||||
|
||||
add_executable(test_bdd-mobilenetv2ssd tests/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp)
|
||||
target_link_libraries(test_bdd-mobilenetv2ssd tkDNN)
|
||||
|
||||
add_executable(test_mobilenetv2ssd512 tests/mobilenetv2ssd512/mobilenetv2ssd512.cpp)
|
||||
target_link_libraries(test_mobilenetv2ssd512 tkDNN)
|
||||
|
||||
@@ -124,6 +127,9 @@ target_link_libraries(test_resnet101 tkDNN)
|
||||
add_executable(test_csresnext50-panet-spp tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp)
|
||||
target_link_libraries(test_csresnext50-panet-spp tkDNN)
|
||||
|
||||
add_executable(test_bdd-csresnext50-panet-spp tests/bdd-csresnext50-panet-spp/bdd-csresnext50-panet-spp.cpp)
|
||||
target_link_libraries(test_bdd-csresnext50-panet-spp tkDNN)
|
||||
|
||||
add_executable(test_resnet101_cnet tests/resnet101_cnet/resnet101_cnet.cpp)
|
||||
target_link_libraries(test_resnet101_cnet tkDNN)
|
||||
|
||||
|
||||
@@ -167,10 +167,16 @@ N.b. INT8 calibration requires TensorRT version greater than or equal to 6.0
|
||||
|
||||
To compute mAP, precision, recall and f1score, run the map_demo.
|
||||
|
||||
A validation set is needed. To download COCO_val2017 run (form the root folder):
|
||||
A validation set is needed.
|
||||
To download COCO_val2017 (80 classes) run (form the root folder):
|
||||
```
|
||||
bash scripts/download_validation.sh
|
||||
bash scripts/download_validation.sh COCO
|
||||
```
|
||||
To download Berkeley_val (10 classes) run (form the root folder):
|
||||
```
|
||||
bash scripts/download_validation.sh BDD
|
||||
```
|
||||
|
||||
To compute the map, the following parameters are needed:
|
||||
```
|
||||
./map_demo <network rt> <network type [y|c|m]> <labels file path> <config file path>
|
||||
@@ -199,7 +205,7 @@ cd build
|
||||
| yolo_tiny | YOLO v2 tiny<sup>1</sup> | [COCO 2014](http://cocodataset.org/) | 80 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/m3orfJr8pGrN5mQ/download) |
|
||||
| yolo_voc | YOLO v2<sup>1</sup> | [VOC ](http://host.robots.ox.ac.uk/pascal/VOC/) | 21 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/DJC5Fi2pEjfNDP9/download) |
|
||||
| yolo3 | YOLO v3<sup>2</sup> | [COCO 2014](http://cocodataset.org/) | 80 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download) |
|
||||
| yolo3_512 | YOLO v3<sup>2</sup> | [COCO 2017](http://cocodataset.org/) | 80 | 512x512 | [weights](https://cloud.hipert.unimore.it/s/e7HfScx77JEHeYb/download) |
|
||||
| yolo3_512 | YOLO v3<sup>2</sup> | [COCO 2017](http://cocodataset.org/) | 80 | 512x512 | [weights](https://cloud.hipert.unimore.it/s/RGecMeGLD4cXEWL/download) |
|
||||
| yolo3_berkeley | YOLO v3<sup>2</sup> | [BDD100K ](https://bair.berkeley.edu/blog/2018/05/30/bdd/) | 10 | 320x544 | [weights](https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download) |
|
||||
| yolo3_coco4 | YOLO v3<sup>2</sup> | [COCO 2014](http://cocodataset.org/) | 4 | 416x416 | [weights](https://cloud.hipert.unimore.it/s/o27NDzSAartbyc4/download) |
|
||||
| yolo3_flir | YOLO v3<sup>2</sup> | [FREE FLIR](https://www.flir.com/oem/adas/adas-dataset-form/) | 3 | 320x544 | [weights](https://cloud.hipert.unimore.it/s/62DECncmF6bMMiH/download) |
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
function elaborate_testset {
|
||||
wget $1 -O $2.zip
|
||||
unzip -d $2 $2.zip
|
||||
rm $2.zip
|
||||
cd $2/
|
||||
realpath labels/* > all_labels.txt
|
||||
realpath images/* > all_images.txt
|
||||
cd ..
|
||||
}
|
||||
|
||||
cd demo
|
||||
wget https://cloud.hipert.unimore.it/s/LNxBDk4wzqXPL8c/download -O COCO_val2017.zip
|
||||
unzip -d COCO_val2017 COCO_val2017.zip
|
||||
rm COCO_val2017.zip
|
||||
cd COCO_val2017/
|
||||
realpath labels/* > all_labels.txt
|
||||
for valset in $@
|
||||
do
|
||||
|
||||
if [ $valset = "COCO" ]; then
|
||||
echo "Downloading $valset validation set in demo"
|
||||
elaborate_testset "https://cloud.hipert.unimore.it/s/LNxBDk4wzqXPL8c/download" "COCO_val2017"
|
||||
elif [ $valset = "BDD" ]; then
|
||||
echo "Downloading $valset validation set in demo"
|
||||
elaborate_testset "https://cloud.hipert.unimore.it/s/bikqk3FzCq2tg4D/download" "BDD100K_val"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
@@ -172,7 +172,12 @@ bool MobilenetDetection::init(const std::string& tensor_path, const int n_classe
|
||||
colors[c] = cv::Scalar(int(255.0 * b), int(255.0 * g), int(255.0 * r));
|
||||
}
|
||||
|
||||
if(classes == 21){
|
||||
if(classes == 11){ //BDD
|
||||
const char *classes_names_[] = {
|
||||
"person","car","truck","bus","motor","bike","rider","traffic light","traffic sign","train"};
|
||||
classesNames = std::vector<std::string>(classes_names_, std::end(classes_names_));
|
||||
}
|
||||
else if(classes == 21){ //VOC
|
||||
const char *classes_names_[] = {
|
||||
"aeroplane", "bicycle", "bird", "boat", "bottle", "bus",
|
||||
"car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike",
|
||||
@@ -180,7 +185,7 @@ bool MobilenetDetection::init(const std::string& tensor_path, const int n_classe
|
||||
classesNames = std::vector<std::string>(classes_names_, std::end(classes_names_));
|
||||
|
||||
}
|
||||
else if (classes == 81){
|
||||
else if (classes == 81){ //COCO
|
||||
const char *classes_names_[] = {
|
||||
"person" , "bicycle" , "car" , "motorbike" , "aeroplane" , "bus" ,
|
||||
"train" , "truck" , "boat" , "traffic light" , "fire hydrant" , "stop sign" ,
|
||||
|
||||
@@ -0,0 +1,554 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "tkdnn.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
// Network layout
|
||||
tk::dnn::dataDim_t dim(1, 3, 320, 544, 1);
|
||||
tk::dnn::Network net(dim);
|
||||
|
||||
// create bdd-csresnext50-panet-spp model
|
||||
std::string bin_path = "bdd-csresnext50-panet-spp";
|
||||
int classes = 10;
|
||||
tk::dnn::Yolo *yolo[3];
|
||||
|
||||
std::string input_bin = bin_path + "/layers/input.bin";
|
||||
std::string output_bin = bin_path + "/debug/layer137_out.bin";
|
||||
std::vector<std::string> output_bins = {
|
||||
bin_path + "/debug/layer115_out.bin",
|
||||
bin_path + "/debug/layer126_out.bin",
|
||||
bin_path + "/debug/layer137_out.bin"};
|
||||
std::string c0_bin = bin_path + "/layers/c0.bin";
|
||||
std::string c2_bin = bin_path + "/layers/c2.bin";
|
||||
std::string c4_bin = bin_path + "/layers/c4.bin";
|
||||
std::string c5_bin = bin_path + "/layers/c5.bin";
|
||||
std::string c6_bin = bin_path + "/layers/c6.bin";
|
||||
std::string c7_bin = bin_path + "/layers/c7.bin";
|
||||
std::string c9_bin = bin_path + "/layers/c9.bin";
|
||||
std::string c10_bin = bin_path + "/layers/c10.bin";
|
||||
std::string c11_bin = bin_path + "/layers/c11.bin";
|
||||
std::string c13_bin = bin_path + "/layers/c13.bin";
|
||||
std::string c14_bin = bin_path + "/layers/c14.bin";
|
||||
std::string c15_bin = bin_path + "/layers/c15.bin";
|
||||
std::string c17_bin = bin_path + "/layers/c17.bin";
|
||||
std::string c19_bin = bin_path + "/layers/c19.bin";
|
||||
std::string c20_bin = bin_path + "/layers/c20.bin";
|
||||
std::string c21_bin = bin_path + "/layers/c21.bin";
|
||||
std::string c23_bin = bin_path + "/layers/c23.bin";
|
||||
std::string c24_bin = bin_path + "/layers/c24.bin";
|
||||
std::string c25_bin = bin_path + "/layers/c25.bin";
|
||||
std::string c26_bin = bin_path + "/layers/c26.bin";
|
||||
std::string c28_bin = bin_path + "/layers/c28.bin";
|
||||
std::string c29_bin = bin_path + "/layers/c29.bin";
|
||||
std::string c30_bin = bin_path + "/layers/c30.bin";
|
||||
std::string c32_bin = bin_path + "/layers/c32.bin";
|
||||
std::string c33_bin = bin_path + "/layers/c33.bin";
|
||||
std::string c34_bin = bin_path + "/layers/c34.bin";
|
||||
std::string c36_bin = bin_path + "/layers/c36.bin";
|
||||
std::string c38_bin = bin_path + "/layers/c38.bin";
|
||||
std::string c39_bin = bin_path + "/layers/c39.bin";
|
||||
std::string c40_bin = bin_path + "/layers/c40.bin";
|
||||
std::string c42_bin = bin_path + "/layers/c42.bin";
|
||||
std::string c43_bin = bin_path + "/layers/c43.bin";
|
||||
std::string c44_bin = bin_path + "/layers/c44.bin";
|
||||
std::string c45_bin = bin_path + "/layers/c45.bin";
|
||||
std::string c47_bin = bin_path + "/layers/c47.bin";
|
||||
std::string c48_bin = bin_path + "/layers/c48.bin";
|
||||
std::string c49_bin = bin_path + "/layers/c49.bin";
|
||||
std::string c51_bin = bin_path + "/layers/c51.bin";
|
||||
std::string c52_bin = bin_path + "/layers/c52.bin";
|
||||
std::string c53_bin = bin_path + "/layers/c53.bin";
|
||||
std::string c55_bin = bin_path + "/layers/c55.bin";
|
||||
std::string c56_bin = bin_path + "/layers/c56.bin";
|
||||
std::string c57_bin = bin_path + "/layers/c57.bin";
|
||||
std::string c59_bin = bin_path + "/layers/c59.bin";
|
||||
std::string c60_bin = bin_path + "/layers/c60.bin";
|
||||
std::string c61_bin = bin_path + "/layers/c61.bin";
|
||||
std::string c63_bin = bin_path + "/layers/c63.bin";
|
||||
std::string c65_bin = bin_path + "/layers/c65.bin";
|
||||
std::string c66_bin = bin_path + "/layers/c66.bin";
|
||||
std::string c67_bin = bin_path + "/layers/c67.bin";
|
||||
std::string c69_bin = bin_path + "/layers/c69.bin";
|
||||
std::string c70_bin = bin_path + "/layers/c70.bin";
|
||||
std::string c71_bin = bin_path + "/layers/c71.bin";
|
||||
std::string c72_bin = bin_path + "/layers/c72.bin";
|
||||
std::string c74_bin = bin_path + "/layers/c74.bin";
|
||||
std::string c75_bin = bin_path + "/layers/c75.bin";
|
||||
std::string c76_bin = bin_path + "/layers/c76.bin";
|
||||
std::string c78_bin = bin_path + "/layers/c78.bin";
|
||||
std::string c80_bin = bin_path + "/layers/c80.bin";
|
||||
std::string c81_bin = bin_path + "/layers/c81.bin";
|
||||
std::string c82_bin = bin_path + "/layers/c82.bin";
|
||||
std::string c83_bin = bin_path + "/layers/c83.bin";
|
||||
std::string c90_bin = bin_path + "/layers/c90.bin";
|
||||
std::string c91_bin = bin_path + "/layers/c91.bin";
|
||||
std::string c92_bin = bin_path + "/layers/c92.bin";
|
||||
std::string c93_bin = bin_path + "/layers/c93.bin";
|
||||
std::string c96_bin = bin_path + "/layers/c96.bin";
|
||||
std::string c98_bin = bin_path + "/layers/c98.bin";
|
||||
std::string c99_bin = bin_path + "/layers/c99.bin";
|
||||
std::string c100_bin = bin_path + "/layers/c100.bin";
|
||||
std::string c101_bin = bin_path + "/layers/c101.bin";
|
||||
std::string c102_bin = bin_path + "/layers/c102.bin";
|
||||
std::string c103_bin = bin_path + "/layers/c103.bin";
|
||||
std::string c106_bin = bin_path + "/layers/c106.bin";
|
||||
std::string c108_bin = bin_path + "/layers/c108.bin";
|
||||
std::string c109_bin = bin_path + "/layers/c109.bin";
|
||||
std::string c110_bin = bin_path + "/layers/c110.bin";
|
||||
std::string c111_bin = bin_path + "/layers/c111.bin";
|
||||
std::string c112_bin = bin_path + "/layers/c112.bin";
|
||||
std::string c113_bin = bin_path + "/layers/c113.bin";
|
||||
std::string c114_bin = bin_path + "/layers/c114.bin";
|
||||
std::string c117_bin = bin_path + "/layers/c117.bin";
|
||||
std::string c119_bin = bin_path + "/layers/c119.bin";
|
||||
std::string c120_bin = bin_path + "/layers/c120.bin";
|
||||
std::string c121_bin = bin_path + "/layers/c121.bin";
|
||||
std::string c122_bin = bin_path + "/layers/c122.bin";
|
||||
std::string c123_bin = bin_path + "/layers/c123.bin";
|
||||
std::string c124_bin = bin_path + "/layers/c124.bin";
|
||||
std::string c125_bin = bin_path + "/layers/c125.bin";
|
||||
std::string c128_bin = bin_path + "/layers/c128.bin";
|
||||
std::string c130_bin = bin_path + "/layers/c130.bin";
|
||||
std::string c131_bin = bin_path + "/layers/c131.bin";
|
||||
std::string c132_bin = bin_path + "/layers/c132.bin";
|
||||
std::string c133_bin = bin_path + "/layers/c133.bin";
|
||||
std::string c134_bin = bin_path + "/layers/c134.bin";
|
||||
std::string c135_bin = bin_path + "/layers/c135.bin";
|
||||
std::string c136_bin = bin_path + "/layers/c136.bin";
|
||||
std::string g115_bin = bin_path + "/layers/g115.bin";
|
||||
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//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);
|
||||
|
||||
tk::dnn::Conv2d c2(&net, 128, 1, 1, 1, 1, 0, 0, c2_bin, true);
|
||||
tk::dnn::Activation a2(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r3_layers[1] = {&p1};
|
||||
tk::dnn::Route r3(&net, r3_layers, 1);
|
||||
|
||||
tk::dnn::Conv2d c4(&net, 64, 1, 1, 1, 1, 0, 0, c4_bin, true);
|
||||
tk::dnn::Activation a4(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
// //1-1
|
||||
tk::dnn::Conv2d c5(&net, 128, 1, 1, 1, 1, 0, 0, c5_bin, true);
|
||||
tk::dnn::Activation a5(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c6(&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true, false, 32, false);
|
||||
tk::dnn::Activation a6(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c7(&net, 128, 1, 1, 1, 1, 0, 0, c7_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s8(&net, &a4);
|
||||
tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//1-2
|
||||
tk::dnn::Conv2d c9(&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true);
|
||||
tk::dnn::Activation a9(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c10(&net, 128, 3, 3, 1, 1, 1, 1, c10_bin, true, false, 32);
|
||||
tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c11(&net, 128, 1, 1, 1, 1, 0, 0, c11_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s12(&net, &a8);
|
||||
tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//1-3
|
||||
tk::dnn::Conv2d c13(&net, 128, 1, 1, 1, 1, 0, 0, c13_bin, true);
|
||||
tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c14(&net, 128, 3, 3, 1, 1, 1, 1, c14_bin, true, false, 32);
|
||||
tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c15(&net, 128, 1, 1, 1, 1, 0, 0, c15_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s16(&net, &a12);
|
||||
tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
// //1-T
|
||||
tk::dnn::Conv2d c17(&net, 128, 1, 1, 1, 1, 0, 0, c17_bin, true);
|
||||
tk::dnn::Activation a17(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r18_layers[2] = {&a17, &a2};
|
||||
tk::dnn::Route r18(&net, r18_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c19(&net, 256, 1, 1, 1, 1, 0, 0, c19_bin, true);
|
||||
tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c20(&net, 256, 3, 3, 2, 2, 1, 1, c20_bin, true, false, 32);
|
||||
tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c21(&net, 256, 1, 1, 1, 1, 0, 0, c21_bin, true);
|
||||
|
||||
tk::dnn::Layer *r22_layers[2] = {&a20};
|
||||
tk::dnn::Route r22(&net, r22_layers, 1);
|
||||
|
||||
tk::dnn::Conv2d c23(&net, 256, 1, 1, 1, 1, 0, 0, c23_bin, true);
|
||||
|
||||
//2-1
|
||||
tk::dnn::Conv2d c24(&net, 256, 1, 1, 1, 1, 0, 0, c24_bin, true);
|
||||
tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c25(&net, 256, 3, 3, 1, 1, 1, 1, c25_bin, true, false, 32);
|
||||
tk::dnn::Activation a25(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c26(&net, 256, 1, 1, 1, 1, 0, 0, c26_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s27(&net, &c23);
|
||||
tk::dnn::Activation a27(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//2-2
|
||||
tk::dnn::Conv2d c28(&net, 256, 1, 1, 1, 1, 0, 0, c28_bin, true);
|
||||
tk::dnn::Activation a28(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c29(&net, 256, 3, 3, 1, 1, 1, 1, c29_bin, true, false, 32);
|
||||
tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c30(&net, 256, 1, 1, 1, 1, 0, 0, c30_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s31(&net, &a27);
|
||||
tk::dnn::Activation a31(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//2-3
|
||||
tk::dnn::Conv2d c32(&net, 256, 1, 1, 1, 1, 0, 0, c32_bin, true);
|
||||
tk::dnn::Activation a32(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c33(&net, 256, 3, 3, 1, 1, 1, 1, c33_bin, true, false, 32);
|
||||
tk::dnn::Activation a33(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c34(&net, 256, 1, 1, 1, 1, 0, 0, c34_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s35(&net, &a31);
|
||||
tk::dnn::Activation a35(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
// //2-T
|
||||
tk::dnn::Conv2d c36(&net, 256, 1, 1, 1, 1, 0, 0, c36_bin, true);
|
||||
tk::dnn::Activation a36(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r37_layers[2] = {&a36, &c21};
|
||||
tk::dnn::Route r37(&net, r37_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c38(&net, 512, 1, 1, 1, 1, 0, 0, c38_bin, true);
|
||||
tk::dnn::Activation a38(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c39(&net, 512, 3, 3, 2, 2, 1, 1, c39_bin, true, false, 32);
|
||||
tk::dnn::Activation a39(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c40(&net, 512, 1, 1, 1, 1, 0, 0, c40_bin, true);
|
||||
|
||||
tk::dnn::Layer *r41_layers[2] = {&a39};
|
||||
tk::dnn::Route r41(&net, r41_layers, 1);
|
||||
|
||||
tk::dnn::Conv2d c42(&net, 512, 1, 1, 1, 1, 0, 0, c42_bin, true);
|
||||
|
||||
//3-1
|
||||
tk::dnn::Conv2d c43(&net, 512, 1, 1, 1, 1, 0, 0, c43_bin, true);
|
||||
tk::dnn::Activation a43(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c44(&net, 512, 3, 3, 1, 1, 1, 1, c44_bin, true, false, 32);
|
||||
tk::dnn::Activation a44(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c45(&net, 512, 1, 1, 1, 1, 0, 0, c45_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s46(&net, &c42);
|
||||
tk::dnn::Activation a46(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//3-2
|
||||
tk::dnn::Conv2d c47(&net, 512, 1, 1, 1, 1, 0, 0, c47_bin, true);
|
||||
tk::dnn::Activation a47(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c48(&net, 512, 3, 3, 1, 1, 1, 1, c48_bin, true, false, 32);
|
||||
tk::dnn::Activation a48(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c49(&net, 512, 1, 1, 1, 1, 0, 0, c49_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s50(&net, &a46);
|
||||
tk::dnn::Activation a50(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//3-3
|
||||
tk::dnn::Conv2d c51(&net, 512, 1, 1, 1, 1, 0, 0, c51_bin, true);
|
||||
tk::dnn::Activation a51(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c52(&net, 512, 3, 3, 1, 1, 1, 1, c52_bin, true, false, 32);
|
||||
tk::dnn::Activation a52(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c53(&net, 512, 1, 1, 1, 1, 0, 0, c53_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s54(&net, &a50);
|
||||
tk::dnn::Activation a54(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//3-4
|
||||
tk::dnn::Conv2d c55(&net, 512, 1, 1, 1, 1, 0, 0, c55_bin, true);
|
||||
tk::dnn::Activation a55(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c56(&net, 512, 3, 3, 1, 1, 1, 1, c56_bin, true, false, 32);
|
||||
tk::dnn::Activation a56(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c57(&net, 512, 1, 1, 1, 1, 0, 0, c57_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s58(&net, &a54);
|
||||
tk::dnn::Activation a58(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//3-5
|
||||
tk::dnn::Conv2d c59(&net, 512, 1, 1, 1, 1, 0, 0, c59_bin, true);
|
||||
tk::dnn::Activation a59(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c60(&net, 512, 3, 3, 1, 1, 1, 1, c60_bin, true, false, 32);
|
||||
tk::dnn::Activation a60(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c61(&net, 512, 1, 1, 1, 1, 0, 0, c61_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s62(&net, &a58);
|
||||
tk::dnn::Activation a62(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//3-T
|
||||
tk::dnn::Conv2d c63(&net, 512, 1, 1, 1, 1, 0, 0, c63_bin, true);
|
||||
tk::dnn::Activation a63(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r64_layers[2] = {&a63, &c40};
|
||||
tk::dnn::Route r64(&net, r64_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c65(&net, 1024, 1, 1, 1, 1, 0, 0, c65_bin, true);
|
||||
tk::dnn::Activation a65(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c66(&net, 1024, 3, 3, 2, 2, 1, 1, c66_bin, true, false, 32);
|
||||
tk::dnn::Activation a66(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c67(&net, 1024, 1, 1, 1, 1, 0, 0, c67_bin, true);
|
||||
tk::dnn::Activation a67(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r68_layers[2] = {&a66};
|
||||
tk::dnn::Route r68(&net, r68_layers, 1);
|
||||
|
||||
tk::dnn::Conv2d c69(&net, 1024, 1, 1, 1, 1, 0, 0, c69_bin, true);
|
||||
tk::dnn::Activation a69(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//4-1
|
||||
tk::dnn::Conv2d c70(&net, 1024, 1, 1, 1, 1, 0, 0, c70_bin, true);
|
||||
tk::dnn::Activation a70(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c71(&net, 1024, 3, 3, 1, 1, 1, 1, c71_bin, true, false, 32);
|
||||
tk::dnn::Activation a71(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c72(&net, 1024, 1, 1, 1, 1, 0, 0, c72_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s73(&net, &a69);
|
||||
tk::dnn::Activation a73(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//4-2
|
||||
tk::dnn::Conv2d c74(&net, 1024, 1, 1, 1, 1, 0, 0, c74_bin, true);
|
||||
tk::dnn::Activation a74(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c75(&net, 1024, 3, 3, 1, 1, 1, 1, c75_bin, true, false, 32);
|
||||
tk::dnn::Activation a75(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c76(&net, 1024, 1, 1, 1, 1, 0, 0, c76_bin, true);
|
||||
|
||||
tk::dnn::Shortcut s77(&net, &a73);
|
||||
tk::dnn::Activation a77(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//4-T
|
||||
tk::dnn::Conv2d c78(&net, 1024, 1, 1, 1, 1, 0, 0, c78_bin, true);
|
||||
tk::dnn::Activation a78(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Layer *r79_layers[2] = {&a78, &a67};
|
||||
tk::dnn::Route r79(&net, r79_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c80(&net, 2048, 1, 1, 1, 1, 0, 0, c80_bin, true);
|
||||
tk::dnn::Activation a80(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
// ////////////////////
|
||||
|
||||
tk::dnn::Conv2d c81(&net, 512, 1, 1, 1, 1, 0, 0, c81_bin, true);
|
||||
tk::dnn::Activation a81(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c82(&net, 1024, 3, 3, 1, 1, 1, 1, c82_bin, true);
|
||||
tk::dnn::Activation a82(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c83(&net, 512, 1, 1, 1, 1, 0, 0, c83_bin, true);
|
||||
tk::dnn::Activation a83(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
//SPP
|
||||
tk::dnn::Pooling p84(&net, 5, 5, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE);
|
||||
tk::dnn::Layer *r85_layers[1] = {&a83};
|
||||
tk::dnn::Route r85(&net, r85_layers, 1);
|
||||
|
||||
tk::dnn::Pooling p86(&net, 9, 9, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE);
|
||||
tk::dnn::Layer *r87_layers[1] = {&a83};
|
||||
tk::dnn::Route r87(&net, r87_layers, 1);
|
||||
|
||||
tk::dnn::Pooling p88(&net, 13, 13, 1, 1, 12, 12, tk::dnn::POOLING_MAX_FIXEDSIZE);
|
||||
tk::dnn::Layer *r89_layers[4] = {&p88, &p86, &p84, &a83};
|
||||
tk::dnn::Route r89(&net, r89_layers, 4);
|
||||
//END SPP
|
||||
|
||||
tk::dnn::Conv2d c90(&net, 512, 1, 1, 1, 1, 0, 0, c90_bin, true);
|
||||
tk::dnn::Activation a90(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c91(&net, 1024, 3, 3, 1, 1, 1, 1, c91_bin, true);
|
||||
tk::dnn::Activation a91(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c92(&net, 512, 1, 1, 1, 1, 0, 0, c92_bin, true);
|
||||
tk::dnn::Activation a92(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c93(&net, 256, 1, 1, 1, 1, 0, 0, c93_bin, true);
|
||||
tk::dnn::Activation a93(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Upsample u94(&net, 2);
|
||||
tk::dnn::Layer *r95_layers[1] = {&a65};
|
||||
tk::dnn::Route r95(&net, r95_layers, 1);
|
||||
tk::dnn::Conv2d c96(&net, 256, 1, 1, 1, 1, 0, 0, c96_bin, true);
|
||||
tk::dnn::Activation a96(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Layer *r97_layers[2] = {&a96,&u94};
|
||||
tk::dnn::Route r97(&net, r97_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c98(&net, 256, 1, 1, 1, 1, 0, 0, c98_bin, true);
|
||||
tk::dnn::Activation a98(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c99(&net, 512, 3, 3, 1, 1, 1, 1, c99_bin, true);
|
||||
tk::dnn::Activation a99(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c100(&net, 256, 1, 1, 1, 1, 0, 0, c100_bin, true);
|
||||
tk::dnn::Activation a100(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c101(&net, 512, 3, 3, 1, 1, 1, 1, c101_bin, true);
|
||||
tk::dnn::Activation a101(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c102(&net, 256, 1, 1, 1, 1, 0, 0, c102_bin, true);
|
||||
tk::dnn::Activation a102(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c103(&net, 128, 1, 1, 1, 1, 0, 0, c103_bin, true);
|
||||
tk::dnn::Activation a103(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Upsample u104(&net, 2);
|
||||
tk::dnn::Layer *r105_layers[1] = {&a38};
|
||||
tk::dnn::Route r105(&net, r105_layers, 1);
|
||||
tk::dnn::Conv2d c106(&net, 128, 1, 1, 1, 1, 0, 0, c106_bin, true);
|
||||
tk::dnn::Activation a106(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Layer *r107_layers[2] = {&a106,&u104};
|
||||
tk::dnn::Route r107(&net, r107_layers, 2);
|
||||
|
||||
|
||||
tk::dnn::Conv2d c108(&net, 128, 1, 1, 1, 1, 0, 0, c108_bin, true);
|
||||
tk::dnn::Activation a108(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c109(&net, 256, 3, 3, 1, 1, 1, 1, c109_bin, true);
|
||||
tk::dnn::Activation a109(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c110(&net, 128, 1, 1, 1, 1, 0, 0, c110_bin, true);
|
||||
tk::dnn::Activation a110(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c111(&net, 256, 3, 3, 1, 1, 1, 1, c111_bin, true);
|
||||
tk::dnn::Activation a111(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c112(&net, 128, 1, 1, 1, 1, 0, 0, c112_bin, true);
|
||||
tk::dnn::Activation a112(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
// ###########################
|
||||
|
||||
tk::dnn::Conv2d c113(&net, 256, 3, 3, 1, 1, 1, 1, c113_bin, true);
|
||||
tk::dnn::Activation a113(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c114(&net, 45, 1, 1, 1, 1, 0, 0, c114_bin, false);
|
||||
tk::dnn::Yolo yolo115(&net, classes, 3, g115_bin);
|
||||
|
||||
tk::dnn::Layer *r116_layers[1] = {&a112};
|
||||
tk::dnn::Route r116(&net, r116_layers, 1);
|
||||
tk::dnn::Conv2d c117(&net, 256, 3, 3, 2, 2, 1, 1, c117_bin, true);
|
||||
tk::dnn::Activation a117(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Layer *r118_layers[2] = {&a117,&a102};
|
||||
tk::dnn::Route r118(&net, r118_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c119(&net, 256, 1, 1, 1, 1, 0, 0, c119_bin, true);
|
||||
tk::dnn::Activation a119(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c120(&net, 512, 3, 3, 1, 1, 1, 1, c120_bin, true);
|
||||
tk::dnn::Activation a120(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c121(&net, 256, 1, 1, 1, 1, 0, 0, c121_bin, true);
|
||||
tk::dnn::Activation a121(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c122(&net, 512, 3, 3, 1, 1, 1, 1, c122_bin, true);
|
||||
tk::dnn::Activation a122(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c123(&net, 256, 1, 1, 1, 1, 0, 0, c123_bin, true);
|
||||
tk::dnn::Activation a123(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Conv2d c124(&net, 512, 3, 3, 1, 1, 1, 1, c124_bin, true);
|
||||
tk::dnn::Activation a124(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c125(&net, 45, 1, 1, 1, 1, 0, 0, c125_bin, false);
|
||||
tk::dnn::Yolo yolo126(&net, classes, 3, g126_bin);
|
||||
|
||||
tk::dnn::Layer *r127_layers[1] = {&a123};
|
||||
tk::dnn::Route r127(&net, r127_layers, 1);
|
||||
tk::dnn::Conv2d c128(&net, 512, 3, 3, 2, 2, 1, 1, c128_bin, true);
|
||||
tk::dnn::Activation a128(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Layer *r129_layers[2] = {&a128,&a92};
|
||||
tk::dnn::Route r129(&net, r129_layers, 2);
|
||||
|
||||
tk::dnn::Conv2d c130(&net, 512, 1, 1, 1, 1, 0, 0, c130_bin, true);
|
||||
tk::dnn::Activation a130(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c131(&net, 1024, 3, 3, 1, 1, 1, 1, c131_bin, true);
|
||||
tk::dnn::Activation a131(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c132(&net, 512, 1, 1, 1, 1, 0, 0, c132_bin, true);
|
||||
tk::dnn::Activation a132(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c133(&net, 1024, 3, 3, 1, 1, 1, 1, c133_bin, true);
|
||||
tk::dnn::Activation a133(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c134(&net, 512, 1, 1, 1, 1, 0, 0, c134_bin, true);
|
||||
tk::dnn::Activation a134(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
|
||||
tk::dnn::Conv2d c135(&net, 1024, 3, 3, 1, 1, 1, 1, c135_bin, true);
|
||||
tk::dnn::Activation a135(&net, tk::dnn::ACTIVATION_LEAKY);
|
||||
tk::dnn::Conv2d c136(&net, 45, 1, 1, 1, 1, 0, 0, c136_bin, false);
|
||||
tk::dnn::Yolo yolo137(&net, classes, 3, g137_bin);
|
||||
|
||||
yolo[0] = &yolo115;
|
||||
yolo[1] = &yolo126;
|
||||
yolo[2] = &yolo137;
|
||||
|
||||
// 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"};
|
||||
}
|
||||
|
||||
// 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, net.getNetworkRTName("bdd-csresnext50-panet-spp"));
|
||||
|
||||
// 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 < ndets; j++)
|
||||
{
|
||||
tk::dnn::Yolo::box b = dets[j].bbox;
|
||||
int x0 = (b.x - b.w / 2.);
|
||||
int x1 = (b.x + b.w / 2.);
|
||||
int y0 = (b.y - b.h / 2.);
|
||||
int y1 = (b.y + b.h / 2.);
|
||||
|
||||
int cl = 0;
|
||||
for (int c = 0; c < classes; ++c)
|
||||
{
|
||||
float prob = dets[j].prob[c];
|
||||
if (prob > 0)
|
||||
cl = c;
|
||||
}
|
||||
std::cout << cl << ": " << x0 << " " << y0 << " " << x1 << " " << y1 << "\n";
|
||||
}
|
||||
TIMER_STOP
|
||||
|
||||
tk::dnn::dataDim_t dim2 = dim;
|
||||
printCenteredTitle(" TENSORRT inference ", '=', 30);
|
||||
{
|
||||
dim2.print();
|
||||
TIMER_START
|
||||
netRT.infer(dim2, data);
|
||||
TIMER_STOP
|
||||
dim2.print();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
rt_out[i] = (dnnType *)netRT.buffersRT[i + 1];
|
||||
|
||||
int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
printCenteredTitle((std::string(" YOLO ") + std::to_string(i) + " CHECK RESULTS ").c_str(), '=', 30);
|
||||
dnnType *out, *out_h;
|
||||
int odim = out_dim[i].tot();
|
||||
readBinaryFile(output_bins[i], odim, &out_h, &out);
|
||||
std::cout<<"CUDNN vs correct";
|
||||
ret_cudnn |= checkResult(odim, cudnn_out[i], out) == 0 ? 0: ERROR_CUDNN;
|
||||
std::cout<<"TRT vs correct";
|
||||
ret_tensorrt |= checkResult(odim, rt_out[i], out) == 0 ? 0 : ERROR_TENSORRT;
|
||||
std::cout<<"CUDNN vs TRT ";
|
||||
ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
}
|
||||
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,546 @@
|
||||
#include <iostream>
|
||||
#include "tkdnn.h"
|
||||
|
||||
|
||||
const char *output_bin1 = "bdd-mobilenetv2ssd/debug/classification_headers-5.bin";
|
||||
const char *output_bin2 = "bdd-mobilenetv2ssd/debug/regression_headers-5.bin";
|
||||
const char *input_bin = "bdd-mobilenetv2ssd/debug/input.bin";
|
||||
|
||||
const char *conv0_bin = "bdd-mobilenetv2ssd/layers/base_net-0-0.bin";
|
||||
const char *inverted_residual1[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-1-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-1-conv-3.bin"};
|
||||
const char *inverted_residual2[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-2-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-2-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-2-conv-6.bin"};
|
||||
const char *inverted_residual3[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-3-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-3-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-3-conv-6.bin"};
|
||||
const char *inverted_residual4[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-4-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-4-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-4-conv-6.bin"};
|
||||
const char *inverted_residual5[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-5-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-5-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-5-conv-6.bin"};
|
||||
const char *inverted_residual6[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-6-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-6-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-6-conv-6.bin"};
|
||||
const char *inverted_residual7[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-7-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-7-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-7-conv-6.bin"};
|
||||
const char *inverted_residual8[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-8-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-8-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-8-conv-6.bin"};
|
||||
const char *inverted_residual9[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-9-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-9-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-9-conv-6.bin"};
|
||||
const char *inverted_residual10[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-10-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-10-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-10-conv-6.bin"};
|
||||
const char *inverted_residual11[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-11-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-11-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-11-conv-6.bin"};
|
||||
const char *inverted_residual12[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-12-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-12-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-12-conv-6.bin"};
|
||||
const char *inverted_residual13[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-13-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-13-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-13-conv-6.bin"};
|
||||
const char *inverted_residual14[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-14-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-14-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-14-conv-6.bin"};
|
||||
const char *inverted_residual15[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-15-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-15-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-15-conv-6.bin"};
|
||||
const char *inverted_residual16[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-16-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-16-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-16-conv-6.bin"};
|
||||
const char *inverted_residual17[] = {
|
||||
"bdd-mobilenetv2ssd/layers/base_net-17-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-17-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/base_net-17-conv-6.bin"};
|
||||
|
||||
const char *conv18 = "bdd-mobilenetv2ssd/layers/base_net-18-0.bin";
|
||||
|
||||
const char *extras0[] = {
|
||||
"bdd-mobilenetv2ssd/layers/extras-0-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-0-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-0-conv-6.bin"};
|
||||
const char *extras1[] = {
|
||||
"bdd-mobilenetv2ssd/layers/extras-1-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-1-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-1-conv-6.bin"};
|
||||
const char *extras2[] = {
|
||||
"bdd-mobilenetv2ssd/layers/extras-2-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-2-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-2-conv-6.bin"};
|
||||
const char *extras3[] = {
|
||||
"bdd-mobilenetv2ssd/layers/extras-3-conv-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-3-conv-3.bin",
|
||||
"bdd-mobilenetv2ssd/layers/extras-3-conv-6.bin"};
|
||||
|
||||
const char *classification_header0[] = {
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-0-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-0-3.bin"};
|
||||
const char *classification_header1[] = {
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-1-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-1-3.bin"};
|
||||
const char *classification_header2[] = {
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-2-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-2-3.bin"};
|
||||
const char *classification_header3[] = {
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-3-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-3-3.bin"};
|
||||
const char *classification_header4[] = {
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-4-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/classification_headers-4-3.bin"};
|
||||
|
||||
const char *classification_header5 = "bdd-mobilenetv2ssd/layers/classification_headers-5.bin";
|
||||
|
||||
const char *regression_header0[] = {
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-0-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-0-3.bin"};
|
||||
const char *regression_header1[] = {
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-1-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-1-3.bin"};
|
||||
const char *regression_header2[] = {
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-2-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-2-3.bin"};
|
||||
const char *regression_header3[] = {
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-3-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-3-3.bin"};
|
||||
const char *regression_header4[] = {
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-4-0.bin",
|
||||
"bdd-mobilenetv2ssd/layers/regression_headers-4-3.bin"};
|
||||
|
||||
const char *regression_header5 = "bdd-mobilenetv2ssd/layers/regression_headers-5.bin";
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
// downloadWeightsifDoNotExist(input_bin, "bdd-mobilenetv2ssd", "https://cloud.hipert.unimore.it/s//download");
|
||||
|
||||
int classes = 11;
|
||||
|
||||
// Network layout
|
||||
tk::dnn::dataDim_t dim(1, 3, 300, 300, 1);
|
||||
tk::dnn::Network net(dim);
|
||||
|
||||
tk::dnn::Conv2d conv1(&net, 32, 3, 3, 2, 2, 1, 1, conv0_bin, true);
|
||||
tk::dnn::Activation relu3(&net, CUDNN_ACTIVATION_RELU);
|
||||
|
||||
//Inverted Residual 1
|
||||
|
||||
tk::dnn::Conv2d conv2(&net, 32, 3, 3, 1, 1, 1, 1, inverted_residual1[0], true, false, 32);
|
||||
tk::dnn::Activation relu5(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d conv3(&net, 16, 1, 1, 1, 1, 0, 0, inverted_residual1[1], true);
|
||||
|
||||
//Inverted Residual 2
|
||||
tk::dnn::Conv2d ir_2_conv1(&net, 96, 1, 1, 1, 1, 0, 0, inverted_residual2[0], true);
|
||||
tk::dnn::Activation relu_2_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_2_conv2(&net, 96, 3, 3, 2, 2, 1, 1, inverted_residual2[1], true, false, 96);
|
||||
tk::dnn::Activation relu_2_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_2_conv3(&net, 24, 1, 1, 1, 1, 0, 0, inverted_residual2[2], true);
|
||||
|
||||
//Inverted Residual 3
|
||||
tk::dnn::Layer *last = &ir_2_conv3;
|
||||
tk::dnn::Conv2d ir_3_conv1(&net, 144, 1, 1, 1, 1, 0, 0, inverted_residual3[0], true);
|
||||
tk::dnn::Activation relu_3_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_3_conv2(&net, 144, 3, 3, 1, 1, 1, 1, inverted_residual3[1], true, false, 144);
|
||||
tk::dnn::Activation relu_3_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_3_conv3(&net, 24, 1, 1, 1, 1, 0, 0, inverted_residual3[2], true);
|
||||
|
||||
tk::dnn::Shortcut s3_0(&net, last);
|
||||
// //Inverted Residual 4
|
||||
tk::dnn::Conv2d ir_4_conv1(&net, 144, 1, 1, 1, 1, 0, 0, inverted_residual4[0], true);
|
||||
tk::dnn::Activation relu_4_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_4_conv2(&net, 144, 3, 3, 2, 2, 1, 1, inverted_residual4[1], true, false, 144);
|
||||
tk::dnn::Activation relu_4_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_4_conv3(&net, 32, 1, 1, 1, 1, 0, 0, inverted_residual4[2], true);
|
||||
|
||||
// // //Inverted Residual 5
|
||||
last = &ir_4_conv3;
|
||||
tk::dnn::Conv2d ir_5_conv1(&net, 192, 1, 1, 1, 1, 0, 0, inverted_residual5[0], true);
|
||||
tk::dnn::Activation relu_5_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_5_conv2(&net, 192, 3, 3, 1, 1, 1, 1, inverted_residual5[1], true, false, 192);
|
||||
tk::dnn::Activation relu_5_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_5_conv3(&net, 32, 1, 1, 1, 1, 0, 0, inverted_residual5[2], true);
|
||||
|
||||
tk::dnn::Shortcut s5_0(&net, last);
|
||||
// // // //Inverted Residual 6
|
||||
last = &s5_0;
|
||||
tk::dnn::Conv2d ir_6_conv1(&net, 192, 1, 1, 1, 1, 0, 0, inverted_residual6[0], true);
|
||||
tk::dnn::Activation relu_6_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_6_conv2(&net, 192, 3, 3, 1, 1, 1, 1, inverted_residual6[1], true, false, 192);
|
||||
tk::dnn::Activation relu_6_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_6_conv3(&net, 32, 1, 1, 1, 1, 0, 0, inverted_residual6[2], true);
|
||||
|
||||
tk::dnn::Shortcut s6_0(&net, last);
|
||||
//Inverted Residual 7
|
||||
tk::dnn::Conv2d ir_7_conv1(&net, 192, 1, 1, 1, 1, 0, 0, inverted_residual7[0], true);
|
||||
tk::dnn::Activation relu_7_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_7_conv2(&net, 192, 3, 3, 2, 2, 1, 1, inverted_residual7[1], true, false, 192);
|
||||
tk::dnn::Activation relu_7_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_7_conv3(&net, 64, 1, 1, 1, 1, 0, 0, inverted_residual7[2], true);
|
||||
|
||||
// //Inverted Residual 8
|
||||
last = &ir_7_conv3;
|
||||
tk::dnn::Conv2d ir_8_conv1(&net, 384, 1, 1, 1, 1, 0, 0, inverted_residual8[0], true);
|
||||
tk::dnn::Activation relu_8_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_8_conv2(&net, 384, 3, 3, 1, 1, 1, 1, inverted_residual8[1], true, false, 384);
|
||||
tk::dnn::Activation relu_8_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_8_conv3(&net, 64, 1, 1, 1, 1, 0, 0, inverted_residual8[2], true);
|
||||
|
||||
tk::dnn::Shortcut s8_0(&net, last);
|
||||
//Inverted Residual 9
|
||||
last = &s8_0;
|
||||
tk::dnn::Conv2d ir_9_conv1(&net, 384, 1, 1, 1, 1, 0, 0, inverted_residual9[0], true);
|
||||
tk::dnn::Activation relu_9_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_9_conv2(&net, 384, 3, 3, 1, 1, 1, 1, inverted_residual9[1], true, false, 384);
|
||||
tk::dnn::Activation relu_9_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_9_conv3(&net, 64, 1, 1, 1, 1, 0, 0, inverted_residual9[2], true);
|
||||
|
||||
tk::dnn::Shortcut s9_0(&net, last);
|
||||
//Inverted Residual 10
|
||||
last = &s9_0;
|
||||
tk::dnn::Conv2d ir_10_conv1(&net, 384, 1, 1, 1, 1, 0, 0, inverted_residual10[0], true);
|
||||
tk::dnn::Activation relu_10_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_10_conv2(&net, 384, 3, 3, 1, 1, 1, 1, inverted_residual10[1], true, false, 384);
|
||||
tk::dnn::Activation relu_10_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_10_conv3(&net, 64, 1, 1, 1, 1, 0, 0, inverted_residual10[2], true);
|
||||
|
||||
tk::dnn::Shortcut s10_0(&net, last);
|
||||
//Inverted Residual 11
|
||||
tk::dnn::Conv2d ir_11_conv1(&net, 384, 1, 1, 1, 1, 0, 0, inverted_residual11[0], true);
|
||||
tk::dnn::Activation relu_11_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_11_conv2(&net, 384, 3, 3, 1, 1, 1, 1, inverted_residual11[1], true, false, 384);
|
||||
tk::dnn::Activation relu_11_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_11_conv3(&net, 96, 1, 1, 1, 1, 0, 0, inverted_residual11[2], true);
|
||||
|
||||
last = &ir_11_conv3;
|
||||
//Inverted Residual 12
|
||||
tk::dnn::Conv2d ir_12_conv1(&net, 576, 1, 1, 1, 1, 0, 0, inverted_residual12[0], true);
|
||||
tk::dnn::Activation relu_12_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_12_conv2(&net, 576, 3, 3, 1, 1, 1, 1, inverted_residual12[1], true, false, 576);
|
||||
tk::dnn::Activation relu_12_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_12_conv3(&net, 96, 1, 1, 1, 1, 0, 0, inverted_residual12[2], true);
|
||||
|
||||
tk::dnn::Shortcut s12_0(&net, last);
|
||||
last = &s12_0;
|
||||
//Inverted Residual 13
|
||||
tk::dnn::Conv2d ir_13_conv1(&net, 576, 1, 1, 1, 1, 0, 0, inverted_residual13[0], true);
|
||||
tk::dnn::Activation relu_13_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_13_conv2(&net, 576, 3, 3, 1, 1, 1, 1, inverted_residual13[1], true, false, 576);
|
||||
tk::dnn::Activation relu_13_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_13_conv3(&net, 96, 1, 1, 1, 1, 0, 0, inverted_residual13[2], true);
|
||||
|
||||
tk::dnn::Shortcut s13_0(&net, last);
|
||||
// //Inverted Residual 14
|
||||
tk::dnn::Conv2d ir_14_conv1(&net, 576, 1, 1, 1, 1, 0, 0, inverted_residual14[0], true);
|
||||
tk::dnn::Activation relu_14_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_14_conv2(&net, 576, 3, 3, 2, 2, 1, 1, inverted_residual14[1], true, false, 576);
|
||||
tk::dnn::Activation relu_14_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_14_conv3(&net, 160, 1, 1, 1, 1, 0, 0, inverted_residual14[2], true);
|
||||
|
||||
// //Inverted Residual 15
|
||||
last = &ir_14_conv3;
|
||||
tk::dnn::Conv2d ir_15_conv1(&net, 960, 1, 1, 1, 1, 0, 0, inverted_residual15[0], true);
|
||||
tk::dnn::Activation relu_15_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_15_conv2(&net, 960, 3, 3, 1, 1, 1, 1, inverted_residual15[1], true, false, 960);
|
||||
tk::dnn::Activation relu_15_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_15_conv3(&net, 160, 1, 1, 1, 1, 0, 0, inverted_residual15[2], true);
|
||||
|
||||
tk::dnn::Shortcut s15_0(&net, last);
|
||||
//Inverted Residual 16
|
||||
last = &s15_0;
|
||||
tk::dnn::Conv2d ir_16_conv1(&net, 960, 1, 1, 1, 1, 0, 0, inverted_residual16[0], true);
|
||||
tk::dnn::Activation relu_16_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_16_conv2(&net, 960, 3, 3, 1, 1, 1, 1, inverted_residual16[1], true, false, 960);
|
||||
tk::dnn::Activation relu_16_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_16_conv3(&net, 160, 1, 1, 1, 1, 0, 0, inverted_residual16[2], true);
|
||||
|
||||
tk::dnn::Shortcut s16_0(&net, last);
|
||||
//Inverted Residual 17
|
||||
tk::dnn::Conv2d ir_17_conv1(&net, 960, 1, 1, 1, 1, 0, 0, inverted_residual17[0], true);
|
||||
tk::dnn::Activation relu_17_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_17_conv2(&net, 960, 3, 3, 1, 1, 1, 1, inverted_residual17[1], true, false, 960);
|
||||
tk::dnn::Activation relu_17_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d ir_17_conv3(&net, 320, 1, 1, 1, 1, 0, 0, inverted_residual17[2], true);
|
||||
|
||||
//Conv 18
|
||||
tk::dnn::Conv2d ir_18_conv1(&net, 1280, 1, 1, 1, 1, 0, 0, conv18, true);
|
||||
tk::dnn::Activation relu_18_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Layer *header_1[1] = {&relu_18_1};
|
||||
|
||||
// //extras Inverted Residual 0
|
||||
tk::dnn::Conv2d e_0_conv1(&net, 256, 1, 1, 1, 1, 0, 0, extras0[0], true);
|
||||
tk::dnn::Activation e_relu_0_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_0_conv2(&net, 256, 3, 3, 2, 2, 1, 1, extras0[1], true, false, 256);
|
||||
tk::dnn::Activation e_relu_0_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_0_conv3(&net, 512, 1, 1, 1, 1, 0, 0, extras0[2], true);
|
||||
tk::dnn::Layer *header_2[1] = {&e_0_conv3};
|
||||
|
||||
// //extras Inverted Residual 1
|
||||
tk::dnn::Conv2d e_1_conv1(&net, 128, 1, 1, 1, 1, 0, 0, extras1[0], true);
|
||||
tk::dnn::Activation e_relu_1_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_1_conv2(&net, 128, 3, 3, 2, 2, 1, 1, extras1[1], true, false, 128);
|
||||
tk::dnn::Activation e_relu_1_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_1_conv3(&net, 256, 1, 1, 1, 1, 0, 0, extras1[2], true);
|
||||
tk::dnn::Layer *header_3[1] = {&e_1_conv3};
|
||||
|
||||
//extras Inverted Residual 2
|
||||
tk::dnn::Conv2d e_2_conv1(&net, 128, 1, 1, 1, 1, 0, 0, extras2[0], true);
|
||||
tk::dnn::Activation e_relu_2_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_2_conv2(&net, 128, 3, 3, 2, 2, 1, 1, extras2[1], true, false, 128);
|
||||
tk::dnn::Activation e_relu_2_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_2_conv3(&net, 256, 1, 1, 1, 1, 0, 0, extras2[2], true);
|
||||
tk::dnn::Layer *header_4[1] = {&e_2_conv3};
|
||||
|
||||
//extras Inverted Residual 3
|
||||
tk::dnn::Conv2d e_3_conv1(&net, 64, 1, 1, 1, 1, 0, 0, extras3[0], true);
|
||||
tk::dnn::Activation e_relu_3_1(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_3_conv2(&net, 64, 3, 3, 2, 2, 1, 1, extras3[1], true, false, 64);
|
||||
tk::dnn::Activation e_relu_3_2(&net, CUDNN_ACTIVATION_RELU);
|
||||
tk::dnn::Conv2d e_3_conv3(&net, 64, 1, 1, 1, 1, 0, 0, extras3[2], true);
|
||||
tk::dnn::Layer *header_5[1] = {&e_3_conv3};
|
||||
|
||||
// classification header 0
|
||||
tk::dnn::Layer *header_0[1] = {&relu_14_1};
|
||||
tk::dnn::Route rout_ch_0(&net, header_0, 1);
|
||||
tk::dnn::Conv2d ch_0_conv1(&net, 576, 3, 3, 1, 1, 1, 1, classification_header0[0], true, false, 576, true);
|
||||
tk::dnn::Activation ch_relu_0_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d ch_0_conv2(&net, 66, 1, 1, 1, 1, 0, 0, classification_header0[1], false);
|
||||
tk::dnn::Layer *conf0[1] = {&ch_0_conv2};
|
||||
|
||||
// // classification header 1
|
||||
tk::dnn::Route rout_ch_1(&net, header_1, 1);
|
||||
tk::dnn::Conv2d ch_1_conv1(&net, 1280, 3, 3, 1, 1, 1, 1, classification_header1[0], true, false, 1280, true);
|
||||
tk::dnn::Activation ch_relu_1_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d ch_1_conv2(&net, 66, 1, 1, 1, 1, 0, 0, classification_header1[1], false);
|
||||
tk::dnn::Layer *conf1[1] = {&ch_1_conv2};
|
||||
|
||||
// //classification header 2
|
||||
tk::dnn::Route rout_ch_2(&net, header_2, 1);
|
||||
tk::dnn::Conv2d ch_2_conv1(&net, 512, 3, 3, 1, 1, 1, 1, classification_header2[0], true, false, 512, true);
|
||||
tk::dnn::Activation ch_relu_2_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d ch_2_conv2(&net, 66, 1, 1, 1, 1, 0, 0, classification_header2[1], false);
|
||||
tk::dnn::Layer *conf2[1] = {&ch_2_conv2};
|
||||
|
||||
// //classification header 3
|
||||
tk::dnn::Route rout_ch_3(&net, header_3, 1);
|
||||
tk::dnn::Conv2d ch_3_conv1(&net, 256, 3, 3, 1, 1, 1, 1, classification_header3[0], true, false, 256, true);
|
||||
tk::dnn::Activation ch_relu_3_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d ch_3_conv2(&net, 66, 1, 1, 1, 1, 0, 0, classification_header3[1], false);
|
||||
tk::dnn::Layer *conf3[1] = {&ch_3_conv2};
|
||||
|
||||
// //classification header 4
|
||||
tk::dnn::Route rout_ch_4(&net, header_4, 1);
|
||||
tk::dnn::Conv2d ch_4_conv1(&net, 256, 3, 3, 1, 1, 1, 1, classification_header4[0], true, false, 256, true);
|
||||
tk::dnn::Activation ch_relu_4_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d ch_4_conv2(&net, 66, 1, 1, 1, 1, 0, 0, classification_header4[1], false);
|
||||
tk::dnn::Layer *conf4[1] = {&ch_4_conv2};
|
||||
|
||||
// //classification header 5
|
||||
tk::dnn::Route rout_ch_5(&net, header_5, 1);
|
||||
tk::dnn::Conv2d ch_5_conv(&net, 66, 1, 1, 1, 1, 0, 0, classification_header5, false);
|
||||
ch_5_conv.setFinal();
|
||||
tk::dnn::Layer *conf5[1] = {&ch_5_conv};
|
||||
|
||||
//regression header 0
|
||||
tk::dnn::Route rout_rh_0(&net, header_0, 1);
|
||||
tk::dnn::Conv2d rh_0_conv1(&net, 576, 3, 3, 1, 1, 1, 1, regression_header0[0], true, false, 576, true);
|
||||
tk::dnn::Activation rh_relu_0_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d rh_0_conv2(&net, 24, 1, 1, 1, 1, 0, 0, regression_header0[1], false);
|
||||
tk::dnn::Layer *loc0[1] = {&rh_0_conv2};
|
||||
|
||||
// //regression header 1
|
||||
tk::dnn::Route rout_rh_1(&net, header_1, 1);
|
||||
tk::dnn::Conv2d rh_1_conv1(&net, 1280, 3, 3, 1, 1, 1, 1, regression_header1[0], true, false, 1280, true);
|
||||
tk::dnn::Activation rh_relu_1_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d rh_1_conv2(&net, 24, 1, 1, 1, 1, 0, 0, regression_header1[1], false);
|
||||
tk::dnn::Layer *loc1[1] = {&rh_1_conv2};
|
||||
|
||||
//regression header 2
|
||||
tk::dnn::Route rout_rh_2(&net, header_2, 1);
|
||||
tk::dnn::Conv2d rh_2_conv1(&net, 512, 3, 3, 1, 1, 1, 1, regression_header2[0], true, false, 512, true);
|
||||
tk::dnn::Activation rh_relu_2_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d rh_2_conv2(&net, 24, 1, 1, 1, 1, 0, 0, regression_header2[1], false);
|
||||
tk::dnn::Layer *loc2[1] = {&rh_2_conv2};
|
||||
|
||||
//regression header 3
|
||||
tk::dnn::Route rout_rh_3(&net, header_3, 1);
|
||||
tk::dnn::Conv2d rh_3_conv1(&net, 256, 3, 3, 1, 1, 1, 1, regression_header3[0], true, false, 256, true);
|
||||
tk::dnn::Activation rh_relu_3_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d rh_3_conv2(&net, 24, 1, 1, 1, 1, 0, 0, regression_header3[1], false);
|
||||
tk::dnn::Layer *loc3[1] = {&rh_3_conv2};
|
||||
|
||||
//regression header 4
|
||||
|
||||
tk::dnn::Route rout_rh_4(&net, header_4, 1);
|
||||
tk::dnn::Conv2d rh_4_conv1(&net, 256, 3, 3, 1, 1, 1, 1, regression_header4[0], true, false, 256, true);
|
||||
tk::dnn::Activation rh_relu_4_1(&net, CUDNN_ACTIVATION_CLIPPED_RELU, 6);
|
||||
tk::dnn::Conv2d rh_4_conv2(&net, 24, 1, 1, 1, 1, 0, 0, regression_header4[1], false);
|
||||
tk::dnn::Layer *loc4[1] = {&rh_4_conv2};
|
||||
|
||||
//regression header 5
|
||||
tk::dnn::Route rout_rh_5(&net, header_5, 1);
|
||||
tk::dnn::Conv2d rh_5_conv(&net, 24, 1, 1, 1, 1, 0, 0, regression_header5, false);
|
||||
rh_5_conv.setFinal();
|
||||
tk::dnn::Layer *loc5[1] = {&rh_5_conv};
|
||||
|
||||
last = &rh_5_conv;
|
||||
|
||||
//flatten all confidence
|
||||
tk::dnn::Route r_conf_0(&net, conf0, 1);
|
||||
tk::dnn::Flatten fl_c_0(&net);
|
||||
tk::dnn::Route r_conf_1(&net, conf1, 1);
|
||||
tk::dnn::Flatten fl_c_1(&net);
|
||||
tk::dnn::Route r_conf_2(&net, conf2, 1);
|
||||
tk::dnn::Flatten fl_c_2(&net);
|
||||
tk::dnn::Route r_conf_3(&net, conf3, 1);
|
||||
tk::dnn::Flatten fl_c_3(&net);
|
||||
tk::dnn::Route r_conf_4(&net, conf4, 1);
|
||||
tk::dnn::Flatten fl_c_4(&net);
|
||||
tk::dnn::Route r_conf_5(&net, conf5, 1);
|
||||
tk::dnn::Flatten fl_c_5(&net);
|
||||
|
||||
// //flatten all locations
|
||||
tk::dnn::Route r_loc_0(&net, loc0, 1);
|
||||
tk::dnn::Flatten fl_l_0(&net);
|
||||
tk::dnn::Route r_loc_1(&net, loc1, 1);
|
||||
tk::dnn::Flatten fl_l_1(&net);
|
||||
tk::dnn::Route r_loc_2(&net, loc2, 1);
|
||||
tk::dnn::Flatten fl_l_2(&net);
|
||||
tk::dnn::Route r_loc_3(&net, loc3, 1);
|
||||
tk::dnn::Flatten fl_l_3(&net);
|
||||
tk::dnn::Route r_loc_4(&net, loc4, 1);
|
||||
tk::dnn::Flatten fl_l_4(&net);
|
||||
tk::dnn::Route r_loc_5(&net, loc5, 1);
|
||||
tk::dnn::Flatten fl_l_5(&net);
|
||||
|
||||
// //concat confidence + softmax
|
||||
tk::dnn::Layer *confidences[6] = {&fl_c_0, &fl_c_1, &fl_c_2, &fl_c_3, &fl_c_4, &fl_c_5};
|
||||
tk::dnn::Route rout_conf(&net, confidences, 6);
|
||||
tk::dnn::dataDim_t olddim_c = net.layers[net.num_layers - 1]->output_dim;
|
||||
tk::dnn::dataDim_t dim_resh(1, olddim_c.c * olddim_c.h * olddim_c.w / classes, classes, 1, 1);
|
||||
|
||||
tk::dnn::Reshape reshape_conf1(&net, dim_resh);
|
||||
tk::dnn::Flatten fl_l_6(&net);
|
||||
tk::dnn::dataDim_t newdim_c(1, classes, olddim_c.c * olddim_c.h * olddim_c.w / classes, 1, 1);
|
||||
|
||||
tk::dnn::Reshape reshape_conf2(&net, newdim_c);
|
||||
|
||||
tk::dnn::Softmax sm_1(&net, &newdim_c);
|
||||
sm_1.setFinal();
|
||||
// tk::dnn::Flatten fl_l_7(&net);
|
||||
// tk::dnn::Reshape reshape_conf3(&net,dim_resh, true);
|
||||
tk::dnn::Layer *conf = &sm_1;
|
||||
|
||||
//concat locations
|
||||
tk::dnn::Layer *locations[6] = {&fl_l_0, &fl_l_1, &fl_l_2, &fl_l_3, &fl_l_4, &fl_l_5};
|
||||
tk::dnn::Route rout_loc(&net, locations, 6);
|
||||
tk::dnn::dataDim_t olddim_l = net.layers[net.num_layers - 1]->output_dim;
|
||||
tk::dnn::dataDim_t newdim_l(1, olddim_l.c * olddim_l.h * olddim_l.w / 4, 1, 4, 1);
|
||||
tk::dnn::Reshape reshape_loc(&net, newdim_l);
|
||||
reshape_loc.setFinal();
|
||||
tk::dnn::Layer *loc = &reshape_loc;
|
||||
|
||||
// Load input
|
||||
dnnType *data;
|
||||
dnnType *input_h;
|
||||
readBinaryFile(input_bin, dim.tot(), &input_h, &data);
|
||||
//printDeviceVector(64, data, true);
|
||||
|
||||
//print network model
|
||||
net.print();
|
||||
|
||||
// convert network to tensorRT
|
||||
tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("bdd-mobilenetv2ssd"));
|
||||
|
||||
tk::dnn::dataDim_t dim1 = dim; //input dim
|
||||
printCenteredTitle(" CUDNN inference ", '=', 30);
|
||||
{
|
||||
dim1.print();
|
||||
TIMER_START
|
||||
net.infer(dim1, data);
|
||||
TIMER_STOP
|
||||
dim1.print();
|
||||
}
|
||||
|
||||
dnnType *cudnn_out1 = conf5[0]->dstData;
|
||||
tk::dnn::dataDim_t out_dim1 = conf5[0]->output_dim;
|
||||
dnnType *cudnn_out2 = loc5[0]->dstData;
|
||||
tk::dnn::dataDim_t out_dim2 = loc5[0]->output_dim;
|
||||
|
||||
tk::dnn::dataDim_t dim2 = dim;
|
||||
printCenteredTitle(" TENSORRT inference ", '=', 30);
|
||||
{
|
||||
dim2.print();
|
||||
TIMER_START
|
||||
netRT.infer(dim2, data);
|
||||
TIMER_STOP
|
||||
dim2.print();
|
||||
}
|
||||
|
||||
dnnType *rt_out1 = (dnnType *)netRT.buffersRT[1];
|
||||
dnnType *rt_out2 = (dnnType *)netRT.buffersRT[2];
|
||||
dnnType *rt_out3 = (dnnType *)netRT.buffersRT[3];
|
||||
dnnType *rt_out4 = (dnnType *)netRT.buffersRT[4];
|
||||
|
||||
printCenteredTitle(std::string(" RESNET CHECK RESULTS ").c_str(), '=', 30);
|
||||
dnnType *out1, *out1_h;
|
||||
int odim1 = out_dim1.tot();
|
||||
readBinaryFile(output_bin1, odim1, &out1_h, &out1);
|
||||
|
||||
dnnType *out2, *out2_h;
|
||||
int odim2 = out_dim2.tot();
|
||||
readBinaryFile(output_bin2, odim2, &out2_h, &out2);
|
||||
int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0;
|
||||
|
||||
std::cout << "CUDNN vs correct" << std::endl;
|
||||
ret_cudnn |= checkResult(odim1, cudnn_out1, out1) == 0 ? 0 : ERROR_CUDNN;
|
||||
ret_cudnn |= checkResult(odim2, cudnn_out2, out2) == 0 ? 0 : ERROR_CUDNN;
|
||||
|
||||
std::cout << "TRT vs correct" << std::endl;
|
||||
ret_tensorrt |= checkResult(odim1, rt_out1, out1) == 0 ? 0 : ERROR_TENSORRT;
|
||||
ret_tensorrt |= checkResult(odim2, rt_out2, out2) == 0 ? 0 : ERROR_TENSORRT;
|
||||
|
||||
std::cout << "CUDNN vs TRT " << std::endl;
|
||||
ret_cudnn_tensorrt |= checkResult(odim1, cudnn_out1, rt_out1) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
ret_cudnn_tensorrt |= checkResult(odim2, cudnn_out2, rt_out2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
|
||||
std::cout << "---------------------------------------------------" << std::endl;
|
||||
std::cout << "Confidence CUDNN" << std::endl;
|
||||
printDeviceVector(64, conf->dstData, true);
|
||||
std::cout << "Locations CUDNN" << std::endl;
|
||||
printDeviceVector(64, loc->dstData, true);
|
||||
std::cout << "---------------------------------------------------" << std::endl;
|
||||
|
||||
std::cout << "Confidence tensorRT" << std::endl;
|
||||
printDeviceVector(64, rt_out3, true);
|
||||
std::cout << "Locations tensorRT" << std::endl;
|
||||
printDeviceVector(64, rt_out4, true);
|
||||
std::cout << "---------------------------------------------------" << std::endl;
|
||||
|
||||
std::cout << "CUDNN vs TRT " << std::endl;
|
||||
ret_cudnn_tensorrt |= checkResult(conf->output_dim.tot(), conf->dstData, rt_out3) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
ret_cudnn_tensorrt |= checkResult(loc->output_dim.tot(), loc->dstData, rt_out4) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
|
||||
|
||||
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ int main() {
|
||||
|
||||
// create yolo3 model
|
||||
std::string bin_path = "yolo3_512";
|
||||
downloadWeightsifDoNotExist("yolo3_512/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/e7HfScx77JEHeYb/download");
|
||||
downloadWeightsifDoNotExist("yolo3_512/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/RGecMeGLD4cXEWL/download");
|
||||
int classes = 80;
|
||||
tk::dnn::Yolo *yolo [3];
|
||||
#include "models/Yolo3.h"
|
||||
|
||||
Reference in New Issue
Block a user