AnonymousECCV2026 commited on
Commit
55a8cfa
·
verified ·
1 Parent(s): b858e6b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -3
README.md CHANGED
@@ -1,3 +1,53 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-feature-extraction
4
+ - cell representation
5
+ - histology
6
+ - medical imaging
7
+ - self-supervised learning
8
+ - vision transformer
9
+ - foundation model
10
+ license: mit
11
+ ---
12
+
13
+ # Model card for LEMON
14
+
15
+ `LEMON` is an open-source foundation model for single-cell histology images. The model is a Vision Transformer (ViT-s/8) trained using self-supervised learning on a dataset of 10 million histology cell images sampled from 10,000 slides from TCGA.
16
+
17
+ `LEMON` can be used to extract robust features from single-cell histology images for various downstream applications, such as gene expression prediction or cell type classification.
18
+
19
+
20
+ ## How to use it to extract features.
21
+
22
+ The code below can be used to run inference. `LEMON` expects images of size 40x40 that were extracted at 0.25 microns per pixel (40X).
23
+
24
+ ```python
25
+ import torch
26
+ from pathlib import Path
27
+ from torchvision.transforms import ToPILImage
28
+ from model import prepare_transform, get_vit_feature_extractor
29
+
30
+ device = "cpu"
31
+ model_name = "vits8"
32
+ target_cell_size = 40
33
+ weight_path = Path("lemon.pth.tar")
34
+ stats_path = Path("mean_std.json")
35
+
36
+ # Model
37
+ transform = prepare_transform(stats_path, size=target_cell_size)
38
+ model = get_vit_feature_extractor(weight_path, model_name, img_size=target_cell_size)
39
+ model.eval()
40
+ model.to(device)
41
+
42
+ # Data
43
+ input = torch.rand(3, target_cell_size, target_cell_size)
44
+ input = ToPILImage()(input)
45
+
46
+ # Inference
47
+ with torch.autocast(device_type=device, dtype=torch.float16):
48
+ with torch.inference_mode():
49
+ features = model(transform(input).unsqueeze(0).to(device))
50
+
51
+ assert features.shape == (1, 384)
52
+ ```
53
+