Midnight-12k-SPECTRA

MedARC · Sophont · Paper (coming soon)

Midnight-12k-SPECTRA is midnight adapted with SPECTRA by MedARC and Sophont. We trained on registered PLISM image tiles, aligning representations of the same tissue across scanners and stains with a contrastive objective. The learned updates are merged into the full model weights.

The model maps RGB histology tiles to 3,072-dimensional embeddings for downstream analysis. All inference weights are included; no separate base checkpoint, adapter, or cluster access is required.

Inference

In a Python environment:

uv pip install torch torchvision "transformers==4.57.6" huggingface_hub safetensors pillow
import torch
from PIL import Image
from torchvision import transforms as T
from transformers import AutoModel

device = "cuda"  # Use "cpu" to run without a GPU.
model = AutoModel.from_pretrained("medarc/Midnight-12k-SPECTRA").eval().to(device)
transform = T.Compose([
    T.Resize(224, interpolation=T.InterpolationMode.BILINEAR),
    T.CenterCrop(224),
    T.ToTensor(),
    T.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)),
])

image = Image.open("tile.png").convert("RGB")
batch = transform(image).unsqueeze(0).to(device)
with torch.inference_mode():
    tokens = model(batch).last_hidden_state
    embedding = torch.cat([tokens[:, 0], tokens[:, 1:].mean(dim=1)], dim=-1)
print(embedding.shape)  # torch.Size([1, 3072])

The example uses bilinear resizing to 224 pixels, a 224 × 224 center crop, and mean/std (0.5, 0.5, 0.5). The embedding concatenates the CLS token and mean patch token.

These are tile embeddings. Slide-level predictions require a downstream model.

Paper

Coming soon. We will add the paper link and citation here.

Downloads last month
18
Safetensors
Model size
1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for medarc/Midnight-12k-SPECTRA

Finetuned
(2)
this model

Collection including medarc/Midnight-12k-SPECTRA