Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
| 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 convnext_v1_tiny_eu-common
|
| 11 |
+
|
| 12 |
+
A ConvNeXt v1 Tiny image classification model. This model was trained on the `eu-common` dataset containing common European bird species.
|
| 13 |
+
|
| 14 |
+
The species list is derived from the Collins bird guide [^1].
|
| 15 |
+
|
| 16 |
+
[^1]: Svensson, L., Mullarney, K., & Zetterström, D. (2022). Collins bird guide (3rd ed.). London, England: William Collins.
|
| 17 |
+
|
| 18 |
+
Note: A 256 x 256 variant of this model is available as `convnext_v1_tiny_eu-common256px`.
|
| 19 |
+
|
| 20 |
+
## Model Details
|
| 21 |
+
|
| 22 |
+
- **Model Type:** Image classification and detection backbone
|
| 23 |
+
- **Model Stats:**
|
| 24 |
+
- Params (M): 28.4
|
| 25 |
+
- Input image size: 384 x 384
|
| 26 |
+
- **Dataset:** eu-common (707 classes)
|
| 27 |
+
|
| 28 |
+
- **Papers:**
|
| 29 |
+
- A ConvNet for the 2020s: <https://arxiv.org/abs/2201.03545>
|
| 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("convnext_v1_tiny_eu-common", inference=True)
|
| 40 |
+
# Note: A 256x256 variant is available as "convnext_v1_tiny_eu-common256px"
|
| 41 |
+
|
| 42 |
+
# Get the image size the model was trained on
|
| 43 |
+
size = birder.get_size_from_signature(model_info.signature)
|
| 44 |
+
|
| 45 |
+
# Create an inference transform
|
| 46 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
| 47 |
+
|
| 48 |
+
image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
|
| 49 |
+
(out, _) = infer_image(net, image, transform)
|
| 50 |
+
# out is a NumPy array with shape of (1, 707), representing class probabilities.
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
### Image Embeddings
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
import birder
|
| 57 |
+
from birder.inference.classification import infer_image
|
| 58 |
+
|
| 59 |
+
(net, model_info) = birder.load_pretrained_model("convnext_v1_tiny_eu-common", inference=True)
|
| 60 |
+
|
| 61 |
+
# Get the image size the model was trained on
|
| 62 |
+
size = birder.get_size_from_signature(model_info.signature)
|
| 63 |
+
|
| 64 |
+
# Create an inference transform
|
| 65 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
| 66 |
+
|
| 67 |
+
image = "path/to/image.jpeg" # or a PIL image
|
| 68 |
+
(out, embedding) = infer_image(net, image, transform, return_embedding=True)
|
| 69 |
+
# embedding is a NumPy array with shape of (1, 768)
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
### Detection Feature Map
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
from PIL import Image
|
| 76 |
+
import birder
|
| 77 |
+
|
| 78 |
+
(net, model_info) = birder.load_pretrained_model("convnext_v1_tiny_eu-common", inference=True)
|
| 79 |
+
|
| 80 |
+
# Get the image size the model was trained on
|
| 81 |
+
size = birder.get_size_from_signature(model_info.signature)
|
| 82 |
+
|
| 83 |
+
# Create an inference transform
|
| 84 |
+
transform = birder.classification_transform(size, model_info.rgb_stats)
|
| 85 |
+
|
| 86 |
+
image = Image.open("path/to/image.jpeg")
|
| 87 |
+
features = net.detection_features(transform(image).unsqueeze(0))
|
| 88 |
+
# features is a dict (stage name -> torch.Tensor)
|
| 89 |
+
print([(k, v.size()) for k, v in features.items()])
|
| 90 |
+
# Output example:
|
| 91 |
+
# [('stage1', torch.Size([1, 96, 96, 96])),
|
| 92 |
+
# ('stage2', torch.Size([1, 192, 48, 48])),
|
| 93 |
+
# ('stage3', torch.Size([1, 384, 24, 24])),
|
| 94 |
+
# ('stage4', torch.Size([1, 768, 12, 12]))]
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Citation
|
| 98 |
+
|
| 99 |
+
```bibtex
|
| 100 |
+
@misc{liu2022convnet2020s,
|
| 101 |
+
title={A ConvNet for the 2020s},
|
| 102 |
+
author={Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie},
|
| 103 |
+
year={2022},
|
| 104 |
+
eprint={2201.03545},
|
| 105 |
+
archivePrefix={arXiv},
|
| 106 |
+
primaryClass={cs.CV},
|
| 107 |
+
url={https://arxiv.org/abs/2201.03545},
|
| 108 |
+
}
|
| 109 |
+
```
|