# Medical-Transformer
<a href="https://arxiv.org/abs/2102.10662"> </a>
Pytorch code for the paper
["Medical Transformer: Gated Axial-Attention for
Medical Image Segmentation"](https://arxiv.org/pdf/2102.10662.pdf), MICCAI 2021
[Paper](https://arxiv.org/pdf/2102.10662.pdf) | [Poster](https://drive.google.com/file/d/1gMjc5guT_dYQFT6TEEwdHAFKwG5XkEc9/view?usp=sharing)
### About this repo:
This repo hosts the code for the following networks:
1) Gated Axial Attention U-Net
2) MedT
## Introduction
Majority of existing Transformer-based network architectures proposed for vision applications require large-scale
datasets to train properly. However, compared to the datasets for vision
applications, for medical imaging the number of data samples is relatively
low, making it difficult to efficiently train transformers for medical appli-
cations. To this end, we propose a Gated Axial-Attention model which
extends the existing architectures by introducing an additional control
mechanism in the self-attention module. Furthermore, to train the model
effectively on medical images, we propose a Local-Global training strat-
egy (LoGo) which further improves the performance. Specifically, we op-
erate on the whole image and patches to learn global and local features,
respectively. The proposed Medical Transformer (MedT) uses LoGo training strategy on Gated Axial Attention U-Net.
<p align="center">
<img src="img/medt1.png" width="800"/>
</p>
### Using the code:
- Clone this repository:
```bash
git clone https://github.com/jeya-maria-jose/Medical-Transformer
cd Medical-Transformer
```
The code is stable using Python 3.6.10, Pytorch 1.4.0
To install all the dependencies using conda:
```bash
conda env create -f environment.yml
conda activate medt
```
To install all the dependencies using pip:
```bash
pip install -r requirements.txt
```
### Links for downloading the public Datasets:
1) MoNuSeG Dataset - <a href="https://monuseg.grand-challenge.org/Data/"> Link (Original)</a>
2) GLAS Dataset - <a href="https://warwick.ac.uk/fac/sci/dcs/research/tia/glascontest/"> Link (Original) </a>
3) Brain Anatomy US dataset from the paper will be made public soon !
## Using the Code for your dataset
### Dataset Preparation
Prepare the dataset in the following format for easy use of the code. The train and test folders should contain two subfolders each: img and label. Make sure the images their corresponding segmentation masks are placed under these folders and have the same name for easy correspondance. Please change the data loaders to your need if you prefer not preparing the dataset in this format.
```bash
Train Folder-----
img----
0001.png
0002.png
.......
labelcol---
0001.png
0002.png
.......
Validation Folder-----
img----
0001.png
0002.png
.......
labelcol---
0001.png
0002.png
.......
Test Folder-----
img----
0001.png
0002.png
.......
labelcol---
0001.png
0002.png
.......
```
- The ground truth images should have pixels corresponding to the labels. Example: In case of binary segmentation, the pixels in the GT should be 0 or 255.
### Training Command:
```bash
python train.py --train_dataset "enter train directory" --val_dataset "enter validation directory" --direc 'path for results to be saved' --batch_size 4 --epoch 400 --save_freq 10 --modelname "gatedaxialunet" --learning_rate 0.001 --imgsize 128 --gray "no"
```
```bash
Change modelname to MedT or logo to train them
```
### Testing Command:
```bash
python test.py --loaddirec "./saved_model_path/model_name.pth" --val_dataset "test dataset directory" --direc 'path for results to be saved' --batch_size 1 --modelname "gatedaxialunet" --imgsize 128 --gray "no"
```
The results including predicted segmentations maps will be placed in the results folder along with the model weights. Run the performance metrics code in MATLAB for calculating F1 Score and mIoU.
### Notes:
1)Note that these experiments were conducted in Nvidia Quadro 8000 with 48 GB memory.
2)Google Colab Code is an unofficial implementation for quick train/test. Please follow original code for proper training.
### Acknowledgement:
The dataloader code is inspired from <a href="https://github.com/cosmic-cortex/pytorch-UNet"> pytorch-UNet </a>. The axial attention code is developed from <a href="https://github.com/csrhddlam/axial-deeplab">axial-deeplab</a>.
# Citation:
```bash
@InProceedings{jose2021medical,
author="Valanarasu, Jeya Maria Jose
and Oza, Poojan
and Hacihaliloglu, Ilker
and Patel, Vishal M.",
title="Medical Transformer: Gated Axial-Attention for Medical Image Segmentation",
booktitle="Medical Image Computing and Computer Assisted Intervention -- MICCAI 2021",
year="2021",
publisher="Springer International Publishing",
address="Cham",
pages="36--46",
isbn="978-3-030-87193-2"
}
```
Open an issue or mail me directly in case of any queries or suggestions.
没有合适的资源?快使用搜索试试~ 我知道了~
基于Transformer实现语义分割 带皮肤病变分割 完整代码+数据集 毕业设计
共2000个文件
jpg:5447个
pyc:25个
py:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 11 下载量 149 浏览量
2023-03-18
20:18:47
上传
评论 7
收藏 59.39MB ZIP 举报
温馨提示
基于Transformer实现语义分割 带皮肤病变分割 完整代码+数据集 毕业设计
资源推荐
资源详情
资源评论
收起资源包目录
基于Transformer实现语义分割 带皮肤病变分割 完整代码+数据集 毕业设计 (2000个子文件)
0103.jpg 17KB
0437.jpg 16KB
0116.jpg 16KB
1278.jpg 15KB
0145.jpg 14KB
1045.jpg 14KB
0016.jpg 14KB
0009.jpg 14KB
0065.jpg 14KB
0062.jpg 14KB
0213.jpg 14KB
1272.jpg 14KB
1434.jpg 14KB
0928.jpg 13KB
1177.jpg 13KB
1466.jpg 13KB
0143.jpg 13KB
0107.jpg 13KB
1169.jpg 13KB
0894.jpg 13KB
1779.jpg 13KB
0137.jpg 13KB
0024.jpg 13KB
0225.jpg 13KB
0258.jpg 13KB
0184.jpg 13KB
1449.jpg 13KB
1058.jpg 13KB
1572.jpg 13KB
0090.jpg 13KB
0011.jpg 13KB
0073.jpg 13KB
0185.jpg 13KB
0248.jpg 12KB
0027.jpg 12KB
0413.jpg 12KB
0200.jpg 12KB
0694.jpg 12KB
0393.jpg 12KB
0385.jpg 12KB
0660.jpg 12KB
0006.jpg 12KB
1356.jpg 12KB
1109.jpg 12KB
0356.jpg 12KB
0029.jpg 12KB
0166.jpg 12KB
0181.jpg 12KB
1646.jpg 12KB
1797.jpg 12KB
1349.jpg 12KB
0391.jpg 12KB
0132.jpg 12KB
0502.jpg 12KB
1566.jpg 12KB
0396.jpg 12KB
0079.jpg 12KB
1781.jpg 12KB
0954.jpg 12KB
1391.jpg 12KB
1512.jpg 12KB
0191.jpg 11KB
0230.jpg 11KB
0428.jpg 11KB
0127.jpg 11KB
1294.jpg 11KB
0573.jpg 11KB
0193.jpg 11KB
0082.jpg 11KB
0106.jpg 11KB
0143.jpg 11KB
0968.jpg 11KB
0386.jpg 11KB
1796.jpg 11KB
1160.jpg 11KB
0257.jpg 11KB
0341.jpg 11KB
0187.jpg 11KB
1651.jpg 11KB
1713.jpg 11KB
0013.jpg 11KB
0052.jpg 11KB
0488.jpg 11KB
0250.jpg 11KB
0013.jpg 11KB
0523.jpg 11KB
1342.jpg 11KB
0137.jpg 11KB
1657.jpg 11KB
0662.jpg 11KB
1377.jpg 11KB
1764.jpg 11KB
0229.jpg 11KB
1057.jpg 11KB
0193.jpg 11KB
0778.jpg 11KB
1785.jpg 11KB
1633.jpg 11KB
0477.jpg 11KB
1568.jpg 11KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
计算机毕设论文
- 粉丝: 1w+
- 资源: 399
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页