|
|
1 день назад | |
|---|---|---|
| .. | ||
| README.md | 1 день назад | |
| metafile.yml | 1 день назад | |
| mobilevit-small_8xb128_in1k.py | 1 день назад | |
| mobilevit-xsmall_8xb128_in1k.py | 1 день назад | |
| mobilevit-xxsmall_8xb128_in1k.py | 1 день назад | |
MobileViT Light-weight, General-purpose, and Mobile-friendly Vision Transformer
MobileViT aims at introducing a light-weight network, which takes the advantages of both ViTs and CNNs, uses the InvertedResidual blocks in MobileNetV2 and MobileViTBlock which refers to ViT transformer blocks to build a standard 5-stage model structure.
The MobileViTBlock reckons transformers as convolutions to perform a global representation, meanwhile conbined with original convolution layers for local representation to build a block with global receptive field. This is different from ViT, which adds an extra class token and position embeddings for learning relative relationship. Without any position embeddings, MobileViT can benfit from multi-scale inputs during training.
Also, this paper puts forward a strategy for multi-scale training to dynamically adjust batch size based on the image size to both improve training efficiency and final performance.
It is also proven effective in downstream tasks such as object detection and segmentation.
Predict image
from mmpretrain import inference_model
predict = inference_model('mobilevit-small_3rdparty_in1k', 'demo/bird.JPEG')
print(predict['pred_class'])
print(predict['pred_score'])
Use the model
import torch
from mmpretrain import get_model
model = get_model('mobilevit-small_3rdparty_in1k', pretrained=True)
inputs = torch.rand(1, 3, 224, 224)
out = model(inputs)
print(type(out))
# To extract features.
feats = model.extract_feat(inputs)
print(type(feats))
Test Command
Prepare your dataset according to the docs.
Test:
python tools/test.py configs/mobilevit/mobilevit-small_8xb128_in1k.py https://download.openmmlab.com/mmclassification/v0/mobilevit/mobilevit-small_3rdparty_in1k_20221018-cb4f741c.pth
| Model | Pretrain | Params (M) | Flops (G) | Top-1 (%) | Top-5 (%) | Config | Download |
|---|---|---|---|---|---|---|---|
mobilevit-small_3rdparty_in1k* |
From scratch | 5.58 | 2.03 | 78.25 | 94.09 | config | model |
mobilevit-xsmall_3rdparty_in1k* |
From scratch | 2.32 | 1.05 | 74.75 | 92.32 | config | model |
mobilevit-xxsmall_3rdparty_in1k* |
From scratch | 1.27 | 0.42 | 69.02 | 88.91 | config | model |
*Models with * are converted from the official repo. The config files of these models are only for inference. We haven't reproduce the training results.*
@article{mehta2021mobilevit,
title={MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer},
author={Mehta, Sachin and Rastegari, Mohammad},
journal={arXiv preprint arXiv:2110.02178},
year={2021}
}