Skip to content

Commit

Permalink
add torch.no_grad()
Browse files Browse the repository at this point in the history
  • Loading branch information
Youngmin Baek committed Dec 4, 2019
1 parent 3cd65f5 commit e332dd8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ def test_net(net, image, text_threshold, link_threshold, low_text, cuda, poly, r
x = x.cuda()

# forward pass
y, feature = net(x)
with torch.no_grad():
y, feature = net(x)

# make score and link map
score_text = y[0,:,:,0].cpu().data.numpy()
score_link = y[0,:,:,1].cpu().data.numpy()

# refine link
if refine_net is not None:
y_refiner = refine_net(y, feature)
with torch.no_grad():
y_refiner = refine_net(y, feature)
score_link = y_refiner[0,:,:,0].cpu().data.numpy()

t0 = time.time() - t0
Expand Down

0 comments on commit e332dd8

Please sign in to comment.