Dootmaan/MT-UNet

使用Synapse权重无法进行测试

Opened this issue · 1 comments

您好,非常感谢您的工作,收获很多,我在使用您给的Synapse权重尝试直接进行测试得到预测的分割图像时一直报错,如下所示:
Traceback (most recent call last): File "/data/cy-codes/MT-UNet-main/test_Synapse.py", line 23, in <module> model.load_state_dict(torch.load(args.checkpoint)) File "/data/miniconda/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2041, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for MTUNet: size mismatch for SegmentationHead.weight: copying a param with shape torch.Size([9, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([4, 64, 1, 1]). size mismatch for SegmentationHead.bias: copying a param with shape torch.Size([9]) from checkpoint, the shape in current model is torch.Size([4]).
我已经设置了num_classes的值为9,但是仍然报错,所以想向您请教,当然如果您能提供MT-UNet预测的分割结果,我会不胜感激,我的邮箱是allure0719@163.com,非常感谢!!

Hi @Candice-Y and thank you for your question. Seems like you are trying to use ACDC weights for Synapse validation. This will cause a size mismatch for the classifier of MT-UNet as ACDC weights is for 4-class classification task. You can simply change to use our provided Synapse weights for this task.