AI SeedbankHelp preserve open and free AI for humanity's future

← All models

microsoft_BiomedCLIP-PubMedBERT_256-vit_base_patch16_224

microsoft · View on Hugging Face ↗

Get this model

Download TorrentMagnet Link

Seeders: · Leechers:

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


language: en tags:


BiomedCLIP-PubMedBERT_256-vit_base_patch16_224

BiomedCLIP is a biomedical vision-language foundation model that is pretrained on PMC-15M, a dataset of 15 million figure-caption pairs extracted from biomedical research articles in PubMed Central, using contrastive learning. It uses PubMedBERT as the text encoder and Vision Transformer as the image encoder, with domain-specific adaptations. It can perform various vision-language processing (VLP) tasks such as cross-modal retrieval, image classification, and visual question answering. BiomedCLIP establishes new state of the art in a wide range of standard datasets, and substantially outperforms prior VLP approaches:

Contents

Training Data

We have released BiomedCLIP Data Pipeline at https://github.com/microsoft/BiomedCLIP_data_pipeline, which automatically downloads and processes a set of articles from the PubMed Central Open Access dataset. BiomedCLIP builds upon the PMC-15M dataset, which is a large-scale parallel image-text dataset generated by this data pipeline for biomedical vision-language processing. It contains 15 million figure-caption pairs extracted from biomedical research articles in PubMed Central and covers a diverse range of biomedical image types, such as microscopy, radiography, histology, and more.

Model Use

1. Environment

conda create -n biomedclip python=3.10 -y
conda activate biomedclip
pip install open_clip_torch==2.23.0 transformers==4.35.2 matplotlib

2.1 Load from HF hub

import torch
from urllib.request import urlopen
from PIL import Image
from open_clip import create_model_from_pretrained, get_tokenizer

# Load the model and config files from the Hugging Face Hub
model, preprocess = create_model_from_pretrained('hf-hub:microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224')
tokenizer = get_tokenizer('hf-hub:microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224')


# Zero-shot image classification
template = 'this is a photo of '
labels = [
    'adenocarcinoma histopathology',
    'brain MRI',
    'covid line chart',
    'squamous cell carcinoma histopathology',
    'immunohistochemistry histopathology',
    'bone X-ray',
    'chest X-ray',
    'pie chart',
    'hematoxylin and eosin histopathology'
]

dataset_url = 'https://huggingface.co/microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224/resolve/main/example_data/biomed_image_classification_example_data/'
test_imgs = [
    'squamous_cell_carcinoma_histopathology.jpeg',
    'H_and_E_histopathology.jpg',
    'bone_X-ray.jpg',
    'adenocarcinoma_histopathology.jpg',
    'covid_line_chart.png',
    'IHC_histopathology.jpg',
    'chest_X-ray.jpg',
    'brain_MRI.jpg',
    'pie_chart.png'
]
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
model.to(device)
model.eval()

context_length = 256

images = torch.stack([preprocess(Image.open(urlopen(dataset_url + img))) for img in test_imgs]).to(device)
texts = tokenizer([template + l for l in labels], context_length=context_length).to(device)
with torch.no_grad():
    image_features, text_features, logit_scale = model(images, texts)

    logits = (logit_scale * image_features @ text_features.t()).detach().softmax(dim=-1)
    sorted_indices = torch.argsort(logits, dim=-1, descending=True)

    logits = logits.cpu().numpy()
    sorted_indices = sorted_indices.cpu().numpy()

top_k = -1

for i, img in enumerate(test_imgs):
    pred = labels[sorted_indices[i][0]]

    top_k = len(labels) if top_k == -1 else top_k
    print(img.split('/')[-1] + ':')
    for j in range(top_k):
        jth_index = sorted_indices[i][j]
        print(f'{labels[jth_index]}: {logits[i][jth_index]}')
    print('\n')

2.2 Load from local files

import json

from urllib.request import urlopen
from PIL import Image
import torch
from huggingface_hub import hf_hub_download
from open_clip import create_model_and_transforms, get_tokenizer
from open_clip.factory import HF_HUB_PREFIX, _MODEL_CONFIGS


# Download the model and config files
hf_hub_download(
    repo_id="microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224",
    filename="open_clip_pytorch_model.bin",
    local_dir="checkpoints"
)
hf_hub_download(
    repo_id="microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224",
    filename="open_clip_config.json",
    local_dir="checkpoints"
)


# Load the model and config files
model_name = "biomedclip_local"

with open("checkpoints/open_clip_config.json", "r") as f:
    config = json.load(f)
    model_cfg = config["model_cfg"]
    preprocess_cfg = config["preprocess_cfg"]


if (not model_name.startswith(HF_HUB_PREFIX)
    and model_name not in _MODEL_CONFIGS
    and config is not None):
    _MODEL_CONFIGS[model_name] = model_cfg

tokenizer = get_tokenizer(model_name)

