Views
No views yet
DISABLE_CUSTOM_KERNELS=1 before loading the model.1import birder
2from birder.inference.detection import infer_image
3
4# Option 1: manual setup (more control over preprocessing)
5net, model_info = birder.load_pretrained_model("lw_detr_2stg_objects365_pe_spatial_s16", 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.detection_transform(size, model_info.rgb_stats, dynamic_size=model_info.signature["dynamic"])
12
13# Option 2: helper (quick start with default preprocessing)
14net, model_info, transform = birder.load_pretrained_model_and_transform("lw_detr_2stg_objects365_pe_spatial_s16", inference=True)
15
16image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
17detections = infer_image(net, image, transform)
18# detections is a dict with keys: 'boxes', 'labels', 'scores'
19# boxes: torch.Tensor with shape (N, 4) in [x1, y1, x2, y2] format
20# labels: torch.Tensor with shape (N,) containing class indices
21# scores: torch.Tensor with shape (N,) containing confidence scores1@misc{chen2024lwdetrtransformerreplacementyolo,
2 title={LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection},
3 author={Qiang Chen and Xiangbo Su and Xinyu Zhang and Jian Wang and Jiahui Chen and Yunpeng Shen and Chuchu Han and Ziliang Chen and Weixiang Xu and Fanrong Li and Shan Zhang and Kun Yao and Errui Ding and Gang Zhang and Jingdong Wang},
4 year={2024},
5 eprint={2406.03459},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2406.03459},
9}
10
11@misc{bolya2025perceptionencoderbestvisual,
12 title={Perception Encoder: The best visual embeddings are not at the output of the network},
13 author={Daniel Bolya and Po-Yao Huang and Peize Sun and Jang Hyun Cho and Andrea Madotto and Chen Wei and Tengyu Ma and Jiale Zhi and Jathushan Rajasegaran and Hanoona Rasheed and Junke Wang and Marco Monteiro and Hu Xu and Shiyu Dong and Nikhila Ravi and Daniel Li and Piotr Dollár and Christoph Feichtenhofer},
14 year={2025},
15 eprint={2504.13181},
16 archivePrefix={arXiv},
17 primaryClass={cs.CV},
18 url={https://arxiv.org/abs/2504.13181},
19}