STAMP

作者 KatherLab已验证

Solid Tumor Associative Modeling in Pathology

126
Stars
56
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/KatherLab/STAMP

快速入门

使用 STAMP 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

STAMP: A Protocol for Solid Tumor Associative Modeling in Pathology

CI STAMP • Nature Protocols

An efficient, ready‑to‑use workflow from whole‑slide image to biomarker prediction.

STAMP is an end‑to‑end, weakly‑supervised deep‑learning pipeline that helps discover and evaluate candidate image‑based biomarkers from gigapixel histopathology slides, no pixel‑level annotations required. Backed by a peer‑reviewed protocol and used in multi‑center studies across several tumor types, STAMP lets clinical researchers and machine‑learning engineers collaborate on reproducible computational‑pathology projects with a clear, structured workflow.

Want to start now? Jump to Installation or walk through our Getting Started guide for a hands-on tutorial.

Why choose STAMP?

  • 🚀 Scalable: Run locally or on HPC (SLURM) with the same CLI; built to handle multi‑center cohorts and large WSI collections.
  • 🎓 Beginner‑friendly & expert‑ready: Zero‑code CLI and YAML config for routine use; optional code‑level customization for advanced research.
  • 🧩 Model‑rich: Out‑of‑the‑box support for +20 foundation models at tile level (e.g., Virchow‑v2, UNI‑v2) and slide level (e.g., TITAN, COBRA).
  • 🔬 Weakly‑supervised: End‑to‑end MIL with Transformer aggregation for training, cross‑validation and external deployment; no pixel‑level labels required.
  • 🧮 Multi-task learning: Unified framework for classification, multi-target classification, regression, and cox-based survival analysis.
  • 📊 Stats & results: Built‑in metrics and patient‑level predictions, ready for analysis and reporting.
  • 🖼️ Explainable: Generates heatmaps and top‑tile exports out‑of‑the‑box for transparent model auditing and publication‑ready figures.
  • 🤝 Collaborative by design: Clinicians drive hypothesis & interpretation while engineers handle compute; STAMP’s modular CLI mirrors real‑world workflows and tracks every step for full reproducibility.
  • 📑 Peer‑reviewed: Protocol published in Nature Protocols and validated across multiple tumor types and centers.
  • 🔗 MCP Support: Compatible with Model Context Protocol (MCP) via the `mcp/` module, ready for integration into next-gen agentic AI workflows.

Real-World Examples of STAMP in Action

  • Squamous Tumors & Survival: In a multi-cohort study spanning four squamous carcinoma types (head & neck, esophageal, lung, cervical), STAMP was used to extract slide-level features for a deep learning model that predicted patient survival directly from H&E whole-slide images.

  • Inflammatory Bowel Disease Atlas: In a 1,002-patient multi-center IBD study, all histology slides were processed with the STAMP workflow, enabling a weakly-supervised MIL model to accurately predict histologic disease activity scores from H&E tissue sections.

  • Foundation Model Benchmarking: A large-scale evaluation of 19 pathology foundation models built its pipeline on STAMP (v1.1.0) for standardized WSI tiling and feature extraction, demonstrating STAMP’s utility as an open-source framework for reproducible model training across diverse cancer biomarkers.

  • Breast Cancer Risk Stratification: In an international early breast cancer study, STAMP performed slide tessellation and color normalization (e.g. 1.14 µm/px resolution, Macenko norm) as part of a multimodal transformer pipeline to predict recurrence risk (Oncotype DX scores) from pathology images.

  • Endometrial Cancer Subtyping: A recent endometrial cancer project employed a modified STAMP pipeline with a pre-trained vision transformer (Virchow2) to predict molecular tumor subtypes directly from H&E slides, achieving strong diagnostic performance in cross-validation.

Installation

To setup STAMP you need uv 0.12 or newer.

Supported platforms

PythonPlatforms
CPU (--extra cpu)3.13, 3.14Linux x86_64/aarch64, Windows AMD64, Apple Silicon macOS
CUDA (--extra gpu, --extra gpu_all)3.13, 3.14Linux x86_64, Linux aarch64

