Giter Club home page Giter Club logo

uacanet's Introduction

UACANet: Uncertainty Augmented Context Attention for Polyp Segmentation

PWC

PWC

PWC

PWC

Official pytorch implementation of UACANet: Uncertainty Augmented Context Attention for Polyp Segmentation
To appear in the Proceedings of the 29th ACM International Conference on Multimedia (ACMMM 2021)

Teaser

Abstract

We propose Uncertainty Augmented Context Attention network (UACANet) for polyp segmentation which consider a uncertain area of the saliency map. We construct a modified version of U-Net shape network with additional encoder and decoder and compute a saliency map in each bottom-up stream prediction module and propagate to the next prediction module. In each prediction module, previously predicted saliency map is utilized to compute foreground, background and uncertain area map and we aggregate the feature map with three area maps for each representation. Then we compute the relation between each representation and each pixel in the feature map. We conduct experiments on five popular polyp segmentation benchmarks, Kvasir, CVC-ClinicDB, ETIS, CVC-ColonDB and CVC-300, and achieve state-of-the-art performance. Especially, we achieve 76.6% mean Dice on ETIS dataset which is 13.8% improvement compared to the previous state-of-the-art method.

News ๐Ÿš€

Our new work on high-resolution salient object detection, Revisiting Image Pyramid Structure for High Resolution Salient Object Detection has been accepted to ACCV2022. Come and see the results!

0. Automatic Installation

  • (21.10.08 added) by simply using install.sh, you can download and locate train/test datasets, backbone checkpoints, pretrained checkpoints and pre-computed results, and automatically create conda environment named uacanet. If you find error using our script, please create environment and prepare datasets manually.

1. Create environment

  • Create conda environment with following command conda create -n uacanet python=3.7
  • Activate environment with following command conda activate uacanet
  • Install requirements with following command pip install -r requirements.txt

2. Prepare datasets

  • Download Train/Test datasets and Res2Net backbone checkpoint from following URL
  • Move folder data to the repository.
  • Folder should be ordered as follows,
