Skip to main content

scout-tissue

Tissue detection for whole-slide images (WSI) with SCOUT-open. A cheap classical detector covers the whole slide, a small audit network predicts where it is likely wrong, and only those windows are re-segmented by a frozen pathology foundation model (H-optimus-0). The output is a binary tissue mask at 8 µm/px, placed exactly on the slide's level-0 pixel frame.

slide ─► thumbnail 8 µm/px ─► base mask (optical density + morphology)
                           └─► audit U-Net: per-pixel risk ─► rank 448 µm windows near tissue by risk
                                                              └─► top half re-read at 2 µm/px
                                                                  ─► H-optimus-0 + decoder head
      final mask = base, with the escalated windows replaced by the fused FM decision,
                   components < 0.01 mm² removed

Install

pip install scout-tissue                 # once published on PyPI
pip install git+https://github.com/CosmoIknosLab/scout-tissue-detection
pip install "scout-tissue[demo]"         # with the browser demo (Gradio)

Python ≥ 3.10. OpenSlide comes with the openslide-bin wheel; no system library is needed. Install PyTorch first if you need a specific CUDA build (see pytorch.org).

H-optimus-0 is gated. Accept its terms at https://huggingface.co/bioptimus/H-optimus-0 and log in (huggingface-cli login or HF_TOKEN). The SCOUT heads (~7 MB) and H-optimus-0 (~4.5 GB) are downloaded on first use into your Hugging Face cache (HF_HOME); afterwards --offline (or HF_HUB_OFFLINE=1) works without network.

Quick start

scout-tissue predict slide1.svs slide2.ndpi --out masks/ --format npz,png,geojson

Models are loaded once for all slides. Options: --device cuda|cpu, --timing (per-stage times), --skip-existing, --readers N (window-reader processes), --audit-ckpt / --fm-head (local head files instead of the download), --cache-dir, --offline. scout-tissue download fetches the heads in advance.

from scout_tissue import Scout

scout = Scout.from_pretrained(device="cuda")
res = scout.predict("slide.svs")
res.mask            # bool array [H, W] on the 8 µm/px grid
res.mpp, res.grid   # 8.0, Grid(origin_x, origin_y, scale, height, width, mpp)
res.to_geojson()    # tissue polygons in level-0 pixel coordinates
res.save("masks/", ("npz", "png", "geojson"))

Browser demo: scout-tissue demo [--host 0.0.0.0] [--port 7860] (slide path on the server or upload; shows thumbnail, mask, escalated windows and audit risk).

Output and coordinates

<slide>.npz (read with scout_tissue.load_npz(path) → (mask, grid)):

member content
mask bit-packed mask: np.unpackbits(z["mask"], count=H*W).reshape(H, W)
shape [H, W]
mpp µm per mask pixel (8.0)
origin_x, origin_y level-0 pixel coordinates of the mask's top-left corner
scale level-0 pixels per mask pixel (mpp / mpp0, not rounded)
grid the same as JSON; system ("final"); meta (JSON: counts, thresholds, versions, weight hashes)

Mask pixel (row r, column c) covers level-0 x ∈ [origin_x + c·scale, origin_x + (c+1)·scale) and y ∈ [origin_y + r·scale, origin_y + (r+1)·scale). Level-0 coordinates are OpenSlide's (origin at the top-left corner of level 0, x right, y down); the origin is the slide's openslide.bounds-x/y (0 if absent, e.g. non-zero for many .mrxs). The last row/column may extend past the scanned area (treated as glass).

<slide>.png: the same mask, 255 = tissue, one pixel per mask pixel (the PNG resolution field stores the 8 µm/px). <slide>.geojson: one Polygon feature per 8-connected tissue component, traced along pixel edges and converted with the convention above, so vertices are level-0 pixel coordinates (features carry a Tissue classification, so QuPath can import them as annotations).

The slide's level-0 MPP must be in its metadata; slides without a usable MPP are rejected, never read at a guessed resolution. Only pyramid levels are read; label and macro images are never opened.

Hardware

A GPU is strongly recommended; the time is dominated by H-optimus-0 on the escalated windows, so it grows with the amount of tissue. Measured on 18 slides (biopsies to large resections) with an NVIDIA RTX 5000 Ada and 8 CPU cores: 6–89 s per slide (median ~41 s) after a one-off model load of ~15 s, peak GPU memory ~6 GB. On CPU only (16 cores) a small biopsy slide took ~5 min and ~10 GB of RAM. Window reads at 2 µm/px use one process per CPU core (--readers).

Masks are deterministic for a given device and software stack. GPU and CPU runs can differ in a few boundary pixels (26 pixels, Dice 0.99997, on one test slide).

Performance

On the Tissues-with-Issues TEST set (113 case groups, 153 slides), SCOUT-open fails on 19.5 % of case groups (95 % CI 12.6–28.0) under the paper's failure rule. See the paper for the protocol and comparisons.

Licences

  • Code: Apache-2.0 (LICENSE).
  • SCOUT heads (downloaded from Cristiandieti/scout-tissue-detection, also on Zenodo, doi:10.5281/zenodo.23664072): CC BY-NC 4.0 (LICENSE-WEIGHTS.md).
  • H-optimus-0 (Bioptimus): Apache-2.0, gated on Hugging Face; not redistributed.
  • The paper's main variant uses Virchow2 as the foundation model; its decoder head is not redistributed because Virchow2's licence (CC-BY-NC-ND 4.0) restricts models trained on its outputs. This package runs SCOUT-open only.

Citation

Cristian Tommasino and Antonio M. Rinaldi (University of Naples Federico II). SCOUT: Risk-Guided Foundation-Model Escalation for Robust Tissue Detection in Whole-Slide Images. Preprint, under review. See CITATION.cff.

Metadata

Release files for scout-tissue 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scout-tissue 1.0.0
File Size Uploaded Provenance Actions
scout_tissue-1.0.0.tar.gz 46.0 kB Without provenance Details for scout_tissue-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scout-tissue 1.0.0
File Interpreter ABI Platform Actions
scout_tissue-1.0.0-py3-none-any.whl Python 3 none any Details for scout_tissue-1.0.0-py3-none-any.whl

Total release size: 89.5 kB

Release files / scout_tissue-1.0.0.tar.gz

Download URL scout_tissue-1.0.0.tar.gz
Size 46.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f9883dfe669e7a508244fc117f6c5361d3f4b5048e107eae99911cd6b86b076a
BLAKE2b-256 checksum
How to use checksums
1899983b85af7a5307806631ad3cd7eb5997e602e288ffe47461096e6d9a6276
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / scout_tissue-1.0.0-py3-none-any.whl

Download URL scout_tissue-1.0.0-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc5d58cfc2d6505b540086e834d880df6f3af0df708a0940e728ba9d2809ae8a
BLAKE2b-256 checksum
How to use checksums
8b3d8a7802d9eb2a66d698c275d1f0f1341a09af2d2f67d033ab606b37916f71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for scout-tissue 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page