Set dynamic to True only if imgsz is dynamic for ONNX (#17872)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
This commit is contained in:
Mohammed Yasin 2024-12-06 05:24:53 +08:00 committed by GitHub
parent 5c84099a9d
commit a672bf79dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,7 +155,7 @@ class BasePredictor:
same_shapes = len({x.shape for x in im}) == 1 same_shapes = len({x.shape for x in im}) == 1
letterbox = LetterBox( letterbox = LetterBox(
self.imgsz, self.imgsz,
auto=same_shapes and (self.model.pt or getattr(self.model, "dynamic", False)), auto=same_shapes and (self.model.pt or (getattr(self.model, "dynamic", False) and not self.model.imx)),
stride=self.model.stride, stride=self.model.stride,
) )
return [letterbox(image=x) for x in im] return [letterbox(image=x) for x in im]