duan8/yolov7
2023-02-02 12:50:58 +08:00
..
include Refactor yolov7 (#1155) 2022-11-27 23:33:34 +08:00
plugin Refactor yolov7 (#1155) 2022-11-27 23:33:34 +08:00
src yolov5/7: fix batch processing bug 2022-12-21 11:06:35 +08:00
CMakeLists.txt Refactor yolov7 (#1153) 2022-11-26 20:41:43 +08:00
gen_wts.py fix coding style 2022-09-23 16:03:40 +08:00
images Refactor yolov7 (#1153) 2022-11-26 20:41:43 +08:00
main.cpp Update main.cpp (#1167) 2022-12-09 21:04:37 +08:00
README.md Fix dead link in yolov7 readme (#1222) 2023-02-02 12:50:58 +08:00
yolov7_trt.py update gen_wts.py and some yolov5's names (#1109) 2022-09-22 11:03:37 +08:00

YOLOv7

The Pytorch implementation is WongKinYiu/yolov7.

The tensorrt code is derived from QIANXUNZDL123/tensorrtx-yolov7

Contributors

Requirements

  • TensorRT 8.0+
  • OpenCV 3.4.0+

Different versions of yolov7

Currently, we support yolov7 v0.1

  • For yolov7 v0.1, download .pt from yolov7 release v0.1, then follow how-to-run in current page.

Config

  • Choose the model tiny/v7/x/d6/w6/e6/e6e from command line arguments.
  • Check more configs in include/config.h

How to Run, yolov7-tiny as example

  1. generate .wts from pytorch with .pt, or download .wts from model zoo
// download https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
cp {tensorrtx}/yolov7/gen_wts.py {WongKinYiu}/yolov7
cd {WongKinYiu}/yolov7
python gen_wts.py
// a file 'yolov7.wts' will be generated.
  1. build tensorrtx/yolov7 and run
cd {tensorrtx}/yolov7/
// update kNumClass in config.h if your model is trained on custom dataset
mkdir build
cd build
cp {WongKinYiu}/yolov7/yolov7.wts {tensorrtx}/yolov7/build
cmake ..
make
sudo ./yolov7 -s [.wts] [.engine] [t/v7/x/w6/e6/d6/e6e gd gw]  // serialize model to plan file
sudo ./yolov7 -d [.engine] [image folder]  // deserialize and run inference, the images in [image folder] will be processed.
// For example yolov7
sudo ./yolov7 -s yolov7.wts yolov7.engine v7
sudo ./yolov7 -d yolov7.engine ../images
  1. check the images generated, as follows. _zidane.jpg and _bus.jpg

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

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

INT8 Quantization

  1. Prepare calibration images, you can randomly select 1000s images from your train set. For coco, you can also download my calibration images coco_calib from GoogleDrive or BaiduPan pwd: a9wh

  2. unzip it in yolov7/build

  3. set the macro USE_INT8 in config.h and make

  4. serialize the model and test

More Information

See the readme in home page.