TransDeepLab

December 29, 2022 · View on GitHub

The official code for "TransDeepLab: Convolution-Free Transformer-based DeepLab v3+ for Medical Image Segmentation".

Proposed Model


Updates

  • July 19, 2022: Initial release.
  • July 4, 2022: Submitted to MICCAI PRIME2022 [Under Review] [Accepted].

Setting up and Training

  • We use the code base from the Swin-Unet GitHub repo as our starting point.

  • In order to run the code and experiments, you need to first install the dependencies and then download and move the data to the right place.

    • For the Synapse dataset, we used the data provided by TransUnet's authors.
    • For ISIC 2017-18 datasets, we used the ISIC Challenge datasets link.
    • For the PH2 dataset, we used this link.
  • We have put the required instructions for doing the above steps in the ./setup.sh file in the repo for your convenience. cd to this repo directory and then run it to install dependencies and download and move data to the right dir.

  • Download Swin-T pre-trained weights from this link and put it into the folder pretrained_ckpt/.

  • Then you need to run the train.py file with the appropriate arguments to run your experiment. let's just see an example for now for the Synapse dataset:

python train.py --config_file 'swin_224_7_{# of SSPP}level' --dataset Synapse --root_path './data' --max_epochs 200 --output_dir '.'  --img_size 224 --base_lr 0.05 --batch_size 24

Config files and hyperparameters

  • All the hyperparameters related to building different models are in separate files in ./model/configs directory.

  • For each experiment, you need to make your desired config_name.py file and put it in the model/configs dir and then enter the file name (without .py suffix) in the python train.py command you saw in the previous section after --config_file arg.

  • For the rest of the hyperparameters like batch_size, max_epochs, base_lr, ... look at the Swin-Unet or the code here to see what you can change and how to do so.


Test

  • The model can be tested with the following command using test.py file. During training, model checkpoints will be saved to disk with the following format: output_dir/{config_file_name}_epoch_{epoch_num}.pth.

  • It takes the checkpoint (model weight file) name as an input argument and loads the appropriate config file from the configs dir.

  • Other arguments and flags can be given to the test.py file if some settings need to be modified but --ckpt_path and --config_file are the only required arguments.

  • Trained weights for our best-reported results in the paper for the Synapse dataset are easily accessible from this link, where you could download it as a sole folder via gdown or setting specific links listed under the below table:

Model setting namePre-trained weights--config_file name
SSPP Level 1linkswin_224_7_1level
SSPP Level 2linkswin_224_7_2level
SSPP Level 3linkswin_224_7_3level
SSPP Level 4linkswin_224_7_4level
  • :exclamation: Remember to put these weights in a specific folder that you are going to address them with test.py via --ckpt_path flag.

  • Comparison results table on the Synapse dataset:

Methods

DSC

HD

AortaGallbladderKidney(L)Kidney(R)LiverPancreasSpleenStomach
V-Net68.81-75.3451.8777.1080.7587.8440.0580.5656.98
R50 U-Net74.6836.8787.7463.6680.6078.1993.7456.9085.8774.16
U-Net76.8539.7089.0769.7277.7768.6093.4353.9886.6775.58
R50 Att-UNet75.5736.9755.9263.9179.2072.7193.5649.3787.1974.95
Att-UNet77.7736.0289.5568.8877.9871.1193.5758.0487.3075.75
R50 ViT71.2932.8773.7355.1375.8072.2091.5145.9981.9973.95
TransUnet77.4831.6987.2363.1381.8777.0294.0855.8685.0875.62
SwinUnet79.1321.5585.4766.5383.2879.6194.2956.5890.6676.60
DeepLabv3+ (CNN)77.6339.9588.0466.5182.7674.2191.2358.3287.4373.53
TransDeepLab80.1621.2586.0469.1684.0879.8893.5361.1989.0078.40
  • Impact of modifying modules inside the proposed method:

Setting

DSC

HD

AortaGallbladderKidney(L)Kidney(R)LiverPancreasSpleenStomach
CNN as Encoder75.8928.8785.0365.1780.1876.3890.4957.2985.6869.93
Basic Scale Fusion79.1622.1485.4468.0582.7780.7993.8058.7487.7875.96
SSPP Level 179.0126.6385.6168.4782.4378.0294.1958.5288.3476.46
SSPP Level 280.1621.2586.0469.1684.0879.8893.5361.1989.0078.40
SSPP Level 379.8718.9386.3466.4184.1382.4093.7359.2889.6676.99
SSPP Level 479.8525.6985.6469.3682.9381.2593.0963.1887.8075.56
  • A look at the number of parameters:
Model# Encoder Parameters# ASPP Parameters# Decoder Parameters# Total
Original DeepLab (Xception-512)37.8615.531.3054.70
Original Swin-Unet (224-7)---27.17
Our TransDeepLab (swin_224_7_1level)12.151.833.4917.48
Our TransDeepLab (swin_224_7_2level)12.155.493.4921.14
Our TransDeepLab (swin_224_7_3level)12.159.203.4924.85
Our TransDeepLab (swin_224_7_4level)12.1512.963.4928.61

Visualization

  • Results on the Synapse dataset: SynapseDataset
ImageGround TruthPrediction
389_isic18_image.png389_isic18_gt.png389_isic18_pred.png
74_ph2_image.png74_ph2_gt.png74_ph2_pred.png

References


Citation

@article{azad2022transdeeplab,
  title={TransDeepLab: Convolution-Free Transformer-based DeepLab v3+ for Medical Image Segmentation},
  author={Azad, Reza and Heidari, Moein and Shariatnia, Moein and Aghdam, Ehsan Khodapanah and Karimijafarbigloo, Sanaz and Adeli, Ehsan and Merhof, Dorit},
  journal={arXiv preprint arXiv:2208.00713},
  year={2022}
}