hassonofer commited on
Commit
131d830
·
verified ·
1 Parent(s): 56e026a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -13
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, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
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, num_classes), representing class probabilities.
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, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
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, embedding_size)
68
  ```
69
 
70
  ### Detection Feature Map
@@ -73,13 +73,13 @@ image = "path/to/image.jpeg" # or a PIL image
73
  from PIL import Image
74
  import birder
75
 
76
- (net, class_to_idx, signature, rgb_stats) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
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))
@@ -96,12 +96,12 @@ print([(k, v.size()) for k, v in features.items()])
96
 
97
  ```bibtex
98
  @misc{woo2023convnextv2codesigningscaling,
99
- title={ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},
100
  author={Sanghyun Woo and Shoubhik Debnath and Ronghang Hu and Xinlei Chen and Zhuang Liu and In So Kweon and Saining Xie},
101
  year={2023},
102
  eprint={2301.00808},
103
  archivePrefix={arXiv},
104
  primaryClass={cs.CV},
105
- url={https://arxiv.org/abs/2301.00808},
106
  }
107
  ```
 
35
  import birder
36
  from birder.inference.classification import infer_image
37
 
38
+ (net, model_info) = birder.load_pretrained_model("convnext_v2_tiny_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("convnext_v2_tiny_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, 768)
68
  ```
69
 
70
  ### Detection Feature Map
 
73
  from PIL import Image
74
  import birder
75
 
76
+ (net, model_info) = birder.load_pretrained_model("convnext_v2_tiny_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))
 
96
 
97
  ```bibtex
98
  @misc{woo2023convnextv2codesigningscaling,
99
+ title={ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},
100
  author={Sanghyun Woo and Shoubhik Debnath and Ronghang Hu and Xinlei Chen and Zhuang Liu and In So Kweon and Saining Xie},
101
  year={2023},
102
  eprint={2301.00808},
103
  archivePrefix={arXiv},
104
  primaryClass={cs.CV},
105
+ url={https://arxiv.org/abs/2301.00808},
106
  }
107
  ```