Feature Extraction
Transformers
Safetensors
English
mosaic
computational-pathology
multimodal
survival-analysis
custom_code
Instructions to use Astaxanthin/MOSAIC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Astaxanthin/MOSAIC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Astaxanthin/MOSAIC", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Astaxanthin/MOSAIC", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,186 Bytes
8850d81 | 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 | import argparse
import torch
from transformers import AutoModel
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--model", required=True, help="Local model folder or HF repository ID")
parser.add_argument("--device", default="cpu")
args = parser.parse_args()
model = AutoModel.from_pretrained(args.model, trust_remote_code=True).to(args.device).eval()
# Synthetic input for checking installation, not a clinical prediction example.
generator = torch.Generator().manual_seed(42)
features = torch.randn(4, 768, generator=generator)
coords = torch.tensor([[0,0], [0,256], [256,0], [256,256]])
output = model.predict(patch_features=features, patch_coords=coords,
cancer_type="Lung Adenocarcinoma",
clinical={"age":65,"sex":"Male","stage":"II"},
genomics={"snv":["TP53"],"cnv":[]})
print("WSI features:", output["wsi_features"].shape)
print("OS risk:", output["os_risk"].tolist())
print("PFS risk:", output["pfs_risk"].tolist())
print("Views:", output["num_views"])
if __name__ == "__main__":
main()
|