PASTA Neuron-related Pathway Prediction Models

This repository contains PASTA (PAthological Super-resolution Transcriptome-guided pAradigm) models trained for predicting neuron-related pathway scores from H&E-stained pathology images.

Model Description

PASTA is a deep learning framework that can predict neuron-related pathway spatial patterns directly from histology images. These benchmark models were trained on HEST-library mouse brain data with different foundation model backbones.

Model Architecture

  • Base Architecture: Modified Dense Prediction Transformer (DPT)
  • Task: Neuron-related pathway score prediction
  • Input: H&E-stained neuropathology image patches (224ร—224 pixels); Paired enriched pathway scores from ST data(optional)
  • Output: Super-resolution spatial pathway maps

Available Models

This repository includes 3 models:

  • UNIv2_neuro1_pos.pt - UNIv2 backbone, Gene set: Neuro1 (2 plaque-related pathways)
  • UNIv2_neuro2_pos.pt - UNIv2 backbone, Gene set: Neuro2 (8 neuro-related pathways)
  • UNI_neuro3_no_pos.pt - UNI backbone, Gene set: Neuro3 (50 aging-related pathways)

Notes on variants:

  • pos: Trained with coarse-grained pathway score/gene expression as positional embeddings. In these variants, you can use coarse-grained pathway scores/gene expression as an optional input.
  • no_pos: Trained without pathway scores.

Usage

๐ŸŒŸ To use PASTA models for inference, please follow the code in PASTA codebase and confirm that you have the access to related backbone foundation models.

Loading and Using the Model

import torch
from pasta.model import PASTA
from huggingface_hub import hf_hub_download
from PIL import Image
import torchvision.transforms as transforms

# Download model checkpoint
model_path = hf_hub_download(
    repo_id="mengflz/pasta-neuro",
    filename="UNIv2_neuro1_pos.pt"
)

# Initialize PASTA model
model = PASTA(
    model_name='UNIv2',
    pathway_dim=2,
    freq_flag=True,
    N=128,
    scale=1.0
)

# Load trained weights
checkpoint = torch.load(model_path, map_location='cpu')
model.load_state_dict(checkpoint, strict=False)
model.eval()

# Prepare input image
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], 
                       std=[0.229, 0.224, 0.225])
])

image = Image.open("path/to/neuro_image.png")
input_tensor = transform(image).unsqueeze(0)

# Run inference
with torch.no_grad():
    feat, feat_mean, feat_recon = model(input_tensor)
    # feat: spatial feature map [B, 3, H, W]
    # feat_mean: class logits [B, 3]
    # feat_recon: reconstructed image [B, 3, H, W]
    
    predictions = torch.softmax(feat_mean, dim=1)
    predicted_class = torch.argmax(predictions, dim=1)

Training Details

Please refer to the original PASTA paper or PASTA Github repository for more details.

Citation

If you use these models in your research, please cite:


License

This project is licensed under GPL-3.0. The underlying foundation models (UNI, UNIv2) have their own licenses.

Contact

For questions and issues, please open an issue on the repository.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including mengflz/pasta-neuro