We introduce MIPHEI-ViT, a U-Net-style architecture that leverages the H-Optimus-0 ViT foundation model as an encoder to predict multi-channel mIF images from H&E slides. Inspired by ViTMatte, the model combines a hybrid transformerβconvolutional encoder with a convolutional decoder.
This repository supports full reproducibility of our paper on predicting multiplex immunofluorescence (mIF) from standard H&E-stained histology images. It includes all code, pretrained models, and preprocessing steps to replicate our results or apply the approach to new datasets.
The demo is no longer hosted on Hugging Face and is now self-hosted. Try it here:
- Quick Start
- Installation
- Data Download
- Model Weights
- Inference
- Benchmark
- Training
- SlideVips
- Preprocessing Pipeline
- Project Status
- Citation
# 1. Install with conda (or with uv, see below)
conda env create -f environment.yaml --name miphei && conda activate miphei
# 2. Download MIPHEI-ViT weights
python scripts/download_miphei.py --out-dir MIPHEI-vit
# 3. Run WSI inference
python run_wsi_inference.py \
--slide_path path/to/slide.svs \
--checkpoint_dir MIPHEI-vit \
--output_dir predictions/Or try it directly in Google Colab:
conda env create -f environment.yaml --name miphei
conda activate mipheiOr using uv:
uv venv --python 3.11
source .venv/bin/activate
apt-get install -y libvips-dev --no-install-recommends
uv pip install pyvips==3.1.1 pyarrow==23.0.1
uv pip install -r requirements.txt
uv pip install -e slidevips-python/Requires Python 3.11 and PyTorch β₯ 2.7 (default: 2.10.0 in
requirements.txt).
We provide several processed datasets used in our H&E β mIF prediction experiments and cell-level evaluations.
All preprocessed versions of OrionCRC and HEMIT are publicly available on Zenodo:
π Zenodo archive: https://doi.org/10.5281/zenodo.15340874
| Included | Description |
|---|---|
| OrionCRC | Fully preprocessed (H&E + mIF tiles, cell segmentations and cell types) |
| HEMIT | Preprocessed supplementary data (cell segmentations and cell types) |
| Dataset | Type | Use |
|---|---|---|
| OrionCRC | H&E + 16-marker mIF | Pixel-level + cell-level evaluation |
| HEMIT | H&E + 3-marker mIF | Pixel-level + cell-level evaluation |
| PathoCell | H&E + 56-marker mIF | Pixel-level + cell-level evaluation |
| Lizard | H&E + human-annotated cell types | Cell-level evaluation only |
| PanNuke | H&E + human-annotated cell types | Cell-level evaluation only |
Instructions for automatically downloading all datasets, as well as adding your own custom dataset, are available in datasets/README.md.
Figure: MIPHEI-ViT Architecture
- MIPHEI-ViT weights can be downloaded from the GitHub release or via:
python scripts/download_miphei.py --out-dir MIPHEI-vit
β οΈ Important: Access to the H-optimus-0 weights on Hugging Face is required to run MIPHEI-ViT. Please make sure you have permission here: H-optimus-0 on Hugging Face
-
All comparison models (MIPHEI-HEMIT, HEMIT-ORION, UNETR H-Optimus-0, U-Net ConvNeXtv2) are on
Weights & Biases .
-
Original HEMIT checkpoint: github.com/BianChang/Pix2pix_DualBranch
To download all model checkpoints into checkpoints/:
python scripts/download_checkpoints.pyEach model folder contains:
- Model checkpoint (
.ckptor.safetensors) config.yamlwith training and architecture parameters.parquetand.csvfiles with per-dataset evaluation results
WSI Inference Example (H&E β mIF)
β οΈ WSI inference requires the conda installation. Thepyvipsdependency does not install correctly viauvor plainpipand will cause runtime when writing output. Make sure you are using the conda environment created withenvironment.yaml.
ulimit -n 4096 # optional, the script opens many files that can exceed the default limit
python run_wsi_inference.py \
--slide_path path/to/slide.wsi \
--checkpoint_dir path/to/miphei_checkpoint \
--output_dir path/to/save_predictionsKey optional parameters:
| Parameter | Default | Description |
|---|---|---|
--tile_size |
512 | Tile size in pixels |
--tile_overlap |
20 | Overlap between adjacent tiles (px) |
--batch_size |
8 | Inference batch size |
--mpp_target |
0.5 | Target microns-per-pixel |
--level |
0 | WSI pyramid level |
Run python run_wsi_inference.py --help for the full list of options.
The output predictions are saved as OME-TIFF files and can be directly visualized in QuPath.
β οΈ Optional β jemalloc (recommended for multiprocessing):
When using multiple workers (PyTorchDataLoader), the default memory allocator may cause memory issues. Usingjemalloccan improve stability.sudo apt-get install libjemalloc2 LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 python run_wsi_inference.py
β οΈ You may have to adjust theChannel maxvalues in QuPath for optimal visualization of the predicted mIF channels.
python run_inference.py \
--checkpoint_dir path/to/model_folder \
--dataset_config_path path/to/config.yaml \
--batch_size 16This generates a folder inside checkpoint_dir containing predicted TIFF images for the entire dataset.
β οΈ This can produce large amounts of data depending on dataset size.
Use the notebook: notebooks/inference.ipynb
Evaluate pixel-level, cell-level, efficiency, and visualizations in the benchmark/ folder.
Figure: Radar Plot Comparison of H&E to mIF Virtual Staining Performance
# OrionCRC
python run_benchmark.py --checkpoint_dir path/to/model --dataset orion --model model_type
# HEMIT
python run_benchmark.py --checkpoint_dir path/to/model --dataset hemit --model model_typeSee benchmark/README.md for full usage, evaluation, efficiency profiling, radar plots, and figure generation.
Train MIPHEI-ViT from scratch on the OrionCRC dataset:
python run.py +default_configs=miphei-vit ++data.augmentation_dir=null # or directory to augmentated h&eWithout Weights & Biases:
WANDB_MODE=offline python run.py +default_configs=miphei-vit Available default configs are in configs/default_configs/. To train on your own data, create configs/data/own_data.yaml and run:
python run.py +default_configs=miphei-vit data=own_dataOverride any parameter via the command line:
python run.py +default_configs=miphei-vit ++train.epochs=100Run all paper experiments:
python run.py -m +experiments/foundation_models='glob(*)'SlideVips is a high-performance pyvips-based tile reader and processing engine for efficient WSI operations, supporting both H&E and high-dimensional mIF images. It serves as an alternative to OpenSlide with full support for multi-channel fluorescence and OME-TIFF metadata.
See slidevips-python/README.md for the full documentation.
To reproduce the preprocessing steps for the OrionCRC dataset or to apply them to your own data, refer to preprocessings/README.md. It covers tile extraction, autofluorescence subtraction, artifact removal, cell segmentation with CellPose/HoverFast, and more.
Full changelog (click to expand)
| Date | Update |
|---|---|
| March 2026 | WSI inference overlap and shift fixes; dataset setup fixes; Colab update |
| December 2025 | Benchmark on OrionCRC, HEMIT, PathoCell, Lizard, PanNuke |
| December 2025 | Data download scripts; ROSIE and DiffusionFT comparison |
| December 2025 | Code cleanup (PEP8); bootstrap analysis; H&E normalization fix |
| Earlier | SlideVips optimized (RAM fix); WSI inference pipeline; Colab notebook; pixel-level metrics |
Planned:
- Refactor preprocessing pipeline for PEP8 compliance
If you use this work, please cite:
@article{balezo2026miphei,
title={MIPHEI-ViT: Multiplex immunofluorescence prediction from H\&E images using ViT foundation models},
author={Balezo, Guillaume and Trullo, Roger and Pla Planas, Albert and Decenciere, Etienne and Walter, Thomas},
journal={Computers in Biology and Medicine},
volume={206},
pages={111564},
year={2026},
doi={10.1016/j.compbiomed.2026.111564}
}