Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion P3-SAM/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def load_state_dict(self,
ignore_seg_s2_mlp=False,
ignore_iou_mlp=False): # load checkpoint
if ckpt_path is not None:
state_dict = torch.load(ckpt_path, map_location="cpu")["state_dict"]
if ckpt_path.endswith('.safetensors'):
from safetensors.torch import load_file
state_dict = load_file(ckpt_path, device="cpu")
else:
state_dict = torch.load(ckpt_path, map_location="cpu")["state_dict"]
elif state_dict is None:
# download from huggingface
print(f'trying to download model from huggingface...')
Expand Down