|
| 1 | +# A MLP-like Architecture for Dense Prediction |
| 2 | + |
| 3 | +[](https://opensource.org/licenses/MIT) |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +<p align="middle"> |
| 9 | + <img src="figures/teaser.png" height="300" /> |
| 10 | + |
| 11 | + <img src="figures/flops.png" height="300" /> |
| 12 | +</p> |
| 13 | + |
| 14 | +# Updates |
| 15 | + |
| 16 | +- (22/07/2021) Initial release. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +# Model Zoo |
| 21 | + |
| 22 | +We provide CycleMLP models pretrained on ImageNet 2012. |
| 23 | + |
| 24 | +| Model | Parameters | FLOPs | Top 1 Acc. | Download | |
| 25 | +| :------------------- | :--------- | :------- | :--------- | :------- | |
| 26 | +| CycleMLP-B1 | 15M | 2.1G | 78.9% | | |
| 27 | +| CycleMLP-B2 | 27M | 3.9G | 81.6% | | |
| 28 | +| CycleMLP-B3 | 38M | 6.9G | 82.4% | | |
| 29 | +| CycleMLP-B4 | 52M | 10.1G | 83.0% | | |
| 30 | +| CycleMLP-B5 | 76M | 12.3G | 83.2% | | |
| 31 | + |
| 32 | + |
| 33 | +# Usage |
| 34 | + |
| 35 | + |
| 36 | +## Install |
| 37 | + |
| 38 | +- PyTorch 1.7.0+ and torchvision 0.8.1+ |
| 39 | +- [timm](https://github.com/rwightman/pytorch-image-models/tree/c2ba229d995c33aaaf20e00a5686b4dc857044be): |
| 40 | +``` |
| 41 | +pip install 'git+https://github.com/rwightman/pytorch-image-models@c2ba229d995c33aaaf20e00a5686b4dc857044be' |
| 42 | +
|
| 43 | +or |
| 44 | +
|
| 45 | +git clone https://github.com/rwightman/pytorch-image-models |
| 46 | +cd pytorch-image-models |
| 47 | +git checkout c2ba229d995c33aaaf20e00a5686b4dc857044be |
| 48 | +pip install -e . |
| 49 | +``` |
| 50 | +- fvcore (optional, for FLOPs calculation) |
| 51 | +- mmcv, mmdetection, mmsegmentation (optional) |
| 52 | + |
| 53 | +## Data preparation |
| 54 | + |
| 55 | +Download and extract ImageNet train and val images from http://image-net.org/. |
| 56 | +The directory structure is: |
| 57 | + |
| 58 | +``` |
| 59 | +│path/to/imagenet/ |
| 60 | +├──train/ |
| 61 | +│ ├── n01440764 |
| 62 | +│ │ ├── n01440764_10026.JPEG |
| 63 | +│ │ ├── n01440764_10027.JPEG |
| 64 | +│ │ ├── ...... |
| 65 | +│ ├── ...... |
| 66 | +├──val/ |
| 67 | +│ ├── n01440764 |
| 68 | +│ │ ├── ILSVRC2012_val_00000293.JPEG |
| 69 | +│ │ ├── ILSVRC2012_val_00002138.JPEG |
| 70 | +│ │ ├── ...... |
| 71 | +│ ├── ...... |
| 72 | +``` |
| 73 | + |
| 74 | +## Evaluation |
| 75 | +To evaluate a pre-trained CycleMLP-B5 on ImageNet val with a single GPU run: |
| 76 | +``` |
| 77 | +python main.py --eval --model CycleMLP_B5 --resume path/to/CycleMLP_B5.pth --data-path /path/to/imagenet |
| 78 | +``` |
| 79 | + |
| 80 | + |
| 81 | +## Training |
| 82 | + |
| 83 | +To train CycleMLP-B5 on ImageNet on a single node with 8 gpus for 300 epochs run: |
| 84 | +``` |
| 85 | +python -m torch.distributed.launch --nproc_per_node=8 --use_env main.py --model CycleMLP_B5 --batch-size 128 --data-path /path/to/imagenet --output_dir /path/to/save |
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | +# License |
| 90 | + |
| 91 | +CycleMLP is released under MIT License. |
0 commit comments