Image Feature Extraction
Birder
PyTorch
biology
hassonofer commited on
Commit
fb7aaf5
·
verified ·
1 Parent(s): f6b85ea

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -0
README.md CHANGED
@@ -1,3 +1,113 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ tags:
3
+ - image-feature-extraction
4
+ - birder
5
+ - pytorch
6
+ - biology
7
+ library_name: birder
8
  license: apache-2.0
9
+ base_model:
10
+ - birder-project/vit_l14_pn_bioclip-v2
11
  ---
12
+
13
+ # Model Card for rope_vit_s14_swiglu_avg_eva-bio
14
+
15
+ A RoPE ViT s14 image encoder pretrained using EVA-style Masked Image Modeling (MIM) distillation from a BioCLIP v2 ViT l14 teacher. This model has *not* been fine-tuned for a specific classification task and is intended to be used as a general-purpose feature extractor or a backbone for downstream tasks like object detection, segmentation, or custom classification.
16
+
17
+ ## Model Details
18
+
19
+ - **Model Type:** Image classification and detection backbone
20
+ - **Model Stats:**
21
+ - Params (M): 28.7
22
+ - Input image size: 224 x 224
23
+ - **Dataset:** Trained on a diverse dataset of approximately 31M images, including:
24
+ - TreeOfLife-10M-EOL-NaturalImages
25
+ - iNaturalist 2021
26
+ - BIOSCAN-5M (pretrain split)
27
+ - TreeOfLife-200M (subset)
28
+ - IP102 v1.1
29
+ - iWildCam 2022 (subset)
30
+ - The Birder dataset (private dataset)
31
+
32
+ - **Papers:**
33
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: <https://arxiv.org/abs/2010.11929>
34
+ - Rotary Position Embedding for Vision Transformer: <https://arxiv.org/abs/2403.13298>
35
+ - EVA-02: A Visual Representation for Neon Genesis: <https://arxiv.org/abs/2303.11331>
36
+
37
+ ## Model Usage
38
+
39
+ ### Image Embeddings
40
+
41
+ ```python
42
+ import birder
43
+ from birder.inference.classification import infer_image
44
+
45
+ # Option 1: manual setup (more control over preprocessing)
46
+ net, model_info = birder.load_pretrained_model("rope_vit_s14_swiglu_avg_eva-bio", inference=True)
47
+
48
+ # Get the image size the model was trained on
49
+ size = birder.get_size_from_signature(model_info.signature)
50
+
51
+ # Create an inference transform
52
+ transform = birder.classification_transform(size, model_info.rgb_stats)
53
+
54
+ # Option 2: helper (quick start with default preprocessing)
55
+ net, model_info, transform = birder.load_pretrained_model_and_transform("rope_vit_s14_swiglu_avg_eva-bio", inference=True)
56
+
57
+ image = "path/to/image.jpeg" # or a PIL image
58
+ out, embedding = infer_image(net, image, transform, return_embedding=True)
59
+ # embedding is a NumPy array with shape of (1, 384)
60
+ ```
61
+
62
+ ### Detection Feature Map
63
+
64
+ ```python
65
+ from PIL import Image
66
+ import birder
67
+
68
+ net, model_info, transform = birder.load_pretrained_model_and_transform("rope_vit_s14_swiglu_avg_eva-bio", inference=True)
69
+
70
+ image = Image.open("path/to/image.jpeg")
71
+ features = net.detection_features(transform(image).unsqueeze(0))
72
+ # features is a dict (stage name -> torch.Tensor)
73
+ print([(k, v.size()) for k, v in features.items()])
74
+ # Output example:
75
+ # [('stage1', torch.Size([1, 384, 16, 16]))]
76
+ ```
77
+
78
+ ## Citation
79
+
80
+ ```bibtex
81
+ @misc{dosovitskiy2021imageworth16x16words,
82
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
83
+ author={Alexey Dosovitskiy and Lucas Beyer and Alexander Kolesnikov and Dirk Weissenborn and Xiaohua Zhai and Thomas Unterthiner and Mostafa Dehghani and Matthias Minderer and Georg Heigold and Sylvain Gelly and Jakob Uszkoreit and Neil Houlsby},
84
+ year={2021},
85
+ eprint={2010.11929},
86
+ archivePrefix={arXiv},
87
+ primaryClass={cs.CV},
88
+ url={https://arxiv.org/abs/2010.11929},
89
+ }
90
+
91
+ @misc{heo2024rotarypositionembeddingvision,
92
+ title={Rotary Position Embedding for Vision Transformer},
93
+ author={Byeongho Heo and Song Park and Dongyoon Han and Sangdoo Yun},
94
+ year={2024},
95
+ eprint={2403.13298},
96
+ archivePrefix={arXiv},
97
+ primaryClass={cs.CV},
98
+ url={https://arxiv.org/abs/2403.13298},
99
+ }
100
+
101
+ @article{Fang_2024,
102
+ title={EVA-02: A visual representation for neon genesis},
103
+ volume={149},
104
+ ISSN={0262-8856},
105
+ url={http://dx.doi.org/10.1016/j.imavis.2024.105171},
106
+ DOI={10.1016/j.imavis.2024.105171},
107
+ journal={Image and Vision Computing},
108
+ publisher={Elsevier BV},
109
+ author={Fang, Yuxin and Sun, Quan and Wang, Xinggang and Huang, Tiejun and Wang, Xinlong and Cao, Yue},
110
+ year={2024},
111
+ month=Sept, pages={105171}
112
+ }
113
+ ```