Model card for vit_base_patch16_224.maco

A Vision Transformer (ViT-B/16) chest X-ray foundation model encoder.
MaCo pre-trains a ViT-B/16 image encoder jointly with a BERT report encoder on MIMIC-CXR using masked contrastive learning with granular radiography-report alignment (Huang et al., Nature Communications 2024).

Model Details

Model Usage

Image Embeddings

from urllib.request import urlopen
from PIL import Image
import timm

# get example image
img = Image.open(
  urlopen(
    "https://raw.githubusercontent.com/SZUHvern/MaCo/main/figure/Figure.png"
  )
).convert("RGB")

# load model from the hub
model = timm.create_model(
  model_name="hf-hub:1aurent/vit_base_patch16_224.maco",
  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{huang2024enhancing,
  title={Enhancing representation in radiography-reports foundation model: A granular alignment algorithm using masked contrastive learning},
  author={Huang, Weijian and Li, Cheng and Zhou, Hong-Yu and Yang, Hao and Liu, Jiarun and Liang, Yong and Zheng, Hairong and Zhang, Shaoting and Wang, Shanshan},
  journal={Nature Communications},
  volume={15},
  number={7620},
  year={2024},
  doi={10.1038/s41467-024-51749-0},
  url={https://doi.org/10.1038/s41467-024-51749-0}
}
Downloads last month
1
Safetensors
Model size
85.8M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including 1aurent/vit_base_patch16_224.maco