diff --git a/CMakeLists.txt b/CMakeLists.txt index f3471e2..9191adc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15) project (tkDNN) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) if(UNIX) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wno-deprecated-declarations -Wno-unused-variable") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wno-deprecated-declarations -Wno-unused-variable -O3") endif() if(WIN32) set(CMAKE_CXX_STANDARD 11) @@ -31,7 +31,7 @@ endif() find_package(CUDA 9.0 REQUIRED) SET(CUDA_SEPARABLE_COMPILATION ON) #set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -arch=sm_30 --compiler-options '-fPIC'") -set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --maxrregcount=32) +set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --maxrregcount=32 -arch=sm_61) find_package(CUDNN REQUIRED) diff --git a/demo/demo/demo.cpp b/demo/demo/demo.cpp index 6e1c2b4..d597da9 100644 --- a/demo/demo/demo.cpp +++ b/demo/demo/demo.cpp @@ -45,14 +45,14 @@ int main(int argc, char *argv[]) { if(argc > 2) - cfgPath = argv[2]; + cfgPath = argv[3]; if(argc > 3) - namePath = argv[3]; + namePath = argv[4]; if(argc > 4) - input = argv[4]; + input = argv[5]; char ntype = 'y'; if(argc > 5) - ntype = argv[5][0]; + ntype = argv[2][0]; int n_classes = 80; if(argc > 6) n_classes = atoi(argv[6]); @@ -72,9 +72,14 @@ int main(int argc, char *argv[]) { if(!show) SAVE_RESULT = true; + if(ntype == 'c' || ntype == 'm'){ + cfgPath = nullptr; + namePath = nullptr; + + } tk::dnn::Yolo3Detection yolo; - //tk::dnn::CenternetDetection cnet; - //tk::dnn::MobilenetDetection mbnet; + tk::dnn::CenternetDetection cnet; + tk::dnn::MobilenetDetection mbnet; tk::dnn::DetectionNN *detNN; @@ -84,10 +89,10 @@ int main(int argc, char *argv[]) { detNN = &yolo; break; case 'c': - //detNN = &cnet; + detNN = &cnet; break; case 'm': - //detNN = &mbnet; + detNN = &mbnet; n_classes++; break; default: diff --git a/include/tkDNN/CenternetDetection.h b/include/tkDNN/CenternetDetection.h index 3c8cfbb..07c80cd 100644 --- a/include/tkDNN/CenternetDetection.h +++ b/include/tkDNN/CenternetDetection.h @@ -73,7 +73,7 @@ public: CenternetDetection() {}; ~CenternetDetection() {}; - bool init(const std::string& tensor_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3); + bool init(const std::string& tensor_path,const std::string& cfg_path,const std::string& name_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3); void preprocess(cv::Mat &frame, const int bi=0); void postprocess(const int bi=0,const bool mAP=false); }; diff --git a/include/tkDNN/MobilenetDetection.h b/include/tkDNN/MobilenetDetection.h index 9a5fedc..ec35b20 100644 --- a/include/tkDNN/MobilenetDetection.h +++ b/include/tkDNN/MobilenetDetection.h @@ -65,7 +65,7 @@ public: MobilenetDetection() {}; ~MobilenetDetection() {}; - bool init(const std::string& tensor_path, const int n_classes, const int n_batches=1, const float conf_thresh=0.3); + bool init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches=1, const float conf_thresh=0.3); void preprocess(cv::Mat &frame, const int bi=0); void postprocess(const int bi=0,const bool mAP=false); }; diff --git a/src/CenternetDetection.cpp b/src/CenternetDetection.cpp index a06bc11..133c682 100644 --- a/src/CenternetDetection.cpp +++ b/src/CenternetDetection.cpp @@ -3,7 +3,7 @@ namespace tk { namespace dnn { -bool CenternetDetection::init(const std::string& tensor_path, const int n_classes, const int n_batches, const float conf_thresh){ +bool CenternetDetection::init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches, const float conf_thresh){ std::cout<<(tensor_path).c_str()<<"\n"; netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str() ); classes = n_classes; diff --git a/src/MobilenetDetection.cpp b/src/MobilenetDetection.cpp index 3c54e28..1d3832d 100644 --- a/src/MobilenetDetection.cpp +++ b/src/MobilenetDetection.cpp @@ -126,7 +126,7 @@ float MobilenetDetection::iou(const tk::dnn::box &a, const tk::dnn::box &b){ return iou; } -bool MobilenetDetection::init(const std::string& tensor_path, const int n_classes, const int n_batches, const float conf_thresh){ +bool MobilenetDetection::init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches, const float conf_thresh){ std::cout<<(tensor_path).c_str()<<"\n"; netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str()); imageSize = netRT->input_dim.h; diff --git a/src/NetworkRT.cpp b/src/NetworkRT.cpp index 7f00cd6..4b3d532 100644 --- a/src/NetworkRT.cpp +++ b/src/NetworkRT.cpp @@ -657,8 +657,8 @@ bool NetworkRT::deserialize(const char *filename) { void NetworkRT::destroy() { contextRT->destroy(); - configRT->destroy(); engineRT->destroy(); + configRT->destroy(); builderRT->destroy(); } diff --git a/src/Yolo3Detection.cpp b/src/Yolo3Detection.cpp index 48e9d5d..bda206a 100644 --- a/src/Yolo3Detection.cpp +++ b/src/Yolo3Detection.cpp @@ -29,7 +29,7 @@ namespace tk { namespace dnn { for(int i=0; i maskTemp,anchorsTemp; std::vector classNamesTemp; - int classes,nms_kind,coords,numTemp; + int nms_kind,coords,numTemp; float nmsthresh; loadYoloInfo(cfg_path,yolosLine[i],maskTemp,anchorsTemp,numTemp,classes,nmsthresh,nms_kind,coords); classNamesTemp = darknetReadNames(name_path); diff --git a/tests/darknet/csresnext50-panet-spp.cpp b/tests/darknet/csresnext50-panet-spp.cpp index a366e14..5413e52 100644 --- a/tests/darknet/csresnext50-panet-spp.cpp +++ b/tests/darknet/csresnext50-panet-spp.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/csresnext50-panet-spp_berkeley.cpp b/tests/darknet/csresnext50-panet-spp_berkeley.cpp index a8ba59f..1f52716 100644 --- a/tests/darknet/csresnext50-panet-spp_berkeley.cpp +++ b/tests/darknet/csresnext50-panet-spp_berkeley.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo2_voc.cpp b/tests/darknet/yolo2_voc.cpp index 94111e6..964c9f7 100644 --- a/tests/darknet/yolo2_voc.cpp +++ b/tests/darknet/yolo2_voc.cpp @@ -27,6 +27,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo2tiny.cpp b/tests/darknet/yolo2tiny.cpp index cc12109..f391a6f 100644 --- a/tests/darknet/yolo2tiny.cpp +++ b/tests/darknet/yolo2tiny.cpp @@ -28,6 +28,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3.cpp b/tests/darknet/yolo3.cpp index d9a684b..d61cf19 100644 --- a/tests/darknet/yolo3.cpp +++ b/tests/darknet/yolo3.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } \ No newline at end of file diff --git a/tests/darknet/yolo3_512.cpp b/tests/darknet/yolo3_512.cpp index c24550b..e4a6316 100644 --- a/tests/darknet/yolo3_512.cpp +++ b/tests/darknet/yolo3_512.cpp @@ -41,6 +41,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3_berkeley.cpp b/tests/darknet/yolo3_berkeley.cpp index 016a8a2..620692a 100644 --- a/tests/darknet/yolo3_berkeley.cpp +++ b/tests/darknet/yolo3_berkeley.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3_coco4.cpp b/tests/darknet/yolo3_coco4.cpp index eaf9bd8..89a1616 100644 --- a/tests/darknet/yolo3_coco4.cpp +++ b/tests/darknet/yolo3_coco4.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3_flir.cpp b/tests/darknet/yolo3_flir.cpp index 24aac7f..557a4ca 100644 --- a/tests/darknet/yolo3_flir.cpp +++ b/tests/darknet/yolo3_flir.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3tiny.cpp b/tests/darknet/yolo3tiny.cpp index c33f7a8..c18a60c 100644 --- a/tests/darknet/yolo3tiny.cpp +++ b/tests/darknet/yolo3tiny.cpp @@ -28,6 +28,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo3tiny_512.cpp b/tests/darknet/yolo3tiny_512.cpp index 8460416..f8aae61 100644 --- a/tests/darknet/yolo3tiny_512.cpp +++ b/tests/darknet/yolo3tiny_512.cpp @@ -41,6 +41,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4-csp.cpp b/tests/darknet/yolo4-csp.cpp index 8ad8aef..f354a48 100644 --- a/tests/darknet/yolo4-csp.cpp +++ b/tests/darknet/yolo4-csp.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } \ No newline at end of file diff --git a/tests/darknet/yolo4_320.cpp b/tests/darknet/yolo4_320.cpp index 0e623e0..db03024 100644 --- a/tests/darknet/yolo4_320.cpp +++ b/tests/darknet/yolo4_320.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_320_coco2.cpp b/tests/darknet/yolo4_320_coco2.cpp index 877e604..b8fd3bf 100644 --- a/tests/darknet/yolo4_320_coco2.cpp +++ b/tests/darknet/yolo4_320_coco2.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_512.cpp b/tests/darknet/yolo4_512.cpp index 9d4c389..b5e3975 100644 --- a/tests/darknet/yolo4_512.cpp +++ b/tests/darknet/yolo4_512.cpp @@ -42,6 +42,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_608.cpp b/tests/darknet/yolo4_608.cpp index dda084f..762f83a 100644 --- a/tests/darknet/yolo4_608.cpp +++ b/tests/darknet/yolo4_608.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_berkeley.cpp b/tests/darknet/yolo4_berkeley.cpp index 89e9f04..70dee4b 100644 --- a/tests/darknet/yolo4_berkeley.cpp +++ b/tests/darknet/yolo4_berkeley.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_berkeley_f1.cpp b/tests/darknet/yolo4_berkeley_f1.cpp index 6dfbc63..f6f4e62 100644 --- a/tests/darknet/yolo4_berkeley_f1.cpp +++ b/tests/darknet/yolo4_berkeley_f1.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4_mmr.cpp b/tests/darknet/yolo4_mmr.cpp index 85649b2..e22f662 100644 --- a/tests/darknet/yolo4_mmr.cpp +++ b/tests/darknet/yolo4_mmr.cpp @@ -29,6 +29,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4tiny_512.cpp b/tests/darknet/yolo4tiny_512.cpp index fd15aea..1b53ed3 100644 --- a/tests/darknet/yolo4tiny_512.cpp +++ b/tests/darknet/yolo4tiny_512.cpp @@ -40,6 +40,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/darknet/yolo4x.cpp b/tests/darknet/yolo4x.cpp index 8df1aef..7f793f7 100644 --- a/tests/darknet/yolo4x.cpp +++ b/tests/darknet/yolo4x.cpp @@ -31,6 +31,7 @@ int main() { int ret = testInference(input_bins, output_bins, net, netRT); net->releaseLayers(); delete net; + netRT->destroy(); delete netRT; return ret; } diff --git a/tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp b/tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp index c3c6472..46064de 100644 --- a/tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp +++ b/tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp @@ -542,5 +542,6 @@ int main() 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; + netRT.destroy(); return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; }