Fix ONNX RuntimeError with dynamic WorldModel (#19322)

Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/19327/head
Mohammed Yasin 3 weeks ago committed by GitHub
parent 8f68ab04dc
commit 4fec5bfa28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      ultralytics/nn/tasks.py

@ -637,8 +637,8 @@ class WorldModel(DetectionModel):
(torch.Tensor): Model's output tensor.
"""
txt_feats = (self.txt_feats if txt_feats is None else txt_feats).to(device=x.device, dtype=x.dtype)
if len(txt_feats) != len(x):
txt_feats = txt_feats.repeat(len(x), 1, 1)
if len(txt_feats) != len(x) or self.model[-1].export:
txt_feats = txt_feats.expand(x.shape[0], -1, -1)
ori_txt_feats = txt_feats.clone()
y, dt, embeddings = [], [], [] # outputs
for m in self.model: # except the head part

Loading…
Cancel
Save