Views
No views yet
eu-common dataset containing common European bird species.1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
5
6# Get the image size the model was trained on
7size = birder.get_size_from_signature(model_info.signature)
8
9# Create an inference transform
10transform = birder.classification_transform(size, model_info.rgb_stats)
11
12image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
13(out, _) = infer_image(net, image, transform)
14# out is a NumPy array with shape of (1, 707), representing class probabilities.1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
5
6# Get the image size the model was trained on
7size = birder.get_size_from_signature(model_info.signature)
8
9# Create an inference transform
10transform = birder.classification_transform(size, model_info.rgb_stats)
11
12image = "path/to/image.jpeg" # or a PIL image
13(out, embedding) = infer_image(net, image, transform, return_embedding=True)
14# embedding is a NumPy array with shape of (1, 768)1from PIL import Image
2import birder
3
4(net, model_info) = birder.load_pretrained_model("convnext_v2_tiny_intermediate-eu-common", inference=True)
5
6# Get the image size the model was trained on
7size = birder.get_size_from_signature(model_info.signature)
8
9# Create an inference transform
10transform = birder.classification_transform(size, model_info.rgb_stats)
11
12image = Image.open("path/to/image.jpeg")
13features = net.detection_features(transform(image).unsqueeze(0))
14# features is a dict (stage name -> torch.Tensor)
15print([(k, v.size()) for k, v in features.items()])
16# Output example:
17# [('stage1', torch.Size([1, 96, 96, 96])),
18# ('stage2', torch.Size([1, 192, 48, 48])),
19# ('stage3', torch.Size([1, 384, 24, 24])),
20# ('stage4', torch.Size([1, 768, 12, 12]))]1@misc{woo2023convnextv2codesigningscaling,
2 title={ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders},
3 author={Sanghyun Woo and Shoubhik Debnath and Ronghang Hu and Xinlei Chen and Zhuang Liu and In So Kweon and Saining Xie},
4 year={2023},
5 eprint={2301.00808},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2301.00808},
9}