Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
[CVPR 2023] Official code release of our paper "BiFormer: Vision Transformer with Bi-Level Routing Attention"
| Date | Stars |
|---|---|
| 2026-07-24 | 583 |
| 2026-07-25 | 583 |
| 2026-07-28 | 583 |
| 2026-07-30 | 583 |
| 2026-08-06 | 583 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# [BiFormer: Vision Transformer with Bi-Level Routing Attention](https://arxiv.org/abs/2303.08810)
Official PyTorch implementation of **BiFormer**, from the following paper:
[BiFormer: Vision Transformer with Bi-Level Routing Attention](https://arxiv.org/abs/2303.08810). CVPR 2023.\
[Lei Zhu](https://github.com/rayleizhu), [Xinjiang Wang](https://scholar.google.com/citations?user=q4lnWaoAAAAJ&hl=en), [Zhanghan Ke](https://zhke.io/), [Wayne Zhang](http://www.statfe.com/), and [Rynson Lau](https://www.cs.cityu.edu.hk/~rynson/)
---
<p align="left">
<img src="assets/teaser.png" width=60% height=60%
class="center">
</p>
<!-- ✅ ⬜️ -->
## News
* 2023-04-11: [object detection code](./object_detection/) is released. It achives significantly better results than the paper reported due to a bug fix.
* 2023-03-24: For better memory and computation efficieny, we are diving into the optimization of BRA with CUDA. Please stay tuned.
- Collaborations and contributions are welcome, especially if you are an expert in CUDA/[cutlass](https://github.com/NVIDIA/cutlass). There is a chance to co-author a paper.
* 2023-03-24: For better readability, BRA and BiFormer-STL has been refactored. See [ops/bra_nchw.py](ops/bra_nchw.py) and [models/biformer_stl_nchw.py](models/biformer_stl_nchw.py). We still keep the [legacy (and a little bit messy) implementation](ops/bra_legacy.py) for compatiability of previously released checkpoints.
## Results and Pre-trained Models
### ImageNet-1K trained models
| name | resolution |acc@1 | #params | FLOPs | model | log | tensorboard log<sup>*</sup> |
|:---:|:---:|:---:|:---:| :---:|:---:|:---:| :---:|
| BiFormer-T | 224x224 | 81.4 | 13.1 M | 2.2 G | [model](https://api.onedrive.com/v1.0/shares/s!AkBbczdRlZvChHEOoGkgwgQzEDlM/root/content) | [log](https://1drv.ms/t/s!AkBbczdRlZvChHNvg1b_QV_Ptw_T?e=Tbuf4l) | - |
| BiFormer-S | 224x224 | 83.8 | 25.5 M | 4.5 G | [model](https://api.onedrive.com/v1.0/shares/s!AkBbczdRlZvChHDyM-x9KWRBZ832/root/content) | [log](https://1drv.ms/t/s!AkBbczdRlZvChHQKrsNAo0PCpgWz?e=k7V8xX) |[tensorboard.dev](https://tensorboard.dev/experiment/VQAZonmIRjasGaVDPloM5Q/#scalars) |
| BiFormer-B | 224x224 | 84.3 | 56.8 M | 9.8 G | [model](https://api.onedrive.com/v1.0/shares/s!AkBbczdRlZvChHI_XPhoadjaNxtO/root/content) | [log](https://1drv.ms/t/s!AkBbczdRlZvChHWq2YS_Iwryhf1g?e=GWiMy9) | - |
| BiFormer-STL | 224x224 | 82.7 | 28.4 M | 4.6 G | [model](https://api.onedrive.com/v1.0/shares/s!AkBbczdRlZvChSf-m7ujkvx9lIQ1/root/content) | [log](https://1drv.ms/t/s!AkBbczdRlZvChSYWxeM5EmrC7-TN?e=W1q15P) | - |
| BiFormer-STL-nchw | 224x224 | 82.7 | 28.4 M | 4.6 G | [model](https://api.onedrive.com/v1.0/shares/s!AkBbczdRlZvChWYrKbWbMgqd2Ai0/root/content) | [log](https://1drv.ms/t/s!AkBbczdRlZvChWf_axjI80DMWy4X?e=uni4Z2) | [tensorboard.dev](https://tensorboard.dev/experiment/CD2QfxOYT6WQ05qnpWdK5A/#scalars&_smoothingWeight=0&tagFilter=acc) |
<font size=1>* : reproduced after the acceptance of our paper.</font>
Here the `BiFormer-STL`(**S**win-**T**iny-**L**ayout) model is used in our ablation study. We hope it provides a good start proint for developing your own awsome attention mechanisms.
All files can be accessed from [onedrive](https://1drv.ms/u/s!AkBbczdRlZvChGsXFqAA-PVnA-R8?e=IPlOCG).
## Installation
Please check [INSTALL.md](INSTALL.md) for installation instructions.
## Evaluation
We did evaluation on a slurm cluster environment, using the command below:
```bash
python hydra_main.py \
data_path=./data/in1k input_size=224 batch_size=128 dist_eval=true \
+slurm=${CLUSTER_ID} slurm.nodes=1 slurm.ngpus=8 \
eval=true load_release=true model='biformer_small'
```
To test on a local machine, you may try
```bash
python -m torch.distributed.launch --nproc_per_node=8 main.py \
--data_path ./data/in1k --input_size 224 --batch_size 128 --dist_eval \
--eval --load_release --model biformer_small
```
This should give
```
* Acc@1 83.754 Acc@5 96.638 loss 0.869
Accuracy of the neExcerpt of 6,157 characters
Read on GitHub14
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:e3421819265dc0d4, topic:computer-vision, topic:object-detection, topic:image-classification