Git Product home page Git Product logo

lightm-unet's Introduction

Official repository for "LightM-UNet: Mamba Assists in Lightweight UNet for Medical Image Segmentation".

Release

  • ๐Ÿ”ฅNews: 2024/3/29: Received feedback on issue#6 and updated the erroneous code in the original code repository.

  • News: 2024/3/17: LightM-UNet released.

  • A regrettable notification: 2024/3/12 Thank you for your attention! The author has been quite busy lately (๏ผ›โ€ฒโŒ’`), so only the main code has been uploaded to this repository for now. Detailed code explanations, data, and configuration details will be completed by March 17, 2024. Thanks again for your interest! o(๏ฟฃโ–ฝ๏ฟฃ)ใƒ–

Introduction to LightM-UNet

LightM-UNet is a lightweight fusion of UNet and Mamba, boasting a mere parameter count of 1M. Through validation on both 2D and 3D real-world datasets, LightM-UNet surpasses existing state-of-the-art models. In comparison to the renowned nnU-Net and contemporaneous U-Mamba, LightM-UNet reduces the parameter count by 116X and 224X, respectively.

result

Get Start

Requirements: CUDA โ‰ฅ 11.6

  1. Create a virtual environment: conda create -n lightmunet python=3.10 -y and conda activate lightmunet
  2. Install Pytorch 2.0.1: pip install torch==2.0.1 torchvision==0.15.2
  3. Install Mamba: pip install causal-conv1d==1.1.1 and pip install mamba-ssm
  4. Download code: git clone https://github.com/MrBlankness/LightM-UNet
  5. cd LightM-UNet/lightm-unet and run pip install -e .

sanity test: Enter python command-line interface and run

import torch
import mamba_ssm

Data Preparation

Download LiTs dataset here and Montgomery&Shenzhen dataset here, then put them into the LightM-Unet/data/nnUNet_raw folder. LightM-UNet is built on the popular nnU-Net framework. If you want to train LightM-UNet on your own dataset, please follow this guideline to prepare the dataset.

Please organize the dataset as follows:

data/
โ”œโ”€โ”€ nnUNet_raw/
โ”‚   โ”œโ”€โ”€ Dataset801_LiverCT/
โ”‚   โ”‚   โ”œโ”€โ”€ imagesTr
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Liver_0001_0000.nii.gz
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Liver_0002_0000.nii.gz
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ labelsTr
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Liver_0001.nii.gz
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Liver_0002.nii.gz
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ dataset.json
โ”‚   โ”œโ”€โ”€ Dataset802_LungXray/
โ”‚   โ”‚   โ”œโ”€โ”€ imagesTr
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Lung_0001_0000.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Lung_0002_0000.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ labelsTr
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Lung_0001.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Lung_0001.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ dataset.json
โ”‚   โ”œโ”€โ”€ ...

Based on nnUNet, preprocess the data and generate the corresponding configuration files (the generated results can be found in the LightM-Unet/data/nnUNet_preprocessed folder).

nnUNetv2_plan_and_preprocess -d DATASET_ID --verify_dataset_integrity

Model Training

Train 2D models

  • Train 2D LightM-Unet model
nnUNetv2_train DATASET_ID 2d all -tr nnUNetTrainerLightMUNet

Train 3D models

  • Train 3D LightM-Unet model
nnUNetv2_train DATASET_ID 3d_fullres all -tr nnUNetTrainerLightMUNet

Inference

Inference 2D models

  • Inference 2D LightM-Unet model
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_ID -c 2d -tr nnUNetTrainerLightMUNet --disable_tta

Inference 3D models

  • Inference 3D LightM-Unet model
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_ID -c 3d_fullres -tr nnUNetTrainerLightMUNet --disable_tta

Citation

If you find our work helpful, please consider citing the following papers

@misc{liao2024lightmunet,
      title={LightM-UNet: Mamba Assists in Lightweight UNet for Medical Image Segmentation}, 
      author={Weibin Liao and Yinghao Zhu and Xinyuan Wang and Chengwei Pan and Yasha Wang and Liantao Ma},
      year={2024},
      eprint={2403.05246},
      archivePrefix={arXiv},
      primaryClass={eess.IV}
}

Acknowledgements

We acknowledge all the authors of the employed public datasets, allowing the community to use these valuable resources for research purposes. We also thank the authors of nnU-Net, Mamba and U-Mamba for making their valuable code publicly available.

lightm-unet's People

Contributors

mrblankness avatar alvinkimbowa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.