Skip to content

Instantly share code, notes, and snippets.

@magesh-technovator
Created April 25, 2021 06:21
Show Gist options
  • Save magesh-technovator/ceb4af826501595630f10957033bbb76 to your computer and use it in GitHub Desktop.
Save magesh-technovator/ceb4af826501595630f10957033bbb76 to your computer and use it in GitHub Desktop.
CRAFT Prediction and post-processing
# Load image as torch tensor
x = torch.from_numpy(x).permute(2, 0, 1) # [h, w, c] to [c, h, w]
x = Variable(x.unsqueeze(0)) # [c, h, w] to [b, c, h, w]
if cuda:
x = x.cuda()
# forward pass
with torch.no_grad():
y, feature = net(x)
# Get Score and Affinity Map
score_text = y[0,:,:,0].cpu().data.numpy()
score_link = y[0,:,:,1].cpu().data.numpy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment