Image Feature Extraction
Birder
PyTorch
hassonofer commited on
Commit
8da5f67
·
verified ·
1 Parent(s): 7ab2a24

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +135 -3
README.md CHANGED
@@ -1,3 +1,135 @@
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
+ ---
9
+
10
+ # Model Card for hieradet_small_dino-v2
11
+
12
+ HieraDet small image encoder pre-trained using DINOv2. 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.
13
+
14
+ ## Model Details
15
+
16
+ - **Model Type:** Image classification and detection backbone
17
+ - **Model Stats:**
18
+ - Params (M): 33.9
19
+ - Input image size: 224 x 224
20
+ - **Dataset:** Trained on a diverse dataset of approximately 21M images, including:
21
+ - iNaturalist 2021 (~2.7M)
22
+ - imagenet-w21-webp-wds (~2.4M random subset)
23
+ - Objects365-2020 (~1.8M)
24
+ - WebVision-2.0 (~1.5M random subset)
25
+ - imagenet-1k-webp (~1.3M)
26
+ - BIOSCAN-1M (~1.1M)
27
+ - GLDv2 (~820K random subset of 100 chunks)
28
+ - VMMR (~285K)
29
+ - SA-1B (~220K random subset of 20 chunks)
30
+ - TreeOfLife-10M (~200K random subset)
31
+ - Places365 (~170K random subset)
32
+ - Open Images V4 (~160K random subset)
33
+ - COCO (~120K) x2
34
+ - SUN397 (~100K)
35
+ - Food-101 (~100K)
36
+ - IP102 v1.1 (~75K)
37
+ - NABirds (~48K)
38
+ - Birdsnap v1.1 (~44K)
39
+ - Country211 (~31K)
40
+ - ADE20K 2016 (~22K) x2
41
+ - VOC2012 (~17K)
42
+ - IndoorCVPR 2009 (~15K)
43
+ - VisDrone2019-DET (~10K) x4
44
+ - BLIP3o-Pretrain-Short-Caption (~10K random subset)
45
+ - comma10k (~10K) x2
46
+ - FGVC-Aircraft 2013 (~10K) x2
47
+ - Oxford-IIIT Pet (~7K) x4
48
+ - CUB-200 2011 (~6K)
49
+ - Flowers102 (~1K) x16
50
+ - The Birder dataset (~8M, private dataset)
51
+
52
+ - **Papers:**
53
+ - Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles: <https://arxiv.org/abs/2306.00989>
54
+ - SAM 2: Segment Anything in Images and Videos: <https://arxiv.org/abs/2408.00714>
55
+ - DINOv2: Learning Robust Visual Features without Supervision: <https://arxiv.org/abs/2304.07193>
56
+
57
+ ## Model Usage
58
+
59
+ ### Image Embeddings
60
+
61
+ ```python
62
+ import birder
63
+ from birder.inference.classification import infer_image
64
+
65
+ (net, model_info) = birder.load_pretrained_model("hieradet_small_dino-v2", inference=True)
66
+
67
+ # Get the image size the model was trained on
68
+ size = birder.get_size_from_signature(model_info.signature)
69
+
70
+ # Create an inference transform
71
+ transform = birder.classification_transform(size, model_info.rgb_stats)
72
+
73
+ image = "path/to/image.jpeg" # or a PIL image
74
+ (out, embedding) = infer_image(net, image, transform, return_embedding=True)
75
+ # embedding is a NumPy array with shape of (1, 768)
76
+ ```
77
+
78
+ ### Detection Feature Map
79
+
80
+ ```python
81
+ from PIL import Image
82
+ import birder
83
+
84
+ (net, model_info) = birder.load_pretrained_model("hieradet_small_dino-v2", inference=True)
85
+
86
+ # Get the image size the model was trained on
87
+ size = birder.get_size_from_signature(model_info.signature)
88
+
89
+ # Create an inference transform
90
+ transform = birder.classification_transform(size, model_info.rgb_stats)
91
+
92
+ image = Image.open("path/to/image.jpeg")
93
+ features = net.detection_features(transform(image).unsqueeze(0))
94
+ # features is a dict (stage name -> torch.Tensor)
95
+ print([(k, v.size()) for k, v in features.items()])
96
+ # Output example:
97
+ # [('stage1', torch.Size([1, 96, 56, 56])),
98
+ # ('stage2', torch.Size([1, 192, 28, 28])),
99
+ # ('stage3', torch.Size([1, 384, 14, 14])),
100
+ # ('stage4', torch.Size([1, 768, 7, 7]))]
101
+ ```
102
+
103
+ ## Citation
104
+
105
+ ```bibtex
106
+ @misc{ryali2023hierahierarchicalvisiontransformer,
107
+ title={Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles},
108
+ author={Chaitanya Ryali and Yuan-Ting Hu and Daniel Bolya and Chen Wei and Haoqi Fan and Po-Yao Huang and Vaibhav Aggarwal and Arkabandhu Chowdhury and Omid Poursaeed and Judy Hoffman and Jitendra Malik and Yanghao Li and Christoph Feichtenhofer},
109
+ year={2023},
110
+ eprint={2306.00989},
111
+ archivePrefix={arXiv},
112
+ primaryClass={cs.CV},
113
+ url={https://arxiv.org/abs/2306.00989},
114
+ }
115
+
116
+ @misc{ravi2024sam2segmentimages,
117
+ title={SAM 2: Segment Anything in Images and Videos},
118
+ author={Nikhila Ravi and Valentin Gabeur and Yuan-Ting Hu and Ronghang Hu and Chaitanya Ryali and Tengyu Ma and Haitham Khedr and Roman Rädle and Chloe Rolland and Laura Gustafson and Eric Mintun and Junting Pan and Kalyan Vasudev Alwala and Nicolas Carion and Chao-Yuan Wu and Ross Girshick and Piotr Dollár and Christoph Feichtenhofer},
119
+ year={2024},
120
+ eprint={2408.00714},
121
+ archivePrefix={arXiv},
122
+ primaryClass={cs.CV},
123
+ url={https://arxiv.org/abs/2408.00714},
124
+ }
125
+
126
+ @misc{oquab2024dinov2learningrobustvisual,
127
+ title={DINOv2: Learning Robust Visual Features without Supervision},
128
+ author={Maxime Oquab and Timothée Darcet and Théo Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Hervé Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
129
+ year={2024},
130
+ eprint={2304.07193},
131
+ archivePrefix={arXiv},
132
+ primaryClass={cs.CV},
133
+ url={https://arxiv.org/abs/2304.07193},
134
+ }
135
+ ```