aminzabardast / SANet

Codes for MICCAI2021 paper "Shallow Attention Network for Polyp Segmentation"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

by Jun Wei, Yiwen Hu, Ruimao Zhang, Zhen Li, S.Kevin Zhou, Shuguang Cui

🔥 Docker support is added by Amin Zabardast

Introduction

frameworkAccurate polyp segmentation is of great importance for colorectal cancer diagnosis. However, even with a powerful deep neural network, there still exists three big challenges that impede the development of polyp segmentation. (i) Samples collected under different conditions show inconsistent colors, causing the feature distribution gap and overfitting issue; (ii) Due to repeated feature downsampling, small polyps are easily degraded; (iii) Foreground and background pixels are imbalanced, leading to a biased training. To address the above issues, we propose the Shallow Attention Network (SANet) for polyp segmentation. Specifically, to eliminate the effects of color, we design the color exchange operation to decouple the image contents and colors, and force the model to focus more on the target shape and structure. Furthermore, to enhance the segmentation quality of small polyps, we propose the shallow attention module to filter out the background noise of shallow features. Thanks to the high resolution of shallow features, small polyps can be preserved correctly. In addition, to ease the severe pixel imbalance for small polyps, we propose a probability correction strategy (PCS) during the inference phase. Note that even though PCS is not involved in the training phase, it can still work well on a biased model and consistently improve the segmentation performance. Quantitative and qualitative experimental results on five challenging benchmarks confirm that our proposed SANet outperforms previous state-of-the-art methods by a large margin and achieves a speed about 72FPS.

Clone repository

git clone https://github.com/weijun88/SANet.git
cd SANet/

File tree

SANet                           
├─data                          
│  ├─test                       
│  │  ├─CVC-300                 
│  │  │  ├─image
│  │  │  └─mask
│  │  ├─CVC-ClinicDB
│  │  │  ├─image
│  │  │  └─mask
│  │  ├─CVC-ColonDB
│  │  │  ├─image
│  │  │  └─mask
│  │  ├─ETIS-LaribPolypDB
│  │  │  ├─image
│  │  │  └─mask
│  │  └─Kvasir
│  │      ├─image
│  │      └─mask
│  └─train
│      ├─image
│      └─mask
├─eval
│  └─prediction
│      └─SANet
│          ├─CVC-300
│          ├─CVC-ClinicDB
│          ├─CVC-ColonDB
│          ├─ETIS-LaribPolypDB
│          └─Kvasir
├─fig
├─res
└─src
    └─out

Download dataset

The training and testing datasets come from PraNet. Download these datasets and unzip them into data folder

Download model

  • If you want to test the performance of SANet, please download our trained model (Baidu: km9q | Google) into src/out folder
  • If you want to train your own model, please download the pretrained model into res folder

Prerequisites

Using Docker Containers

Matching specific requirements (Python version, CUDA version, cuDNN version, etc.) may be challenging. You can use containerization technology to make sure environment is consistent.

To do so, follow these steps:

  1. Make sure that docker, and nvidia-container-toolkit are installed in your system.
  2. Create the custom image using the DockerFile.
  3. Create a container form the image. Make sure that GPU parameters and volume mapping are added to the container creation command.
  4. Connect to the container and execute training or evaluation.

Creating the Docker Image

Make sure you are in the root directory of the project, then execute the following command:

  docker build -f DockerFile -t sanet .
  • -f attribute is to point to the location of DockerFile.
  • -t attribute is to name the image.

Creating the Container

Replace <ABSOLUTE_PATH_TO_PROJECT_ROOT> with the absolute path to project's root. Then execute the following code to create the container.

    docker run \
    -v <ABSOLUTE_PATH_TO_PROJECT_ROOT>:/workspace \
    --name sanet-dev \
    --pull missing \
    --ipc host \
    --gpus all \
    sanet:latest 
  • -v is to map a directory from your machine to the container.
  • --name is the name of the container.
  • --gpus all will give GPU access to GPUs.

Connecting to the Container

Execute the following command to connect to the created container.

  docker exec --workdir /workspace -it sanet-dev bash

Training

    cd src/
    python3 train.py

Testing

    cd src
    python3 test.py
  • After testing, predictions of testing dataset will be saved in eval/SANet/ folder.

Evaluation

  • To evaluate the performace of SANet, please use MATLAB to run main.m
    cd eval
    matlab
    main

Predictions & Trained model

Citation

  • If you find this work is helpful, please cite our paper
@inproceedings{SANet,
  title        = {Shallow Attention Network for Polyp Segmentation},
  author       = {Wei, Jun and Hu, Yiwen and Zhang, Ruimao and Li, Zhen and Zhou, S.Kevin and Cui, Shuguang},
  booktitle    = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  pages        = {699--708},
  year         = {2021},
  organization = {Springer}
}

About

Codes for MICCAI2021 paper "Shallow Attention Network for Polyp Segmentation"

License:MIT License


Languages

Language:MATLAB 52.5%Language:Python 47.5%