Views
No views yet
1import birder
2from birder.inference.classification import infer_image
3
4# Option 1: manual setup (more control over preprocessing)
5net, model_info = birder.load_pretrained_model("rope_vit_m14_swiglu_avg_eva-bio", inference=True)
6
7# Get the image size the model was trained on
8size = birder.get_size_from_signature(model_info.signature)
9
10# Create an inference transform
11transform = birder.classification_transform(size, model_info.rgb_stats)
12
13# Option 2: helper (quick start with default preprocessing)
14net, model_info, transform = birder.load_pretrained_model_and_transform("rope_vit_m14_swiglu_avg_eva-bio", inference=True)
15
16image = "path/to/image.jpeg" # or a PIL image
17out, embedding = infer_image(net, image, transform, return_embedding=True)
18# embedding is a NumPy array with shape of (1, 512)1from PIL import Image
2import birder
3
4net, model_info, transform = birder.load_pretrained_model_and_transform("rope_vit_m14_swiglu_avg_eva-bio", inference=True)
5
6image = Image.open("path/to/image.jpeg")
7features = net.detection_features(transform(image).unsqueeze(0))
8# features is a dict (stage name -> torch.Tensor)
9print([(k, v.size()) for k, v in features.items()])
10# Output example:
11# [('stage1', torch.Size([1, 512, 16, 16]))]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@article{Fang_2024,
22 title={EVA-02: A visual representation for neon genesis},
23 volume={149},
24 ISSN={0262-8856},
25 url={http://dx.doi.org/10.1016/j.imavis.2024.105171},
26 DOI={10.1016/j.imavis.2024.105171},
27 journal={Image and Vision Computing},
28 publisher={Elsevier BV},
29 author={Fang, Yuxin and Sun, Quan and Wang, Xinggang and Huang, Tiejun and Wang, Xinlong and Cao, Yue},
30 year={2024},
31 month=Sept, pages={105171}
32}