Python 3.14 is recommended and is what .python-version selects; 3.13 remains supported. The CUDA builds are pinned to one ABI stack: CUDA 13.0 with PyTorch 2.11.0 and TorchVision 0.26.0.

CI runs the test suite on Linux. macOS is checked for installation and imports only, so it stays usable for development but is not a tested target.

There is no CUDA build for macOS or Windows. flash-attn, mamba-ssm and causal-conv1d are only published as pre-built wheels for Linux, and STAMP refuses to compile them (see below), so a GPU extra on those platforms fails with a clear resolution error rather than a compiler error.

[!IMPORTANT] uv is required for the GPU workflow. The PyTorch and Astral wheel indexes are configured through [tool.uv.sources] in pyproject.toml, which is uv-specific and invisible to other installers. Installing with plain pip would mean pointing it at https://download.pytorch.org/whl/cu130 and https://wheels.astral.sh/simple/cu130/ yourself, and re-deriving the exact pins by hand. See Why uv is required.

Install or Update uv:

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Update uv
uv self update

Install STAMP from the Repository:

git clone https://github.com/KatherLab/STAMP.git
cd STAMP
# GPU (CUDA) Installation (excluding conchv1_5, gigapath and musk)

uv sync --extra gpu
source .venv/bin/activate
# CPU-only Installation (excluding conchv1_5, gigapath and musk)

uv sync --extra cpu
source .venv/bin/activate

For the full GPU stack, add conchv1_5, gigapath and musk:

# GPU (CUDA) Installation - everything
uv sync --extra gpu_all
source .venv/bin/activate

Both GPU extras install pre-built wheels by default. flash-attn, mamba-ssm and causal-conv1d come from the Astral wheel index already compiled against CUDA 13.0 and PyTorch 2.11, so nothing is compiled locally and no CUDA toolkit needs to be installed to install STAMP. You still need an NVIDIA driver to run on a GPU.

[!NOTE] --extra gpu_prebuilt is deprecated and now just an alias for --extra gpu_all, which is pre-built anyway. It will be removed in the next breaking release.

If you encounter errors during installation please read Installation Troubleshooting below.

Additional Dependencies

[!IMPORTANT] STAMP additionally requires OpenCV dependencies to be installed.

For Ubuntu < 23.10:

apt update && apt install -y libgl1-mesa-glx

For Ubuntu >= 23.10:

apt update && apt install -y libgl1 libglx-mesa0 libglib2.0-0

Why uv is required

The GPU workflow depends on configuration that only uv reads:

  • [tool.uv.sources] routes torch and torchvision to https://download.pytorch.org/whl/cu130 (or .../cpu for the cpu extra) and the three compiled extensions to https://wheels.astral.sh/simple/cu130/.
  • [tool.uv.exclude-dependencies] drops the unconditional CUDA requirements that the UNI, GigaPath and COBRA forks declare, so a CPU install stays free of CUDA-only packages.
  • [tool.uv.no-build-package] forbids source builds of flash-attn, mamba-ssm and causal-conv1d.

None of this is visible to pip, which reads only [project]. Installing with pip would resolve flash-attn from PyPI and try to compile it — which is exactly what this configuration exists to prevent. If you must use pip, you have to add both indexes yourself and pin the extensions to the same +cu.13.0.torch.2.11 local versions listed in pyproject.toml.

Source builds of the three extensions are refused on purpose: they are ABI-locked to one PyTorch build, take a long time, need a matching CUDA toolkit, and were the most common cause of broken installs. An unsupported platform now fails during resolution with a clear message instead of part-way through a compile.

Basic Usage

If the installation was successful, running stamp in your terminal should yield the following output:

$ stamp
usage: stamp [-h] [--config CONFIG_FILE_PATH] {init,preprocess,encode_slides,encode_patients,train,crossval,deploy,statistics,config,heatmaps} ...

STAMP: Solid Tumor Associative Modeling in Pathology