|-- configs
|-- data
|   |-- TestDataset
|   |   |-- CVC-300
|   |   |   |-- images
|   |   |   `-- masks
|   |   |-- CVC-ClinicDB
|   |   |   |-- images
|   |   |   `-- masks
|   |   |-- CVC-ColonDB
|   |   |   |-- images
|   |   |   `-- masks
|   |   |-- ETIS-LaribPolypDB
|   |   |   |-- images
|   |   |   `-- masks
|   |   `-- Kvasir
|   |       |-- images
|   |       `-- masks
|   `-- TrainDataset
|       |-- images
|       `-- masks
|-- lib
|   |-- backbones
|   |-- losses
|   `-- modules
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ results
โ”‚   โ”œโ”€โ”€ result_CVC-300.csv
โ”‚   โ”œโ”€โ”€ result_CVC-ClinicDB.csv
โ”‚   โ”œโ”€โ”€ result_CVC-ColonDB.csv
โ”‚   โ”œโ”€โ”€ result_ETIS-LaribPolypDB.csv
โ”‚   โ””โ”€โ”€ result_Kvasir.csv
โ”œโ”€โ”€ run
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ Eval.py
โ”‚   โ”œโ”€โ”€ Inference.py
โ”‚   โ”œโ”€โ”€ Test.py
โ”‚   โ””โ”€โ”€ Train.py
โ”œโ”€โ”€ snapshots
โ”‚   โ”œโ”€โ”€ UACANet-L
โ”‚   โ”‚   โ”œโ”€โ”€ CVC-300
โ”‚   โ”‚   โ”œโ”€โ”€ CVC-ClinicDB
โ”‚   โ”‚   โ”œโ”€โ”€ CVC-ColonDB
โ”‚   โ”‚   โ”œโ”€โ”€ ETIS-LaribPolypDB
โ”‚   โ”‚   โ”œโ”€โ”€ Kvasir
โ”‚   โ”‚   โ””โ”€โ”€ latest.pth
โ”‚   โ””โ”€โ”€ UACANet-S
โ”‚       โ”œโ”€โ”€ CVC-300
โ”‚       โ”œโ”€โ”€ CVC-ClinicDB
โ”‚       โ”œโ”€โ”€ CVC-ColonDB
โ”‚       โ”œโ”€โ”€ ETIS-LaribPolypDB
โ”‚       โ”œโ”€โ”€ Kvasir
โ”‚       โ””โ”€โ”€ latest.pth
โ””โ”€โ”€ utils
    โ”œโ”€โ”€ custom_transforms.py
    โ”œโ”€โ”€ dataloader.py
    โ”œโ”€โ”€ eval_functions.py
    โ”œโ”€โ”€ __pycache__
    โ””โ”€โ”€ utils.py

3. Train & Evaluate

Train

# Single GPU
CUDA_VISIBLE_DEVICES=0 python run/Train.py --config configs/UACANet-L.yaml --verbose --debug

# Multi GPU (e.g., 0 and 1)
CUDA_VISIBLE_DEVICES=0,1 python -m torchrun --nproc_per_node 2 run/Train.py --config configs/UACANet-L.yaml --verbose --debug

Test

# Generate prediction for benchmarks
python run/Test.py --config configs/UACANet-L.yaml --verbose

Evaluate

# Evaluate on various metrics (e.g., S-measure, E-measure, etc.)
python run/Eval.py --config configs/UACANet-L.yaml --verbose

All-in-One command

# Train, Test, and Evaluate with single command

# Single GPU
CUDA_VISIBLE_DEVICES=0 python Expr.py --config configs/UACANet-L.yaml --verbose --debug

# Multi GPU
CUDA_VISIBLE_DEVICES=0,1 python -m torchrun --nproc_per_node 2 Expr.py --config configs/UACANet-L.yaml --verbose --debug

Pre-computed Maps

Download our best result checkpoint and pre-computed maps from following URL for UACANet-L and UACANet-S.

4. Experimental Results

  • UACANet-S
dataset              meanDic    meanIoU    wFm     Sm    meanEm    mae    maxEm    maxDic    maxIoU    meanSen    maxSen    meanSpe    maxSpe
-----------------  ---------  ---------  -----  -----  --------  -----  -------  --------  --------  ---------  --------  ---------  --------
CVC-300                0.902      0.837  0.886  0.934     0.974  0.006    0.976     0.906     0.840      0.959     1.000      0.992     0.995
CVC-ClinicDB           0.916      0.870  0.917  0.940     0.965  0.008    0.968     0.919     0.873      0.942     1.000      0.991     0.995
Kvasir                 0.905      0.852  0.897  0.914     0.948  0.026    0.951     0.908     0.855      0.911     1.000      0.976     0.979
CVC-ColonDB            0.783      0.704  0.772  0.848     0.894  0.034    0.897     0.786     0.706      0.801     1.000      0.958     0.962
ETIS-LaribPolypDB      0.694      0.615  0.650  0.815     0.848  0.023    0.851     0.696     0.618      0.833     1.000      0.887     0.891
  • UACANet-L
dataset              meanDic    meanIoU    wFm     Sm    meanEm    mae    maxEm    maxDic    maxIoU    meanSen    maxSen    meanSpe    maxSpe
-----------------  ---------  ---------  -----  -----  --------  -----  -------  --------  --------  ---------  --------  ---------  --------
CVC-300                0.910      0.849  0.901  0.937     0.977  0.005    0.980     0.913     0.853      0.940     1.000      0.993     0.997
CVC-ClinicDB           0.926      0.880  0.928  0.943     0.974  0.006    0.976     0.929     0.883      0.943     1.000      0.992     0.996
Kvasir                 0.912      0.859  0.902  0.917     0.955  0.025    0.958     0.915     0.862      0.923     1.000      0.983     0.987
CVC-ColonDB            0.751      0.678  0.746  0.835     0.875  0.039    0.878     0.753     0.680      0.754     1.000      0.953     0.957
ETIS-LaribPolypDB      0.766      0.689  0.740  0.859     0.903  0.012    0.905     0.769     0.691      0.813     1.000      0.932     0.936
  • Qualitative Results

results

5. Citation

@inproceedings{kim2021uacanet,
  title={UACANet: Uncertainty Augmented Context Attention for Polyp Segmentation},
  author={Kim, Taehun and Lee, Hyemin and Kim, Daijin},
  booktitle={Proceedings of the 29th ACM International Conference on Multimedia},
  pages={2167--2175},
  year={2021}
}
  • Conference version will be added soon.

6. Acknowledgement

  • Basic training strategy, datasets and evaluation methods are brought from PraNet. Especially for the evalutation, we made Python version based on PraNet's MatLab version and verified on various samples. Thanks for the great work!
  • This work was supported by Institute of Information & communications Technology Planning & Evaluation(IITP) grant funded by the Korea government(MSIT) (No.B0101-15-0266, Development of High Performance Visual BigData Discovery Platform for Large-Scale Realtime Data Analysis), (No.2017-0-00897, Development of Object Detection and Recognition for Intelligent Vehicles) and (No.2018-0-01290, Development of an Open Dataset and Cognitive Processing Technology for the Recognition of Features Derived From Unstructured Human Motions Used in Self-driving Cars)

uacanet's People

Contributors

plemeri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

uacanet's Issues

result problem

image

I follow the settings of the readme, the code has not been modified in any way, but the effect is particularly poor, can you help me reproduce it?

Some questions about the โ€˜bce_iou_lossโ€™ function

def bce_iou_loss(pred, mask):
    weight = 1 + 5 * torch.abs(F.avg_pool2d(mask, kernel_size=31, stride=1, padding=15) - mask)
  
    bce = F.binary_cross_entropy_with_logits(pred, mask, reduction='none')
   
    pred = torch.sigmoid(pred)
    inter = pred * mask
    union = pred + mask
    iou = 1 - (inter + 1) / (union - inter + 1)

    weighted_bce = (weight * bce).sum(dim=(2, 3)) / weight.sum(dim=(2, 3))
    weighted_iou = (weight * iou).sum(dim=(2, 3)) / weight.sum(dim=(2, 3))

    return (weighted_bce + weighted_iou).mean()

question

I am looking forward to your reply๏ผ

About SFA implementation

Hello, Is it convenient to share the SFA code in this article? Suddenly found that the original author deleted this code

Results on ETIS-LaribPolypDB dataset

I tried to reproduce your results following your README instructions. I used the default UACANet-L config with a batch size of 8 instead of 32.

The mDICE I get on 3 runs on ETIS-LaribPolypDB is 0.52/0.56/0.53 while in the paper you get 0.76
Can you verify this? Why is the lower batch size affecting only this dataset?

Clarification on pretrained weights

When pretrained: True the pretrained weights in data/backbone_ckpt/res2net50_v1b_26w_4s-3cf99910.pth are used.
Where do these weights come from? Are they pretrained on colon images by you, or they are pretrained just on ImageNet?

About checkpoint saved

In run/Train.py, Line122

if epoch % opt.Train.Checkpoint.checkpoint_epoch == 0: torch.save(model.module.state_dict() if args.device_num > 1 else model.state_dict( ), os.path.join(opt.Train.Checkpoint.checkpoint_dir, 'latest.pth'))

To my understanding, this code fragment save checkpoint by each 20 epochs , this can not ensure the checkpoint saved is the optimal during training.

And in Line 130,
if args.local_rank <= 0: torch.save(model.module.state_dict() if args.device_num > 1 else model.state_dict( ), os.path.join(opt.Train.Checkpoint.checkpoint_dir, 'latest.pth'))
this code just save the weights of last epoch, and it also can not ensure the checkpoint saved is the optimal.

Why don't you save the optimal checkpoint? Would you mind explaining it for me?
Many thanks to you๏ผ
Happy New Year!

Some questions about Axial-attention

Hi~I have some questions about Axial-attention
Why there is no premute operation before view in mode h?

# for mode h
projected_query = self.query_conv(x).premute(0, 1, 3, 2).view(*view).permute(0, 2, 1)

I think premute is necessary. Although the shape of those values are correct to calculate๏ผŒit has a very different meaning for mode h comparing to mode w. Without premute, the projected_query can't actually collect the columns to the dimension with size Hight
For example:
image
For mode W, the way of reshape is correct.
image
Without permute for mode H, it is obviously not what we want:
image
With permute for mode H,[0, 5, 10, 15] is the column of a.:
image

The evaluation result is not good.

I run the commad:

python Expr.py --config configs/UACANet-L.yaml

However, the result listed as follows:
Screenshot from 2021-08-11 22-05-30
The official result of UACANet-L mentioned at README is

dataset              meanDic    meanIoU    wFm     Sm    meanEm    mae    maxEm    maxDic    maxIoU    meanSen    maxSen    meanSpe    maxSpe
-----------------  ---------  ---------  -----  -----  --------  -----  -------  --------  --------  ---------  --------  ---------  --------
CVC-300                0.910      0.849  0.901  0.937     0.977  0.005    0.980     0.913     0.853      0.940     1.000      0.993     0.997
CVC-ClinicDB           0.926      0.880  0.928  0.943     0.974  0.006    0.976     0.929     0.883      0.943     1.000      0.992     0.996
Kvasir                 0.912      0.859  0.902  0.917     0.955  0.025    0.958     0.915     0.862      0.923     1.000      0.983     0.987
CVC-ColonDB            0.751      0.678  0.746  0.835     0.875  0.039    0.878     0.753     0.680      0.754     1.000      0.953     0.957
ETIS-LaribPolypDB      0.766      0.689  0.740  0.859     0.903  0.012    0.905     0.769     0.691      0.813     1.000      0.932     0.936

Why is the result I run so bad? I didn't change any configuration file.

ๅ…ณไบŽ layers.py ไธญ็š„ไธ€ๆฎตไปฃ็ 

Hello! Sir,
I've been looking at the code for your paper(UACANet: Uncertainty Augmented Context Attention for Polyp Segmentation), and it's very well written, especially the yaml configuration, which is very simple and clear! However, when I was looking at layers.py, I encountered a little problem, so far I have not figured it out, I hope you could teach me when you got time, thank you!
here, if I pass kernel_size=1 & padding='same' and according to your code below, I will got a kernel_size=(0,0)๏ผŒI think this is not a valid value of kernel_size?
image

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.