-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd8c9c6
commit 5433b4d
Showing
8 changed files
with
1,180 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cmake_minimum_required(VERSION 2.6) | ||
|
||
project(yolov7) | ||
|
||
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(yolov7 ${PROJECT_SOURCE_DIR}/yolov7.cpp) | ||
target_link_libraries(yolov7 nvinfer) | ||
target_link_libraries(yolov7 cudart) | ||
target_link_libraries(yolov7 ${OpenCV_LIBS}) | ||
|
||
add_definitions(-O2 -pthread) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# YOLOV7-TensorRT in C++ | ||
|
||
## Step 1: 准备TRT序列化引擎 | ||
|
||
```shell | ||
https://github.com/WongKinYiu/yolov7.git | ||
``` | ||
### 导出onnx | ||
```shell | ||
python models/export.py --weights ../yolov7.pt --grid | ||
``` | ||
|
||
### 转化为TensorRT Engine | ||
|
||
``` | ||
python export.py -o onnx-name -e trt-name -p fp32/16/int8 | ||
``` | ||
### 测试 | ||
|
||
``` | ||
cd yolov7 | ||
python trt.py | ||
``` | ||
|
||
## Step 2: C++ | ||
|
||
Please follow the [TensorRT Installation Guide](https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html) to install TensorRT. | ||
|
||
And you should set the TensorRT path and CUDA path in CMakeLists.txt. | ||
|
||
If you train your custom dataset, you may need to modify the value of `num_class`. | ||
|
||
```c++ | ||
const int num_class = 80; | ||
``` | ||
|
||
Install opencv with ```sudo apt-get install libopencv-dev``` (we don't need a higher version of opencv like v3.3+). | ||
|
||
build the demo: | ||
|
||
```shell | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
Then run the demo: | ||
|
||
```shell | ||
./yolov7 ../model_trt.engine -i ../../../../assets/dog.jpg | ||
``` | ||
|
||
or | ||
|
||
```shell | ||
./yolov7 <path/to/your/engine_file> -i <path/to/image> | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.