STAMP (Spatial Transcriptomics-guided Alignment framework for Molecular Profiling) aims to bridge the gap between histological morphology and molecular biology in pathology foundation models (PFMs). By integrating spatial transcriptomics (ST) data, STAMP endows PFMs with intrinsic molecular awareness. To support this paradigm, we curated HumanST-1k, a human ST dataset spanning diverse anatomical organs and sequencing platforms. This atlas yields 1.8 million pairs of H&E patches and corresponding transcriptomic profiles, providing a corpus that links histological structures with their molecular states. To mitigate the technical noise inherent to raw transcriptomics, STAMP applies a pathway-informed alignment strategy that aggregates transcriptomic data into biologically functional pathways, which are subsequently integrated into PFMs via parameter-efficient fine-tuning. This alignment enriches the representation space of PFMs and unlocks their capacity to resolve sub-visual molecular signatures.
Quick Start
STAMP requires the following dependencies:
- python >= 3.13.2
- pytorch >= 2.6.0
- torchmetrics >= 1.8.0
- timm >= 1.0.19
- peft >= 0.17.1
- numpy >= 2.2.6
- pillow >= 11.3.0
Then, the features can be extracted as follows:
import torch
import numpy as np
from PIL import Image
from stamp import get_trans, get_model
# build model and transforms
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
ckpt_path = "YOUR_PATH_TO_MODEL/STAMP.pth" # please download the model weights first
trans = get_trans()
model = get_model(device, ckpt_path)
# dummy input
img = Image.fromarray((np.random.rand(224, 224, 3) * 255).astype(np.uint8))
img = img.convert("RGB")
# feature extraction
img = trans(img).unsqueeze(0).to(device)
feature = model(img)