Downloads · 30 days
17
14% of all-time downloads
perturblab/cellfm-80m
cellfm-80m is a machine learning model from perturblab. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
CellFM is a large-scale foundation model pre-trained on transcriptomics of 100 million human cells using a retention-based architecture (MAE Autobin).
Downloads · 30 days
17
14% of all-time downloads
All-time downloads
124
Public
Repo size
345 MB
Likes
0
Public
Click a slice to open those files.
.pt345 MB · 100%
From the Hugging Face model README
CellFM is a large-scale foundation model pre-trained on transcriptomics of 100 million human cells using a retention-based architecture (MAE Autobin).
from perturblab.model.cellfm import CellFMModel
# Load pretrained model
model = CellFMModel.from_pretrained('cellfm-80m')
# Or from local path
model = CellFMModel.from_pretrained('./weights/cellfm-80m')
import scanpy as sc
from perturblab.data import PerturbationData
# Load your data
adata = sc.read_h5ad('your_data.h5ad')
# Preprocess
adata = CellFMModel.prepare_data(adata)
# Get embeddings
embeddings = model.predict_embeddings(
adata,
batch_size=32,
return_cls_token=True,
)
# Access cell embeddings
cell_embeddings = embeddings['cell_embeddings'] # Shape: (n_cells, enc_dims)
from perturblab.model.cellfm import CellFMModel, CellFMConfig
# Initialize model with classification head
config = CellFMConfig(
model_name='80M',
num_cls=10, # Number of cell types
)
model = CellFMModel(config, for_finetuning=True)
# Load pretrained weights
model.load_weights('./weights/cellfm-80m/model.pt')
# Fine-tune on your labeled data
# ... (training code)
from perturblab.model.cellfm import CellFMPerturbationModel
from perturblab.data import PerturbationData
# Load perturbation data
data = PerturbationData.from_anndata(adata)
data.split_data(train=0.7, val=0.15, test=0.15)
# Initialize model
model = CellFMPerturbationModel.from_pretrained('cellfm-80m')
# Initialize perturbation head
model.init_perturbation_head_from_dataset(data)
# Train
model.train_model(data, epochs=20)
# Predict
predictions = model.predict_perturbation(data, split='test')
config.json: Model configurationmodel.pt: Model weights (PyTorch state dict)README.md: This fileIf you use CellFM in your research, please cite:
@article{cellfm2024,
title={CellFM: A Large-Scale Foundation Model for Single-Cell Transcriptomics},
author={...},
journal={...},
year={2024}
}