All Projects → qidiso → mxnet-retrain

qidiso / mxnet-retrain

Licence: other
Create mxnet finetuner (retrain) for mac/linux ,no need install docker and supports CPU, GPU(eGpu/cudnn).support the inception,resnet ,squeeznet,mobilenet...

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Modelica
51 projects

Projects that are alternatives of or similar to mxnet-retrain

neural-dream
PyTorch implementation of DeepDream algorithm
Stars: ✭ 110 (+243.75%)
Mutual labels:  nin, resnet, inception
Tianchi Medical Lungtumordetect
天池医疗AI大赛[第一季]:肺部结节智能诊断 UNet/VGG/Inception/ResNet/DenseNet
Stars: ✭ 314 (+881.25%)
Mutual labels:  resnet, inception
i3d-tensorflow
Inflated 3D ConvNets for video understanding
Stars: ✭ 46 (+43.75%)
Mutual labels:  resnet, inception
Tensornets
High level network definitions with pre-trained weights in TensorFlow
Stars: ✭ 982 (+2968.75%)
Mutual labels:  resnet, inception
Fusenet
Deep fusion project of deeply-fused nets, and the study on the connection to ensembling
Stars: ✭ 230 (+618.75%)
Mutual labels:  mxnet, resnet
DeepNetModel
记录每一个常用的深度模型结构的特点(图和代码)
Stars: ✭ 25 (-21.87%)
Mutual labels:  resnet, inception
Keras Idiomatic Programmer
Books, Presentations, Workshops, Notebook Labs, and Model Zoo for Software Engineers and Data Scientists wanting to learn the TF.Keras Machine Learning framework
Stars: ✭ 720 (+2150%)
Mutual labels:  resnet, inception
tensorflow-retrain-sample
A sample for tensorflow retraining
Stars: ✭ 25 (-21.87%)
Mutual labels:  inception, retrain
Caffe Model
Caffe models (including classification, detection and segmentation) and deploy files for famouse networks
Stars: ✭ 1,258 (+3831.25%)
Mutual labels:  resnet, inception
M Pact
A one stop shop for all of your activity recognition needs.
Stars: ✭ 85 (+165.63%)
Mutual labels:  resnet, inception
Dogs vs cats
猫狗大战
Stars: ✭ 570 (+1681.25%)
Mutual labels:  resnet, inception
gluon2pytorch
Gluon to PyTorch deep neural network model converter
Stars: ✭ 72 (+125%)
Mutual labels:  mxnet, resnet
Pretrained Models.pytorch
Pretrained ConvNets for pytorch: NASNet, ResNeXt, ResNet, InceptionV4, InceptionResnetV2, Xception, DPN, etc.
Stars: ✭ 8,318 (+25893.75%)
Mutual labels:  resnet, inception
python cv AI ML
用python做计算机视觉,人工智能,机器学习,深度学习等
Stars: ✭ 73 (+128.13%)
Mutual labels:  mxnet, resnet
Gluon2pytorch
Gluon to PyTorch deep neural network model converter
Stars: ✭ 70 (+118.75%)
Mutual labels:  mxnet, resnet
Mx Lsoftmax
mxnet version of Large-Margin Softmax Loss for Convolutional Neural Networks.
Stars: ✭ 175 (+446.88%)
Mutual labels:  mxnet
Coach
Reinforcement Learning Coach by Intel AI Lab enables easy experimentation with state of the art Reinforcement Learning algorithms
Stars: ✭ 2,085 (+6415.63%)
Mutual labels:  mxnet
Crnn Mxnet Chinese Text Recognition
An implementation of CRNN (CNN+LSTM+warpCTC) on MxNet for chinese text recognition
Stars: ✭ 161 (+403.13%)
Mutual labels:  mxnet
MQBench Quantize
QAT(quantize aware training) for classification with MQBench
Stars: ✭ 29 (-9.37%)
Mutual labels:  resnet
Netron
Visualizer for neural network, deep learning, and machine learning models
Stars: ✭ 17,193 (+53628.13%)
Mutual labels:  mxnet

mxnet-finetuner-for-mac-no-docker

Create mxnet fine tuner for mac ,no need install docker and support GPU(egpu).

Prerequisites

python 2.7 mxnet(cpu) or mxnet-cu80 (you need setup egpu for mac) RUN pip install
attrdict
awscli
jupyter
matplotlib
nose
nose-timer
numpy
opencv-python
pandas
pandas_ml
Pillow
pylint
pyyaml
requests
seaborn
sklearn-pandas
slackclient
tqdm

Setup

1. Arrange images into their respective directories

A training data directory (images/train), validation data directory (images/valid), and test data directory (images/test) should containing one subdirectory per image class.

For example, arrange training, validation, and test data as follows.

images/
    train/
        airplanes/
            airplane001.jpg
            airplane002.jpg
            ...
        watch/
            watch001.jpg
            watch002.jpg
            ...
    valid/
        airplanes/
            airplane101.jpg
            airplane102.jpg
            ...
        watch/
            watch101.jpg
            watch102.jpg
            ...
    test/
        airplanes/
            airplane201.jpg
            airplane202.jpg
            ...
        watch/
            watch201.jpg
            watch202.jpg
            ...

2. Edit config/config.yml

Edit config.yml as you like.

For example

