WZH0120 / SAM2-UNet

SAM2-UNet: Segment Anything 2 Makes Strong Encoder for Natural and Medical Image Segmentation
Apache License 2.0
98 stars 11 forks source link

wrong checkpoint #18

Open waner1998 opened 1 day ago

waner1998 commented 1 day ago

Thank you for your wonderful work. 'Encoder. SAM2-UNet applys the Hiera [38] backbone pretrained by SAM2.' However, I download the checkpoint from 'https://dl.fbaipublicfiles.com/segment_anything_2/092824/sam2.1_hiera_large.pt' in 'https://github.com/facebookresearch/sam2/tree/main/checkpoints', but failed to init the model, can you send me the checkpoint you use in the paper? My e-mail adress is: wan_er1998@163.com Sincerely,

File "F:\seg\SAM2-UNet-main\SAM2-UNet-main\untils.py", line 55, in init_net return SAM2UNet(checkpoint_path=path) File "F:\seg\SAM2-UNet-main\SAM2-UNet-main\SAM2UNet.py", line 129, in init model = build_sam2(model_cfg, checkpoint_path) File "F:\seg\SAM2-UNet-main\SAM2-UNet-main\sam2\build_sam.py", line 36, in build_sam2 _load_checkpoint(model, ckpt_path) File "F:\seg\SAM2-UNet-main\SAM2-UNet-main\sam2\build_sam.py", line 82, in _load_checkpoint missing_keys, unexpected_keys = model.load_state_dict(sd) File "C:\Users\user.conda\envs\torch\lib\site-packages\torch\nn\modules\module.py", line 2189, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for SAM2Base: Unexpected key(s) in state_dict: "no_obj_embed_spatial", "obj_ptr_tpos_proj.weight", "obj_ptr_tpos_proj.bias".

xiongxyowo commented 1 day ago

Hi, it seems that you downloaded the checkpoint of just released SAM2.1 rather than SAM2. Currently, SAM2.1 is not fully compatible with SAM2. You can download the SAM2 checkpoint from here.

waner1998 commented 1 day ago

Thank you for your efficient response, the problem has been solved, thanks! Looking forward to your new contributions in China.