Skip to content

Commit

Permalink
support on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Khoa-NT committed Jan 30, 2024
1 parent 69b5185 commit f56b3f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
SAM_MODEL_TYPE = "vit_b"
MedSAM_CKPT_PATH = "work_dir/MedSAM/medsam_vit_b.pth"
MEDSAM_IMG_INPUT_SIZE = 1024
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

if torch.backends.mps.is_available():
device = torch.device("mps")
else:
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")


@torch.no_grad()
Expand Down
2 changes: 1 addition & 1 deletion segment_anything/build_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ def _build_sam(

if checkpoint is not None:
with open(checkpoint, "rb") as f:
state_dict = torch.load(f)
state_dict = torch.load(f, map_location=torch.device('cpu'))
sam.load_state_dict(state_dict)
return sam

0 comments on commit f56b3f7

Please sign in to comment.