model, _, preprocess = create_model_and_transforms(
    model_name=model_name,
    pretrained="checkpoints/open_clip_pytorch_model.bin",
    **{f"image_{k}": v for k, v in preprocess_cfg.items()},
)


# Zero-shot image classification
template = 'this is a photo of '
labels = [
    'adenocarcinoma histopathology',
    'brain MRI',
    'covid line chart',
    'squamous cell carcinoma histopathology',
    'immunohistochemistry histopathology',
    'bone X-ray',
    'chest X-ray',
    'pie chart',
    'hematoxylin and eosin histopathology'
]

dataset_url = 'https://huggingface.co/microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224/resolve/main/example_data/biomed_image_classification_example_data/'
test_imgs = [
    'squamous_cell_carcinoma_histopathology.jpeg',
    'H_and_E_histopathology.jpg',
    'bone_X-ray.jpg',
    'adenocarcinoma_histopathology.jpg',
    'covid_line_chart.png',
    'IHC_histopathology.jpg',
    'chest_X-ray.jpg',
    'brain_MRI.jpg',
    'pie_chart.png'
]
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
model.to(device)
model.eval()

context_length = 256

images = torch.stack([preprocess(Image.open(urlopen(dataset_url + img))) for img in test_imgs]).to(device)
texts = tokenizer([template + l for l in labels], context_length=context_length).to(device)
with torch.no_grad():
    image_features, text_features, logit_scale = model(images, texts)

    logits = (logit_scale * image_features @ text_features.t()).detach().softmax(dim=-1)
    sorted_indices = torch.argsort(logits, dim=-1, descending=True)

    logits = logits.cpu().numpy()
    sorted_indices = sorted_indices.cpu().numpy()

top_k = -1

for i, img in enumerate(test_imgs):
    pred = labels[sorted_indices[i][0]]

    top_k = len(labels) if top_k == -1 else top_k
    print(img.split('/')[-1] + ':')
    for j in range(top_k):
        jth_index = sorted_indices[i][j]
        print(f'{labels[jth_index]}: {logits[i][jth_index]}')
    print('\n')

Use in Jupyter Notebook

Please refer to this example notebook.

Intended Use

This model is intended to be used solely for (I) future research on visual-language processing and (II) reproducibility of the experimental results reported in the reference paper.

Primary Intended Use

The primary intended use is to support AI researchers building on top of this work. BiomedCLIP and its associated models should be helpful for exploring various biomedical VLP research questions, especially in the radiology domain.

Out-of-Scope Use

Any deployed use case of the model --- commercial or otherwise --- is currently out of scope. Although we evaluated the models using a broad set of publicly-available research benchmarks, the models and evaluations are not intended for deployed use cases. Please refer to the associated paper for more details.

Reference

