Skip to content

Commit c8571c7

Browse files
deepsworldglenn-jocher
authored andcommitted
Update yolo.py
Checking for `onnx_dynamic` first should suppress the warning: ```log TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic ```
1 parent d895a7f commit c8571c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

models/yolo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def forward(self, x):
5555
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
5656

5757
if not self.training: # inference
58-
if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic:
58+
if self.onnx_dynamic or self.grid[i].shape[2:4] != x[i].shape[2:4]:
5959
self.grid[i], self.anchor_grid[i] = self._make_grid(nx, ny, i)
6060

6161
y = x[i].sigmoid()

0 commit comments

Comments
 (0)