askerlee / segtran

Medical Image Segmentation using Squeeze-and-Expansion Transformers
216 stars 49 forks source link

test.py checking #19

Closed bhralzz closed 2 years ago

bhralzz commented 3 years ago

Hi again. I also tested the multi gpu train.py form and worked fine till now in training, however I need to use trained model for testing on new samples. did you checked test.py file? Error shown as below TypeError: init() got an unexpected keyword argument 'mask_num_classes' there are some another errors like undefined name visualize_model, evalrobustness, testloader, ... please check test.py waiting to hear from you. thanks

askerlee commented 3 years ago

You mean test3d.py right? Previously I suggested you to insert a structure like below to use brats 2020 dataset. But seems brats 2020 folders are already included in this structure:

                     'brats': {
                                 'num_classes': 4,
                                 'bce_weight':  [0., 3, 1, 1.75],  # bg, ET, WT, TC
                                 'ds_class':    'BratsSet',
                                 'train_ds_names':  '2019train',
                                 'test_ds_name':    '2019valid',
                                 'chosen_modality': -1,
                                 'xyz_permute':     None, # (1, 2, 0),
                                 'orig_input_size': None,
                                 # each dim of the orig_patch_size should always be multiply of 8.
                                 'orig_patch_size': (112, 112, 96),
                                 'input_scale':     (1,   1,   1),
                                 'D_pool_K':         2,
                                 'has_mask':    { '2019train': True,    '2019valid': False, 
                                                  '2020train': True,    '2020valid': False },
                                 'weight':      { '2019train': 1,       '2019valid': 1, 
                                                  '2020train': 1,       '2020valid': 1 }
                               },   

But you need to name the names of the training and validation folders to 2020train and 2020valid, respectively. Then the test command line will be like: python3 test3d.py --task brats --split all --bs 5 --ds 2020valid --net segtran --attractors 1024 --translayers 1 --cpdir ../model/segtran-brats-2019train-01170142 --iters 8000

bhralzz commented 3 years ago

but still getting below error in test3d.py TypeError: init() got an unexpected keyword argument 'mask_num_classes'

when running the command python3 test3d.py --task brats --split all --bs 5 --ds BraTS20_Valid --net segtran --attractors 1024 --translayers 1 --cpdir ../model/segtran-brats-BraTS20_Train-09211348 --iters 1000 as the train and validation folder path as below: BraTS20_Train & BraTS20_Valid and the train3d.py worked correctly in this setting

by removing such keywords worked!

askerlee commented 3 years ago

Thank you! Yes it's because I updated datasets3d.py but forgot to update test3d.py. So some useless variables were still there. I've fixed the code.