GithubHelp home page GithubHelp logo

mobilenetv2's Introduction

MobileNet v2

A Python 3 and Keras 2 implementation of MobileNet V2 and provide train method.

According to the paper: Inverted Residuals and Linear Bottlenecks Mobile Networks for Classification, Detection and Segmentation.

Requirement

  • OpenCV 3.4
  • Python 3.5
  • Tensorflow-gpu 1.2.0
  • Keras 2.1.3

MobileNet v2 and inverted residual block architectures

MobileNet v2:

Each line describes a sequence of 1 or more identical (modulo stride) layers, repeated n times. All layers in the same sequence have the same number c of output channels. The first layer of each sequence has a stride s and all others use stride 1. All spatial convolutions use 3 X 3 kernels. The expansion factor t is always applied to the input size.

MobileNetV2

Bottleneck Architectures:

residual block architectures

Train the model

The recommended size of the image in the paper is 224 * 224. The data\convert.py file provide a demo of resize cifar-100 dataset to this size.

The dataset folder structure is as follows:

| - data/
	| - train/
  		| - class 0/
			| - image.jpg
				....
		| - class 1/
		  ....
		| - class n/
	| - validation/
  		| - class 0/
		| - class 1/
		  ....
		| - class n/

Run command below to train the model:

python train.py --classes num_classes --batch batch_size --epochs epochs --size image_size

The .h5 weight file was saved at model folder. If you want to do fine tune the trained model, you can run the following command. However, it should be noted that the size of the input image should be consistent with the original model.

python train.py --classes num_classes --batch batch_size --epochs epochs --size image_size --weights weights_path --tclasses pre_classes

Parameter explanation

  • --classes, The number of classes of dataset.
  • --size, The image size of train sample.
  • --batch, The number of train samples per batch.
  • --epochs, The number of train iterations.
  • --weights, Fine tune with other weights.
  • --tclasses, The number of classes of pre-trained model.

Experiment

Due to the limited computational resources, we used cifar-100 dataset to test the model.

device: Tesla K80
dataset: cifar-100
optimizer: Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08)  
batch_szie: 128 

These are the details for the CIFAR-100 experiment. Although the network did not completely converge, still achieved good accuracy.

Metrics Loss Top-1 Accuracy Top-5 Accuracy
cifar-100 0.195 94.42% 99.82%

evaluate

Reference

@article{MobileNetv2,  
  title={Inverted Residuals and Linear Bottlenecks Mobile Networks for Classification, Detection and Segmentatio},  
  author={Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen},
  journal={arXiv preprint arXiv:1801.04381},
  year={2018}
}

Copyright

See LICENSE for details.

mobilenetv2's People

Contributors

justinasdz avatar xiaochus avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.