PhenoSeq / example.py
naidooreed's picture
Upload folder using huggingface_hub
fdb5676 verified
Raw
History Blame Contribute Delete
1.85 kB
"""
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}]")