TransUNet 2D & 3D - nntrongnghia/TDSI21-Shoulder-Muscle-Segmentation GitHub Wiki
Implementation
- The official code of TransUNet is used for the model 2D implementation. Intermediate outputs are added in the model to perform deep supervision training.
- For TransUNet3D, all convolution are changed to Conv3D.
- To train with nnUNet, a planner and trainer are also implemented:
- Planner:
- Determine the batch size based on GPU maximum memory
- Define the image patch size
- Trainer: inspired from nnUNetTrainerV2, this trainer is adapted to instantiate the model, to calculate deep supervision loss weights based on TransUNet configuration.
- Planner:
Training
- Train 1 fold:
nnUNet_train MODEL TransUNetTrainer TASK_NAME FOLD
MODEL could be TransUNet2D or TransUNet3D
- After training all 5 folds, we need to determine the postprocessing of ensemble of these 5 folds:
nnUNet_find_best_configuration -m TransUNet3D -t TASK_NUMBER
Inference
nnUNet_predict -i INPUT_IMAGE_DIR -o OUTPUT_INFERENCE_DIR -m TransUNet3D --save_npz -t TASK_NAME
Evaluate
nnUNet_evaluate_folder -ref TARGET_IMAGE_DIR -pred PREDICTION_DIR -l L [Class number like 1 2 3 4 5]