Skip to content

a yolov5 implementation using tensorrt, running on Jetson devices.

Notifications You must be signed in to change notification settings

hlld/tensorrt-yolov5

Repository files navigation

tensorrt-yolov5

The Pytorch implementation is ultralytics/yolov5.

This repo contains a slightly modified version of tensorrtx, and only support yolov5 v3.0.

Config

  • Specify the model s/m/l/x when running command ./yolov5
  • Input shape defined in yololayer.h
  • Number of classes defined in yololayer.h
  • FP16/FP32 can be selected by the macro in yolov5.cpp
  • GPU id can be selected by the macro in yolov5.cpp
  • NMS thresh in yolov5.cpp
  • BBox confidence thresh in yolov5.cpp
  • Batch size in yolov5.cpp, default 1

How to Run, yolov5s as example

1. generate yolov5sv3.wts from pytorch with yolov5sv3.pt

git clone https://github.com/hlld/tensorrt-yolov5.git
git clone https://github.com/ultralytics/yolov5.git
// download its weights 'yolov5sv3.pt'
// copy tensorrt-yolov5/yolov5/gen_wts.py into ultralytics/yolov5
// ensure the file name is yolov5sv3.pt and yolov5sv3.wts in gen_wts.py
// go to ultralytics/yolov5
python gen_wts.py
// a file 'yolov5sv3.wts' will be generated.

2. build tensorrt-yolov5/yolov5 and run

// put yolov5sv3.wts into tensorrt-yolov5/yolov5
// go to tensorrt-yolov5/yolov5
mkdir build
cd build
cmake ..
make
sudo ./yolov5 -s s           // serialize model to plan file i.e. 'yolov5sv3.engine'
sudo ./yolov5 -e s -d  ../images // deserialize plan file and run inference, the images in samples will be processed.

3. check the images generated, as follows. _zidane.jpg and _bus.jpg

4. optional, load and run the tensorrt model in python

// install python-tensorrt, pycuda, etc.
// ensure the yolov5sv3.engine and libmyplugins.so have been built
python yolov5_trt.py

More Information

See the readme in tensorrtx home page.

About

a yolov5 implementation using tensorrt, running on Jetson devices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published