Giter Site home page Giter Site logo

cgnerds / unext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeya-maria-jose/unext-pytorch

1.0 0.0 0.0 781 KB

Official Pytorch Code base for "UNeXt: MLP-based Rapid Medical Image Segmentation Network", MICCAI 2022

Home Page: https://jeya-maria-jose.github.io/UNext-web/

License: MIT License

Python 93.16% Jupyter Notebook 6.84%

unext's Introduction

UNeXt

Official Pytorch Code base for UNeXt: MLP-based Rapid Medical Image Segmentation Network, MICCAI 2022

Paper | Project

Introduction

UNet and its latest extensions like TransUNet have been the leading medical image segmentation methods in recent years. However, these networks cannot be effectively adopted for rapid image segmentation in point-of-care applications as they are parameter-heavy, computationally complex and slow to use. To this end, we propose UNeXt which is a Convolutional multilayer perceptron (MLP) based network for image segmentation. We design UNeXt in an effective way with an early convolutional stage and a MLP stage in the latent stage. We propose a tokenized MLP block where we efficiently tokenize and project the convolutional features and use MLPs to model the representation. To further boost the performance, we propose shifting the channels of the inputs while feeding in to MLPs so as to focus on learning local dependencies. Using tokenized MLPs in latent space reduces the number of parameters and computational complexity while being able to result in a better representation to help segmentation. The network also consists of skip connections between various levels of encoder and decoder. We test UNeXt on multiple medical image segmentation datasets and show that we reduce the number of parameters by 72x, decrease the computational complexity by 68x, and improve the inference speed by 10x while also obtaining better segmentation performance over the state-of-the-art medical image segmentation architectures.

Using the code:

The code is stable while using Python 3.10.13, CUDA >=12.1

  • Clone this repository:
git clone https://github.com/cgnerds/UNeXt
cd UNeXt

To install all the dependencies using conda:

conda create -n unext python=3.10 -y
conda activate unext
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip install -r requirements.txt

# WSL Only
# export QT_QPA_PLATFORM="xcb"
# sudo apt install libqt5x11extras5 libxcb-xinerama0

Datasets

  1. ISIC 2018 - Link
  2. BUSI - Link

Data Format

Make sure to put the files as the following structure (e.g. the number of classes is 2):

inputs
└── <dataset name>
    ├── images
    |   ├── 001.png
    │   ├── 002.png
    │   ├── 003.png
    │   ├── ...
    |
    └── masks
        ├── 0
        |   ├── 001.png
        |   ├── 002.png
        |   ├── 003.png
        |   ├── ...
        |
        └── 1
            ├── 001.png
            ├── 002.png
            ├── 003.png
            ├── ...

For binary segmentation problems, just use folder 0.

Create softlink for the dataset.

sudo ln -s /home/xy/DEV/Datasets/ARM arm

Training and Validation

  1. Train the model.
# python train.py --dataset wrist --arch UNext --name wrist --img_ext .jpg --mask_ext .jpg --lr 0.0001 --epochs 500 --input_w 512 --input_h 512 --b 8  
# python train.py --dataset arm --arch UNext --name arm --img_ext .jpg --mask_ext .jpg --lr 0.0001 --epochs 500 --input_w 512 --input_h 512 --b 32
python train.py --dataset <dataset name> --arch UNext --name <exp name> --img_ext .png --mask_ext .png --lr 0.0001 --epochs 500 --input_w 512 --input_h 512 --b 8
  1. Evaluate.
# <exp name> - wrist
python val.py --name <exp name>
  1. Inference.
python inference.py

Acknowledgements:

This code-base uses certain code-blocks and helper functions from UNet++, Segformer, and AS-MLP. Naming credits to Poojan.

Citation:

@article{valanarasu2022unext,
  title={UNeXt: MLP-based Rapid Medical Image Segmentation Network},
  author={Valanarasu, Jeya Maria Jose and Patel, Vishal M},
  journal={arXiv preprint arXiv:2203.04967},
  year={2022}
}

unext's People

Contributors

cgnerds avatar jeya-maria-jose avatar

Stargazers

 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.