Merge pull request #21 from coderobe/main
load sam_hq to cpu if cuda is unavailable
This commit is contained in:
@@ -64,7 +64,10 @@ def _load_sam_checkpoint(sam: Sam, checkpoint=None):
|
||||
sam.eval()
|
||||
if checkpoint is not None:
|
||||
with open(checkpoint, "rb") as f:
|
||||
state_dict = torch.load(f)
|
||||
if torch.cuda.is_available():
|
||||
state_dict = torch.load(f)
|
||||
else:
|
||||
state_dict = torch.load(f, map_location=torch.device('cpu'))
|
||||
info = sam.load_state_dict(state_dict, strict=False)
|
||||
print(info)
|
||||
for _, p in sam.named_parameters():
|
||||
|
||||
Reference in New Issue
Block a user