Skip to main content

Multi-Modality

Vision Mamba

Implementation of Vision Mamba from the paper: "Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model" It's 2.8x faster than DeiT and saves 86.8% GPU memory when performing batch inference to extract features on high-res images.

PAPER LINK

Installation

pip install vision-mamba

Usage

import torch
from vision_mamba import Vim

# Forward pass
x = torch.randn(1, 3, 224, 224)  # Input tensor with shape (batch_size, channels, height, width)

# Model
model = Vim(
    dim=256,  # Dimension of the transformer model
    heads=8,  # Number of attention heads
    dt_rank=32,  # Rank of the dynamic routing matrix
    dim_inner=256,  # Inner dimension of the transformer model
    d_state=256,  # Dimension of the state vector
    num_classes=1000,  # Number of output classes
    image_size=224,  # Size of the input image
    patch_size=16,  # Size of each image patch
    channels=3,  # Number of input channels
    dropout=0.1,  # Dropout rate
    depth=12,  # Depth of the transformer model
)

# Forward pass
out = model(x)  # Output tensor from the model
print(out.shape)  # Print the shape of the output tensor
print(out)  # Print the output tensor

Citation

@misc{zhu2024vision,
    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},
    year={2024},
    eprint={2401.09417},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

License

MIT

Todo

  • Create training script for imagenet
  • Create a visual mamba for facial recognition

Release files for vision-mamba 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vision-mamba 0.1.0
File Size Uploaded
vision_mamba-0.1.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vision-mamba 0.1.0
File Interpreter ABI Platform
vision_mamba-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / vision_mamba-0.1.0.tar.gz

Download URL vision_mamba-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
acb7c01d794daff3d05ecd6d8852150e8c8d269d65002f258c3ef3d241ec5edf
BLAKE2b-256 checksum
How to use checksums
129fab5e240c1b13f0bc48e79beed1fbec33f4da6b450f2274926087dd99d60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0

Release files / vision_mamba-0.1.0-py3-none-any.whl

Download URL vision_mamba-0.1.0-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f21a8c22888b877e2f1b0b5737f805083faec824394245f98133cf41f7a7cb3
BLAKE2b-256 checksum
How to use checksums
cde7a1119b151c25d62f0c7688c3ba850b0bfa09e011f3e00723f6bfffb7225b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page