Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,106 @@
|
|
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 hornet_tiny_7x7_danube-delta
|
11 |
+
|
12 |
+
A HorNet image classification model. This model was trained on the `danube-delta` dataset (all the relevant bird species found int the Danube Delta region).
|
13 |
+
|
14 |
+
The species list is derived from data available at <https://www.discoverdanubedelta.com/wp-content/uploads/2023/01/BirdsList-ian-2023.pdf>.
|
15 |
+
|
16 |
+
Note: this is a subset of the `eu-common` dataset.
|
17 |
+
|
18 |
+
## Model Details
|
19 |
+
|
20 |
+
- **Model Type:** Image classification and detection backbone
|
21 |
+
- **Model Stats:**
|
22 |
+
- Params (M): 22.1
|
23 |
+
- Input image size: 256 x 256
|
24 |
+
- **Dataset:** danube-delta (368 classes)
|
25 |
+
|
26 |
+
- **Papers:**
|
27 |
+
- HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions: <https://arxiv.org/abs/2207.14284>
|
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("hornet_tiny_7x7_danube-delta", 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, 368), 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("hornet_tiny_7x7_danube-delta", 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, 512)
|
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("hornet_tiny_7x7_danube-delta", 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, 64, 64, 64])),
|
89 |
+
# ('stage2', torch.Size([1, 128, 32, 32])),
|
90 |
+
# ('stage3', torch.Size([1, 256, 16, 16])),
|
91 |
+
# ('stage4', torch.Size([1, 512, 8, 8]))]
|
92 |
+
```
|
93 |
+
|
94 |
+
## Citation
|
95 |
+
|
96 |
+
```bibtex
|
97 |
+
@misc{rao2022hornetefficienthighorderspatial,
|
98 |
+
title={HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions},
|
99 |
+
author={Yongming Rao and Wenliang Zhao and Yansong Tang and Jie Zhou and Ser-Nam Lim and Jiwen Lu},
|
100 |
+
year={2022},
|
101 |
+
eprint={2207.14284},
|
102 |
+
archivePrefix={arXiv},
|
103 |
+
primaryClass={cs.CV},
|
104 |
+
url={https://arxiv.org/abs/2207.14284},
|
105 |
+
}
|
106 |
+
```
|