Open mr-september opened 1 year ago
This is due to https://jdhao.github.io/2022/01/28/pytorch_model_load_error/
The fix for that specific error is to add map_location=torch.device('cpu')
in build_sam_hq.py
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, map_location=torch.device('cpu'))
info = sam.load_state_dict(state_dict, strict=False)
print(info)
for _, p in sam.named_parameters():
p.requires_grad = False
return sam
But if you are trying to run this on a non-nvidia card you'll probably still run into other issues...
Is there an existing issue for this?
Have you updated WebUI and this extension to the latest version?
Do you understand that you should read the 1st item of https://github.com/continue-revolution/sd-webui-segment-anything#faq if you cannot install GroundingDINO?
Do you understand that you should use the latest ControlNet extension and enable external control if you want SAM extension to control ControlNet?
Do you understand that you should read the 2nd item of https://github.com/continue-revolution/sd-webui-segment-anything#faq if you observe problems like AttributeError bool object has no attribute enabled and TypeError bool object is not subscriptable?
What happened?
Tries to use CUDA even in CPU-only mode
Steps to reproduce the problem
What should have happened?
Do not try to use CUDA, and generate segmentations.
Commit where the problem happens
webui: Ishqqytiger/DirectML - ba780a8 extension: 780fc49
What browsers do you use to access the UI ?
No response
Command Line Arguments
Console logs
Additional information
No response