-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TensorRT infer support #57
base: main
Are you sure you want to change the base?
Conversation
When exported with --grid: Building the TensorRT engine fails:
Any idea how to fix that @xiang-wuu ? |
I have the same issue when using trtexec for conversion, so this is definitely a TensorRT / ONNX issue. |
@philipp-schmidt that could be an issue due to PyTorch and ONNX version, try upgrading to latest versions for both of them. however am working on post-processing part with |
Yes it was the pytorch version. I also had to run onnx-simplify, otherwise TensorRT had issues with a few resize operations. Looking forward to try your implementation. |
Almost done, with some final typo's to be resolved. |
Quickly scanned the code and it looks really good! A few questions / remarks:
|
Hi, sorry to write here. I've tried your branch with tensorrt and yolov7-tiny custom trained on a Nvidia Jetson Xavier NX. I converted the model trained from pytorch with no problem after some tries, but when testing results, both mAP and FPS are much lower:
Is this normal? Am I doing something wrong? |
|
Optimization is out of scope for this PR, this PR is intended to support minimalistic deployable TRT implementation, the optimization is altogether subject to further contribution. |
@albertfaromatics |
@philipp-schmidt These steps gave me the FPS (40ish vs 25ish). For mAP I used the test here and adapted a code to get the detections from TensorRT and "manually" compute mAP. |
Try to run your engine with trtexec instead, it will give you a very good indication of actual compute latency. Last few steps of this: https://github.com/isarsoft/yolov4-triton-tensorrt#build-tensorrt-engine |
I don't think that it comes prebuilt in the Linux 4 Tegra TensorRT docker images for jetson though. |
@philipp-schmidt I'll give it a try. I can compile it myself from tensorrt/samples folder, but never used it before. I'll try and see why I have this results. |
@WongKinYiu good to merge. |
it works,but no bounding box is drawn |
share the environment details? |
torch 1.11.0+cu113 onnx 1.12.0 tensorrt 8.4.1.5 |
I use deploy_onnx_trt branch to generate yolov7.onnx, to get yolov7.engine, I run the following command: |
@dongdengwei , try without building the plugin , if using TRT > 8.0 |
I run the following command to do the inference: |
it seem that I should replace "return x if self.training else (torch.cat(z, 1), x)" with "return x if self.training else (torch.cat(z, 1), ) if not self.export else (torch.cat(z, 1), x)" in yolo.py. |
@dongdengwei PyTorch > 1.11.0 is required to make it work, recommended is 1.12.0 |
@xiang-wuu @philipp-schmidt @AlexeyAB @Linaom1214 can you share the map performance of converted model? is the accuracy same after conversion ? or how much drop in accuracy?also it would be great if you add support for checking map of .trt model ,its inference on video. Thanks |
Linaom1214/TensorRT-For-YOLO-Series#26 not able to do inference on videos |
Hi, I have tested the yolov7-tiny tensorRT model on jetson Xavier NX by my own code, and the result is showed in issue #703:#703, maybe you can check it. |
the reason is colab env don't support opencv imshow fucntion |
Hi @xiang-wuu , Environment setup: Should the requirements.txt from yolov7 repo be used on Xavier AGX as it is? Inference on Jetson device: Is the original detect.py sufficient for inference using .pt weights on Jetson devices? Looking forward to your response. Cheers :) |
This PR is intended to export model from PyTorch to
onnx
, and then serialize the exported onnx model to native TRT engine, which will be inferred using TensorRT I.E,onnx_to_tensorrt.py
scriptonnx
model to TensorRT enginedetect.py
script to TensorRT infer script