hassonofer commited on
Commit
2d5d809
·
verified ·
1 Parent(s): 31deb4a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +105 -3
README.md CHANGED
@@ -1,3 +1,105 @@
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 focalnet_b_lrf_intermediate-eu-common
11
+
12
+ A FocalNet image classification model. The model follows a two-stage training process: first undergoing intermediate training on a large-scale dataset containing diverse bird species from around the world, then fine-tuned specifically on the `eu-common` 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
+ ## Model Details
17
+
18
+ - **Model Type:** Image classification and detection backbone
19
+ - **Model Stats:**
20
+ - Params (M): 88.4
21
+ - Input image size: 384 x 384
22
+ - **Dataset:** eu-common (707 classes)
23
+ - Intermediate training involved ~5500 species from asia, europe and eastern africa
24
+
25
+ - **Papers:**
26
+ - Focal Modulation Networks: <https://arxiv.org/abs/2203.11926>
27
+
28
+ ## Model Usage
29
+
30
+ ### Image Classification
31
+
32
+ ```python
33
+ import birder
34
+ from birder.inference.classification import infer_image
35
+
36
+ (net, model_info) = birder.load_pretrained_model("focalnet_b_lrf_intermediate-eu-common", inference=True)
37
+
38
+ # Get the image size the model was trained on
39
+ size = birder.get_size_from_signature(model_info.signature)
40
+
41
+ # Create an inference transform
42
+ transform = birder.classification_transform(size, model_info.rgb_stats)
43
+
44
+ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
45
+ (out, _) = infer_image(net, image, transform)
46
+ # out is a NumPy array with shape of (1, 707), representing class probabilities.
47
+ ```
48
+
49
+ ### Image Embeddings
50
+
51
+ ```python
52
+ import birder
53
+ from birder.inference.classification import infer_image
54
+
55
+ (net, model_info) = birder.load_pretrained_model("focalnet_b_lrf_intermediate-eu-common", inference=True)
56
+
57
+ # Get the image size the model was trained on
58
+ size = birder.get_size_from_signature(model_info.signature)
59
+
60
+ # Create an inference transform
61
+ transform = birder.classification_transform(size, model_info.rgb_stats)
62
+
63
+ image = "path/to/image.jpeg" # or a PIL image
64
+ (out, embedding) = infer_image(net, image, transform, return_embedding=True)
65
+ # embedding is a NumPy array with shape of (1, 1024)
66
+ ```
67
+
68
+ ### Detection Feature Map
69
+
70
+ ```python
71
+ from PIL import Image
72
+ import birder
73
+
74
+ (net, model_info) = birder.load_pretrained_model("focalnet_b_lrf_intermediate-eu-common", inference=True)
75
+
76
+ # Get the image size the model was trained on
77
+ size = birder.get_size_from_signature(model_info.signature)
78
+
79
+ # Create an inference transform
80
+ transform = birder.classification_transform(size, model_info.rgb_stats)
81
+
82
+ image = Image.open("path/to/image.jpeg")
83
+ features = net.detection_features(transform(image).unsqueeze(0))
84
+ # features is a dict (stage name -> torch.Tensor)
85
+ print([(k, v.size()) for k, v in features.items()])
86
+ # Output example:
87
+ # [('stage1', torch.Size([1, 128, 96, 96])),
88
+ # ('stage2', torch.Size([1, 256, 48, 48])),
89
+ # ('stage3', torch.Size([1, 512, 24, 24])),
90
+ # ('stage4', torch.Size([1, 1024, 12, 12]))]
91
+ ```
92
+
93
+ ## Citation
94
+
95
+ ```bibtex
96
+ @misc{yang2022focalmodulationnetworks,
97
+ title={Focal Modulation Networks},
98
+ author={Jianwei Yang and Chunyuan Li and Xiyang Dai and Lu Yuan and Jianfeng Gao},
99
+ year={2022},
100
+ eprint={2203.11926},
101
+ archivePrefix={arXiv},
102
+ primaryClass={cs.CV},
103
+ url={https://arxiv.org/abs/2203.11926},
104
+ }
105
+ ```