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/resnet50.tcga_brca_simclr",
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@misc{chen2022selfsupervised,
2 title = {Self-Supervised Vision Transformers Learn Visual Concepts in Histopathology},
3 author = {Richard J. Chen and Rahul G. Krishnan},
4 year = {2022},
5 eprint = {2203.00585},
6 archiveprefix = {arXiv},
7 primaryclass = {cs.CV}
8}