Skip to content

Commit a983364

Browse files
authored
load weights to cpu if use_cuda is False
1 parent 4272fd0 commit a983364

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

efficientdet_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858

5959
model = EfficientDetBackbone(compound_coef=compound_coef, num_classes=len(obj_list),
6060
ratios=anchor_ratios, scales=anchor_scales)
61-
model.load_state_dict(torch.load(f'weights/efficientdet-d{compound_coef}.pth'))
61+
if use_cuda:
62+
model.load_state_dict(torch.load(f'weights/efficientdet-d{compound_coef}.pth'))
63+
else:
64+
model.load_state_dict(torch.load(f'weights/efficientdet-d{compound_coef}.pth', map_location=torch.device('cpu')))
6265
model.requires_grad_(False)
6366
model.eval()
6467

0 commit comments

Comments
 (0)