Model
SophontAI

SophontAI/OpenMidnight

OpenMidnight !figure1(https://cdn-uploads.huggingface.co/production/uploads/6057b823861b9d53d9c4b8df/2PJpVl2k51pfjFg2Vs-oS.png) Overview of the OpenMidnight pathology foundation model State-of-the-art pathology foundation model trained on 12K slides...

41thích
0tải xuống
3lượt xem

OpenMidnight

figure1

Overview of the OpenMidnight pathology foundation model

State-of-the-art pathology foundation model trained on 12K slides

Developed by Sophont

Blog Post | GitHub | Demo


What is OpenMidnight?

OpenMidnight is our open replication of Kaiko.AI's Midnight, a 1.1 billion parameter Vision Transformer foundation model for computational pathology. OpenMidnight achieves state-of-the-art performance despite being trained on significantly less data than Kaiko.AI's Midnight or comparable models.

Key advantages:

  • 🏆 State-of-the-art performance: Achieves 0.775 average score across 14 benchmarks
  • ⚡ Efficient training: Trained in ~83 hours on 8× H100 GPUs for only $1,600 USD (estimated)
  • 📊 Minimal data requirements: Uses only 12K slides from TCGA for training
  • 🔓 Fully open source: Complete model weights, training code, and pipeline publicly available

OpenMidnight is aimed for computational pathology tasks including:

  • Tumor detection and classification
  • Histological grading
  • Tissue segmentation
  • Margin assessment
  • Clinical outcome prediction

Model Description

Usage

Requirements

pip install torch torchvision huggingface_hub

Recommended: Run on GPU with mixed precision for optimal performance.

Quick Start: Loading the Model

import torch
from huggingface_hub import hf_hub_download

#Downloads to hf cache location
download_location = hf_hub_download(repo_id="SophontAI/OpenMidnight", filename="teacher_checkpoint_load.pt")
model = torch.hub.load('facebookresearch/dinov2', 'dinov2_vitg14_reg', weights = None)

#Load OpenMidnight weights
checkpoint = torch.load(download_location, map_location = "cpu")

#Required because dinov2 is baseline 392 and we are baseline 224 resolution
pos_embed = checkpoint["pos_embed"]
model.pos_embed = torch.nn.parameter.Parameter(pos_embed)
model.load_state_dict(checkpoint)
model.eval()

print(f"Model loaded with {sum(p.numel() for p in model.parameters()):,} parameters")

Extracting Embeddings from Tissue Patches

from PIL import Image
import torchvision.transforms as transforms

# Standard preprocessing for pathology images
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(
        mean=[0.485, 0.456, 0.406],  # ImageNet normalization
        std=[0.229, 0.224, 0.225]
    )
])

# Load and preprocess an H&E tissue patch
image = Image.open("path/to/tissue_patch.jpg")
input_tensor = transform(image).unsqueeze(0)  # Shape: [1, 3, 224, 224]

# Extract embeddings
with torch.no_grad():
    embeddings = model(input_tensor)  # Shape: [1, 1536]

print(f"Embedding shape: {embeddings.shape}")
print(f"Embedding norm: {embeddings.norm().item():.4f}")

Model Performance

OpenMidnight achieves competitive or superior performance compared to models trained on 8-30× more data:

Benchmark Comparison

performance_barplot

Average performance of top pathology foundation models and baselines across computational pathology benchmarks

Detailed Benchmark Results

Model#WSIsPCam (10 shots)BACHBRACSBreakHisCRC-100KGleasonMHISTPCamCam16 (small)Panda (small)CoNSePMoNuSACHESTAverage
OpenMidnight (Ours)12K0.7900.9160.6610.8730.9610.8170.8440.9380.9460.6520.6310.6550.3900.775
Midnight92K0.9000.9060.6420.8500.9640.8090.8250.9510.8310.6330.6630.7070.3840.774
UNI-2350K0.8870.9140.6610.8600.9650.7780.8230.9490.8680.6590.6280.6440.4140.773
UNI-2/392350K0.8210.9170.6630.8290.9650.7910.8490.9270.8580.6530.6290.6590.4070.767
Virchow23.1M0.8510.8840.6240.8230.9660.7780.8610.9360.8650.6560.6390.6760.3980.766
Midnight 92k92K0.8760.8960.6160.7890.9660.8200.8110.9500.8610.6250.6290.6560.3920.761
Midnight 12k12K0.7910.9040.6440.8410.9660.8010.8070.9300.8500.6630.6260.6630.3950.760
H-Optimus-0500K0.8240.7570.6150.8080.9560.7710.8420.9420.8380.6700.6440.6850.4150.751
Kaiko-B829K0.7860.8720.6170.8250.9570.7480.8280.9170.8310.6420.6430.6860.3730.748
TCGA-100M12K0.7740.8640.6150.7790.9670.7990.7920.9270.8520.6670.6220.6560.3960.747
Prov-GigaPath171K0.8520.7660.6160.8210.9510.7200.8310.9420.7910.6600.6260.6870.3930.743
Hibou-L1.1M0.8040.8110.6370.7400.9330.7630.8390.9520.8230.6340.6450.6680.3880.740
UNI100K0.8150.7910.5930.7890.9480.7570.8400.9380.8220.6550.6270.6590.3860.740
UNI/512100K0.7370.8770.6120.7320.9500.7540.8140.8830.8140.6540.6210.6580.3640.728
Phikon12K0.8200.7350.5680.7130.9420.7290.8040.9230.8090.6440.6230.6440.3670.717
Phikon v260K0.7410.7340.6000.7160.9390.7550.7840.8930.8030.6310.6260.6450.3750.711
DINOv2-giant (pretrained)00.7190.7250.5830.8320.9350.7440.8620.8740.5070.3820.5640.6140.3420.668
DINOv2-giant (random)00.6490.4730.4110.4270.7480.4640.5690.7550.5660.3080.4610.4280.1720.495

