Views
No views yet
1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("rope_vit_reg8_so150m_p14_swiglu_rms_ap_rotnet-capi", 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, 4), representing class probabilities.
15# index 0 -> 0° (upright)
16# index 1 -> 90° rotation
17# index 2 -> 180° rotation
18# index 3 -> 270° rotation1import birder
2from birder.inference.classification import infer_image
3
4(net, model_info) = birder.load_pretrained_model("rope_vit_reg8_so150m_p14_swiglu_rms_ap_rotnet-capi", 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, 896)1from PIL import Image
2import birder
3
4(net, model_info) = birder.load_pretrained_model("rope_vit_reg8_so150m_p14_swiglu_rms_ap_rotnet-capi", 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# [('neck', torch.Size([1, 896, 18, 18]))]1@misc{dosovitskiy2021imageworth16x16words,
2 title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
3 author={Alexey Dosovitskiy and Lucas Beyer and Alexander Kolesnikov and Dirk Weissenborn and Xiaohua Zhai and Thomas Unterthiner and Mostafa Dehghani and Matthias Minderer and Georg Heigold and Sylvain Gelly and Jakob Uszkoreit and Neil Houlsby},
4 year={2021},
5 eprint={2010.11929},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2010.11929},
9}
10
11@misc{heo2024rotarypositionembeddingvision,
12 title={Rotary Position Embedding for Vision Transformer},
13 author={Byeongho Heo and Song Park and Dongyoon Han and Sangdoo Yun},
14 year={2024},
15 eprint={2403.13298},
16 archivePrefix={arXiv},
17 primaryClass={cs.CV},
18 url={https://arxiv.org/abs/2403.13298},
19}
20
21@misc{darcet2024visiontransformersneedregisters,
22 title={Vision Transformers Need Registers},
23 author={Timothée Darcet and Maxime Oquab and Julien Mairal and Piotr Bojanowski},
24 year={2024},
25 eprint={2309.16588},
26 archivePrefix={arXiv},
27 primaryClass={cs.CV},
28 url={https://arxiv.org/abs/2309.16588},
29}
30
31@misc{alabdulmohsin2024gettingvitshapescaling,
32 title={Getting ViT in Shape: Scaling Laws for Compute-Optimal Model Design},
33 author={Ibrahim Alabdulmohsin and Xiaohua Zhai and Alexander Kolesnikov and Lucas Beyer},
34 year={2024},
35 eprint={2305.13035},
36 archivePrefix={arXiv},
37 primaryClass={cs.CV},
38 url={https://arxiv.org/abs/2305.13035},
39}
40
41@misc{darcet2025clusterpredictlatentpatches,
42 title={Cluster and Predict Latent Patches for Improved Masked Image Modeling},
43 author={Timothée Darcet and Federico Baldassarre and Maxime Oquab and Julien Mairal and Piotr Bojanowski},
44 year={2025},
45 eprint={2502.08769},
46 archivePrefix={arXiv},
47 primaryClass={cs.CV},
48 url={https://arxiv.org/abs/2502.08769},
49}