/Object-Detection-Yolov7-TensorRT-Nvidia

Yolov7 TensorRT model process with Nvidia cudNN c++.

Primary LanguageC++

Object-Detection-Yolov7-TensorRT-Nvidia

Yolov7 Deep MI TesorRT model process with Nvidia DNN C++ in Windows 10.
Deep-learning Machine Intelligence Network.
Base is Yolov7
TensorRT model format description using for the IoT device: NVIDIA TensorRT.

Nvidia
If you compiled embedded Linux, it is used for IoT + Camera, example: Jetson modules.
Opencv
OpenCV office

Enviroment

  • Windows 10 64-bit
  • NVIDIA Geforce GTX 960 2 Gbyte RAM
  • Microsoft Visual Studio Community 2022
  • TensorRT-8.5.2.2:
    c:\Program Files\NVIDIA GPU Computing Toolkit\TensorRT-8.5.2.2\
  • CUDA Toolkit v11.8:
    c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\
  • cudnn-8.7.0.84:
    c:\Program Files\NVIDIA GPU Computing Toolkit\cudnn-windows-x86_64-8.7.0.84_cuda11\

Installation

Downloading opencv files, there files are archive:
opencv-4.6.0.zip include, library, binary dll files.
unzip and copy to ./3rdparty and .x64/vc17/bin dll files to copy to .x64/Debug and x64/Release directory.

Building the ImageDetector-yolov7-tensorRT VS2022 project

-VS2022 started.
-"Open a project or solution".
-in Browse to search the "ImageDetector-yolov7-tensorRT.sln" file, and it open that.
-Build->Build Solution (F7).
Builded in "./x64/Release/ImageDetector-yolov7-tensorRT.exe".
- xcopy /Y .\3rdparty\opencv-4.6.0\x64\vc17\bin\opencv_world460.dll .\x64\Release
  xcopy /Y .\3rdparty\opencv-4.6.0\x64\vc17\bin\opencv_videoio_ffmpeg460_64.dll .\x64\Release
  xcopy /Y "c:\Program Files\NVIDIA GPU Computing Toolkit\TensorRT-8.5.2.2\lib\nvinfer.dll" .\x64\Release
  xcopy /Y "c:\Program Files\NVIDIA GPU Computing Toolkit\TensorRT-8.5.2.2\lib\nvinfer_plugin.dll" .\x64\Release

Running the "ImageDetector-yolov7-opencv.exe" app.

Program arguments:

Examples: Image:

ImageDetector-yolov7-tensorRT_image1.bat

Result image:

Video:

ImageDetector-yolov7-tensorRT_video1.bat

Result video:
YouTube video (click):

YouTube video


Inference time is 50-100 ms per image.

Conversion *.onnx model to *.tr model:

yolov7:
python export.py --weights yolov7-tiny.pt --grid --simplify // --end2end later
cd c:\Program Files\NVIDIA GPU Computing Toolkit\TensorRT-8.5.2.2\bin\
trtexec.exec --onnx=yolov7-tiny.onnx --saveEngine=yolov7-tiny.trt --fp16 //conversion
trtexec --loadEngine=yolov7-tiny.trt //tested, checked

The model conversion and system of TensoRT version need equal !!
Current is version number: 8.5.2.2

Python

show in python/Example_tr_detect.ipynb Jupyter Notebook