Skip to content

Commit

Permalink
update the README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bianhao123 committed Jun 13, 2023
1 parent 3f6bbe8 commit 15d8d50
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
79 changes: 77 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,86 @@
# TransMIL: Transformer based Correlated Multiple Instance Learning for Whole Slide Image Classification [NeurIPS 2021]
## Abstract
Multiple instance learning (MIL) is a powerful tool to solve the weakly supervised classification in whole slide image (WSI) based pathology diagnosis. However, the current MIL methods are usually based on independent and identical distribution hypothesis, thus neglect the correlation among different instances. To address this problem, we proposed a new framework, called correlated MIL, and provided a proof for convergence. Based on this framework, we devised a Transformer based MIL (TransMIL), which explored both morphological and spatial information. The proposed TransMIL can effectively deal with unbalanced/balanced and binary/multiple classification with great visualization and interpretability. We conducted various experiments for three different computational pathology problems and achieved better performance and faster convergence compared with state-of-the-art methods. The test AUC for the binary tumor classification can be up to 93.09% over CAMELYON16 dataset. And the AUC over the cancer subtypes classification can be up to 96.03% and 98.82% over TCGA-NSCLC dataset and TCGA-RCC dataset, respectively.

<details>
<summary>
<b>TransMIL: Transformer based Correlated Multiple Instance Learning for Whole Slide Image Classification</b>. <a href="https://proceedings.neurips.cc/paper/2021/file/10c272d06794d3e5785d5e7c5356e9ff-Paper.pdf" target="blank">[NeurIPS2021]</a>
</summary>

```tex
@article{shao2021transmil,
title={Transmil: Transformer based correlated multiple instance learning for whole slide image classification},
author={Shao, Zhuchen and Bian, Hao and Chen, Yang and Wang, Yifeng and Zhang, Jian and Ji, Xiangyang and others},
journal={Advances in Neural Information Processing Systems},
volume={34},
pages={2136--2147},
year={2021}
}
```

**Abstract:** With the development of computational pathology, deep learning methods for Gleason grading through whole slide images (WSIs) have excellent prospects. Since the size of WSIs is extremely large, the image label usually contains only slide-level label or limited pixel-level labels. The current mainstream approach adopts multi-instance learning to predict Gleason grades. However, some methods only considering the slide-level label ignore the limited pixel-level labels containing rich local information. Furthermore, the method of additionally considering the pixel-level labels ignores the inaccuracy of pixel-level labels. To address these problems, we propose a mixed supervision Transformer based on the multiple instance learning framework. The model utilizes both slidelevel label and instance-level labels to achieve more accurate Gleason grading at the slide level. The impact of inaccurate instance-level labels is further reduced by introducing an efficient random masking strategy in the mixed supervision training process. We achieve the state-of-the-art performance on the SICAPv2 dataset, and the visual analysis shows the accurate prediction results of instance level.

</details>

![overview](docs/overview.png)


## Data Preprocess
we follow the CLAM's WSI processing solution (https://github.com/mahmoodlab/CLAM)
```bash
# WSI Segmentation and Patching
python create_patches_fp.py --source DATA_DIRECTORY --save_dir RESULTS_DIRECTORY --patch_size 256 --preset bwh_biopsy.csv --seg --patch --stitch

# Feature Extraction
CUDA_VISIBLE_DEVICES=0,1 python extract_features_fp.py --data_h5_dir DIR_TO_COORDS --data_slide_dir DATA_DIRECTORY --csv_path CSV_FILE_NAME --feat_dir FEATURES_DIRECTORY --batch_size 512 --slide_ext .svs
```


## Installation
- Linux (Tested on Ubuntu 18.04)
- NVIDIA GPU (Tested on a single Nvidia GeForce RTX 3090)
- Python (3.7.11), h5py (2.10.0), opencv-python (4.1.2.30), PyTorch (1.10.1), torchvision (0.11.2), pytorch-lightning (1.5.10).

Please refer to the following instructions.
```bash
# create and activate the conda environment
conda create -n transmil python=3.7 -y
conda activate transmil

# install pytorch
## pip install
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113
## conda install
conda install pytorch=1.11 torchvision cudatoolkit=11.3 -c pytorch
# install related package
pip install -r requirements.txt
```

### Train

```python
python train.py --stage='train' --config='Camelyon/TransMIL.yaml' --gpus=0 --fold=0
```

### Test

```python
python train.py --stage='test' --config='Camelyon/TransMIL.yaml' --gpus=0 --fold=0
```

## Reference
- If you found our work useful in your research, please consider citing our works(s) at:


```tex
@article{shao2021transmil,
title={Transmil: Transformer based correlated multiple instance learning for whole slide image classification},
author={Shao, Zhuchen and Bian, Hao and Chen, Yang and Wang, Yifeng and Zhang, Jian and Ji, Xiangyang and others},
journal={Advances in Neural Information Processing Systems},
volume={34},
pages={2136--2147},
year={2021}
}
```
© This code is made available under the GPLv3 License and is available for non-commercial academic purposes.
Binary file added docs/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
addict==2.4.0
albumentations==1.1.0
dgl==0.4.3.post2
einops==0.4.0
h5py==3.6.0
omegaconf==2.2.0
opencv-python==4.1.2.30
opencv-python-headless==4.5.5.62
openslide-python==1.1.2
Pillow==8.4.0
pytorch-lightning==1.5.10
pytorch-toolbelt==0.4.4
PyYAML==6.0
scikit-image==0.17.2
scikit-learn==1.0.2
tensorboard==2.7.0
tifffile==2021.11.2
timm==0.5.4
torchmetrics==0.6.2
nystrom_attention

0 comments on commit 15d8d50

Please sign in to comment.