Fix TensorRT --dynamic excess outputs bug#8869
Conversation
Potential fix for #8790
|
@democat3457 confirm fix for #8866. Can you please review this PR and see if this approach makes sense? |
|
I have a better solution, should I make a PR? Add this line: ...
self.context.set_binding_shape(self.model.get_binding_index('images'), img.shape)
self.bindings['images'] = self.bindings['images']._replace(shape=img.shape)
+ self.bindings['output'].data.resize_(tuple(self.context.get_binding_shape(self.model.get_binding_index('output'))))
... |
|
@democat3457 got it! I'll add your line and remove my fix. |
|
@democat3457 stupid question, is the previous line not modifying inplace? Does it need a reasignment like you have here? self.bindings['images'] = self.bindings['images']._replace(shape=im.shape)i.e. could this just be: self.bindings['images']._replace(shape=im.shape) |
|
@democat3457 how does this look? |
It does not modify in place, the underscore just stops it from getting mixed up with a possible field of the namedtuple. (Also, I looked - there doesn't exist an in-place replacement, sadly) |
Looks good to me! |
|
@democat3457 PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐ |
* Fix TensorRT --dynamic excess outputs bug Potential fix for ultralytics#8790 * Cleanup * Update common.py * Update common.py * New fix

Potential fix for #8790
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Improved TensorRT dynamic input handling in YOLOv5 🚀
📊 Key Changes
dynamic_inputvariable todynamicto simplify naming.🎯 Purpose & Impact