Performance comparison of OpenMidnight to existing pathology foundation models on eva+HEST benchmarks. Scores for existing models are taken from Midnight paper. We report balanced accuracy for the classification tasks, Dice score for semantic segmentation (CoNSeP and MoNuSAC), and the average Pearson correlation for the nine HEST regression tasks. Only performance with [CLS] token is reported. Best score per dataset is bolded.


Model Details

Architecture

ParameterValue
Base ArchitectureViT-G/14
Parameters1.1 billion
Patch Size14×14 pixels
Input Resolution224×224 pixels
Embedding Dimension1536
Number of Layers40
Number of Heads16
InitializationMeta's DINOv2 pre-trained weights

Training Data

  • Dataset: TCGA (The Cancer Genome Atlas)
  • Slides: 12k FFPE H&E-stained whole slide images
  • Cancer Types: 32 different cancer types
  • Total Patches: 96 million
  • Unique Patches: 29 million
  • Stain Type: Hematoxylin and Eosin (H&E)
  • Preprocessing: Non-informative patch filtering

Training Configuration

  • Hardware: 8× NVIDIA H100 GPUs (80GB each)
  • Batch Size: 48 per GPU (384 global batch size)
  • Training Steps: 250,000
  • Optimizer: AdamW
  • Learning Rate: 2.0e-4
  • Regularization: KDE regularizer for training stability
  • Augmentation: Hematoxylin-Eosin-DAB colorspace transformations
  • Training Time: ~83 hours wall-clock time (667 GPU-hrs)
  • Training Cost: ~$1,600 USD (at $2.50/H100/hour)

Blog Post

For an in-depth discussion of OpenMidnight, read the full blog post.


Contact

For questions, feedback, or collaboration opportunities:

We welcome:

  • Bug reports and feature requests
  • Contributions to the training code
  • Benchmark results on new datasets
  • Applications of OpenMidnight to novel tasks

Acknowledgments

We thank Mikhail Karasikov for answering questions about Midnight. We thank Nicolas Känzig for answering questions about eva. We thank the members of MedARC and the broader research community for their feedback and support. We are very grateful to FAL AI for granting compute to support this open-source research.


Citation

If you use OpenMidnight in your research, please cite:

@article{kaplan2025openmidnight,
            author = {Kaplan, Daniel and Grandhi, Ratna Sagari and Lane, Connor and Warner, Benjamin and Abraham, Tanishq Mathew and Scotti, Paul S.},
            title = {How to Train a State-of-the-Art Pathology Foundation Model with \$1.6k},
            year = {2025},
            url = {https://sophont.med/blog/openmidnight},
          }

License

This model is released under the Apache 2.0 License.


Terms of Use

Research Use: This model is primarily intended for research purposes in computational pathology, medical imaging, and related fields.

Clinical Use: This model is not intended for use in medical diagnosis, treatment, or prevention of disease of real patients. It should not be used as a substitute for professional medical advice.

Responsible Use: Users should:

  • Validate model performance on their specific use cases
  • Be aware of potential biases in the training data (TCGA)
  • Consider demographic and geographic limitations
  • Respect privacy rights and comply with applicable data protection laws
  • Follow applicable regulations and ethical guidelines

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryPython
rendeirolab/LazySlide

Accessible and interoperable whole slide image analysis for digital pathology in Python

333
Oct 6, 2026
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026
Model
genbio-ai/genbio-pathfm

GenBio-PathFM !Banner.(https://genbio-ai.github.io/genbio-pathfm/resources/banner.jpg) GenBio-PathFM is a histopathology foundation (FM) model from GenBio AI(https://genbio.ai/). At the time of release, GenBio-PathFM is the strongest open-weight his...

♥0
727
Apr 7, 2026
Modelimage-text-to-text
autotrust/JEV-27B-VL

autotrust/JEV-27B-VL JEV-27B that can see: the same System 1 decisions and System 2, now on images autotrust/JEV-27B-VL is autotrust/JEV-27B(https://huggingface.co/autotrust/JEV-27B) with vision. | | what it does | output | |---|---|---| | System 1...

♥0
63.7k
Oct 14, 2026
RepositoryPython
Dana-Farber-AIOS/pathml

Tools for computational pathology

469
Aug 14, 2026
RepositoryPython
slideflow/slideflow

Powerful, open-source AI tools for digital pathology.

377
Nov 30, 2026
RepositoryJupyter Notebook
Richarizardd/Self-Supervised-ViT-Path

Self-Supervised Vision Transformers Learn Visual Concepts in Histopathology (LMRL Workshop, NeurIPS 2021)

146
Jun 9, 2022
Modelimage-text-to-text
Qwen/Qwen3.8-27B

Qwen3.8-27B !Note This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format. These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc. !Tip F...

♥0
4.8M
Nov 7, 2026
Model
unsloth/Qwen3.8-27B-GGUF

Read our How to Run Qwen3.8-27B Guide!(https://unsloth.ai/docs/models/qwen3.8) This GGUF uses Unsloth Dynamic V3.0 (preview) for SOTA quantization performance. Developer Role Support so Qwen3.8 can work in agentic tools like Codex and more! MTP for...

♥0
8.7M
Nov 12, 2026