Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,116 @@
|
|
1 |
-
---
|
2 |
-
|
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 resnet_v1_50_arabian-peninsula
|
11 |
+
|
12 |
+
A Resnet v1 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 |
+
The training followed RSB procedure A2.
|
14 |
+
|
15 |
+
The species list is derived from data available at <https://avibase.bsc-eoc.org/checklist.jsp?region=ARA>.
|
16 |
+
|
17 |
+
## Model Details
|
18 |
+
|
19 |
+
- **Model Type:** Image classification and detection backbone
|
20 |
+
- **Model Stats:**
|
21 |
+
- Params (M): 25.0
|
22 |
+
- Input image size: 256 x 256
|
23 |
+
- **Dataset:** arabian-peninsula (735 classes)
|
24 |
+
|
25 |
+
- **Papers:**
|
26 |
+
- Deep Residual Learning for Image Recognition: <https://arxiv.org/abs/1512.03385>
|
27 |
+
- ResNet strikes back: An improved training procedure in timm: <https://arxiv.org/abs/2110.00476>
|
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("resnet_v1_50_arabian-peninsula", inference=True)
|
38 |
+
|
39 |
+
# Get the image size the model was trained on
|
40 |
+
size = birder.get_size_from_signature(model_info.signature)
|
41 |
+
|
42 |
+
# Create an inference transform
|
43 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
44 |
+
|
45 |
+
image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
|
46 |
+
(out, _) = infer_image(net, image, transform)
|
47 |
+
# out is a NumPy array with shape of (1, 735), representing class probabilities.
|
48 |
+
```
|
49 |
+
|
50 |
+
### Image Embeddings
|
51 |
+
|
52 |
+
```python
|
53 |
+
import birder
|
54 |
+
from birder.inference.classification import infer_image
|
55 |
+
|
56 |
+
(net, model_info) = birder.load_pretrained_model("resnet_v1_50_arabian-peninsula", inference=True)
|
57 |
+
|
58 |
+
# Get the image size the model was trained on
|
59 |
+
size = birder.get_size_from_signature(model_info.signature)
|
60 |
+
|
61 |
+
# Create an inference transform
|
62 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
63 |
+
|
64 |
+
image = "path/to/image.jpeg" # or a PIL image
|
65 |
+
(out, embedding) = infer_image(net, image, transform, return_embedding=True)
|
66 |
+
# embedding is a NumPy array with shape of (1, 2048)
|
67 |
+
```
|
68 |
+
|
69 |
+
### Detection Feature Map
|
70 |
+
|
71 |
+
```python
|
72 |
+
from PIL import Image
|
73 |
+
import birder
|
74 |
+
|
75 |
+
(net, model_info) = birder.load_pretrained_model("resnet_v1_50_arabian-peninsula", inference=True)
|
76 |
+
|
77 |
+
# Get the image size the model was trained on
|
78 |
+
size = birder.get_size_from_signature(model_info.signature)
|
79 |
+
|
80 |
+
# Create an inference transform
|
81 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
82 |
+
|
83 |
+
image = Image.open("path/to/image.jpeg")
|
84 |
+
features = net.detection_features(transform(image).unsqueeze(0))
|
85 |
+
# features is a dict (stage name -> torch.Tensor)
|
86 |
+
print([(k, v.size()) for k, v in features.items()])
|
87 |
+
# Output example:
|
88 |
+
# [('stage1', torch.Size([1, 256, 64, 64])),
|
89 |
+
# ('stage2', torch.Size([1, 512, 32, 32])),
|
90 |
+
# ('stage3', torch.Size([1, 1024, 16, 16])),
|
91 |
+
# ('stage4', torch.Size([1, 2048, 8, 8]))]
|
92 |
+
```
|
93 |
+
|
94 |
+
## Citation
|
95 |
+
|
96 |
+
```bibtex
|
97 |
+
@misc{he2015deepresiduallearningimage,
|
98 |
+
title={Deep Residual Learning for Image Recognition},
|
99 |
+
author={Kaiming He and Xiangyu Zhang and Shaoqing Ren and Jian Sun},
|
100 |
+
year={2015},
|
101 |
+
eprint={1512.03385},
|
102 |
+
archivePrefix={arXiv},
|
103 |
+
primaryClass={cs.CV},
|
104 |
+
url={https://arxiv.org/abs/1512.03385},
|
105 |
+
}
|
106 |
+
|
107 |
+
@misc{wightman2021resnetstrikesbackimproved,
|
108 |
+
title={ResNet strikes back: An improved training procedure in timm},
|
109 |
+
author={Ross Wightman and Hugo Touvron and Hervé Jégou},
|
110 |
+
year={2021},
|
111 |
+
eprint={2110.00476},
|
112 |
+
archivePrefix={arXiv},
|
113 |
+
primaryClass={cs.CV},
|
114 |
+
url={https://arxiv.org/abs/2110.00476},
|
115 |
+
}
|
116 |
+
```
|