MobileViT GSoC 2022



Project Report

This repository provides TensorFlow / Keras implementations of different MobileViT [1] variants. It also provides the TensorFlow / Keras models that have been populated with the original MobileViT pre-trained weights available from [2]. These models are not blackbox SavedModels i.e., they can be fully expanded into tf.keras.Model objects and one can call all the utility functions on them (example: .summary()).

As of today, all the TensorFlow / Keras variants of the models listed here are available in this repository. This list includes the ImageNet-1k models.

Refer to the “Using the models” section to get started.


TensorFlow / Keras implementations are available in mobilevit/models/ Conversion utilities are in


The converted models will be available on TF-Hub.

There should be a total of 3 different models each having two variants: classifier and feature extractor. You can load any model and get started like so:

import tensorflow as tf

model = tf.keras.models.load_model('model_path')

The model names are interpreted as follows:


Results are on ImageNet-1k validation set (top-1 accuracy).

name original acc@1 keras acc@1
MobileViT_XXS 69.0 68.59
MobileViT_XS 74.7 74.67
MobileViT_S 78.3 78.36

Differences in the results are primarily because of the differences in the library implementations especially how image resizing is implemented in PyTorch and TensorFlow. Results can be verified with the code in imagenet_1k_eval. Logs are available at this URL.

Using the models

Pre-trained models:

Randomly initialized models:

from mobilevit.models.mobilevit import get_mobilevit_model

model = get_mobilevit_model(
      model_name='mobilevit_xxs', # [mobilevit_xxs, mobilevit_xs, mobilevit_s]
      image_shape=(256, 256, 3),


To view different model configurations, refer here.

Upcoming Contributions


[1] MobileViT Paper:

[2] Official MobileViT weights:

[3] Hugging Face MobileViT: MobileViT-HF


portfolio linkedin twitter