UltraSam: A Foundation Model for Ultrasound using Large Open-Access Segmentation Datasets
Paper • 2411.16222 • Published
How to use 1aurent/samvit_base_patch16_1024.ultrasam with timm:
import timm
model = timm.create_model("hf-hub:1aurent/samvit_base_patch16_1024.ultrasam", pretrained=True)A SAM ViT-B/16 image encoder at 1024x1024 from UltraSam, a foundation model for ultrasound.
Ported from the official CAMMA checkpoint (mmdet format) to timm (samvit_base_patch16).
from urllib.request import urlopen
from PIL import Image
import timm
# get example image
img = Image.open(
urlopen(
"https://github.com/CAMMA-public/UltraSam/raw/main/assets/UltraSam_main.png"
)
)
# load model from the hub
model = timm.create_model(
model_name="hf-hub:1aurent/samvit_base_patch16_1024.ultrasam",
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.convert("RGB")).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{meyer2025ultrasam,
title={Ultrasam: a foundation model for ultrasound using large open-access segmentation datasets},
author={Meyer, Adrien and Murali, Aditya and Zarin, Farahdiba and Mutter, Didier and Padoy, Nicolas},
journal={International Journal of Computer Assisted Radiology and Surgery},
pages={1--10},
year={2025},
publisher={Springer}
}