Comments (3)
Hello! It looks like you're on the right track with setting up dynamic dimensions for your custom YOLOv8 model export to TensorRT. However, the issue you're encountering with the first dimension not being set to -1
for certain tensors is likely due to how TensorRT handles dynamic shapes during the export process.
For TensorRT, when you specify dynamic axes, you need to ensure that the model's architecture and the export settings are correctly aligned to handle these dynamic dimensions. From your description, it seems that only the last two output tensors are correctly recognizing the dynamic batch size.
Here's a couple of things you might want to check or adjust:
- Ensure Consistency in Model Definition: Double-check your model's forward function and make sure that all tensors that should have dynamic dimensions are correctly defined to handle varying batch sizes.
- Adjust Export Settings: Sometimes, explicitly setting the dynamic axes for all outputs as you've done might not be recognized due to internal handling by the export function. You might need to adjust or simplify how you define these settings.
If these steps don't resolve the issue, consider providing a minimal reproducible example when you seek further help. This way, the community or the support team can replicate the issue exactly and provide more targeted assistance.
Here's a simplified dynamic setting you might try adjusting to:
dynamic_axes = {'input': {0: 'batch'}, 'output': {0: 'batch'}}
model.export(format='engine', imgsz=1920, batch=1, half=True, dynamic_axes=dynamic_axes, simplify=False, int8=False)
Hope this helps! Let us know how it goes. π
from ultralytics.
@glenn-jocher
My forward function is quite complicated, involving multiple stages of scaling, NMS, sorting, indexing, matching, etc. It uses a for loop to iterate the samples in each batch. If TensorRT requires the dynamic dimension to be aligned through all these steps, it is not surprising it cannot work.
And yes, a simpler example does work with dynamic batch size.
My application does not really require dynamic batch size, so I might just set it to 1 for now. Thanks for the advice!
from ultralytics.
Hi there! π
It sounds like you've got a complex forward function with multiple operations that might indeed complicate the handling of dynamic dimensions in TensorRT. Sticking to a fixed batch size, especially if dynamic batching isn't a requirement for your application, is a practical approach. Setting the batch size to 1, as you mentioned, should help maintain consistency and stability in your model's performance.
If you ever need to revisit dynamic batching or encounter any other issues, feel free to reach out. Happy coding! π
from ultralytics.
Related Issues (20)
- Joint angle detection HOT 8
- Model interpretability or showing most valuable features HOT 2
- Image URLs without file extension lead to 500 error & server crash HOT 4
- non_max_suppression slow HOT 3
- Why does training accuracy suddently decrease? HOT 7
- Postprocess Yolov8-segmentation raw prediction HOT 4
- how to validate my model on different MAP values ? for ex: at 0.7 , 0.9 HOT 3
- The inference time suddenly became very long. I donβt know whether it is a GPU driver problem or a change in the underlying model. HOT 1
- Ultralytics support v9 and v10 at the same package? HOT 7
- Accurate Detection of Inner Corner Points in Parking Slots Using YOLOv8-Pose HOT 4
- reimplement YOLOv8-obb result on DOTA HOT 6
- Poor results and remove pretrained classes from training HOT 4
- Created a method to reproduce imgsz and rect, please check, for article. HOT 1
- Problem on detection of static objects HOT 3
- Trouble installing Ultralytics on the Jetson Nano HOT 5
- The ray tune result is incomplete HOT 2
- blurry details after resizing images to 640x360 HOT 2
- How to Perform Inference on YOLOv8 Model Deployed on Triton Inference Server using TritonClient? HOT 4
- Bounding Box Level Augmentations Recommendation HOT 1
- A question about Batch Shape Strategy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.