a quick solution for yolov7 tensorRT deployment
- first make sure tensorRT is installed in your machine.
- install torch & torchvision
- install torch2trt and other requirements
git clone https://github.com/NVIDIA-AI-IOT/torch2trt.git
cd torch2trt
python3 setup.py install
cd ..
pip3 install -r requirements.txt
- first copy file export_ONNX_for_TRT.py to the path of yolov7 project ( yolov7 main page )
python3 export_ONNX_for_TRT.py --weights yolov7.pt --img-size 640 --batch-size 1 --simplify --opset 10
and yolov7_640x640.onnx and yolov7_640x640.yaml will be generated, copy both of them to the path of this project
python3 onnx2trt.py --onnx yolov7_640x640.onnx --yaml yolov7_640x640.yaml --workspace 8 --fp16
and yolov7_640x640.engine and yolov7_640x640.pt will be generated for tensorRT c++ inference and python inference
modify some params in detect.py and then
python3 detect.py
modify your lib path in cpp/CMakeLists.txt and then
cd cpp
mkdir build && cd build
cmake ..
make
cd ..
modify params in run.py and then
python3 run.py