You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

  • This model and associated code are released under Waiv custom license and may only be used for non-commercial, academic research purposes with proper attribution.
  • Any commercial use, sale, or other monetization of the mascaret model and its derivatives, which include models trained on outputs from the mascaret model or datasets created from the mascaret model, is prohibited and requires prior approval.
  • Please note that the primary email used to sign up for your Hugging Face account must match your institutional email to receive approval. By downloading the model, you attest that all information (affiliation, research use) is correct and up-to-date. Downloading the model requires prior registration on Hugging Face and agreeing to the terms of use. By downloading this model, you agree not to distribute, publish or reproduce a copy of the model. If another user within your organization wishes to use the mascaret model, they must register as an individual user and agree to comply with the terms of use. Users may not attempt to re-identify the deidentified data used to develop the underlying model.
  • This model is provided "as-is" without warranties of any kind, express or implied. This model has not been reviewed, certified, or approved by any regulatory body, including but not limited to the FDA (U.S.), EMA (Europe), MHRA (UK), or other medical device authorities. Any application of this model in healthcare or biomedical settings must comply with relevant regulatory requirements and undergo independent validation. Users assume full responsibility for how they use this model and any resulting consequences. The authors, contributors, and distributors disclaim any liability for damages, direct or indirect, resulting from model use. Users are responsible for ensuring compliance with data protection regulations (e.g., GDPR, HIPAA) when using it in research that involves patient data.
  • We require users to fill in their ORCID ID, which can be created at https://orcid.org/register.
  • If you are a commercial entity, please contact us at fm-license@wearewaiv.com to discuss licensing options.

Log in or Sign Up to review the conditions and access this model content.

Say hi to Mascaret, the robustified version of Midnight-12k, by Waiv

Waiv, formerly Owkin Dx, builds AI-powered digital pathology to catalyze precision medicine in oncology. This organization hosts pathology foundation models and research artifacts we share with the community for benchmarking and research use. On July 29th, 2026, we released:

  • Phaet โ€” a robustified version of Phikon-v2
  • Mascaret โ€” a robustified version of Midnight-12k

Both come from a model-agnostic fine-tuning recipe that makes pathology foundation models invariant to acquisition factors like scanner and lab, improving robustness and downstream performance together. The names follow a wave theme drawn from the Waiv brand โ€” a mascaret is a tidal bore, a wave that carries its shape forward.

Learn more:

Graphical abstract

Usage

End-to-end example: load the model, load an image, extract features.

import torch
import torchvision.transforms as T
from huggingface_hub import hf_hub_download
from PIL import Image
from transformers import AutoModel

REPO = "wearewaiv/mascaret"

# Load the fine-tuned encoder
model = AutoModel.from_pretrained(REPO, trust_remote_code=True)
model.eval()

# Build the preprocessing transform from the model config
# (pixel_mean / pixel_std are stored in the config, so this stays correct)
transform = T.Compose([
    T.Resize(224),        # shorter side -> 224, aspect ratio preserved
    T.CenterCrop(224),    # ... then crop, so the result really is 224x224
    T.ToTensor(),
    T.Normalize(mean=model.config.pixel_mean, std=model.config.pixel_std),
])

# Load the example image shipped with this repository
image = Image.open(hf_hub_download(REPO, "assets/image.jpg")).convert("RGB")

# Preprocess -> (B, 3, 224, 224)
pixel_values = transform(image).unsqueeze(0)

# L2-normalised CLS embedding โ€” the recommended feature vector
features = model.encode(pixel_values)       # (1, 1536); encode() is already no-grad
print(features.shape)

# Full token sequence when patch-level features are needed
with torch.inference_mode():
    out = model(pixel_values=pixel_values)
out.last_hidden_state                       # (1, 257, 1536) โ€” CLS at index 0
out.pooler_output                           # (1, 1536)      โ€” L2-normalised CLS (== features)

trust_remote_code=True makes transformers fetch this repository's modeling_finetuned_encoder.py, and it prints a warning every time a new version of that file is downloaded. Pass an explicit revision to pin the code you reviewed and silence it:

model = AutoModel.from_pretrained(REPO, trust_remote_code=True, revision="<commit-sha>")

Preprocessing

pixel_mean and pixel_std are stored in the config, so you never need to hardcode them:

model.config.pixel_mean  # [0.500, 0.500, 0.500]
model.config.pixel_std   # [0.500, 0.500, 0.500]

Environment

We recommend an isolated environment โ€” trust_remote_code models are sensitive to the transformers version, and mixing them into a large existing environment tends to surface version conflicts:

uv venv --python 3.11 ~/venvs/waiv
source ~/venvs/waiv/bin/activate
uv pip install torch torchvision "transformers>=5.14,<6" "safetensors>=0.8.0" \
    huggingface-hub pillow

The snippet above is verified end-to-end on this combination:

Package Version
Python 3.11
torch 2.5.1+cu124
torchvision 0.20.1+cu124
transformers 5.14.1
safetensors 0.8.0
huggingface_hub 1.25.1

Notes:

  • transformers 5.x requires safetensors >= 0.8.0. An older safetensors pinned by some other dependency makes import transformers fail outright with an ImportError โ€” this is the most common setup problem we see.
  • timm is not needed for this model. It is imported lazily, and only for checkpoints that use the timm loader; this one uses the hf_transformers loader (DINOv2).
  • CPU is fine for a handful of images. For batches, model.to("cuda") and move pixel_values to the same device.

Acknowledgments

Computing resources. This work was granted access to the High-Performance Computing (HPC) resources of IDRIS under the allocation 2026-A0201012519 made by GENCI. Fine-tuning experiments were performed using the EuroHPC supercomputer MareNostrum 5, hosted by the Barcelona Supercomputing Center (BSC). We gratefully acknowledge EuroHPC and BSC for providing access to these resources under the EHPC-AIF-2026PG01-102 allocation.

Data access. The results presented here are in part based upon data generated by the TCGA Research Network: https://www.cancer.gov/tcga.

Example image attribution

assets/image.jpg, used by the snippet above, is not covered by the license that applies to the model weights โ€” it keeps its own terms and is included solely as a runnable example input.

Where our users are

World map of access-request origins

Access-request origins (accepted) as of 2026-07-29. 0 located across 0 countries; 0 of unknown origin. Top: โ€”.

Inferred from requesters' institutional email domains โ€” Hugging Face does not expose per-download geolocation. For this gated model, granted requesters are the population able to download it.

Downloads last month
13
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 wearewaiv/mascaret

Finetuned
(1)
this model

Paper for wearewaiv/mascaret