git clone https://github.com/NKI-AI/STAPLER.git
setup.py
cd STAPLER
STAPLER
package (should take less than 10 minutes)
python -m pip install .
The following data is available here:
STAPLER was pre-trained and fine-tuned using an a100 GPU. At this moment no other GPU's have been tested.
Inside the tools
directory the following file should be changed:
.env.example
: Which is an environment file with paths to data, model checkpoints and output paths. It should be adapt the .env.example
to your local file-system and then change the file-name to .env
. For more information see python-dotenv.Inside the tools
directory contains the following files to pre-train, fine-tune and/or test STAPLER on a SLURM cluster. Also provide an argument to --partition
to specify the partition to use.
sbatch pretrain_STAPLER.sh
: Pre-train STAPLER.sbatch train_STAPLER.sh
: Fine-tune STAPLER using 5-fold cross-validation.sbatch test_STAPLER.sh
: Test on a test set using a fine-tuned model checkpoint. Alternatively run STAPLER directly on a machine with an appropriate GPU (see requirements).
python pretrain.py
: Pre-train STAPLER.python train_5_fold.py
: Fine-tune STAPLER using 5-fold cross-validation.python test.py
: Test on a test set using a fine-tuned model checkpoint.The pre-training should take a day, fine-tuning should take a couple of hours per fold and testing/inference should take a couple of minutes for all 5-fold predictions.
To experiment with custom model parameters
change the paramteres inside the config
directory (implemented using Hydra).
The config
directory contains the following main configuration files:
pretrain.yaml
: Configuration parameters file for pre-training.train_5_fold.yaml
: Configuration parameters file for fine-tuning.test.yaml
: Configuration parameters file for testing.To request a feature or to discuss any issues, please let us know by opening an issue on the issues page.
Corresponding author: Ton Schumacher
Ton Schumacher group (NKI) - Group website -
Ai for Oncology group (NKI) - Group website -
The development of the STAPLER model is the result of a collaboration between the Schumacher lab AIforOncology lab at the Netherlands Cancer Institute. The following people contributed to the development of the model:
A part of the data was provided, and consequent results were interpreted by the following people from the Wu lab (DFCI and Harvard Medical School):
STAPLER is built on top of the x-transformers package
Distributed under the Apache 2.0 License.