DCXFM models
Collection
DCXFM: CXR foundation model for dense prediction (IEEE TMI 2025), https://github.com/HKU-MedAI/DCXFM • 1 item • Updated
How to use 1aurent/resnet50.dcxfm with timm:
import timm
model = timm.create_model("hf-hub:1aurent/resnet50.dcxfm", pretrained=True)ResNet-50 image encoder of DCXFM (Dense Chest X-ray Foundation Model), ported to timm from the official stage-1 checkpoint "stage1-epoch=11-step=5040.ckpt" (submodule "img_encoder_student") of HKU-MedAI/DCXFM. DCXFM is a chest X-ray vision-language foundation model trained with mixed supervisions (text, labels, segmentation masks) for dense prediction (phrase grounding, zero-shot semantic segmentation, zero-shot classification).
from urllib.request import urlopen
from PIL import Image
import timm
# get example chest X-ray image
img = Image.open(
urlopen(
"https://raw.githubusercontent.com/ieee8023/covid-chestxray-dataset/master/images/000001-1.png"
)
).convert("RGB")
# load model from the hub
model = timm.create_model(
model_name="hf-hub:1aurent/resnet50.dcxfm",
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
@article{Wang2025DCXFM,
author = {Wang, Fuying and Yu, Lequan},
title = {Scaling Chest X-Ray Foundation Models From Mixed Supervisions for Dense Prediction},
journal = {IEEE Transactions on Medical Imaging},
year = {2025},
volume = {44},
number = {12},
pages = {5306--5318},
doi = {10.1109/TMI.2025.3589928}
}