This repository contains code for using Cerberus, our multi-task model outlined in our Medical Image Analysis paper.
Scroll down to the bottom to find instructions on downloading our pretrained weights and WSI-level results.
# create base conda environment
conda env create -f environment.yml
# activate environment
conda activate cerberus
# install PyTorch with pip
pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
Below we outline the contents of the directories in the repository.
infer
: Inference scriptsloader
: Data loading and post processing scriptsmisc
: Miscellaneous scripts and functionsmodels
: Scripts relating to model definition and hyperparametersrun_utils
: Model engine and callbacksThe purpose of the main scripts in the repository:
run_infer_tile.py
: Run inference on image tilesrun_infer_wsi.py
: Run inference on whole-slide imagesTo process large image tiles, run:
python run_infer_tile.py --gpu=<gpu_id> --batch_size=<n> --model=<path> --input_dir=<path> --output_dir=<path>
For convenience, we have also included a bash script, where you can populate command line arguments. To make this script executable, run chmod +x run_tile.sh
. Then use the command ./run_tile.sh
.
To process whole-slide images, run:
python run_infer_wsi.py --gpu=<gpu_id> --batch_size=<n> --model=<path> --input_dir=<path> mask_dir=<path> --output_dir=<path>
Similar to the tile mode, we have included an example bash script (run_wsi.sh
) that can be used to run the command, without having to always re-enter the arguments.
For both tile and WSI inference, the model path should point to a directory containing the settings file and the weights (.tar
file). You will see from the above command that there is a mask_dir
argument. In this repo, we assume that tissue masks have been automatically generated. You should include masks - otherwise it will lead to significantly longer processing times.
In this repository, we enable the download of:
Download all of the above weights by visiting this page.
Note, the pretrained weights are designed for weight initialisation - not for model inference.
All weights are under a non-commercial license. See the License section for more details.
Download results from processing 599 CRC WSIs using Cerberus at this page.
Code is under a GPL-3.0 license. See the LICENSE file for further details.
Model weights are licensed under Attribution-NonCommercial-ShareAlike 4.0 International. Please consider the implications of using the weights under this license.
@article{graham2022one,
title={One model is all you need: multi-task learning enables simultaneous histology image segmentation and classification},
author={Graham, Simon and Vu, Quoc Dang and Jahanifar, Mostafa and Raza, Shan E Ahmed and Minhas, Fayyaz and Snead, David and Rajpoot, Nasir},
journal={Medical Image Analysis},
pages={102685},
year={2022},
publisher={Elsevier}
}