hassonofer commited on
Commit
c587823
·
verified ·
1 Parent(s): 1b579f3

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 van_b2_arabian-peninsula
11
+
12
+ An VAN image classification model. This model was trained on the `arabian-peninsula` dataset (all the relevant bird species found in the Arabian peninsula inc. rarities).
13
+
14
+ The species list is derived from data available at <https://avibase.bsc-eoc.org/checklist.jsp?region=ARA>.
15
+
16
+ Note: A 256 x 256 variant of this model is available as `van_b2_arabian-peninsula256px`.
17
+
18
+ ## Model Details
19
+
20
+ - **Model Type:** Image classification and detection backbone
21
+ - **Model Stats:**
22
+ - Params (M): 26.4
23
+ - Input image size: 384 x 384
24
+ - **Dataset:** arabian-peninsula (735 classes)
25
+
26
+ - **Papers:**
27
+ - Visual Attention Network: <https://arxiv.org/abs/2202.09741>
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("van_b2_arabian-peninsula", inference=True)
38
+ # Note: A 256x256 variant is available as "van_b2_arabian-peninsula256px"
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, 735), 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("van_b2_arabian-peninsula", 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, 512)
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("van_b2_arabian-peninsula", 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, 64, 64, 64])),
90
+ # ('stage2', torch.Size([1, 128, 32, 32])),
91
+ # ('stage3', torch.Size([1, 320, 16, 16])),
92
+ # ('stage4', torch.Size([1, 512, 8, 8]))]
93
+ ```
94
+
95
+ ## Citation
96
+
97
+ ```bibtex
98
+ @misc{guo2022visualattentionnetwork,
99
+ title={Visual Attention Network},
100
+ author={Meng-Hao Guo and Cheng-Ze Lu and Zheng-Ning Liu and Ming-Ming Cheng and Shi-Min Hu},
101
+ year={2022},
102
+ eprint={2202.09741},
103
+ archivePrefix={arXiv},
104
+ primaryClass={cs.CV},
105
+ url={https://arxiv.org/abs/2202.09741},
106
+ }
107
+ ```