Image Classification
Birder
PyTorch
hassonofer commited on
Commit
25a0fb6
·
verified ·
1 Parent(s): 886ef3d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +128 -3
README.md CHANGED
@@ -1,3 +1,128 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - birder
5
+ - pytorch
6
+ library_name: birder
7
+ license: apache-2.0
8
+ base_model:
9
+ - birder-project/hieradet_small_dino-v2
10
+ datasets:
11
+ - timm/imagenet-12k-wds
12
+ ---
13
+
14
+ # Model Card for hieradet_small_dino-v2-imagenet12k
15
+
16
+ HieraDet small image classification model. The model follows a two-stage training process: first, DINOv2 pretraining, then fine-tuned on the `ImageNet-12K` dataset.
17
+
18
+ ## Model Details
19
+
20
+ - **Model Type:** Image classification and detection backbone
21
+ - **Model Stats:**
22
+ - Params (M): 43.0
23
+ - Input image size: 256 x 256
24
+ - **Dataset:** ImageNet-12K (11821 classes)
25
+
26
+ - **Papers:**
27
+ - Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles: <https://arxiv.org/abs/2306.00989>
28
+ - SAM 2: Segment Anything in Images and Videos: <https://arxiv.org/abs/2408.00714>
29
+ - DINOv2: Learning Robust Visual Features without Supervision: <https://arxiv.org/abs/2304.07193>
30
+
31
+ ## Model Usage
32
+
33
+ ### Image Classification
34
+
35
+ ```python
36
+ import birder
37
+ from birder.inference.classification import infer_image
38
+
39
+ (net, model_info) = birder.load_pretrained_model("hieradet_small_dino-v2-imagenet12k", inference=True)
40
+
41
+ # Get the image size the model was trained on
42
+ size = birder.get_size_from_signature(model_info.signature)
43
+
44
+ # Create an inference transform
45
+ transform = birder.classification_transform(size, model_info.rgb_stats)
46
+
47
+ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
48
+ (out, _) = infer_image(net, image, transform)
49
+ # out is a NumPy array with shape of (1, 11821), representing class probabilities.
50
+ ```
51
+
52
+ ### Image Embeddings
53
+
54
+ ```python
55
+ import birder
56
+ from birder.inference.classification import infer_image
57
+
58
+ (net, model_info) = birder.load_pretrained_model("hieradet_small_dino-v2-imagenet12k", inference=True)
59
+
60
+ # Get the image size the model was trained on
61
+ size = birder.get_size_from_signature(model_info.signature)
62
+
63
+ # Create an inference transform
64
+ transform = birder.classification_transform(size, model_info.rgb_stats)
65
+
66
+ image = "path/to/image.jpeg" # or a PIL image
67
+ (out, embedding) = infer_image(net, image, transform, return_embedding=True)
68
+ # embedding is a NumPy array with shape of (1, 768)
69
+ ```
70
+
71
+ ### Detection Feature Map
72
+
73
+ ```python
74
+ from PIL import Image
75
+ import birder
76
+
77
+ (net, model_info) = birder.load_pretrained_model("hieradet_small_dino-v2-imagenet12k", inference=True)
78
+
79
+ # Get the image size the model was trained on
80
+ size = birder.get_size_from_signature(model_info.signature)
81
+
82
+ # Create an inference transform
83
+ transform = birder.classification_transform(size, model_info.rgb_stats)
84
+
85
+ image = Image.open("path/to/image.jpeg")
86
+ features = net.detection_features(transform(image).unsqueeze(0))
87
+ # features is a dict (stage name -> torch.Tensor)
88
+ print([(k, v.size()) for k, v in features.items()])
89
+ # Output example:
90
+ # [('stage1', torch.Size([1, 96, 64, 64])),
91
+ # ('stage2', torch.Size([1, 192, 32, 32])),
92
+ # ('stage3', torch.Size([1, 384, 16, 16])),
93
+ # ('stage4', torch.Size([1, 768, 8, 8]))]
94
+ ```
95
+
96
+ ## Citation
97
+
98
+ ```bibtex
99
+ @misc{ryali2023hierahierarchicalvisiontransformer,
100
+ title={Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles},
101
+ 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},
102
+ year={2023},
103
+ eprint={2306.00989},
104
+ archivePrefix={arXiv},
105
+ primaryClass={cs.CV},
106
+ url={https://arxiv.org/abs/2306.00989},
107
+ }
108
+
109
+ @misc{ravi2024sam2segmentimages,
110
+ title={SAM 2: Segment Anything in Images and Videos},
111
+ 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},
112
+ year={2024},
113
+ eprint={2408.00714},
114
+ archivePrefix={arXiv},
115
+ primaryClass={cs.CV},
116
+ url={https://arxiv.org/abs/2408.00714},
117
+ }
118
+
119
+ @misc{oquab2024dinov2learningrobustvisual,
120
+ title={DINOv2: Learning Robust Visual Features without Supervision},
121
+ 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},
122
+ year={2024},
123
+ eprint={2304.07193},
124
+ archivePrefix={arXiv},
125
+ primaryClass={cs.CV},
126
+ url={https://arxiv.org/abs/2304.07193},
127
+ }
128
+ ```