Instructions to use 1aurent/beitv2_base_patch16_224.beph with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use 1aurent/beitv2_base_patch16_224.beph with timm:
import timm model = timm.create_model("hf-hub:1aurent/beitv2_base_patch16_224.beph", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Model card for beitv2_base_patch16_224.beph
A BEiT v2 Vision Transformer (ViT-Base/16) histopathology foundation model (BEPH).
BEiT v2 pre-training on TCGA whole-slide patches.
Model Details
- Model Type: Feature backbone (BEiT v2, relative position bias, layer scale 0.1)
- Model Stats:
- Params: 85.8M (base)
- Image size: 224 x 224 x 3
- Patch size: 16 x 16 x 3
- Papers:
- A foundation model for generalizable cancer diagnosis and survival prediction from histopathological images (Nature Communications 16:2366, 2025)
- Original: https://github.com/Zhcyoung/BEPH (BEPH_backbone.pth, Google Drive)
- License: GPL-3.0
Model Usage
Image Embeddings
from urllib.request import urlopen
from PIL import Image
import timm
# get example image
img = Image.open(
urlopen("https://github.com/owkin/HistoSSLscaling/raw/main/assets/example.tif")
).convert('RGB')
# load model from the hub
model = timm.create_model(
model_name="hf-hub:1aurent/beitv2_base_patch16_224.beph",
pretrained=True,
).eval()
# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)
data = transforms(img).unsqueeze(0) # input is a (batch_size, num_channels, img_size, img_size) shaped tensor
output = model(data) # output is a (batch_size, num_features) shaped tensor
Citation
@article{yang2025beph,
title = {A foundation model for generalizable cancer diagnosis and survival prediction from histopathological images},
author = {Yang, Zhaochang and Wei, Ting and Liang, Ying and Yuan, Xin and Gao, RuiTian and Xia, Yujia and Zhou, Jie and Zhang, Yue and Yu, Zhangsheng},
journal = {Nature Communications},
volume = {16},
pages = {2366},
year = {2025},
doi = {10.1038/s41467-025-57587-y}
}
- Downloads last month
- 74