positional arguments:
  {init,preprocess,encode_slides,encode_patients,train,crossval,deploy,statistics,config,heatmaps}
    init                Create a new STAMP configuration file at the path specified by --config
    preprocess          Preprocess whole-slide images into feature vectors
    encode_slides       Encode patch-level features into slide-level embeddings
    encode_patients     Encode features into patient-level embeddings
    train               Train a Vision Transformer model
    crossval            Train a Vision Transformer model with cross validation for modeling.n_splits folds
    deploy              Deploy a trained Vision Transformer model
    statistics          Generate AUROCs and AUPRCs with 95%CI for a trained Vision Transformer model
    config              Print the loaded configuration
    heatmaps            Generate heatmaps for a trained model

options:
  -h, --help            show this help message and exit
  --config CONFIG_FILE_PATH, -c CONFIG_FILE_PATH
                        Path to config file. Default: config.yaml

Getting Started Guide

For a quick introduction how to run stamp, check out our getting started guide.

Reference

If you find our work useful in your research or if you use parts of this code please consider citing our Nature Protocols publication:

@Article{ElNahhas2024,
  author={El Nahhas, Omar S. M. and van Treeck, Marko and W{\"o}lflein, Georg and Unger, Michaela and Ligero, Marta and Lenz, Tim and Wagner, Sophia J. and Hewitt, Katherine J. and Khader, Firas and Foersch, Sebastian and Truhn, Daniel and Kather, Jakob Nikolas},
  title={From whole-slide image to biomarker prediction: end-to-end weakly supervised deep learning in computational pathology},
  journal={Nature Protocols},
  year={2024},
  month={Sep},
  day={16},
  issn={1750-2799},
  doi={10.1038/s41596-024-01047-2},
  url={https://doi.org/10.1038/s41596-024-01047-2}
}

[!NOTE] This repo contains an updated version of the codebase. For a version compatible with the instructions in the paper, please check out version 1 of STAMP.

Installation Troubleshooting

flash-attn / mamba-ssm / causal-conv1d cannot be installed

These only exist as pre-built wheels for Linux x86_64 and Linux aarch64 on Python 3.13/3.14. On any other platform uv reports that no compatible version was found. This is deliberate — STAMP does not fall back to compiling them. Use --extra cpu on macOS and Windows.

Triton Errors

If you encounter errors related to the Triton package like the following:

SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

Try to delete the triton cache:

rm -r ~/.triton

A re-installation might be necessary afterwards.

Undefined Symbol Error

An error like the following when importing flash_attn, mamba_ssm or causal_conv1d means the installed torch does not match the torch the extension was compiled against:

>       import flash_attn_2_cuda as flash_attn_gpu
E       ImportError: [...]/.venv/lib/python3.14/site-packages/flash_attn_2_cuda.cpython-314-x86_64-linux-gnu.so: undefined symbol: _ZN3c105ErrorC2ENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

This should no longer happen, because the extension versions carry the PyTorch build in their version string (+cu.13.0.torch.2.11) and the lockfile pins them together with torch. If you do hit it, you are almost certainly in an environment left over from an older STAMP release. Check what is installed:

uv run python scripts/verify_installed_stack.py --expect-cuda

and rebuild the environment from the lockfile:

rm -rf .venv
uv sync --locked --extra gpu_all

Reproducibility

[!NOTE] We use a central Seed utility to set seeds for PyTorch, NumPy, and Python’s random. This makes data loading and model initialization reproducible. Always call Seed.set(seed) once at startup. We do not enable torch.use_deterministic_algorithms() because it can cause large performance drops. Expect runs with the same seed to follow the same training trajectory, but not bit-for-bit identical low-level kernels.

常见问题

What is STAMP?

STAMP is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by KatherLab. Solid Tumor Associative Modeling in Pathology. It has 126 GitHub stars.

Is STAMP safe to use?

Yes. STAMP passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install STAMP?

Clone the repository with "git clone https://github.com/KatherLab/STAMP" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is STAMP written in?

STAMP is primarily written in Python. It is open-source under KatherLab on GitHub, so you can review or fork the full source.

Are there alternatives to STAMP?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh STAMP against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情