Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Resolves memory leak caused by using CRAFT detector repeatedly #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def test_net(net, image, text_threshold, link_threshold, low_text, cuda, poly, r
with torch.no_grad():
y, feature = net(x)

# remove X from device memory, no longer needed
del x

# make score and link map
score_text = y[0,:,:,0].cpu().data.numpy()
score_link = y[0,:,:,1].cpu().data.numpy()
Expand All @@ -94,6 +97,13 @@ def test_net(net, image, text_threshold, link_threshold, low_text, cuda, poly, r
y_refiner = refine_net(y, feature)
score_link = y_refiner[0,:,:,0].cpu().data.numpy()


# remove y and feature from device, whether GPU or CPU
del y, feature
# empty cuda cache to allow nvidia-smi to be more accurate
if cuda:
torch.cuda.empty_cache()

t0 = time.time() - t0
t1 = time.time()

Expand Down