Instructions to use medarc/OpenMidnight-1.0-SPECTRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use medarc/OpenMidnight-1.0-SPECTRA with timm:
import timm model = timm.create_model("hf-hub:medarc/OpenMidnight-1.0-SPECTRA", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Download README.md from medarc/OpenMidnight-1.0-SPECTRA: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/medarc/OpenMidnight-1.0-SPECTRA/resolve/main/README.md
- Command line
-
hf download hf://medarc/OpenMidnight-1.0-SPECTRA/README.md
-
curl -L -o README.md https://huggingface.co/medarc/OpenMidnight-1.0-SPECTRA/resolve/main/README.md
language: en
license: apache-2.0
library_name: timm
pipeline_tag: image-feature-extraction
base_model: SophontAI/OpenMidnight
base_model_relation: finetune
tags:
- pathology
- histopathology
- feature-extraction
- spectra
OpenMidnight-1.0-SPECTRA
MedARC · Sophont · Paper (coming soon)
OpenMidnight-1.0-SPECTRA is OpenMidnight 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.
Legacy OpenMidnight 1.0 release. For the current model, use OpenMidnight-1.1-SPECTRA.
The model maps RGB histology tiles to 1,536-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 "timm==1.0.30" huggingface_hub safetensors pillow
import torch
import timm
from PIL import Image
from timm.data import create_transform, resolve_model_data_config
device = "cuda" # Use "cpu" to run without a GPU.
model = timm.create_model(
"hf-hub:medarc/OpenMidnight-1.0-SPECTRA", pretrained=True,
).eval().to(device)
transform = create_transform(**resolve_model_data_config(model), is_training=False)
image = Image.open("tile.png").convert("RGB")
batch = transform(image).unsqueeze(0).to(device)
with torch.inference_mode():
tokens = model.forward_features(batch)
embedding = tokens[:, 0]
print(embedding.shape) # torch.Size([1, 1536])
The configuration supplies bicubic resizing to 256 pixels, a 224 × 224 center crop, and ImageNet normalization stored in config.json. The embedding uses the CLS token.
These are tile embeddings. Slide-level predictions require a downstream model.
Paper
Coming soon. We will add the paper link and citation here.