Skip to content

Questions about *checkpoints* and *pretrain weights* #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yaotingwangofficial opened this issue Jan 30, 2025 · 3 comments
Open

Questions about *checkpoints* and *pretrain weights* #82

yaotingwangofficial opened this issue Jan 30, 2025 · 3 comments

Comments

@yaotingwangofficial
Copy link

Dear Authours,

Many thanks for your efforts on this great work and releasing the code!

I have some questions that (I guess others may also be interested in):

Q1. how to load the pretrain weights correctly?

(1) I got the pretrain weight from: https://huggingface.co/jiayuanz3/MedSAM2_pretrain/tree/main .
(2) I modified your train_2d.py script for evaluation. Specifically, I retained only the validation part and removed the training sections.
(3) I loaded the pretrain weights with code:

ckpt_path = './checkpoints/MedSAM2_pretrain.pth'
checkpoint = torch.load(ckpt_path)
net.load_state_dict(checkpoint['model'])

net.eval()
tol, (eiou, edice) = function.validation_sam(args, nice_test_loader, epoch, net, writer)
  • however, the results on REFUGE is Total score: 1.5096757411956787, IOU: 0.0159607185616769, DICE: 0.026624170053027436.

(4) I also tried with using the args.pretrain without net.load_state_dict in the above:

# with -pretrain MedSAM2_pretrain.pth
Total score: 0.6400713324546814, IOU: 0.07327658690868426, DICE: 0.10690500849569073

# without -pretrain
Total score: 0.6306238174438477, IOU: 0.09716492249995469, DICE: 0.1419979241103477

I guess my results are incorrect. May I get any guidance from you?

Q2. Different SAM2 foundation size

  • Are the released pretrained weights MedSAM2_pretrain.pth suitable for different SAM2 foundation sizes? I noticed that you only included tiny and small in the code. Would it be feasible if I directly replace them with base or large variations?

  • actually I tried to use load_state_dict for small size but got incompatible parameter dimensions.

@yaotingwangofficial
Copy link
Author

check #9

@liuna0420
Copy link

Dear Authours, 亲爱的盖世,

Many thanks for your efforts on this great work and releasing the code!非常感谢您为这个伟大的工作和发布代码所做的努力!

I have some questions that (I guess others may also be interested in):我有一些问题(我想其他人可能也会感兴趣):

Q1. how to load the pretrain weights correctly?

Q1。如何正确加载预训练权值?
(1) I got the pretrain weight from: https://huggingface.co/jiayuanz3/MedSAM2_pretrain/tree/main . (2) I modified your train_2d.py script for evaluation. Specifically, I retained only the validation part and removed the training sections. (3) I loaded the pretrain weights with code:(3)我用代码加载预训练权重:(1)训练前权重来自:https://huggingface.co/jiayuanz3/MedSAM2_pretrain/tree/main。(2)我修改了你的train_2d.py脚本进行评估。具体来说,我只保留了验证部分,并删除了培训部分。

ckpt_path = './checkpoints/MedSAM2_pretrain.pth'
checkpoint = torch.load(ckpt_path)
net.load_state_dict(checkpoint['model'])

net.eval()
tol, (eiou, edice) = function.validation_sam(args, nice_test_loader, epoch, net, writer)
  • however, the results on REFUGE is Total score: 1.5096757411956787, IOU: 0.0159607185616769, DICE: 0.026624170053027436.然而,REFUGE的结果却是。

(4) I also tried with using the args.pretrain without net.load_state_dict in the above:(4)我也试过在上面的句子中使用without:

# with -pretrain MedSAM2_pretrain.pth
Total score: 0.6400713324546814, IOU: 0.07327658690868426, DICE: 0.10690500849569073

# without -pretrain
Total score: 0.6306238174438477, IOU: 0.09716492249995469, DICE: 0.1419979241103477

I guess my results are incorrect. May I get any guidance from you?我想我的结果是错误的。我可以得到你的指导吗?

Q2. Different SAM2 foundation size

Q2。不同的SAM2基础尺寸

  • Are the released pretrained weights MedSAM2_pretrain.pth suitable for different SAM2 foundation sizes? I noticed that you only included tiny and small in the code. Would it be feasible if I directly replace them with base or large variations?释放的预训练权重是否适用于不同的SAM2基础尺寸?我注意到您在代码中只包含了tiny和small。如果我直接用碱基或大的变体替换它们可行吗?
  • actually I tried to use load_state_dict for small size but got incompatible parameter dimensions.实际上,我尝试使用尺寸,但得到不兼容的参数尺寸。

Hello, have you solved this problem? I had the same problem.
Looking forward to your reply, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants