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 use_cpu option for classification eval from cuda trained checkpoint #169

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: 7 additions & 3 deletions test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ def test(model, loader, num_class=40, vote_num=1):
class_acc = np.zeros((num_class, 3))

for j, (points, target) in tqdm(enumerate(loader), total=len(loader)):
vote_pool = torch.zeros(target.size()[0], num_class)

if not args.use_cpu:
points, target = points.cuda(), target.cuda()
points, target, vote_pool = points.cuda(), target.cuda(), vote_pool.cuda()

points = points.transpose(2, 1)
vote_pool = torch.zeros(target.size()[0], num_class).cuda()


for _ in range(vote_num):
pred, _ = classifier(points)
Expand Down Expand Up @@ -102,7 +104,9 @@ def log_string(str):
if not args.use_cpu:
classifier = classifier.cuda()

checkpoint = torch.load(str(experiment_dir) + '/checkpoints/best_model.pth')
torch_load_map_location = torch.device('cpu') if args.use_cpu else torch.device('cuda')
checkpoint = torch.load(str(experiment_dir) + '/checkpoints/best_model.pth', map_location=torch_load_map_location)

classifier.load_state_dict(checkpoint['model_state_dict'])

with torch.no_grad():
Expand Down