Views
No views yet
danube-delta dataset (all the relevant bird species found int the Danube Delta region).eu-common dataset.1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("hornet_tiny_7x7_danube-delta", 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, 368), representing class probabilities.1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("hornet_tiny_7x7_danube-delta", 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, 512)1from PIL import Image
2import birder
3
4(net, model_info) = birder.load_pretrained_model("hornet_tiny_7x7_danube-delta", 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, 64, 64, 64])),
18# ('stage2', torch.Size([1, 128, 32, 32])),
19# ('stage3', torch.Size([1, 256, 16, 16])),
20# ('stage4', torch.Size([1, 512, 8, 8]))]1@misc{rao2022hornetefficienthighorderspatial,
2 title={HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions},
3 author={Yongming Rao and Wenliang Zhao and Yansong Tang and Jie Zhou and Ser-Nam Lim and Jiwen Lu},
4 year={2022},
5 eprint={2207.14284},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2207.14284},
9}