File size: 4,806 Bytes
30e5a24 | 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 | ---
license: mit
language:
- en
library_name: pytorch
datasets:
- MahmoodLab/hest
tags:
- biology
- spatial-transcriptomics
- computational-pathology
- gene-expression
- safetensors
---
# SimpleP2G pretrained prediction heads
This repository contains **10 SimpleP2G checkpoints**: five HEST-1K datasets × two 200-gene panels × 1 setting(s), using **fold 0 and seed 42**.
Each checkpoint was selected by validation-slide PCC-200 after a 100-epoch training run. The released weights are the EMA weights used for the saved test predictions.
The models consume frozen 2,560-dimensional Virchow2 embeddings and predict gene expression in `log2(raw_count + 1)` units. **Virchow2 weights, image embeddings, tissue images, expression data, optimizer states and training logs are not included.** Obtain the image encoder separately from [paige-ai/Virchow2](https://huggingface.co/paige-ai/Virchow2).
## Checkpoints
| Setting | Dataset | Panel | Test slide | Selected epoch | Test PCC-200 |
| --- | --- | --- | --- | ---: | ---: |
| single-patch | Brain | [HMHVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/brain/hmhvg) | NCBI667 | 12 | 0.3803 |
| single-patch | Brain | [HVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/brain/hvg) | NCBI667 | 16 | 0.1690 |
| single-patch | ccRCC | [HMHVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/ccrcc/hmhvg) | INT2 | 19 | 0.2704 |
| single-patch | ccRCC | [HVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/ccrcc/hvg) | INT2 | 7 | 0.1098 |
| single-patch | HER2ST | [HMHVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/her2st/hmhvg) | SPA148 | 21 | 0.7089 |
| single-patch | HER2ST | [HVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/her2st/hvg) | SPA148 | 37 | 0.3798 |
| single-patch | Lung | [HMHVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/lung/hmhvg) | NCBI856 | 7 | 0.8717 |
| single-patch | Lung | [HVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/lung/hvg) | NCBI856 | 8 | 0.4954 |
| single-patch | PRAD | [HMHVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/prad/hmhvg) | MEND145 | 9 | 0.5561 |
| single-patch | PRAD | [HVG-200](https://huggingface.co/king159/SimpleP2G/tree/main/models/single-patch/prad/hvg) | MEND145 | 12 | 0.2199 |
These are the scores of the released fold only, not means across the three evaluation folds. Panels are selected using training slides and can contain different genes across datasets. Keep the exact output-column order in each checkpoint’s `genes.json`.
## Download
```python
from huggingface_hub import snapshot_download
snapshot_download("king159/SimpleP2G", local_dir="simplep2g-checkpoints")
```
## Load and predict
The repository includes the small prediction-head implementation and a loader. From the downloaded repository directory (or an up-to-date SimpleP2G source checkout), install `torch`, `safetensors` and `huggingface_hub`, then:
```python
import torch
from src.pretrained import load_pretrained
model, genes, metadata = load_pretrained(
"king159/SimpleP2G", dataset="brain", panel="hmhvg", setting="single-patch", device="cpu"
)
# Supply your precomputed image embeddings: shape (batch, 2560).
embeddings = torch.load("target_embeddings.pt", map_location="cpu", weights_only=True).float()
with torch.inference_mode():
mean, log_variance = model(embeddings[:16])
# mean[:, i] predicts genes[i] in log2(count + 1) units.
```
To load offline, pass the downloaded repository directory as the first argument. To pin a particular release, pass its Hub commit hash as `revision=`.
The image feature convention is the CLS token concatenated with the mean of patch tokens (register tokens excluded), using the encoder’s prescribed preprocessing. Each model’s `config.json` records architecture, input/output conventions, split IDs, selection rule and metrics.
## Files
`models/<setting>/<dataset>/<panel>/` contains `model.safetensors`, `config.json`, and `genes.json`. `model_index.json` lists all checkpoints; `checksums.json` records SHA-256 hashes. Weights are exported losslessly and checked against the training implementation using strict state-dictionary loading and CPU forward comparisons.
## Scope
These are research models for predicting measured expression from image features. The fixed gene panels and tissue cohorts define their evaluated scope; the release does not include a clinical validation or cell-type classifier.
## License
This release follows the project’s MIT license; see [LICENSE](LICENSE). The separately obtained image encoder and source datasets retain their own terms.
|