ONNX grid float
This commit is contained in:
parent
3bf0cb9c60
commit
efbeb283c4
|
@ -145,7 +145,7 @@ class YOLOLayer(nn.Module):
|
||||||
|
|
||||||
def create_grids(self, ng=(13, 13), device='cpu'):
|
def create_grids(self, ng=(13, 13), device='cpu'):
|
||||||
self.nx, self.ny = ng # x and y grid size
|
self.nx, self.ny = ng # x and y grid size
|
||||||
self.ng = torch.tensor(ng)
|
self.ng = torch.tensor(ng, dtype=torch.float)
|
||||||
|
|
||||||
# build xy offsets
|
# build xy offsets
|
||||||
if not self.training:
|
if not self.training:
|
||||||
|
@ -193,9 +193,9 @@ class YOLOLayer(nn.Module):
|
||||||
elif ONNX_EXPORT:
|
elif ONNX_EXPORT:
|
||||||
# Avoid broadcasting for ANE operations
|
# Avoid broadcasting for ANE operations
|
||||||
m = self.na * self.nx * self.ny
|
m = self.na * self.nx * self.ny
|
||||||
ng = 1 / self.ng.repeat((m, 1))
|
ng = 1. / self.ng.repeat(m, 1)
|
||||||
grid = self.grid.repeat((1, self.na, 1, 1, 1)).view(m, 2)
|
grid = self.grid.repeat(1, self.na, 1, 1, 1).view(m, 2)
|
||||||
anchor_wh = self.anchor_wh.repeat((1, 1, self.nx, self.ny, 1)).view(m, 2) * ng
|
anchor_wh = self.anchor_wh.repeat(1, 1, self.nx, self.ny, 1).view(m, 2) * ng
|
||||||
|
|
||||||
p = p.view(m, self.no)
|
p = p.view(m, self.no)
|
||||||
xy = torch.sigmoid(p[:, 0:2]) + grid # x, y
|
xy = torch.sigmoid(p[:, 0:2]) + grid # x, y
|
||||||
|
|
Loading…
Reference in New Issue