File size: 4,988 Bytes
54fd3a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | ---
license: bsd-3-clause
library_name: pytorch
pipeline_tag: image-to-image
tags:
- virtual-staining
- histopathology
- hemit
- image-to-image
- benchmark
- safetensors
---
# ImplicitStainer CNN — HEMIT benchmark adaptation
Selected prediction weights trained by the Virtual Staining Benchmark on HEMIT.
Input is RGB H&E; output is three independent numerical fluorescence intensity
channels in **DAPI, CD3, panCK** order. This release contains the selected FP32
inference weights and a self-contained loader. No pretrained foundation network
is needed for inference.
Released EDSR/CNN variant: width 64, 16 residual blocks and learned coordinate MLPs. This is the CNN variant, not the Swin/hybrid variant.
This is a disclosed benchmark adaptation of the published architecture, not an
author checkpoint or a reproduction of the paper's training setting or scores.
See [the benchmark](https://thomasdekerf.github.io/virtual-staining-benchmark/), `training_summary.json`, and `release_evidence.json`.
## Use
Install the download client with `python -m pip install huggingface_hub`,
then download the release files:
```python
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="thomasdekerf/implicitstainer-hemit",
local_dir="implicitstainer-hemit",
)
```
Enter the downloaded directory with `cd implicitstainer-hemit`, then run:
```bash
python -m pip install -r requirements.txt
python predict.py --input he_image.png --output prediction.npy --preview preview.png
```
For GPU inference append `--device cuda`. The default uses CPU. The input must be
stored uint8 RGB and at least 256×256 native pixels. The loader takes a fixed
center 256 crop, divides by 255, and never resizes or fits stain normalization.
Physical pixel size is not asserted. Predictions outside the released dataset
or native sampling require separate validation.
`prediction.npy` is an HWC float32 array in DAPI/CD3/panCK order, clamped to [0, 1]
exactly as in benchmark evaluation. `prediction.raw.npy` preserves the unclamped
model forward output. `prediction.json` records channel order and crop coordinates.
The optional preview is three grayscale intensity panels using a fixed [0, 1]
display range; the numerical stack is not an RGB tissue image.
Python loading after downloading the files:
```python
from inference import load_model, load_rgb_center_crop, predict_tensor
model = load_model(device="cpu")
rgb, crop = load_rgb_center_crop("he_image.png")
raw_nchw = predict_tensor(model, rgb)
benchmark_nchw = raw_nchw.clamp(0, 1)
```
## Training and evaluation
- Seed 42; train 3,717, validation 630 and test 945 author fields.
- Splits are disjoint by released author field identity. Patient/whole-slide
mappings are unavailable, so independent patient-level disjointness is not certified.
- Native 256 random training crops; fixed center 256 held-out crops; no resizing.
- Training reached 96,000 optimizer updates, protecting the 80,000-update benchmark
reference horizon and
then observing 8 fresh full-validation checks without improvement.
- Selected checkpoint: update 38,000; minimum full-validation LPIPS. TEST did not select weights.
- Four-GPU native update/resume gate and native adequacy were verified.
Full test split (945 fields), from the original selected-checkpoint evaluation:
| Metric | Value |
|---|---:|
| Numerical mIF PSNR | 27.523707 |
| Numerical mIF 11×11 box SSIM | 0.699224 |
| LPIPS on normalized intensity stack | 0.209927 |
| Numerical mIF MAE | 0.024497 |
Full validation, test and per-channel values are in `evaluation.json`. LPIPS is
an operational image-feature distance on the normalized three-channel stack,
not a validated biological or clinical stain score. Intensities use the released
uint8 / 255 codec, without physical fluorescence calibration.
## Channel convention and provenance
Output channels are already in the benchmark's canonical DAPI/CD3/panCK order;
do not permute the model output. Ingestion converted the original raw TIFF
panCK/CD3/DAPI storage order using indices [2, 1, 0]. This numerical mapping is
documented in retained decoder/probe, named channel statistics and ingestion QC;
it is separate from the display colour or marker listing in a dataset README.
See `release_evidence.json` for source hashes and references.
## Scope and license
For research image translation. This model has no established diagnostic or
clinical grading use. Dataset source, author attribution and terms appear in
`THIRD_PARTY_NOTICES.md`; code terms are retained in `LICENSE` and
`UPSTREAM_NOTICE.md`. No source tissue images are included in this repository.
HEMIT: Chang Bian, Beth Phillips, Tim Cootes and Martin Fergie (2024), Mendeley Data,
version 1, [DOI 10.17632/3gx53zm49d.1](https://data.mendeley.com/datasets/3gx53zm49d/1),
CC BY 4.0. Original architecture: IMPLICITSTAINER: Resolution Agnostic Data-Efficient Virtual Staining Using Neural Implicit Functions,
https://arxiv.org/abs/2505.09831.
|