Skip to content
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

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

Open
yaotingwangofficial opened this issue Jan 30, 2025 · 1 comment
Open

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

yaotingwangofficial opened this issue Jan 30, 2025 · 1 comment

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

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

1 participant