hassonofer commited on
Commit
b85dea2
·
verified ·
1 Parent(s): 788320a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -17
README.md CHANGED
@@ -32,17 +32,17 @@ The species list is derived from data available at <https://www.israbirding.com/
32
  import birder
33
  from birder.inference.classification import infer_image
34
 
35
- (net, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
36
 
37
  # Get the image size the model was trained on
38
- size = birder.get_size_from_signature(signature)
39
 
40
  # Create an inference transform
41
- transform = birder.classification_transform(size, rgb_stats)
42
 
43
  image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
44
  (out, _) = infer_image(net, image, transform)
45
- # out is a NumPy array with shape of (1, num_classes), representing class probabilities.
46
  ```
47
 
48
  ### Image Embeddings
@@ -51,17 +51,17 @@ image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
51
  import birder
52
  from birder.inference.classification import infer_image
53
 
54
- (net, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
55
 
56
  # Get the image size the model was trained on
57
- size = birder.get_size_from_signature(signature)
58
 
59
  # Create an inference transform
60
- transform = birder.classification_transform(size, rgb_stats)
61
 
62
  image = "path/to/image.jpeg" # or a PIL image
63
  (out, embedding) = infer_image(net, image, transform, return_embedding=True)
64
- # embedding is a NumPy array with shape of (1, embedding_size)
65
  ```
66
 
67
  ### Detection Feature Map
@@ -70,35 +70,35 @@ image = "path/to/image.jpeg" # or a PIL image
70
  from PIL import Image
71
  import birder
72
 
73
- (net, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
74
 
75
  # Get the image size the model was trained on
76
- size = birder.get_size_from_signature(signature)
77
 
78
  # Create an inference transform
79
- transform = birder.classification_transform(size, rgb_stats)
80
 
81
  image = Image.open("path/to/image.jpeg")
82
  features = net.detection_features(transform(image).unsqueeze(0))
83
  # features is a dict (stage name -> torch.Tensor)
84
  print([(k, v.size()) for k, v in features.items()])
85
  # Output example:
86
- # [('stage1', torch.Size([1, 96, 96, 96])),
87
- # ('stage2', torch.Size([1, 192, 48, 48])),
88
- # ('stage3', torch.Size([1, 384, 24, 24])),
89
- # ('stage4', torch.Size([1, 768, 12, 12]))]
90
  ```
91
 
92
  ## Citation
93
 
94
  ```bibtex
95
  @misc{elnouby2021xcitcrosscovarianceimagetransformers,
96
- title={XCiT: Cross-Covariance Image Transformers},
97
  author={Alaaeldin El-Nouby and Hugo Touvron and Mathilde Caron and Piotr Bojanowski and Matthijs Douze and Armand Joulin and Ivan Laptev and Natalia Neverova and Gabriel Synnaeve and Jakob Verbeek and Hervé Jegou},
98
  year={2021},
99
  eprint={2106.09681},
100
  archivePrefix={arXiv},
101
  primaryClass={cs.CV},
102
- url={https://arxiv.org/abs/2106.09681},
103
  }
104
  ```
 
32
  import birder
33
  from birder.inference.classification import infer_image
34
 
35
+ (net, model_info) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
36
 
37
  # Get the image size the model was trained on
38
+ size = birder.get_size_from_signature(model_info.signature)
39
 
40
  # Create an inference transform
41
+ transform = birder.classification_transform(size, model_info.rgb_stats)
42
 
43
  image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
44
  (out, _) = infer_image(net, image, transform)
45
+ # out is a NumPy array with shape of (1, 371), representing class probabilities.
46
  ```
47
 
48
  ### Image Embeddings
 
51
  import birder
52
  from birder.inference.classification import infer_image
53
 
54
+ (net, model_info) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
55
 
56
  # Get the image size the model was trained on
57
+ size = birder.get_size_from_signature(model_info.signature)
58
 
59
  # Create an inference transform
60
+ transform = birder.classification_transform(size, model_info.rgb_stats)
61
 
62
  image = "path/to/image.jpeg" # or a PIL image
63
  (out, embedding) = infer_image(net, image, transform, return_embedding=True)
64
+ # embedding is a NumPy array with shape of (1, 128)
65
  ```
66
 
67
  ### Detection Feature Map
 
70
  from PIL import Image
71
  import birder
72
 
73
+ (net, model_info) = birder.load_pretrained_model("xcit_nano12_p16_il-common", inference=True)
74
 
75
  # Get the image size the model was trained on
76
+ size = birder.get_size_from_signature(model_info.signature)
77
 
78
  # Create an inference transform
79
+ transform = birder.classification_transform(size, model_info.rgb_stats)
80
 
81
  image = Image.open("path/to/image.jpeg")
82
  features = net.detection_features(transform(image).unsqueeze(0))
83
  # features is a dict (stage name -> torch.Tensor)
84
  print([(k, v.size()) for k, v in features.items()])
85
  # Output example:
86
+ # [('stage1', torch.Size([1, 128, 16, 16])),
87
+ # ('stage2', torch.Size([1, 128, 16, 16])),
88
+ # ('stage3', torch.Size([1, 128, 16, 16])),
89
+ # ('stage4', torch.Size([1, 128, 16, 16]))]
90
  ```
91
 
92
  ## Citation
93
 
94
  ```bibtex
95
  @misc{elnouby2021xcitcrosscovarianceimagetransformers,
96
+ title={XCiT: Cross-Covariance Image Transformers},
97
  author={Alaaeldin El-Nouby and Hugo Touvron and Mathilde Caron and Piotr Bojanowski and Matthijs Douze and Armand Joulin and Ivan Laptev and Natalia Neverova and Gabriel Synnaeve and Jakob Verbeek and Hervé Jegou},
98
  year={2021},
99
  eprint={2106.09681},
100
  archivePrefix={arXiv},
101
  primaryClass={cs.CV},
102
+ url={https://arxiv.org/abs/2106.09681},
103
  }
104
  ```