converting yolov7's .pt to tensorRT .trt format
yea yolov7's .pt is fine but we're not getting the best Performance™ out of our hardware.
so in this tutorial We will be converting yolov7's .pt to Nvidia's TensorRT .trt format.
there won't be much complex janky setup , as it is a streamlined with using a docker container
(you do have to deal with nvidia drivers though but you're probably already dealing with it anyways)
before we begin make sure you have these 3 components:
- nvidia drivers
- docker
- nvidia-docker
- make (proabbly already installed if u are on linux like me)
clone my repo:
git clone https://github.com/heabeounMKTO/docker_yolo2trt.git
make a local docker registry to store your docker images:
docker run -d -p 5000:5000 --name registry registry:latest
build the base image
(you'd probably need sudo
if you dont allow docker to run without sudo )
make trtconvbase
example conversion:
sudo make trt_engine $MODEL_DIR=/path/to/model/folder $MODEL_NAME=/path/to/model/file
make
arguments
Argument | Type | Description |
---|---|---|
DOCKER_REGISTRY | Optional | address of the (local) docker registry that you build and store your images to should you have a different port than the default 5000 |
TRT_CONVBASE | Optional | name of TRT conversion container |
MODEL_DIR | Required | directory that stores the .pt models, will be mounted to docker container |
MODEL_NAME | Required | name of the model you want converted |
(yea i just copy-pasted my OWN readme)
how it works:
yolov7.pt => yolov7.onnx => yolov7.trt
there is batch processing suppourt but maybe i'll write that one up later idk. that's all for now.