common:
  num_threads: 4
  gpus: 0

data:
  quality: 100
  shuffle: 1
  center_crop: 0

finetune:
  models:
    - imagenet1k-resnet-50
  optimizers:
    - sgd
  num_epochs: 30
  lr: 0.0001
  lr_factor: 0.1
  lr_step_epochs: 10,20
  mom: 0.9
  wd: 0.00001
  batch_size: 10

3. Do Fine-tuning

$ sh finetune.sh

mxnet-finetuner will automatically execute the followings according to config.yml.

  • Create RecordIO data from images
  • Download pretrained models
  • Replace the last fully-connected layer with a new one that outputs the desired number of classes
  • Data augumentaion
  • Do Fine-tuning
  • Make training accuracy graph
  • Make confusion matrix
  • Upload training accuracy graph and confusion matrix to Slack

Training accuracy graph and/or confusion matrix are save at logs/ directory.
Trained models are save at model/ directory.

Trained models are saved with the following file name for each epoch.

model/201705292200-imagenet1k-nin-sgd-0000.params

If you want to upload results to Slack, set SLACK_API_TOKEN environment variable and edit config.yml as below.

finetune:
  train_accuracy_graph_slack_upload: 1
test:
  confusion_matrix_slack_upload: 1

p1 continue: p1

4. Predict with trained models

Select the trained model and epoch you want to use for testing and edit config.yml

If you want to use model/201705292200-imagenet1k-nin-sgd-0001.params, edit config.yml as blow.

test:
  model: 201705292200-imagenet1k-nin-sgd-0001

When you want to use the latest highest validation accuracy trained model, edit config.yml as below.

test:
  use_latest: 1

If set this option, model is ignored.

When you are done, you can predict with the following command

$ docker-compose run finetuner test

Predict result and classification report and/or confusion matrix are save at logs/ directory.

Available pretrained models

model pretrained model name
CaffeNet imagenet1k-caffenet
SqueezeNet imagenet1k-squeezenet
NIN imagenet1k-nin
VGG16 imagenet1k-vgg16
Inception-BN imagenet1k-inception-bn
ResNet-50 imagenet1k-resnet-50
ResNet-152 imagenet1k-resnet-152
Inception-v3 imagenet1k-inception-v3
DenseNet-169 imagenet1k-densenet-169
SE-ResNeXt-50 imagenet1k-se-resnext-50

To use these pretrained models, specify the following pretrained model name in config.yml.

For details, please check Available pretrained models

Available optimizers

  • SGD
  • NAG
  • RMSProp
  • Adam
  • AdaGrad
  • AdaDelta
  • Adamax
  • Nadam
  • DCASGD
  • SGLD
  • Signum
  • FTML
  • Ftrl

To use these optimizers, specify the optimizer name in lowercase in config.yml.

Benchmark (Speed and Memory Footprint)

Single TITAN X (Maxwell) with batch size 40

Model speed (images/sec) memory (MiB)
CaffeNet 1077.63 716
ResNet-50 111.04 5483
Inception-V3 82.34 6383
ResNet-152 48.28 11330

For details, please check Benchmark

Utilities

counter.sh

Count the number of files in each subdirectory.

$ counter.sh testdir
testdir contains 4 directories
Leopards    197
Motorbikes  198
airplanes   199
watch       200

move_images.sh

Move the specified number of jpeg images from the target directory to the output directory while maintaining the directory structure.

$ move_images.sh 20 testdir newdir
processing Leopards
processing Motorbikes
processing airplanes
processing watch
$ counter.sh newdir
newdir contains 4 directories
Leopards    20
Motorbikes  20
airplanes   20
watch       20

Prepare sample images for fine-tuning

Download [Caltech 101] dataset, and split part of it into the example_images directory.

$ caltech101_prepare.sh
  • example_images/train is train set of 60 images for each classes
  • example_images/valid is validation set of 20 images for each classes
  • example_imags/test is test set of 20 images for each classes
$ counter.sh example_images/train
example_images/train contains 10 directories
Faces       60
Leopards    60
Motorbikes  60
airplanes   60
bonsai      60
car_side    60
chandelier  60
hawksbill   60
ketch       60
watch       60

With this data you can immediately try fine-tuning.

$ caltech101_prepare.sh
$ rm -rf images
$ mv exmaple_images images
$ sh finetune.sh

Misc

How to freeze layers during fine-tuning

If you set the number of target layer to finetune.num_active_layers in config.yml as below, only layers whose number is not greater than the number of the specified layer will be train.

finetune:
  models:
    - imagenet1k-nin
  optimizers:
    - sgd
  num_active_layers: 6

The default for finetune.num_active_layers is 0, in which case all layers are trained.

If you set 1 to finetune.num_active_layers, only the last fully-connected layers are trained.

You can check the layer numbers of various pretrained models with num_layers command.

$ sh finetune.sh num_layers <pretrained model name>

For details, please check How to freeze layers during fine-tuning

Training from scratch

Edit config.yml as below.

finetune:
  models:
    - scratch-alexnet

You can also run fine-tuning and training from scratch together.

finetune:
  models:
    - imagenet1k-inception-v3
    - scratch-inception-v3

For details, please check Available models training from scratch

Refrence

Mxnet-finetuner(https://github.com/knjcode/mxnet-finetuner)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].