shanev / keras-food-classifier

Multi-class food classifier convoluted neural network in Keras

Home Page:http://notnothotdog.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NVIDIA DIGITS CNN training

Based on http://reza.codes/2017-07-29/how-to-train-your-own-dataset-for-coreml/.

  1. Compress image data
cd ~/Dropbox/SousChef/data
tar -zcvf food.tar.gz food
  1. Upload to AWS

aws s3 cp food.tar.gz s3://souschef.ai/data/food.tar.gz --acl public-read

  1. Start instance

aws ec2 start-instances --instance-ids i-0ade0ef688dee181e

  1. Get instance public IP
aws ec2 describe-instances \
  --query "Reservations[*].Instances[*].PublicIpAddress" \
  --output=text | pbcopy
  1. Login to DIGITS and upload data
cd ~/Projects/MachineLearning/keras/food
ssh -i DIGITS/digits.pem ubuntu@[PUBLIC IP ADDRESS]
cd data
wget -O food.tar.gz "https://s3.amazonaws.com/souschef.ai/data/food.tar.gz"
tar xvzf food.tar.gz
chmod -R 0755 food

Note: May need to add SSH inbound rule for MyIP in security policy.

  1. Train model

Go to IP address in previous step for DIGITS web interface.

Datasets -> New Dataset -> Classification

Folder: /home/ubuntu/data/food/images

Models -> New Model -> Classification

Change base learning rate to 0.001

Pretrained model: /home/ubuntu/models/bvlc_alexnet.caffemodel

Use caffe.json, or select Previous Networks and customize.

Model name: Foods

  1. Stop instance

aws ec2 stop-instances --instance-ids i-0ade0ef688dee181e

  1. Download model and convert to CoreML

Unzip to DIGITS/caffe_model

Modify run.py with new model name, i.e: snapshot_iter_1230.caffemodel

source activate coreml
cd DIGITS && python run.py
  1. Upload CoreML model to S3:
aws s3 cp ../models/Foods.mlmodel s3://souschef.ai/coreml/Foods.mlmodel --acl public-read

About

Multi-class food classifier convoluted neural network in Keras

http://notnothotdog.com


Languages

Language:Jupyter Notebook 51.5%Language:Python 47.7%Language:Shell 0.8%