Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xiaochus/MobileNetV2
A Keras implementation of MobileNetV2.
https://github.com/xiaochus/MobileNetV2
cnn image-classification keras mobilenetv2
Last synced: about 1 month ago
JSON representation
A Keras implementation of MobileNetV2.
- Host: GitHub
- URL: https://github.com/xiaochus/MobileNetV2
- Owner: xiaochus
- License: mit
- Created: 2018-02-01T03:17:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-25T14:04:34.000Z (over 5 years ago)
- Last Synced: 2024-08-01T22:50:05.201Z (4 months ago)
- Topics: cnn, image-classification, keras, mobilenetv2
- Language: Python
- Homepage:
- Size: 1.96 MB
- Stars: 319
- Watchers: 14
- Forks: 161
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-image-classification - unofficial-keras : https://github.com/xiaochus/MobileNetV2
- awesome-image-classification - unofficial-keras : https://github.com/xiaochus/MobileNetV2
README
# 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](https://arxiv.org/abs/1801.04381).
## Requirement
- OpenCV 3.4
- Python 3.5
- Tensorflow-gpu 1.5.0
- Keras 2.2## 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](/images/net.jpg)
**Bottleneck Architectures:**
![residual block architectures](/images/stru.jpg)
## 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.## 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](LICENSE) for details.