hassonofer commited on
Commit
e0fcc5a
·
verified ·
1 Parent(s): 2a157ea

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +107 -3
README.md CHANGED
@@ -1,3 +1,107 @@
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
+ ---
9
+
10
+ # Model Card for mvit_v2_s_yellowstone
11
+
12
+ A MViTv2 small image classification model. This model was trained on the `yellowstone` dataset (all the relevant bird species found in the Yellowstone national park).
13
+
14
+ The species list is derived from data available at <https://avibase.bsc-eoc.org/checklist.jsp?region=USmtys>.
15
+
16
+ Note: A 256 x 256 variant of this model is available as `mvit_v2_s_yellowstone256px`.
17
+
18
+ ## Model Details
19
+
20
+ - **Model Type:** Image classification and detection backbone
21
+ - **Model Stats:**
22
+ - Params (M): 34.4
23
+ - Input image size: 384 x 384
24
+ - **Dataset:** yellowstone (330 classes)
25
+
26
+ - **Papers:**
27
+ - MViTv2: Improved Multiscale Vision Transformers for Classification and Detection: <https://arxiv.org/abs/2112.01526>
28
+
29
+ ## Model Usage
30
+
31
+ ### Image Classification
32
+
33
+ ```python
34
+ import birder
35
+ from birder.inference.classification import infer_image
36
+
37
+ (net, model_info) = birder.load_pretrained_model("mvit_v2_s_yellowstone", inference=True)
38
+ # Note: A 256x256 variant is available as "mvit_v2_s_yellowstone256px"
39
+
40
+ # Get the image size the model was trained on
41
+ size = birder.get_size_from_signature(model_info.signature)
42
+
43
+ # Create an inference transform
44
+ transform = birder.classification_transform(size, model_info.rgb_stats)
45
+
46
+ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
47
+ (out, _) = infer_image(net, image, transform)
48
+ # out is a NumPy array with shape of (1, 330), representing class probabilities.
49
+ ```
50
+
51
+ ### Image Embeddings
52
+
53
+ ```python
54
+ import birder
55
+ from birder.inference.classification import infer_image
56
+
57
+ (net, model_info) = birder.load_pretrained_model("mvit_v2_s_yellowstone", inference=True)
58
+
59
+ # Get the image size the model was trained on
60
+ size = birder.get_size_from_signature(model_info.signature)
61
+
62
+ # Create an inference transform
63
+ transform = birder.classification_transform(size, model_info.rgb_stats)
64
+
65
+ image = "path/to/image.jpeg" # or a PIL image
66
+ (out, embedding) = infer_image(net, image, transform, return_embedding=True)
67
+ # embedding is a NumPy array with shape of (1, 768)
68
+ ```
69
+
70
+ ### Detection Feature Map
71
+
72
+ ```python
73
+ from PIL import Image
74
+ import birder
75
+
76
+ (net, model_info) = birder.load_pretrained_model("mvit_v2_s_yellowstone", inference=True)
77
+
78
+ # Get the image size the model was trained on
79
+ size = birder.get_size_from_signature(model_info.signature)
80
+
81
+ # Create an inference transform
82
+ transform = birder.classification_transform(size, model_info.rgb_stats)
83
+
84
+ image = Image.open("path/to/image.jpeg")
85
+ features = net.detection_features(transform(image).unsqueeze(0))
86
+ # features is a dict (stage name -> torch.Tensor)
87
+ print([(k, v.size()) for k, v in features.items()])
88
+ # Output example:
89
+ # [('stage1', torch.Size([1, 96, 96, 96])),
90
+ # ('stage2', torch.Size([1, 192, 48, 48])),
91
+ # ('stage3', torch.Size([1, 384, 24, 24])),
92
+ # ('stage4', torch.Size([1, 768, 12, 12]))]
93
+ ```
94
+
95
+ ## Citation
96
+
97
+ ```bibtex
98
+ @misc{li2022mvitv2improvedmultiscalevision,
99
+ title={MViTv2: Improved Multiscale Vision Transformers for Classification and Detection},
100
+ author={Yanghao Li and Chao-Yuan Wu and Haoqi Fan and Karttikeya Mangalam and Bo Xiong and Jitendra Malik and Christoph Feichtenhofer},
101
+ year={2022},
102
+ eprint={2112.01526},
103
+ archivePrefix={arXiv},
104
+ primaryClass={cs.CV},
105
+ url={https://arxiv.org/abs/2112.01526},
106
+ }
107
+ ```