Home

Awesome

<div align="center"> <h1>Vision Mamba </h1> <h3>Efficient Visual Representation Learning with Bidirectional State Space Model</h3>

Lianghui Zhu<sup>1</sup> *,Bencheng Liao<sup>1</sup> *,Qian Zhang<sup>2</sup>, Xinlong Wang<sup>3</sup>, Wenyu Liu<sup>1</sup>, Xinggang Wang<sup>1 :email:</sup>

<sup>1</sup> Huazhong University of Science and Technology, <sup>2</sup> Horizon Robotics, <sup>3</sup> Beijing Academy of Artificial Intelligence

(*) equal contribution, (<sup>:email:</sup>) corresponding author.

ArXiv Preprint (arXiv 2401.09417)

</div>

News

Abstract

Recently the state space models (SSMs) with efficient hardware-aware designs, i.e., the Mamba deep learning model, have shown great potential for long sequence modeling. Meanwhile building efficient and generic vision backbones purely upon SSMs is an appealing direction. However, representing visual data is challenging for SSMs due to the position-sensitivity of visual data and the requirement of global context for visual understanding. In this paper, we show that the reliance on self-attention for visual representation learning is not necessary and propose a new generic vision backbone with bidirectional Mamba blocks (Vim), which marks the image sequences with position embeddings and compresses the visual representation with bidirectional state space models. On ImageNet classification, COCO object detection, and ADE20k semantic segmentation tasks, Vim achieves higher performance compared to well-established vision transformers like DeiT, while also demonstrating significantly improved computation & memory efficiency. For example, Vim is 2.8x faster than DeiT and saves 86.8% GPU memory when performing batch inference to extract features on images with a resolution of 1248x1248. The results demonstrate that Vim is capable of overcoming the computation & memory constraints on performing Transformer-style understanding for high-resolution images and it has great potential to be the next-generation backbone for vision foundation models.

<div align="center"> <img src="assets/vim_teaser_v1.7.png" /> </div>

Overview

<div align="center"> <img src="assets/vim_pipeline_v1.9.png" /> </div>

Envs. for Pretraining

Train Your Vim

bash vim/scripts/pt-vim-t.sh

Train Your Vim at Finer Granularity

bash vim/scripts/ft-vim-t.sh

Model Weights

Model#param.Top-1 Acc.Top-5 Acc.Hugginface Repo
Vim-tiny7M76.193.0https://huggingface.co/hustvl/Vim-tiny-midclstok
Vim-tiny<sup>+</sup>7M78.394.2https://huggingface.co/hustvl/Vim-tiny-midclstok
Vim-small26M80.595.1https://huggingface.co/hustvl/Vim-small-midclstok
Vim-small<sup>+</sup>26M81.695.4https://huggingface.co/hustvl/Vim-small-midclstok

Notes:

Evaluation on Provided Weights

To evaluate Vim-Ti on ImageNet-1K, run:

python main.py --eval --resume /path/to/ckpt --model vim_tiny_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --data-path /path/to/imagenet

Acknowledgement :heart:

This project is based on Mamba (paper, code), Causal-Conv1d (code), DeiT (paper, code). Thanks for their wonderful works.

Citation

If you find Vim is useful in your research or applications, please consider giving us a star 🌟 and citing it by the following BibTeX entry.

 @article{vim,
  title={Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model},
  author={Lianghui Zhu and Bencheng Liao and Qian Zhang and Xinlong Wang and Wenyu Liu and Xinggang Wang},
  journal={arXiv preprint arXiv:2401.09417},
  year={2024}
}