Giter Club home page Giter Club logo

shufflenetv1-pytorch's Introduction

ShuffleNetV1-PyTorch

Overview

This repository contains an op-for-op PyTorch reimplementation of ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices .

Table of contents

Download weights

Download datasets

Contains MNIST, CIFAR10&CIFAR100, TinyImageNet_200, MiniImageNet_1K, ImageNet_1K, Caltech101&Caltech256 and more etc.

Please refer to README.md in the data directory for the method of making a dataset.

How Test and Train

Both training and testing only need to modify the config.py file.

Test

  • line 29: model_arch_name change to shufflenet_v1_x1_0.
  • line 31: model_mean_parameters change to [0.485, 0.456, 0.406].
  • line 32: model_std_parameters change to [0.229, 0.224, 0.225].
  • line 34: model_num_classes change to 1000.
  • line 36: mode change to test.
  • line 89: model_weights_path change to ./results/pretrained_models/ShuffleNetV1_x1_0-ImageNet_1K-7a092cde.pth.tar.
python3 test.py

Train model

  • line 29: model_arch_name change to shufflenet_v1_x1_0.
  • line 31: model_mean_parameters change to [0.485, 0.456, 0.406].
  • line 32: model_std_parameters change to [0.229, 0.224, 0.225].
  • line 34: model_num_classes change to 1000.
  • line 36: mode change to train.
  • line 50: pretrained_model_weights_path change to ./results/pretrained_models/ShuffleNetV1_x1_0-ImageNet_1K-7a092cde.pth.tar.
python3 train.py

Resume train model

  • line 29: model_arch_name change to shufflenet_v1_x1_0.
  • line 31: model_mean_parameters change to [0.485, 0.456, 0.406].
  • line 32: model_std_parameters change to [0.229, 0.224, 0.225].
  • line 34: model_num_classes change to 1000.
  • line 36: mode change to train.
  • line 53: resume change to ./samples/shufflenet_v1_x1_0-ImageNet_1K/epoch_xxx.pth.tar.
python3 train.py

Result

Source of original paper results: https://arxiv.org/pdf/1707.01083.pdf)

In the following table, the top-x error value in () indicates the result of the project, and - indicates no test.

Model Dataset Top-1 error (val) Top-5 error (val)
shufflenet_v1_x0_5 ImageNet_1K 41.2%(41.1%) 19.0%(19.0%)
shufflenet_v1_x1_0 ImageNet_1K 32.0%(31.9%) 13.6%(13.6%)
shufflenet_v1_x1_5 ImageNet_1K 29.0%(29.9%) 10.4%(10.4%)
shufflenet_v1_x2_0 ImageNet_1K 27.1%(27.0%) 9.2%(9.2%)
# Download `ShuffleNetV1_x1_0-ImageNet_1K-7a092cde.pth.tar` weights to `./results/pretrained_models`
# More detail see `README.md<Download weights>`
python3 ./inference.py 

Input:

Output:

Build `shufflenet_v1_x1_0` model successfully.
Load `shufflenet_v1_x1_0` model weights `/ShuffleNetV1-PyTorch/results/pretrained_models/ShuffleNetV1_x1_0-ImageNet_1K-7a092cde.pth.tar` successfully.
tench, Tinca tinca                                                          (54.11%)
platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus (4.75%)
triceratops                                                                 (2.94%)
armadillo                                                                   (2.64%)
barracouta, snoek                                                           (2.63%)

Contributing

If you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.

I look forward to seeing what the community does with these models!

Credit

ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices

Zhang, Xiangyu and Zhou, Xinyu and Lin, Mengxiao and Sun, Jian

Abstract

We introduce an extremely computation-efficient CNN architecture named ShuffleNet, which is designed specially for mobile devices with very limited computing power (e.g., 10-150 MFLOPs). The new architecture utilizes two new operations, pointwise group convolution and channel shuffle, to greatly reduce computation cost while maintaining accuracy. Experiments on ImageNet classification and MS COCO object detection demonstrate the superior performance of ShuffleNet over other structures, e.g. lower top-1 error (absolute 7.8%) than recent MobileNet on ImageNet classification task, under the computation budget of 40 MFLOPs. On an ARM-based mobile device, ShuffleNet achieves โˆผ13ร— actual speedup over AlexNet while maintaining comparable accuracy.

[Paper]

@inproceedings{zhang2018shufflenet,
            title={Shufflenet: An extremely efficient convolutional neural network for mobile devices},
            author={Zhang, Xiangyu and Zhou, Xinyu and Lin, Mengxiao and Sun, Jian},
            booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
            pages={6848--6856},
            year={2018}
}

shufflenetv1-pytorch's People

Stargazers

 avatar

Watchers

 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.