From 4d2fa7149ab38ee788dc5e352505c193b429cd59 Mon Sep 17 00:00:00 2001 From: wang-xinyu Date: Fri, 28 Aug 2020 19:30:17 +0800 Subject: [PATCH] fix register plugin and cmp --- yolov3-spp/CMakeLists.txt | 1 + yolov3-spp/yololayer.h | 4 +--- yolov3-spp/yolov3-spp.cpp | 3 +-- yolov3-tiny/CMakeLists.txt | 1 + yolov3-tiny/yololayer.h | 4 +--- yolov3-tiny/yolov3-tiny.cpp | 3 +-- yolov3/CMakeLists.txt | 1 + yolov3/yololayer.h | 4 +--- yolov3/yolov3.cpp | 3 +-- yolov4/CMakeLists.txt | 1 + yolov4/mish.h | 1 + yolov4/yololayer.h | 4 +--- yolov4/yolov4.cpp | 4 +--- yolov5/README.md | 2 +- yolov5/common.hpp | 2 +- 15 files changed, 15 insertions(+), 23 deletions(-) diff --git a/yolov3-spp/CMakeLists.txt b/yolov3-spp/CMakeLists.txt index 4774663..0c4be5d 100644 --- a/yolov3-spp/CMakeLists.txt +++ b/yolov3-spp/CMakeLists.txt @@ -28,6 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors - #cuda_add_library(leaky ${PROJECT_SOURCE_DIR}/leaky.cu) cuda_add_library(yololayer SHARED ${PROJECT_SOURCE_DIR}/yololayer.cu) +target_link_libraries(yololayer nvinfer cudart) find_package(OpenCV) include_directories(OpenCV_INCLUDE_DIRS) diff --git a/yolov3-spp/yololayer.h b/yolov3-spp/yololayer.h index 37ad03e..1f080cb 100644 --- a/yolov3-spp/yololayer.h +++ b/yolov3-spp/yololayer.h @@ -151,9 +151,7 @@ namespace nvinfer1 static PluginFieldCollection mFC; static std::vector mPluginAttributes; }; - - - + REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); }; #endif diff --git a/yolov3-spp/yolov3-spp.cpp b/yolov3-spp/yolov3-spp.cpp index b1dd5e0..4fe7c65 100644 --- a/yolov3-spp/yolov3-spp.cpp +++ b/yolov3-spp/yolov3-spp.cpp @@ -37,7 +37,6 @@ static const int OUTPUT_SIZE = 1000 * 7 + 1; // we assume the yololayer outputs const char* INPUT_BLOB_NAME = "data"; const char* OUTPUT_BLOB_NAME = "prob"; static Logger gLogger; -REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); cv::Mat preprocess_img(cv::Mat& img) { int w, h, x, y; @@ -102,7 +101,7 @@ float iou(float lbox[4], float rbox[4]) { return interBoxS/(lbox[2]*lbox[3] + rbox[2]*rbox[3] -interBoxS); } -bool cmp(Yolo::Detection& a, Yolo::Detection& b) { +bool cmp(const Yolo::Detection& a, const Yolo::Detection& b) { return a.det_confidence > b.det_confidence; } diff --git a/yolov3-tiny/CMakeLists.txt b/yolov3-tiny/CMakeLists.txt index fff091e..d1a6c25 100644 --- a/yolov3-tiny/CMakeLists.txt +++ b/yolov3-tiny/CMakeLists.txt @@ -28,6 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors - #cuda_add_library(leaky ${PROJECT_SOURCE_DIR}/leaky.cu) cuda_add_library(yololayer SHARED ${PROJECT_SOURCE_DIR}/yololayer.cu) +target_link_libraries(yololayer nvinfer cudart) find_package(OpenCV) include_directories(OpenCV_INCLUDE_DIRS) diff --git a/yolov3-tiny/yololayer.h b/yolov3-tiny/yololayer.h index b3282ff..bc6c5e7 100644 --- a/yolov3-tiny/yololayer.h +++ b/yolov3-tiny/yololayer.h @@ -142,9 +142,7 @@ namespace nvinfer1 static PluginFieldCollection mFC; static std::vector mPluginAttributes; }; - - - + REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); }; #endif diff --git a/yolov3-tiny/yolov3-tiny.cpp b/yolov3-tiny/yolov3-tiny.cpp index 404d9f6..e5d9b47 100644 --- a/yolov3-tiny/yolov3-tiny.cpp +++ b/yolov3-tiny/yolov3-tiny.cpp @@ -36,7 +36,6 @@ static const int OUTPUT_SIZE = 1000 * 7 + 1; // we assume the yololayer outputs const char* INPUT_BLOB_NAME = "data"; const char* OUTPUT_BLOB_NAME = "prob"; static Logger gLogger; -REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); cv::Mat preprocess_img(cv::Mat& img) { int w, h, x, y; @@ -101,7 +100,7 @@ float iou(float lbox[4], float rbox[4]) { return interBoxS/(lbox[2]*lbox[3] + rbox[2]*rbox[3] -interBoxS); } -bool cmp(Yolo::Detection& a, Yolo::Detection& b) { +bool cmp(const Yolo::Detection& a, const Yolo::Detection& b) { return a.det_confidence > b.det_confidence; } diff --git a/yolov3/CMakeLists.txt b/yolov3/CMakeLists.txt index 4e4ea79..d583485 100644 --- a/yolov3/CMakeLists.txt +++ b/yolov3/CMakeLists.txt @@ -28,6 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors - #cuda_add_library(leaky ${PROJECT_SOURCE_DIR}/leaky.cu) cuda_add_library(yololayer SHARED ${PROJECT_SOURCE_DIR}/yololayer.cu) +target_link_libraries(yololayer nvinfer cudart) find_package(OpenCV) include_directories(OpenCV_INCLUDE_DIRS) diff --git a/yolov3/yololayer.h b/yolov3/yololayer.h index 37ad03e..1f080cb 100644 --- a/yolov3/yololayer.h +++ b/yolov3/yololayer.h @@ -151,9 +151,7 @@ namespace nvinfer1 static PluginFieldCollection mFC; static std::vector mPluginAttributes; }; - - - + REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); }; #endif diff --git a/yolov3/yolov3.cpp b/yolov3/yolov3.cpp index 26378cc..2bd5a8f 100644 --- a/yolov3/yolov3.cpp +++ b/yolov3/yolov3.cpp @@ -37,7 +37,6 @@ static const int OUTPUT_SIZE = 1000 * 7 + 1; // we assume the yololayer outputs const char* INPUT_BLOB_NAME = "data"; const char* OUTPUT_BLOB_NAME = "prob"; static Logger gLogger; -REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); cv::Mat preprocess_img(cv::Mat& img) { int w, h, x, y; @@ -102,7 +101,7 @@ float iou(float lbox[4], float rbox[4]) { return interBoxS/(lbox[2]*lbox[3] + rbox[2]*rbox[3] -interBoxS); } -bool cmp(Yolo::Detection& a, Yolo::Detection& b) { +bool cmp(const Yolo::Detection& a, const Yolo::Detection& b) { return a.det_confidence > b.det_confidence; } diff --git a/yolov4/CMakeLists.txt b/yolov4/CMakeLists.txt index 5901e60..36024c1 100644 --- a/yolov4/CMakeLists.txt +++ b/yolov4/CMakeLists.txt @@ -27,6 +27,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED") cuda_add_library(myplugins SHARED ${PROJECT_SOURCE_DIR}/yololayer.cu ${PROJECT_SOURCE_DIR}/mish.cu) +target_link_libraries(myplugins nvinfer cudart) find_package(OpenCV) include_directories(OpenCV_INCLUDE_DIRS) diff --git a/yolov4/mish.h b/yolov4/mish.h index 1c6fccb..95339b6 100644 --- a/yolov4/mish.h +++ b/yolov4/mish.h @@ -102,5 +102,6 @@ namespace nvinfer1 static PluginFieldCollection mFC; static std::vector mPluginAttributes; }; + REGISTER_TENSORRT_PLUGIN(MishPluginCreator); }; #endif diff --git a/yolov4/yololayer.h b/yolov4/yololayer.h index af30e9c..47d73ee 100644 --- a/yolov4/yololayer.h +++ b/yolov4/yololayer.h @@ -152,9 +152,7 @@ namespace nvinfer1 static PluginFieldCollection mFC; static std::vector mPluginAttributes; }; - - - + REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); }; #endif diff --git a/yolov4/yolov4.cpp b/yolov4/yolov4.cpp index 4e86554..0e7e566 100644 --- a/yolov4/yolov4.cpp +++ b/yolov4/yolov4.cpp @@ -40,8 +40,6 @@ static const int OUTPUT_SIZE = Yolo::MAX_OUTPUT_BBOX_COUNT * DETECTION_SIZE + 1; const char* INPUT_BLOB_NAME = "data"; const char* OUTPUT_BLOB_NAME = "prob"; static Logger gLogger; -REGISTER_TENSORRT_PLUGIN(MishPluginCreator); -REGISTER_TENSORRT_PLUGIN(YoloPluginCreator); cv::Mat preprocess_img(cv::Mat& img) { int w, h, x, y; @@ -106,7 +104,7 @@ float iou(float lbox[4], float rbox[4]) { return interBoxS/(lbox[2]*lbox[3] + rbox[2]*rbox[3] -interBoxS); } -bool cmp(Yolo::Detection& a, Yolo::Detection& b) { +bool cmp(const Yolo::Detection& a, const Yolo::Detection& b) { return a.det_confidence > b.det_confidence; } diff --git a/yolov5/README.md b/yolov5/README.md index 884f4a6..382d190 100644 --- a/yolov5/README.md +++ b/yolov5/README.md @@ -5,7 +5,7 @@ The Pytorch implementation is [ultralytics/yolov5](https://github.com/ultralytic Currently, we support yolov5 v1.0(yolov5s only), v2.0 and v3.0. - For yolov5 v3.0, please visit [yolov5 release v3.0](https://github.com/ultralytics/yolov5/releases/tag/v3.0), and use the latest commit of this repo. -- For yolov5 v2.0, please visit [yolov5 release v2.0](https://github.com/ultralytics/yolov5/releases/tag/v2.0), and checkout commit ['7cd092d'](https://github.com/wang-xinyu/tensorrtx/commit/7cd092d38289123442157cf7defab78e816f4440) of this repo or use the latest commit. +- For yolov5 v2.0, please visit [yolov5 release v2.0](https://github.com/ultralytics/yolov5/releases/tag/v2.0), and checkout commit ['7cd092d'](https://github.com/wang-xinyu/tensorrtx/commit/7cd092d38289123442157cf7defab78e816f4440) of this repo. - For yolov5 v1.0, please visit [yolov5 release v1.0](https://github.com/ultralytics/yolov5/releases/tag/v1.0), and checkout commit ['0504551'](https://github.com/wang-xinyu/tensorrtx/commit/0504551c0b7d0bac5f998eda349810ba410715de) of this repo. ## Config diff --git a/yolov5/common.hpp b/yolov5/common.hpp index baf447c..17d0471 100644 --- a/yolov5/common.hpp +++ b/yolov5/common.hpp @@ -87,7 +87,7 @@ float iou(float lbox[4], float rbox[4]) { return interBoxS/(lbox[2]*lbox[3] + rbox[2]*rbox[3] -interBoxS); } -bool cmp(Yolo::Detection& a, Yolo::Detection& b) { +bool cmp(const Yolo::Detection& a, const Yolo::Detection& b) { return a.conf > b.conf; }