Skip to content

Commit 3cc639a

Browse files
committed
cpu
1 parent ebd8eea commit 3cc639a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

segment_anything/build_sam.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def build_sam_vit_t(checkpoint=None):
8989
mobile_sam.eval()
9090
if checkpoint is not None:
9191
with open(checkpoint, "rb") as f:
92-
state_dict = torch.load(f)
92+
device = "cuda" if torch.cuda.is_available() else "cpu"
93+
state_dict = torch.load(f, map_location=device)
9394
info = mobile_sam.load_state_dict(state_dict, strict=False)
9495
print(info)
9596
for n, p in mobile_sam.named_parameters():

0 commit comments

Comments
 (0)