Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Created June 4, 2020 04:45
Show Gist options
  • Save arunm8489/9fd74bc73e39a437f93833e5e4f94d58 to your computer and use it in GitHub Desktop.
Save arunm8489/9fd74bc73e39a437f93833e5e4f94d58 to your computer and use it in GitHub Desktop.
#Add the center offsets
grid = np.arange(grid_size)
a,b = np.meshgrid(grid, grid)
x_offset = torch.FloatTensor(a).view(-1,1) #(1,gridsize*gridsize,1)
y_offset = torch.FloatTensor(b).view(-1,1)
if CUDA:
x_offset = x_offset.cuda()
y_offset = y_offset.cuda()
x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
prediction[:,:,:2] += x_y_offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment