We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf72405 commit ebd8eeaCopy full SHA for ebd8eea
segment_anything/build_sam.py
@@ -157,7 +157,8 @@ def _build_sam(
157
sam.eval()
158
if checkpoint is not None:
159
with open(checkpoint, "rb") as f:
160
- state_dict = torch.load(f)
+ device = "cuda" if torch.cuda.is_available() else "cpu"
161
+ state_dict = torch.load(f, map_location=device)
162
info = sam.load_state_dict(state_dict, strict=False)
163
print(info)
164
for n, p in sam.named_parameters():
0 commit comments