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://github.com/owkin/HistoSSLscaling/raw/main/assets/example.tif"
9 )
10)
11
12# load model from the hub
13model = timm.create_model(
14 model_name="hf-hub:1aurent/vit_small_patch8_224.lunit_dino",
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
22output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor1@inproceedings{kang2022benchmarking,
2 author = {Kang, Mingu and Song, Heon and Park, Seonwook and Yoo, Donggeun and Pereira, Sérgio},
3 title = {Benchmarking Self-Supervised Learning on Diverse Pathology Datasets},
4 booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
5 month = {June},
6 year = {2023},
7 pages = {3344-3354}
8}