Refactor Detect() anchors for ONNX <> OpenCV DNN compatibility (#4833)
* refactor anchors and anchor_grid in Detect Layer * fix CI failures by adding compatibility * fix tf failure * fix different devices errors * Cleanup * fix anchors overwriting issue * better refactoring * Remove self.anchor_grid shape check (redundant with self.grid check) Also PEP8 / 120 line width * Convert _make_grid() from static to dynamic method * Remove anchor_grid.to(device) clone() should already clone to same device as self.anchors * fix different devices error Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
153873e9e4
commit
9d75e42f98
5 files changed
+24
-16
No files matched your search
@@ -295,6 +295,8 @@ class AutoShape(nn.Module):
|
||||
m = self.model.model[-1] # Detect()
|
||||
m.stride = fn(m.stride)
|
||||
m.grid = list(map(fn, m.grid))
|
||||
if isinstance(m.anchor_grid, list):
|
||||
m.anchor_grid = list(map(fn, m.anchor_grid))
|
||||
return self
|
||||
|
||||
@torch.no_grad()
|
||||
|
||||
Reference in new issue
Block a user