Feature Extraction
timm
Safetensors
1aurent commited on
Commit
60a4434
·
1 Parent(s): 88a2d47

Add vit_base_patch16_224.endofm (timm re-upload of official Endo-FM spatial encoder; bit-identical 150/150, parity PASS)

Browse files
Files changed (3) hide show
  1. README.md +84 -0
  2. config.json +47 -0
  3. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - timm
4
+ - feature-extraction
5
+ library_name: timm
6
+ license: apache-2.0
7
+ pipeline_tag: feature-extraction
8
+ ---
9
+
10
+ # Model card for vit_base_patch16_224.endofm
11
+
12
+ 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).
13
+
14
+ 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.
15
+
16
+ ![](https://raw.githubusercontent.com/med-air/Endo-FM/main/assets/framework.png)
17
+
18
+ ## Model Details
19
+
20
+ - **Model Type:** Feature backbone (Vision Transformer, encoder-only, num_classes=0)
21
+ - **Developed by**: Med-AIR, CUHK (Zhao Wang, Chang Liu, Shaoting Zhang, Qi Dou)
22
+ - **Model Stats:**
23
+ - Params: 85.8M (ViT-Base)
24
+ - Image size: 224 x 224 x 3
25
+ - Patch size: 16 x 16 x 3
26
+ - **Pre-training:**
27
+ - Dataset: 33K+ endoscopy video clips (6 public + 1 private), up to 5M frames
28
+ - Framework: self-supervised pre-training (DINO-style self-distillation with global/local views) on a divided space-time video transformer (TimeSformer, 8 frames @ 224x224); the released teacher backbone is ported here as a spatial image encoder
29
+ - **Papers:**
30
+ - [Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train](https://arxiv.org/abs/2306.16741) (MICCAI 2023)
31
+ - **Original:** https://github.com/med-air/Endo-FM (checkpoint: Google Drive file 1H7B91Ewm4QkZRsnUk1Bn0IQch5P8C7Xl, endo_fm.pth, teacher backbone)
32
+ - **License:** [Apache-2.0](https://github.com/med-air/Endo-FM/blob/main/LICENSE)
33
+
34
+ ## Model Usage
35
+
36
+ ### Image Embeddings
37
+ ```python
38
+ from urllib.request import urlopen
39
+ from PIL import Image
40
+ import timm
41
+
42
+ # get example image
43
+ img = Image.open(
44
+ urlopen(
45
+ "https://raw.githubusercontent.com/med-air/Endo-FM/main/assets/dataset_visualization.png"
46
+ )
47
+ )
48
+
49
+ # load model from the hub
50
+ model = timm.create_model(
51
+ model_name="hf-hub:1aurent/vit_base_patch16_224.endofm",
52
+ pretrained=True,
53
+ ).eval()
54
+
55
+ # get model specific transforms (normalization, resize)
56
+ data_config = timm.data.resolve_model_data_config(model)
57
+ transforms = timm.data.create_transform(**data_config, is_training=False)
58
+
59
+ data = transforms(img).unsqueeze(0) # input is a (batch_size, num_channels, img_size, img_size) shaped tensor
60
+ output = model(data) # output is a (batch_size, num_features) shaped tensor
61
+ ```
62
+
63
+ ## Citation
64
+ ```bibtex
65
+ @inproceedings{wang2023foundation,
66
+ title={Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train},
67
+ author={Zhao Wang and Chang Liu and Shaoting Zhang and Qi Dou},
68
+ booktitle={International Conference on Medical Image Computing and Computer-Assisted Intervention},
69
+ pages={101--111},
70
+ year={2023},
71
+ organization={Springer},
72
+ doi={10.1007/978-3-031-43996-4_10}
73
+ }
74
+
75
+ @article{wang2023arxiv,
76
+ title={Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train},
77
+ author={Zhao Wang and Chang Liu and Shaoting Zhang and Qi Dou},
78
+ journal={arXiv preprint arXiv:2306.16741},
79
+ year={2023},
80
+ eprint={2306.16741},
81
+ archivePrefix={arXiv},
82
+ doi={10.48550/arXiv.2306.16741}
83
+ }
84
+ ```
config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "vit_base_patch16_224",
3
+ "num_classes": 0,
4
+ "num_features": 768,
5
+ "global_pool": "token",
6
+ "model_args": {
7
+ "img_size": 224,
8
+ "patch_size": 16,
9
+ "in_chans": 3,
10
+ "embed_dim": 768,
11
+ "depth": 12,
12
+ "num_heads": 12,
13
+ "mlp_ratio": 4.0,
14
+ "qkv_bias": true,
15
+ "num_classes": 0,
16
+ "global_pool": "token"
17
+ },
18
+ "pretrained_cfg": {
19
+ "tag": "endofm",
20
+ "custom_load": false,
21
+ "input_size": [
22
+ 3,
23
+ 224,
24
+ 224
25
+ ],
26
+ "fixed_input_size": true,
27
+ "interpolation": "bilinear",
28
+ "crop_pct": 1.0,
29
+ "crop_mode": "center",
30
+ "mean": [
31
+ 0.45,
32
+ 0.45,
33
+ 0.45
34
+ ],
35
+ "std": [
36
+ 0.225,
37
+ 0.225,
38
+ 0.225
39
+ ],
40
+ "num_classes": 0,
41
+ "pool_size": null,
42
+ "first_conv": "patch_embed.proj",
43
+ "classifier": "head",
44
+ "license": "apache-2.0",
45
+ "hf_hub_id": "1aurent/vit_base_patch16_224.endofm"
46
+ }
47
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11192d3366f344e81cc0e6eeca7c855cd19bd4d22f9696e6272ca3ac686b1dee
3
+ size 343208584