| .. | ||
| include | ||
| plugin | ||
| src | ||
| CMakeLists.txt | ||
| gen_wts.py | ||
| images | ||
| main.cpp | ||
| README.md | ||
| yolov8_trt.py | ||
yolov8
The Pytorch implementation is ultralytics/yolov8.
The tensorrt code is derived from xiaocao-tian/yolov8_tensorrt
Contributors
Requirements
- TensorRT 8.0+
- OpenCV 3.4.0+
Different versions of yolov8
Currently, we support yolov8
- For yolov8 , download .pt from https://github.com/ultralytics/assets/releases, then follow how-to-run in current page.
Config
- Choose the model n/s/m/l/x from command line arguments.
- Check more configs in include/config.h
How to Run, yolov8-tiny as example
- generate .wts from pytorch with .pt, or download .wts from model zoo
// download https://github.com/ultralytics/assets/releases/yolov8n.pt
cp {tensorrtx}/yolov8/gen_wts.py {ultralytics}/ultralytics
cd {ultralytics}/ultralytics
python gen_wts.py
// a file 'yolov8.wts' will be generated.
- build tensorrtx/yolov8 and run
cd {tensorrtx}/yolov8/
// update kNumClass in config.h if your model is trained on custom dataset
mkdir build
cd build
cp {ultralytics}/ultralytics/yolov8.wts {tensorrtx}/yolov8/build
cmake ..
make
sudo ./yolov8 -s [.wts] [.engine] [n/s/m/l/x] // serialize model to plan file
sudo ./yolov8 -d [.engine] [image folder] // deserialize and run inference, the images in [image folder] will be processed.
// For example yolov8
sudo ./yolov8 -s yolov8n.wts yolov8.engine n
sudo ./yolov8 -d yolov8n.engine ../images
-
check the images generated, as follows. _zidane.jpg and _bus.jpg
-
optional, load and run the tensorrt model in python
// install python-tensorrt, pycuda, etc.
// ensure the yolov8n.engine and libmyplugins.so have been built
python yolov8_trt.py
INT8 Quantization
-
Prepare calibration images, you can randomly select 1000s images from your train set. For coco, you can also download my calibration images
coco_calibfrom GoogleDrive or BaiduPan pwd: a9wh -
unzip it in yolov8/build
-
set the macro
USE_INT8in config.h and make -
serialize the model and test
More Information
See the readme in home page.