Skip to content

Unofficial implementation of MobileNetV3 architecture described in paper Searching for MobileNetV3.

License

Notifications You must be signed in to change notification settings

Bisonai/mobilenetv3-tensorflow

Repository files navigation

MobileNetV3 TensorFlow

Unofficial implementation of MobileNetV3 architecture described in paper Searching for MobileNetV3. This repository contains small and large MobileNetV3 architecture implemented using TensforFlow with tf.keras API.

Google Colab

  • Open In Colab MNIST
  • Open In Colab CIFAR10

Requirements

  • Python 3.6
  • TensorFlow 1.13
pip install -r requirements.txt

Build model

MobileNetV3 Small

from mobilenetv3_factory import build_mobilenetv3
model = build_mobilenetv3(
    "small",
    input_shape=(224, 224, 3),
    num_classes=1001,
    width_multiplier=1.0,
)

MobileNetV3 Large

from mobilenetv3_factory import build_mobilenetv3
model = build_mobilenetv3(
    "large",
    input_shape=(224, 224, 3),
    num_classes=1001,
    width_multiplier=1.0,
)

Train

CIFAR10 dataset

python train.py \
    --model_type small \
    --width_multiplier 1.0 \
    --height 128 \
    --width 128 \
    --dataset cifar10 \
    --lr 0.01 \
    --optimizer rmsprop \
    --train_batch_size 256 \
    --valid_batch_size 256 \
    --num_epoch 10 \
    --logdir logdir

MNIST dataset

python train.py \
    --model_type small \
    --width_multiplier 1.0 \
    --height 128 \
    --width 128 \
    --dataset mnist \
    --lr 0.01 \
    --optimizer rmsprop \
    --train_batch_size 256 \
    --valid_batch_size 256 \
    --num_epoch 10 \
    --logdir logdir

Evaluate

CIFAR10 dataset

python evaluate.py \
    --model_type small \
    --width_multiplier 1.0 \
    --height 128 \
    --width 128 \
    --dataset cifar10 \
    --valid_batch_size 256 \
    --model_path mobilenetv3_small_cifar10_10.h5

MNIST dataset

python evaluate.py \
    --model_type small \
    --width_multiplier 1.0 \
    --height 128 \
    --width 128 \
    --dataset mnist \
    --valid_batch_size 256 \
    --model_path mobilenetv3_small_mnist_10.h5

TensorBoard

Graph, training and evaluaion metrics are saved to TensorBoard event file uder directory specified with --logdir` argument during training. You can launch TensorBoard using following command.

tensorboard --logdir logdir

License

Apache License 2.0