@article{zhang2024biomedclip,
  title={A Multimodal Biomedical Foundation Model Trained from Fifteen Million Image–Text Pairs},
  author={Sheng Zhang and Yanbo Xu and Naoto Usuyama and Hanwen Xu and Jaspreet Bagga and Robert Tinn and Sam Preston and Rajesh Rao and Mu Wei and Naveen Valluri and Cliff Wong and Andrea Tupini and Yu Wang and Matt Mazzola and Swadheen Shukla and Lars Liden and Jianfeng Gao and Angela Crabtree and Brian Piening and Carlo Bifulco and Matthew P. Lungren and Tristan Naumann and Sheng Wang and Hoifung Poon},
  journal={NEJM AI},
  year={2024},
  volume={2},
  number={1},
  doi={10.1056/AIoa2400640},
  url={https://ai.nejm.org/doi/full/10.1056/AIoa2400640}
}

Limitations

This model was developed using English corpora, and thus can be considered English-only.

Further information

Please refer to the corresponding paper, "Large-Scale Domain-Specific Pretraining for Biomedical Vision-Language Processing" for additional details on the model training and evaluation.

Magnet link

Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:

magnet:?xt=urn:btih:227751ce1f31e06e6bc820546cc3cbf97060c6db&dn=microsoft_BiomedCLIP-PubMedBERT_256-vit_base_patch16_224

Open magnet in torrent client · infohash 227751ce1f31e06e6bc820546cc3cbf97060c6db

Files & hashes

PathSizesha1sha256
LICENSE.md1.0 KB (1,072 B)3dc959f471a21e1e691c66b53752fca579865b8d222c691afe0dcdc498bb9a31cb4b331ce72a55a2351cab8d98ce246dd7799ffa
README.md10.0 KB (10,287 B)a698a31a6e0560f1f4e28423ddc43acaf60bfbab4f23faa276bdeef957a0f7c00088f913214bcaad93d79e7768accb9ab5d0f58e
biomed-vlp-eval.svg61.9 KB (63,364 B)563ae11fa3bb8300632aaa70f9335f4ef8a390a297ddb395bab0c4dab222ee28c42380c7c2ef04c0712c4fd296fcc93dccb2d559
biomed_clip_example.ipynb2.8 MB (2,890,452 B)964810b4a3240ae626b972634073b673a4239cb340a45005a45dbdef47e78b083f9ff31246e7dbb3c5d3dd4631d92b40a825b499
example_data/biomed_image_classification_example_data/H_and_E_histopathology.jpg173.3 KB (177,447 B)9aa023c6a81e35a2c00a0fecd37ca0d854d6fbfefb1b0e2adc9858d8972a7739fb43b022f0be3b677f5d6405b45d7555b3231b05
example_data/biomed_image_classification_example_data/IHC_histopathology.jpg176.7 KB (180,984 B)f80ad45ad389b47999b37831df12d2cb22bd06551bbba7a4acc84d2e93572823fe3467f201d98b2d9b8c413bf4e1d37892aac69f
example_data/biomed_image_classification_example_data/adenocarcinoma_histopathology.jpg26.3 KB (26,948 B)4e4c8dca98219a630aea0da7a3bb6ae9fb358993f9361790bf53556a11c452173b44ff32bfd8d920824b9d202b215a19dce9e43d
example_data/biomed_image_classification_example_data/bone_X-ray.jpg7.3 KB (7,436 B)f41db7b36f59a8c536ab719ed264607835304b6f8e7d61839700fcd506b3f9fa320b7b10dd69d77557c377a85049e0d7f2b9e7ea
example_data/biomed_image_classification_example_data/brain_MRI.jpg125.2 KB (128,221 B)a3c38680958db795d59536d052c1b9ec0925e3dbafdabc2afad6480f754fbabe1a90589cfe59bd870d4510262a81b8b098596ccf
example_data/biomed_image_classification_example_data/chest_X-ray.jpg885.1 KB (906,335 B)18570159889a8c15b2031415ea7dc6aacdde0b594cbbcf805291db949e4ff085ca3c7258b2823de21b2857ae684e6c91ff9a38a4
example_data/biomed_image_classification_example_data/covid_line_chart.png6.2 KB (6,303 B)ddf963a1b5ad2206913c82cb430ab3309d510a723710620efa33c0d3394b8f69374b0e803f642730562ae5ce7b140229f28d858f
example_data/biomed_image_classification_example_data/pie_chart.png362.5 KB (371,161 B)7a662d680e0f996ec8a81903e7319f04cd2dc81ac1f32b2b48970ee2820e8470c1c8138c2413253f695be1498a8da424d5526a38
example_data/biomed_image_classification_example_data/squamous_cell_carcinoma_histopathology.jpeg16.8 KB (17,236 B)9eefdc09c41ac10652dfb9df2550fb728cb7a4311dce0422227b914e221744e95c31b0fe83f7384de72105e01e529a6f91360442
open_clip_config.json707 B (707 B)127246c8e2bdbec4fff72874d2814f92ac77a4039a41f334a8c444678772c0ebb9ab854c97ab350bced3a17b803e258d39c23dc0
open_clip_pytorch_model.bin747.4 MB (783,705,670 B)e773532a05c5623e5eb3e5a525123cbd3c2f79c152cc993c5c5ff962bd0c60931874bc001e7e9b41666a385530f4a036294576be
special_tokens_map.json125 B (125 B)a8b3208c2884c4efb86e49300fdd3dc877220cdfb6d346be366a7d1d48332dbc9fdf3bf8960b5d879522b7799ddba59e76237ee3
tokenizer.json663.3 KB (679,168 B)12dad549bdbaebc16053beef12821e667968ec20defc1f91456606e7847af3a2fb4a8abb96441423aa5407a52498395ea68327ff
tokenizer_config.json394 B (394 B)42046bd361a033a24264dc41de1fe6cafd68072fe1790949631401af1bfb6c9c7aeec7fcf612e274d73579d99f704faea40c8ba7
vocab.txt219.8 KB (225,062 B)9d65c8495e044c70ce1a30e2ae8e2f0b3738dbae7b36651908a88bc38bda41b728b2a598191e0d3b553cbacf7b1e5f026d5b5b9f

Cite this release

Canonical URL
https://aiseedbank.org/models/microsoft_BiomedCLIP-PubMedBERT_256-vit_base_patch16_224/
Slug
microsoft_BiomedCLIP-PubMedBERT_256-vit_base_patch16_224
Infohash
227751ce1f31e06e6bc820546cc3cbf97060c6db
License
mit
Signing key fingerprint
85a3b32c3712427b

Every file carries a locally computed sha256 — verify a download against the signed sums: microsoft_BiomedCLIP-PubMedBERT_256-vit_base_patch16_224.SHA256SUMS (+ minisign signature).

Provenance

Upstream repositorymicrosoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224
Revision (pinned)9f341de24bfb00180f1b847274256e9b65a3a32e
Fetched at2026-09-04T02:08:09Z
License at fetchmit
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

✓ verified · rehash-vs-hf-metadata at 2026-09-04T02:08:22Z

mit752.8 MB (789,398,372 bytes)open_clipclipbiologymedicalzero-shot-image-classification1 language (en)