Views
No views yet

1from urllib.request import urlopen
2from PIL import Image
3import timm
4
5# get example histology image
6img = Image.open(
7 urlopen(
8 "https://raw.githubusercontent.com/zxaoyou/segmentation_WBC/master/Dataset%201/001.bmp"
9 )
10)
11
12# load model from the hub
13model = timm.create_model(
14 model_name="hf-hub:1aurent/vit_base_patch14_224.dinobloom",
15 pretrained=True,
16).eval()
17
18# get model specific transforms (normalization, resize)
19data_config = timm.data.resolve_model_data_config(model)
20transforms = timm.data.create_transform(**data_config, is_training=False)
21
22data = transforms(img).unsqueeze(0) # input is a (batch_size, num_channels, img_size, img_size) shaped tensor
23output = model(data) # output is a (batch_size, num_features) shaped tensor1@misc{koch2024dinobloom,
2 title = {DinoBloom: A Foundation Model for Generalizable Cell Embeddings in Hematology},
3 author = {Valentin Koch and Sophia J. Wagner and Salome Kazeminia and Ece Sancar and Matthias Hehr and Julia Schnabel and Tingying Peng and Carsten Marr},
4 year = {2024},
5 eprint = {2404.05022},
6 archivePrefix = {arXiv},
7 primaryClass = {cs.CV}
8}