Image Feature Extraction
Birder
PyTorch
hassonofer commited on
Commit
f4849ae
·
verified ·
1 Parent(s): 979d2dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +116 -0
README.md CHANGED
@@ -1,3 +1,119 @@
1
  ---
 
 
 
 
 
2
  license: apache-2.0
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ tags:
3
+ - image-feature-extraction
4
+ - birder
5
+ - pytorch
6
+ library_name: birder
7
  license: apache-2.0
8
+ base_model:
9
+ - QuanSun/EVA-CLIP
10
  ---
11
+
12
+ # Model Card for rope_i_vit_l14_nf_swiglu_c1_eva02-clip
13
+
14
+ A RoPE ViT-L14 image encoder from the EVA02 CLIP model by Sun et al., converted to the Birder format for image feature extraction.
15
+ This version retains the original model weights and architecture.
16
+ It is a general-purpose visual backbone.
17
+
18
+ See: <https://huggingface.co/QuanSun/EVA-CLIP> for further details.
19
+
20
+ ## Model Details
21
+
22
+ - **Model Type:** Image classification and detection backbone
23
+ - **Model Stats:**
24
+ - Params (M): 304.5
25
+ - Input image size: 336 x 336
26
+
27
+ - **Papers:**
28
+ - EVA-02: A Visual Representation for Neon Genesis: <https://arxiv.org/abs/2303.11331>
29
+ - EVA-CLIP: Improved Training Techniques for CLIP at Scale: <https://arxiv.org/abs/2303.15389>
30
+
31
+ ## Model Usage
32
+
33
+ ### Image Classification
34
+
35
+ ```python
36
+ import birder
37
+ from birder.inference.classification import infer_image
38
+
39
+ # Option 1: manual setup (more control over preprocessing)
40
+ net, model_info = birder.load_pretrained_model("rope_i_vit_l14_nf_swiglu_c1_eva02-clip", inference=True)
41
+
42
+ # Get the image size the model was trained on
43
+ size = birder.get_size_from_signature(model_info.signature)
44
+
45
+ # Create an inference transform
46
+ transform = birder.classification_transform(size, model_info.rgb_stats)
47
+
48
+ # Option 2: helper (quick start with default preprocessing)
49
+ net, model_info, transform = birder.load_pretrained_model_and_transform("rope_i_vit_l14_nf_swiglu_c1_eva02-clip", inference=True)
50
+
51
+ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
52
+ out, _ = infer_image(net, image, transform)
53
+ # out is a NumPy array with shape of (1, 768), representing class probabilities.
54
+ ```
55
+
56
+ ### Image Embeddings
57
+
58
+ ```python
59
+ import birder
60
+ from birder.inference.classification import infer_image
61
+
62
+ # Option 1: manual setup (more control over preprocessing)
63
+ net, model_info = birder.load_pretrained_model("rope_i_vit_l14_nf_swiglu_c1_eva02-clip", inference=True)
64
+
65
+ # Get the image size the model was trained on
66
+ size = birder.get_size_from_signature(model_info.signature)
67
+
68
+ # Create an inference transform
69
+ transform = birder.classification_transform(size, model_info.rgb_stats)
70
+
71
+ # Option 2: helper (quick start with default preprocessing)
72
+ net, model_info, transform = birder.load_pretrained_model_and_transform("rope_i_vit_l14_nf_swiglu_c1_eva02-clip", inference=True)
73
+
74
+ image = "path/to/image.jpeg" # or a PIL image
75
+ out, embedding = infer_image(net, image, transform, return_embedding=True)
76
+ # embedding is a NumPy array with shape of (1, 1024)
77
+ ```
78
+
79
+ ### Detection Feature Map
80
+
81
+ ```python
82
+ from PIL import Image
83
+ import birder
84
+
85
+ net, model_info, transform = birder.load_pretrained_model_and_transform("rope_i_vit_l14_nf_swiglu_c1_eva02-clip", inference=True)
86
+
87
+ image = Image.open("path/to/image.jpeg")
88
+ features = net.detection_features(transform(image).unsqueeze(0))
89
+ # features is a dict (stage name -> torch.Tensor)
90
+ print([(k, v.size()) for k, v in features.items()])
91
+ # Output example:
92
+ # [('stage1', torch.Size([1, 1024, 24, 24]))]
93
+ ```
94
+
95
+ ## Citation
96
+
97
+ ```bibtex
98
+ @article{Fang_2024,
99
+ title={EVA-02: A visual representation for neon genesis},
100
+ volume={149},
101
+ ISSN={0262-8856},
102
+ url={http://dx.doi.org/10.1016/j.imavis.2024.105171},
103
+ DOI={10.1016/j.imavis.2024.105171},
104
+ journal={Image and Vision Computing},
105
+ publisher={Elsevier BV},
106
+ author={Fang, Yuxin and Sun, Quan and Wang, Xinggang and Huang, Tiejun and Wang, Xinlong and Cao, Yue},
107
+ year={2024},
108
+ month=Sept, pages={105171}
109
+ }
110
+ @misc{sun2023evaclipimprovedtrainingtechniques,
111
+ title={EVA-CLIP: Improved Training Techniques for CLIP at Scale},
112
+ author={Quan Sun and Yuxin Fang and Ledell Wu and Xinlong Wang and Yue Cao},
113
+ year={2023},
114
+ eprint={2303.15389},
115
+ archivePrefix={arXiv},
116
+ primaryClass={cs.CV},
117
+ url={https://arxiv.org/abs/2303.15389},
118
+ }
119
+ ```