Beckschen/3D-TransUNet

Problem with validation on folds and inference

Opened this issue · 0 comments

Hi. First of all, congratulations for the work and thanks for sharing it!

I created a model with BraTS2021 database, just using T1ce and enhanced tumour region. I have been trying to run inference but there is some problem with the code. There is an example of the running command on fold 0:

nnunet_use_progress_bar=1 torchrun --nproc_per_node=1 /code/maincode/train.py --task="Task001_BraTS_T1captante" --fold=0 --config="/code/data/nnUNet_raw_data_base/nnUNet_raw/nnUNet_raw_data/Task001_BraTS_T1captante/encoder_plus_decoder.yaml" --network="3d_fullres" --resume='' --local-rank=0 --optim_name="adam" --valbest --val_final --npz

Everything works find until the final step of validation (the model ends the training phase). I tried to run the validation on fold 0 to get the predictions:

nnunet_use_progress_bar=1 torchrun --nproc_per_node=1 /code/maincode/train.py --task="Task001_BraTS_T1captante" --fold=0 --config="/code/data/nnUNet_raw_data_base/nnUNet_raw/nnUNet_raw_data/Task001_BraTS_T1captante/encoder_plus_decoder.yaml"
--network="3d_fullres" --resume='' --local-rank=0 --optim_name="adam" --val_final --validation_only

The error is the following:

computing Gaussian
run?
Traceback (most recent call last):
File "/code/maincode/train.py", line 321, in
main()
File "/code/maincode/train.py", line 307, in main
trainer.validate(save_softmax=args.npz, validation_folder_name=val_folder,
File "/code/maincode/nn_transunet/trainer/nnUNetTrainerV2_DDP.py", line 1188, in validate
softmax_pred = self.predict_preprocessed_data_return_seg_and_softmax(data[:-1],
File "/code/maincode/nn_transunet/trainer/nnUNetTrainerV2_DDP.py", line 1313, in predict_preprocessed_data_return_seg_and_softmax
return ret
UnboundLocalError: local variable 'ret' referenced before assignment

I also tried to run the inference.py script:

python3 /code/maincode/inference.py --config="/code/data/nnUNet_raw_data_base/nnUNet_raw/nnUNet_raw_data/Task001_BraTS_T1captante/encoder_plus_decoder.yaml"
--fold=0 --raw_data_dir="/code/data/nnUNet_raw_data_base/nnUNet_raw/nnUNet_raw_data/Task001_BraTS_T1captante/imagesTs" --raw_data_folder="imagesTs"--save_folder="/code/data/nnUNet_results/UNet_IN_NANFang/Task001_BraTS_T1captante/nnUNetTrainerV2_DDP__nnUNetPlansv2.1/GeTU500_3DTransUNet_encoder_plus_decoder/fold_0/predicts" --local_rank=0 --num_examples=250 --n_class=1

The execution works without errors, but the network does not return any files.

Can anybody help me? Thanks!