xinghaochen commited on
Commit
973f2c1
1 Parent(s): 5236358

Update tinysam/build_sam.py

Browse files
Files changed (1) hide show
  1. tinysam/build_sam.py +2 -1
tinysam/build_sam.py CHANGED
@@ -88,7 +88,8 @@ def build_sam_vit_t(checkpoint=None):
88
  mobile_sam.eval()
89
  if checkpoint is not None:
90
  with open(checkpoint, "rb") as f:
91
- state_dict = torch.load(f)
 
92
  mobile_sam.load_state_dict(state_dict)
93
  return mobile_sam
94
 
 
88
  mobile_sam.eval()
89
  if checkpoint is not None:
90
  with open(checkpoint, "rb") as f:
91
+ device = "cuda" if torch.cuda.is_available() else "cpu"
92
+ state_dict = torch.load(f, map_location=device)
93
  mobile_sam.load_state_dict(state_dict)
94
  return mobile_sam
95