ziyangwang007 / Mamba-UNet

Mamba-UNet Zoo
Apache License 2.0
343 stars 22 forks source link

How to use Synapse dataset? #17

Open onion-LHJ opened 1 month ago

onion-LHJ commented 1 month ago

Hi!Your team have made a amazing work!But I got some troubles about it. I saw you used Synapse dataset in your paper,but i don't find the usage about Synapse dataset in your github. And then I try to reproduce the code and make some modification on my own way for Synapse dataset,but i got a different result and some bug: 1.When i used --max_iterations 10000,i got

Traceback (most recent call last): File "train_fully_supervised_2D_VIM.py", line 257, in train(args, snapshot_path) File "train_fully_supervised_2D_VIM.py", line 186, in train metric_i = test_single_volume( File "/home/zh_701/new_sda_2T/LHJ/Mamba-UNet/code/val_2D.py", line 39, in test_single_volume metric_list.append(calculate_metric_percase( File "/home/zh_701/new_sda_2T/LHJ/Mamba-UNet/code/val_2D.py", line 14, in calculate_metric_percase hd95 = metric.binary.hd95(pred, gt) File "/home/zh_701/anaconda3/envs/Munet/lib/python3.8/site-packages/medpy/metric/binary.py", line 413, in hd95 hd1 = surface_distances(result, reference, voxelspacing, connectivity) File "/home/zh_701/anaconda3/envs/Munet/lib/python3.8/site-packages/medpy/metric/binary.py", line 1269, in surface_distances raise RuntimeError( RuntimeError: The second supplied array does not contain any binary object.

2.When i used --max_iterations 1000,i got: mean_dice : 0.407416 mean_hd95 : 99.048800

I coudn't reproduce the result,I don't how do fix it . I will be appreciate it if your could help me .

ziyangwang007 commented 1 month ago

Hi, for Synapse datasets (this is somehow different from ACDC and prostate), please import the dataset:

from dataloaders.dataset import BaseDataSets_Synapse

and then replace the orginal dataset.

and the bugs indicates the evaluation metrics error. This is not a significant problems, and I guess you could just potentially not use the HD95 metrics, that would be fine. because ths loss is based on dice, not HD95.

hi, have you tried to train a model with 10,000 iterations? or 30,000 iterations?

Thanks.

onion-LHJ commented 1 month ago

Hi, for Synapse datasets (this is somehow different from ACDC and prostate), please import the dataset:

from dataloaders.dataset import BaseDataSets_Synapse

and then replace the orginal dataset.

and the bugs indicates the evaluation metrics error. This is not a significant problems, and I guess you could just potentially not use the HD95 metrics, that would be fine. because ths loss is based on dice, not HD95.

hi, have you tried to train a model with 10,000 iterations? or 30,000 iterations?

Thanks.

It did works!But I got a new trouble when i run test_2D_fully.py I ran as : python test_2D_fully.py --root_path ../data/Synapse --exp Synapse/VIM --model mambaunet --num_classes 9 --labeled_num 8 And then got a bug: test_2D_fully.py:12: DeprecationWarning: Please use zoom from the scipy.ndimage namespace, the scipy.ndimage.interpolation namespace is deprecated. from scipy.ndimage.interpolation import zoom => merge config from ../code/configs/swin_tiny_patch4_window7_224_lite.yaml None ../model/Synapse/VIM_8_labeled/mambaunet/mambaunet_best_model.pth Traceback (most recent call last): File "test_2D_fully.py", line 125, in metric = Inference(FLAGS) File "test_2D_fully.py", line 105, in Inference net.load_state_dict(torch.load(save_mode_path)) AttributeError: 'NoneType' object has no attribute 'load_state_dict'

Notice net is a None type.I trace back in networks.net_factory ,and found: def net_factory(net_type="unet", in_chns=1, class_num=4): if net_type == "unet": net = UNet(in_chns=in_chns, class_num=class_num).cuda() elif net_type == "enet": net = ENet(in_channels=in_chns, num_classes=class_num).cuda() elif net_type == "unet_ds": net = UNet_DS(in_chns=in_chns, class_num=class_num).cuda() elif net_type == "unet_cct": net = UNet_CCT(in_chns=in_chns, class_num=class_num).cuda() elif net_type == "unet_urpc": net = UNet_URPC(in_chns=in_chns, class_num=class_num).cuda() elif net_type == "efficient_unet": net = Effi_UNet('efficientnet-b3', encoder_weights='imagenet', in_channels=in_chns, classes=class_num).cuda() elif net_type == "ViT_Seg" :#or "mambaunet" net = ViT_seg(config, img_size=args.patch_size, num_classes=args.num_classes).cuda() elif net_type == "pnet": net = PNet2D(in_chns, class_num, 64, [1, 2, 4, 8, 16]).cuda() elif net_type == "nnUNet": net = initialize_network(num_classes=class_num).cuda() else: net = None return net

It mean that model" mambaunet" actually has no net

I dont konw how to solve it . Thank a lot for your reply!And could you please help me for the new problem?Thanks again!