Remove named arguments where possible (#7105)
* Remove named arguments where possible Speed improvements. * Update yolo.py * Update yolo.py * Update yolo.py
This commit is contained in:
1 parent
6134ec5d94
commit
ecc2c7ba73
2 files changed
+12
-12
No files matched your search
+5
-5
@@ -71,13 +71,13 @@ class Detect(nn.Module):
|
||||
|
||||
def _make_grid(self, nx=20, ny=20, i=0):
|
||||
d = self.anchors[i].device
|
||||
shape = 1, self.na, ny, nx, 2 # grid shape
|
||||
if check_version(torch.__version__, '1.10.0'): # torch>=1.10.0 meshgrid workaround for torch>=0.7 compatibility
|
||||
yv, xv = torch.meshgrid([torch.arange(ny, device=d), torch.arange(nx, device=d)], indexing='ij')
|
||||
yv, xv = torch.meshgrid(torch.arange(ny, device=d), torch.arange(nx, device=d), indexing='ij')
|
||||
else:
|
||||
yv, xv = torch.meshgrid([torch.arange(ny, device=d), torch.arange(nx, device=d)])
|
||||
grid = torch.stack((xv, yv), 2).expand((1, self.na, ny, nx, 2)).float()
|
||||
anchor_grid = (self.anchors[i].clone() * self.stride[i]) \
|
||||
.view((1, self.na, 1, 1, 2)).expand((1, self.na, ny, nx, 2)).float()
|
||||
yv, xv = torch.meshgrid(torch.arange(ny, device=d), torch.arange(nx, device=d))
|
||||
grid = torch.stack((xv, yv), 2).expand(shape).float()
|
||||
anchor_grid = (self.anchors[i] * self.stride[i]).view((1, self.na, 1, 1, 2)).expand(shape).float()
|
||||
return grid, anchor_grid
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user