Skip to content

Commit

Permalink
🎉 Support C++ for End2end
Browse files Browse the repository at this point in the history
  • Loading branch information
Linaom1214 committed Aug 13, 2022
1 parent 2449c51 commit bacd195
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 16 deletions.
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
YOLOv7、YOLOv6、 YOLOX、 YOLOV5

## Update
- 2022.8.13 rename reop public new version
- 2022.8.13 rename reop public new version**C++ for end2end**
- 2022.8.11 nms plugin support ==> Now you can set --end2end flag while use `export.py` get a engine file
- 2022.7.8 support YOLOV7
- 2022.7.3 support TRT int8 post-training quantization
Expand All @@ -32,23 +32,10 @@ show in `Examples.ipynb` <a href="https://github.com/Linaom1214/TensorRT-For-YOL

### C++

Now C++ don`t support model with nms plugin

Edit code
```c++
static const int INPUT_W = 640;
static const int INPUT_H = 640;
const char* INPUT_BLOB_NAME = "image_arrays";
const char* OUTPUT_BLOB_NAME = "outputs";
```
support **NMS plugin**
show in [C++ Demo](cpp/README.MD)


```shell
cd cpp && mkdir build && build
cmake ..
make
./yolo ../model_trt.engine -i ../*.jpg
```

## Old version
[v0.0.1](https://github.com/Linaom1214/TensorRT-For-YOLO-Series/releases/tag/v0.0.1)
Expand Down
37 changes: 37 additions & 0 deletions cpp/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## With NMS Plugin

**Edit code for you model**

```c++
const cv::Size& new_shape = cv::Size(640, 640),
static const int INPUT_H = 640;
auto in_dims = engine->getBindingDimensions(engine->getBindingIndex("image_arrays"));
```
**run**
```shell
cd end2end && mkdir build && build
cmake ..
make
./yolo -model_path engine -image_path xxx.jpg
```


## Without NMS Plugin

**Edit code for you model**

```c++
static const int INPUT_W = 640;
static const int INPUT_H = 640;
const char* INPUT_BLOB_NAME = "image_arrays";
const char* OUTPUT_BLOB_NAME = "outputs";
```
**run**

```shell
cd norm && mkdir build && build
cmake ..
make
./yolo ../model_trt.engine -i ../*.jpg
```
34 changes: 34 additions & 0 deletions cpp/end2end/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 2.6)

project(yolo)

add_definitions(-std=c++11)

option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
# add_definitions("-Wall -g")
find_package(CUDA REQUIRED)

include_directories(${PROJECT_SOURCE_DIR}/include)
# include and link dirs of cuda and tensorrt, you need adapt them if yours are different
# cuda
include_directories(/usr/local/cuda/include)
link_directories(/usr/local/cuda/lib64)
# tensorrt
include_directories(/usr/include/x86_64-linux-gnu/)
link_directories(/usr/lib/x86_64-linux-gnu/)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")

find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})

add_executable(yolo ${PROJECT_SOURCE_DIR}/main.cpp)
target_link_libraries(yolo nvinfer)
target_link_libraries(yolo nvinfer_plugin)
target_link_libraries(yolo cudart)

target_link_libraries(yolo ${OpenCV_LIBS})

add_definitions(-O2 -pthread)
Loading

0 comments on commit bacd195

Please sign in to comment.