File size: 1,854 Bytes
fdb5676 | 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 | """
PhenoSeq β minimal inference example.
Downloads the pretrained model from HuggingFace and generates
scGPT RNA-seq embeddings from synthetic ViT-L imaging features.
Usage:
pip install torch numpy huggingface_hub
python example.py
"""
import numpy as np
from pipeline import PhenoSeqPipeline
# ββ Load model from the Hub ββββββββββββββββββββββββββββββββββββββββββββββββββββ
pipe = PhenoSeqPipeline.from_pretrained("Sentinal4D/PhenoSeq")
print(pipe)
# ββ Prepare imaging features βββββββββββββββββββββββββββββββββββββββββββββββββββ
# Real use: extract ViT-L/14 embeddings from 5-channel fluorescence microscopy.
# Shape: (n_cells, n_imaging_cells, 5120)
# n_cells β number of single cells to predict RNA for
# n_imaging_cells β imaging cells sampled per well (16 during training)
# 5120 β 5 fluorescence channels Γ 1024 ViT-L dims
n_cells = 8
n_imaging_cells = 16
img_features = np.random.randn(n_cells, n_imaging_cells, 5120).astype(np.float32)
# ββ Run inference ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Returns scGPT-space embeddings in the original (denormalized) scale.
# DDIM with 50 steps by default; pass ddim_steps=0 for full 1000-step DDPM.
rna_predictions = pipe(img_features)
print(f"\nInput imaging features : {img_features.shape}") # (8, 16, 5120)
print(f"Output RNA embeddings : {rna_predictions.shape}") # (8, 512)
print(f"Output range : [{rna_predictions.min():.3f}, {rna_predictions.max():.3f}]")
|