https://github.com/lucidrains/mlp-mixer-pytorch
An All-MLP solution for Vision, from Google AI
https://github.com/lucidrains/mlp-mixer-pytorch
deep-learning vision
Last synced: about 1 year ago
JSON representation
An All-MLP solution for Vision, from Google AI
- Host: GitHub
- URL: https://github.com/lucidrains/mlp-mixer-pytorch
- Owner: lucidrains
- License: mit
- Created: 2021-05-05T15:29:05.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T14:36:43.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T19:56:21.162Z (over 1 year ago)
- Topics: deep-learning, vision
- Language: Python
- Homepage:
- Size: 112 KB
- Stars: 1,016
- Watchers: 11
- Forks: 108
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

## MLP Mixer - Pytorch
An All-MLP solution for Vision, from Google AI, in Pytorch.
No convolutions nor attention needed!
## Install
```bash
$ pip install mlp-mixer-pytorch
```
## Usage
```python
import torch
from mlp_mixer_pytorch import MLPMixer
model = MLPMixer(
image_size = 256,
channels = 3,
patch_size = 16,
dim = 512,
depth = 12,
num_classes = 1000
)
img = torch.randn(1, 3, 256, 256)
pred = model(img) # (1, 1000)
```
Rectangular image
```python
import torch
from mlp_mixer_pytorch import MLPMixer
model = MLPMixer(
image_size = (256, 128),
channels = 3,
patch_size = 16,
dim = 512,
depth = 12,
num_classes = 1000
)
img = torch.randn(1, 3, 256, 128)
pred = model(img) # (1, 1000)
```
Video
```python
import torch
from mlp_mixer_pytorch import MLPMixer3D
model = MLPMixer3D(
image_size = (256, 128),
time_size = 4,
time_patch_size = 2,
channels = 3,
patch_size = 16,
dim = 512,
depth = 12,
num_classes = 1000
)
video = torch.randn(1, 3, 4, 256, 128)
pred = model(video) # (1, 1000)
```
## Citations
```bibtex
@misc{tolstikhin2021mlpmixer,
title = {MLP-Mixer: An all-MLP Architecture for Vision},
author = {Ilya Tolstikhin and Neil Houlsby and Alexander Kolesnikov and Lucas Beyer and Xiaohua Zhai and Thomas Unterthiner and Jessica Yung and Daniel Keysers and Jakob Uszkoreit and Mario Lucic and Alexey Dosovitskiy},
year = {2021},
eprint = {2105.01601},
archivePrefix = {arXiv},
primaryClass = {cs.CV}
}
```
```bibtex
@misc{hou2021vision,
title = {Vision Permutator: A Permutable MLP-Like Architecture for Visual Recognition},
author = {Qibin Hou and Zihang Jiang and Li Yuan and Ming-Ming Cheng and Shuicheng Yan and Jiashi Feng},
year = {2021},
eprint = {2106.12368},
archivePrefix = {arXiv},
primaryClass = {cs.CV}
}
```