Skip to main content

Run patch-based classification on pathology whole slide images.

Project description

WSInfer: deep learning inference on whole slide images

Original H&E Heatmap of Tumor Probability

🔥 🚀 Blazingly fast pipeline to run patch-based classification models on whole slide images.

Continuous Integration Documentation Status Version on PyPI Supported Python versions Published in npj Precision Oncology

See for documentation.

The main feature of WSInfer is a minimal command-line interface for running deep learning inference on whole slide images. Here is an example:

wsinfer run \
   --wsi-dir slides/ \
   --results-dir results/ \
   --model breast-tumor-resnet34.tcga-brca


WSInfer can be installed using pip or conda. WSInfer will install PyTorch automatically if it is not installed, but this may not install GPU-enabled PyTorch even if a GPU is available. For this reason, install PyTorch before installing WSInfer.

Install PyTorch first

Please see PyTorch's installation instructions for help installing PyTorch. The installation instructions differ based on your operating system and choice of pip or conda. Thankfully, the instructions provided by PyTorch also install the appropriate version of CUDA. We refrain from including code examples of installation commands because these commands can change over time. Please refer to PyTorch's installation instructions for the most up-to-date instructions.

You will need a new-enough driver for your NVIDIA GPU. Please see this version compatibility table for the minimum versions required for different CUDA versions.

To test whether PyTorch can detect your GPU, check that this code snippet prints True.

python -c 'import torch; print(torch.cuda.is_available())'

Install WSInfer

WSInfer can be installed with pip or conda (from conda-forge).


To install the latest stable version, use

python -m pip install wsinfer

To install the bleeding edge (which may have breaking changes), use

python -m pip install git+


To install the latest stable version, use

conda install -c conda-forge wsinfer

If you use mamba, simply replace conda install with mamba install.


Clone this GitHub repository and install the package (in editable mode with the dev extras).

git clone
cd wsinfer
python -m pip install --editable .[dev]
pre-commit install

We use pre-commit to automatically run various checks during git commit.


If you find our work useful, please cite our paper!

Kaczmarzyk, J.R., O’Callaghan, A., Inglis, F. et al. Open and reusable deep learning for pathology with WSInfer and QuPath. npj Precis. Onc. 8, 9 (2024).

  title={Open and reusable deep learning for pathology with WSInfer and QuPath},
  author={Kaczmarzyk, Jakub R. and O'Callaghan, Alan and Inglis, Fiona and Gat, Swarad and Kurc, Tahsin and Gupta, Rajarsi and Bremer, Erich and Bankhead, Peter and Saltz, Joel H.},
  journal={npj Precision Oncology},

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsinfer-0.6.1.tar.gz (1.9 MB view hashes)

Uploaded Source

Built Distribution

wsinfer-0.6.1-py3-none-any.whl (43.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page