Code Monkey home page Code Monkey logo

cotr's Introduction

CoTr: Efficient 3D Medical Image Segmentation by bridging CNN and Transformer

This is the official pytorch implementation of the CoTr:

Paper: CoTr: Efficient 3D Medical Image Segmentation by bridging CNN and Transformer.

Requirements

CUDA 11.0
Python 3.7
Pytorch 1.7
Torchvision 0.8.2

Usage

0. Installation

  • Install Pytorch1.7, nnUNet and CoTr as below
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

cd nnUNet
pip install -e .

cd CoTr_package
pip install -e .

1. Data Preparation

  • Download BCV dataset
  • Preprocess the BCV dataset according to the uploaded nnUNet package.
  • Training and Testing ID are in data/splits_final.pkl.

2. Training

cd CoTr_package/CoTr/run

  • Run nohup python run_training.py -gpu='0' -outpath='CoTr' 2>&1 & for training.

3. Testing

  • Run nohup python run_training.py -gpu='0' -outpath='CoTr' -val --val_folder='validation_output' 2>&1 & for validation.

4. Citation

If this code is helpful for your study, please cite:

@article{xie2021cotr,
  title={CoTr: Efficiently Bridging CNN and Transformer for 3D Medical Image Segmentation},
  author={Xie, Yutong and Zhang, Jianpeng and Shen, Chunhua and Xia, Yong},
  booktitle={MICCAI},
  year={2021}
}
  

5. Acknowledgements

Part of codes are reused from the nnU-Net. Thanks to Fabian Isensee for the codes of nnU-Net.

Contact

Yutong Xie ([email protected])

cotr's People

Contributors

ytongxie 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

cotr's Issues

RuntimeError: The size of tensor a (6) must match the size of tensor b (5) at non-singleton dimension 4

Hi,
I'm trying to train the CoTr model on Hippocampus dataset that I downloaded from http://medicaldecathlon.com/
However, I'm getting the error that the size of the tensors when performing the in skip connection operation doesn't match.

image

The error is basically somewhere in the CoTr/network_architecture/ResTranUnet.py line 156
x = x + skip2

I tried to solve the issue but I don't fully understand the source of the error.
Any help will be really appreciated

Thank you

preprocess BTCV DATASET

I have some questions about the preprocessing of BTCV data. I preprocessed according to nnUNet's method, but running "run_trainng.py" shows: KeyError:'bcv_32'.

reference points解释

作者,你好,可以解释下这段代码的意思吗?
def get_reference_points(spatial_shapes, valid_ratios, device):
reference_points_list = []
for lvl, (D_, H_, W_) in enumerate(spatial_shapes):

        ref_d, ref_y, ref_x = torch.meshgrid(torch.linspace(0.5, D_ - 0.5, D_, dtype=torch.float32, device=device),
                                             torch.linspace(0.5, H_ - 0.5, H_, dtype=torch.float32, device=device),
                                             torch.linspace(0.5, W_ - 0.5, W_, dtype=torch.float32, device=device))

        ref_d = ref_d.reshape(-1)[None] / (valid_ratios[:, None, lvl, 0] * D_)
        ref_y = ref_y.reshape(-1)[None] / (valid_ratios[:, None, lvl, 2] * H_)
        ref_x = ref_x.reshape(-1)[None] / (valid_ratios[:, None, lvl, 1] * W_)

        ref = torch.stack((ref_d, ref_x, ref_y), -1)   # D W H
        reference_points_list.append(ref)
    reference_points = torch.cat(reference_points_list, 1)
    reference_points = reference_points[:, :, None] * valid_ratios[:, None]
    return reference_points

Pretrained Checkpoints

Hey,

Thanks for publicizing your Code and the awesome architecture you designed :)
I was wondering if you have some checkpoints for public datasets you used that you already trained as I would like to reuse the original ones in a research project.

Best regards,
Tassilo

About testing

When I want to test, I follow the instructions in README.md, but it seems to start training again? What's going on here?

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.