Run this model with HF Jobs
Run medarc/OpenMidnight-1.0-SPECTRA on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/medarc/OpenMidnight-1.0-SPECTRA. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/medarc/OpenMidnight-1.0-SPECTRA on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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
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 uses crop_pct=1.0 and crop_mode="squash" to resize the full image directly to 224 脳 224 pixels. It uses bicubic interpolation and ImageNet normalization stored in config.json. The embedding uses the CLS token.
These are tile embeddings. Slide-level predictions require a downstream model.
Segmentation preprocessing
The transform resizes the entire image to 224 脳 224 without removing tissue. For square tiles, this preserves the aspect ratio; rectangular images are stretched to fit. The final center-crop operation generated by timm is a no-op because the image is already 224 脳 224.
The image and segmentation mask must cover the same tissue region. With a full-tile resize, decoder logits can be interpolated back to the original mask size before computing the loss or metrics, as THUNDER does. If resizing a discrete label mask instead, use nearest-neighbor interpolation. Exclude the CLS and register tokens when passing patch features to a segmentation decoder: patch_tokens = tokens[:, model.num_prefix_tokens:].
The previous configuration used crop_pct=0.875, which kept only the central 224 脳 224 pixels of a 256 脳 256 tile. Using those features against a full-tile mask misaligns the image and target. Reload the updated configuration, recompute cached embeddings, and retrain the segmentation decoder for a corrected evaluation.
Paper
Coming soon. We will add the paper link and citation here.
- Downloads last month
- 165
Model tree for medarc/OpenMidnight-1.0-SPECTRA
Base model
SophontAI/OpenMidnight