-
Notifications
You must be signed in to change notification settings - Fork 774
MIL example #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
MIL example #431
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5e53bcb
MIL example
87346f1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4e91b28
mil tutorial update
myron b82afc3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7ba5a3c
mil tutorial update
myron 861dd72
Merge branch 'master' of github.com:myron/tutorials
myron 8c50765
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c2d3f9f
Merge branch 'master' into master
bhashemian f344b99
small updates
myron 247dc0b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a9961e2
updated images
myron 2c19bae
Merge branch 'master' of github.com:myron/tutorials
myron c668915
gdown for json
myron abd71ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b6e2e0f
Merge branch 'master' into master
bhashemian 3fb11b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6df772a
Update README
bhashemian 1294b86
Fix formatting and typos
bhashemian dfa9557
small fixes
myron 5978b16
Merge branch 'master' into master
Nic-Ma 0c1192e
stats
myron e3f7cc0
pip install
myron 95157ed
README fixes
myron 0bbe9e9
Merge branch 'master' into master
bhashemian 18cbb35
Merge branch 'master' into master
Nic-Ma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
|
|
||
| # Multiple Instance Learning (MIL) Examples | ||
|
|
||
| This tutorial contains a baseline method of Multiple Instance Learning (MIL) classification from Whole Slide Images (WSI). | ||
| The dataset is from [Prostate cANcer graDe Assessment (PANDA) Challenge - 2020](https://www.kaggle.com/c/prostate-cancer-grade-assessment/) for cancer grade classification from prostate histology WSIs. | ||
| The implementation is based on: | ||
|
|
||
| Andriy Myronenko, Ziyue Xu, Dong Yang, Holger Roth, Daguang Xu: "Accounting for Dependencies in Deep Learning Based Multiple Instance Learning for Whole Slide Imaging". In MICCAI (2021). [arXiv](https://arxiv.org/abs/2111.01556) | ||
|
|
||
|  | ||
|  | ||
|
|
||
| ## Requirements | ||
|
|
||
| The script is tested with: | ||
|
|
||
| - `Ubuntu 18.04` | `Python 3.6` | `CUDA 11.0` | `Pytorch 1.10` | ||
|
|
||
| - the default pipeline requires about 16GB memory per gpu | ||
|
|
||
| - it is tested on 4x16gb multi-gpu machine | ||
|
|
||
| ## Dependencies and installation | ||
|
|
||
| ### MONAI | ||
|
|
||
| Please install the required dependencies | ||
|
|
||
| ```bash | ||
| pip install tifffile | ||
| pip install imagecodecs | ||
| ``` | ||
|
|
||
| For more information please check out [the installation guide](https://docs.monai.io/en/latest/installation.html). | ||
|
|
||
myron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Data | ||
|
|
||
| Prostate biopsy WSI dataset can be downloaded from Prostate cANcer graDe Assessment (PANDA) Challenge on [Kaggle](https://www.kaggle.com/c/prostate-cancer-grade-assessment/data). | ||
| In this tutorial, we assume it is downloaded in the `/PandaChallenge2020` folder | ||
|
|
||
| ## Examples | ||
|
|
||
| Check all possible options | ||
|
|
||
| ```bash | ||
| python ./panda_mil_train_evaluate_pytorch_gpu.py -h | ||
| ``` | ||
|
|
||
| ### Train | ||
|
|
||
| Train in multi-gpu mode with AMP using all available gpus, | ||
| assuming the training images in /PandaChallenge2020/train_images folder, | ||
| it will use the pre-defined 80/20 data split in [datalist_panda_0.json](https://drive.google.com/drive/u/0/folders/1CAHXDZqiIn5QUfg5A7XsK1BncRu6Ftbh) | ||
|
|
||
| ```bash | ||
| python -u panda_mil_train_evaluate_pytorch_gpu.py | ||
| --data_root=/PandaChallenge2020/train_images \ | ||
| --amp \ | ||
| --distributed \ | ||
| --mil_mode=att_trans \ | ||
| --batch_size=4 \ | ||
| --epochs=50 \ | ||
| --logdir=./logs | ||
| ``` | ||
|
|
||
| If you need to use only specific gpus, simply add the prefix `CUDA_VISIBLE_DEVICES=...` | ||
|
|
||
| ```bash | ||
| CUDA_VISIBLE_DEVICES=0,1,2,3 python -u panda_mil_train_evaluate_pytorch_gpu.py | ||
| --data_root=/PandaChallenge2020/train_images \ | ||
| --amp \ | ||
| --distributed \ | ||
| --mil_mode=att_trans \ | ||
| --batch_size=4 \ | ||
| --epochs=50 \ | ||
| --logdir=./logs | ||
| ``` | ||
|
|
||
| ### Validation | ||
|
|
||
| Run inference of the best checkpoint over the validation set | ||
|
|
||
| ```bash | ||
| # Validate checkpoint on a single gpu | ||
| python -u panda_mil_train_evaluate_pytorch_gpu.py | ||
| --data_root=/PandaChallenge2020/train_images \ | ||
| --amp \ | ||
| --mil_mode=att_trans \ | ||
| --checkpoint=./logs/model.pt \ | ||
| --validate | ||
| ``` | ||
|
|
||
| ### Inference | ||
|
|
||
| Run inference on a different dataset. It's the same script as for validation, | ||
| we just specify a different data_root and json list files | ||
|
|
||
| ```bash | ||
| python -u panda_mil_train_evaluate_pytorch_gpu.py | ||
| --data_root=/PandaChallenge2020/some_other_files \ | ||
| --dataset_json=some_other_files.json | ||
| --amp \ | ||
| --mil_mode=att_trans \ | ||
| --checkpoint=./logs/model.pt \ | ||
| --validate | ||
| ``` | ||
|
|
||
| ### Stats | ||
|
|
||
| Expected train and validation loss curves | ||
|
|
||
|  | ||
|  | ||
|
|
||
| Expected validation QWK metric | ||
|
|
||
|  | ||
|
|
||
| ## Questions and bugs | ||
Nic-Ma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - For questions relating to the use of MONAI, please us our [Discussions tab](https://github.com/Project-MONAI/MONAI/discussions) on the main repository of MONAI. | ||
| - For bugs relating to MONAI functionality, please create an issue on the [main repository](https://github.com/Project-MONAI/MONAI/issues). | ||
| - For bugs relating to the running of a tutorial, please create an issue in [this repository](https://github.com/Project-MONAI/Tutorials/issues). | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.