Skip to content
Projets

À propos

(ACM TOMM) Dépôt officiel du code de « VM-UNet: Vision Mamba UNet for Medical Image Segmentation ».

Design et médias

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

VM-UNet

This is the official code repository for "VM-UNet: Vision Mamba UNet for Medical Image Segmentation". {Arxiv Paper}

Abstract

In the realm of medical image segmentation, both CNN-based and Transformer-based models have been extensively explored. However, CNNs exhibit limitations in long-range modeling capabilities, whereas Transformers are hampered by their quadratic computational complexity. Recently, State Space Models (SSMs), exemplified by Mamba, have emerged as a promising approach. They not only excel in modeling long-range interactions but also maintain a linear computational complexity. In this paper, leveraging state space models, we propose a U-shape architecture model for medical image segmentation, named Vision Mamba UNet (VM-UNet). Specifically, the Visual State Space (VSS) block is introduced as the foundation block to capture extensive contextual information, and an asymmetrical encoder-decoder structure is constructed. We conduct comprehensive experiments on the ISIC17, ISIC18, and Synapse datasets, and the results indicate that VM-UNet performs competitively in medical image segmentation tasks. To our best knowledge, this is the first medical image segmentation model constructed based on the pure SSM-based model. We aim to establish a baseline and provide valuable insights for the future development of more efficient and effective SSM-based segmentation systems.

0. Main Environments

conda create -n vmunet python=3.8
conda activate vmunet
pip install torch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
pip install packaging
pip install timm==0.4.12
pip install pytest chardet yacs termcolor
pip install submitit tensorboardX
pip install triton==2.0.0
pip install causal_conv1d==1.0.0  # causal_conv1d-1.0.0+cu118torch1.13cxx11abiFALSE-cp38-cp38-linux_x86_64.whl
pip install mamba_ssm==1.0.1  # mmamba_ssm-1.0.1+cu118torch1.13cxx11abiFALSE-cp38-cp38-linux_x86_64.whl
pip install scikit-learn matplotlib thop h5py SimpleITK scikit-image medpy yacs

The .whl files of causal_conv1d and mamba_ssm could be found here. {Baidu or GoogleDrive}

1. Prepare the dataset

ISIC datasets

  • The ISIC17 and ISIC18 datasets, divided into a 7:3 ratio, can be found here {Baidu}.

  • After downloading the datasets, you are supposed to put them into './data/isic17/' and './data/isic18/', and the file format reference is as follows. (take the ISIC17 dataset as an example.)

  • './data/isic17/'

    • train
      • images
        • .png
      • masks
        • .png
    • val
      • images
        • .png
      • masks
        • .png

Synapse datasets

  • For the Synapse dataset, you could follow Swin-UNet to download the dataset, or you could download them from {Baidu}.

  • After downloading the datasets, you are supposed to put them into './data/Synapse/', and the file format reference is as follows.

  • './data/Synapse/'

    • lists
      • list_Synapse
        • all.lst
        • test_vol.txt
        • train.txt
    • test_vol_h5
      • casexxxx.npy.h5
    • train_npz
      • casexxxx_slicexxx.npz

2. Prepare the pre_trained weights

  • The weights of the pre-trained VMamba could be downloaded from Baidu or GoogleDrive. After that, the pre-trained weights should be stored in './pretrained_weights/'.

3. Train the VM-UNet

cd VM-UNet
python train.py  # Train and test VM-UNet on the ISIC17 or ISIC18 dataset.
python train_synapse.py  # Train and test VM-UNet on the Synapse dataset.

NOTE: If you want to use the trained checkpoint for inference testing only and save the corresponding test images, you can follow these steps:

  • In config_setting:

    • Set the parameter only_test_and_save_figs to True.
    • Fill in the path of the trained checkpoint in best_ckpt_path.
    • Specify the save path for test images in img_save_path.
  • Execute the script:
    After setting the above parameters, you can run train.py.

4. Obtain the outputs

  • After trianing, you could obtain the results in './results/'

5. Trained VM-UNet Checkpoint

6. Acknowledgments

  • We thank the authors of VMamba and Swin-UNet for their open-source codes.

Explorer des projets similaires

Chargement…