Endo-FM models
Collection
Foundation Model for Endoscopy Video Analysis (arXiv:2306.16741, MICCAI 2023), https://github.com/med-air/Endo-FM • 2 items • Updated
Run 1aurent/vit_base_patch16_224.endofm on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/1aurent/vit_base_patch16_224.endofm. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/1aurent/vit_base_patch16_224.endofm on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use 1aurent/vit_base_patch16_224.endofm with timm:
import timm
model = timm.create_model("hf-hub:1aurent/vit_base_patch16_224.endofm", pretrained=True)Endo-FM: a Vision Transformer (ViT-B/16) foundation model for endoscopy video analysis, self-supervised pre-trained by the authors on 33K+ surgical video clips (up to 5M frames) from 9 endoscopy datasets (MICCAI 2023).
This repo ports the released pre-trained Endo-FM encoder (the spatial ViT-B/16 backbone of the video transformer) to timm, for use as an image/video-frame feature extractor.
from urllib.request import urlopen
from PIL import Image
import timm
# get example image
img = Image.open(
urlopen(
"https://raw.githubusercontent.com/med-air/Endo-FM/main/assets/dataset_visualization.png"
)
)
# load model from the hub
model = timm.create_model(
model_name="hf-hub:1aurent/vit_base_patch16_224.endofm",
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
@inproceedings{wang2023foundation,
title={Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train},
author={Zhao Wang and Chang Liu and Shaoting Zhang and Qi Dou},
booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention},
pages={101--111},
year={2023},
organization={Springer},
doi={10.1007/978-3-031-43996-4_10}
}
@article{wang2023arxiv,
title={Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train},
author={Zhao Wang and Chang Liu and Shaoting Zhang and Qi Dou},
journal={arXiv preprint arXiv:2306.16741},
year={2023},
eprint={2306.16741},
archivePrefix={arXiv},
doi={10.48550/arXiv.2306.16741}
}