Update README.md
Browse files
README.md
CHANGED
@@ -35,17 +35,17 @@ The species list is derived from the Collins bird guide [^1].
|
|
35 |
import birder
|
36 |
from birder.inference.classification import infer_image
|
37 |
|
38 |
-
(net,
|
39 |
|
40 |
# Get the image size the model was trained on
|
41 |
-
size = birder.get_size_from_signature(signature)
|
42 |
|
43 |
# Create an inference transform
|
44 |
-
transform = birder.classification_transform(size, 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,
|
49 |
```
|
50 |
|
51 |
### Image Embeddings
|
@@ -54,17 +54,17 @@ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
|
|
54 |
import birder
|
55 |
from birder.inference.classification import infer_image
|
56 |
|
57 |
-
(net,
|
58 |
|
59 |
# Get the image size the model was trained on
|
60 |
-
size = birder.get_size_from_signature(signature)
|
61 |
|
62 |
# Create an inference transform
|
63 |
-
transform = birder.classification_transform(size, 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,
|
68 |
```
|
69 |
|
70 |
### Detection Feature Map
|
@@ -73,35 +73,35 @@ image = "path/to/image.jpeg" # or a PIL image
|
|
73 |
from PIL import Image
|
74 |
import birder
|
75 |
|
76 |
-
(net,
|
77 |
|
78 |
# Get the image size the model was trained on
|
79 |
-
size = birder.get_size_from_signature(signature)
|
80 |
|
81 |
# Create an inference transform
|
82 |
-
transform = birder.classification_transform(size, 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,
|
90 |
-
# ('stage2', torch.Size([1,
|
91 |
-
# ('stage3', torch.Size([1,
|
92 |
-
# ('stage4', torch.Size([1,
|
93 |
```
|
94 |
|
95 |
## Citation
|
96 |
|
97 |
```bibtex
|
98 |
@misc{radosavovic2020designingnetworkdesignspaces,
|
99 |
-
title={Designing Network Design Spaces},
|
100 |
author={Ilija Radosavovic and Raj Prateek Kosaraju and Ross Girshick and Kaiming He and Piotr Dollár},
|
101 |
year={2020},
|
102 |
eprint={2003.13678},
|
103 |
archivePrefix={arXiv},
|
104 |
primaryClass={cs.CV},
|
105 |
-
url={https://arxiv.org/abs/2003.13678},
|
106 |
}
|
107 |
```
|
|
|
35 |
import birder
|
36 |
from birder.inference.classification import infer_image
|
37 |
|
38 |
+
(net, model_info) = birder.load_pretrained_model("regnet_y_8g_intermediate-eu-common", inference=True)
|
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, 707), representing class probabilities.
|
49 |
```
|
50 |
|
51 |
### Image Embeddings
|
|
|
54 |
import birder
|
55 |
from birder.inference.classification import infer_image
|
56 |
|
57 |
+
(net, model_info) = birder.load_pretrained_model("regnet_y_8g_intermediate-eu-common", 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, 2016)
|
68 |
```
|
69 |
|
70 |
### Detection Feature Map
|
|
|
73 |
from PIL import Image
|
74 |
import birder
|
75 |
|
76 |
+
(net, model_info) = birder.load_pretrained_model("regnet_y_8g_intermediate-eu-common", 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, 224, 96, 96])),
|
90 |
+
# ('stage2', torch.Size([1, 448, 48, 48])),
|
91 |
+
# ('stage3', torch.Size([1, 896, 24, 24])),
|
92 |
+
# ('stage4', torch.Size([1, 2016, 12, 12]))]
|
93 |
```
|
94 |
|
95 |
## Citation
|
96 |
|
97 |
```bibtex
|
98 |
@misc{radosavovic2020designingnetworkdesignspaces,
|
99 |
+
title={Designing Network Design Spaces},
|
100 |
author={Ilija Radosavovic and Raj Prateek Kosaraju and Ross Girshick and Kaiming He and Piotr Dollár},
|
101 |
year={2020},
|
102 |
eprint={2003.13678},
|
103 |
archivePrefix={arXiv},
|
104 |
primaryClass={cs.CV},
|
105 |
+
url={https://arxiv.org/abs/2003.13678},
|
106 |
}
|
107 |
```
|