Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Created June 6, 2020 02:47
Show Gist options
  • Save arunm8489/eb9055192ff2c67024c9ddcbb46679de to your computer and use it in GitHub Desktop.
Save arunm8489/eb9055192ff2c67024c9ddcbb46679de to your computer and use it in GitHub Desktop.
im_dim_list = torch.index_select(im_dim, 0, output[:,0].long())
scaling_factor = torch.min(conf_inp_dim/im_dim_list,1)[0].view(-1,1)
output[:,[1,3]] -= (conf_inp_dim - scaling_factor*im_dim_list[:,0].view(-1,1))/2
output[:,[2,4]] -= (conf_inp_dim - scaling_factor*im_dim_list[:,1].view(-1,1))/2
output[:,1:5] /= scaling_factor
# adjusting bounding box size between 0 and configuration image size
output[:,1:5] = torch.clamp(output[:,1:5], 0.0, float(conf_inp_dim))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment