ruk·si

Transfer Learning
Inception

Updated at 2016-11-21 18:52

Inception Model

Inception-v3 model is trained for the ImageNet Large Visual Recognition Challenge using the data from 2012. It classifies whole images to 1000 classes like zebra or dishwasher.

Here is a walkthrough how to apply transfer learning to inception model by using TensorFlow's image_retraining example code.

# You can also check to use the latest from:
# https://console.cloud.google.com/gcr/images/tensorflow/GLOBAL/tensorflow

docker pull gcr.io/tensorflow/tensorflow:1.3.0-devel
docker run -it --rm gcr.io/tensorflow/tensorflow:1.3.0-devel

cd ~/Projects
mkdir ttf
mkdir ttf/data

# Add positive match images to separate directories inside /data
mkdir ttf/data/vader
mkdir ttf/data/jabba
mkdir ttf/data/han

# Note that the training works only for JPGs;
# here is ImageMagick script to convert PNGs to JPGs in the current directory
for f in *.png; do convert ./"$f" ./"${f%.png}.jpg"; done

docker run -it --rm \
    -v ~/Projects/ttf:/ttf \
    gcr.io/tensorflow/tensorflow:1.3.0-devel

python /tensorflow/tensorflow/examples/image_retraining/retrain.py \
        --output_graph=/ttf/retrained_graph.pb \
        --output_labels=/ttf/retrained_labels.txt \
        --bottleneck_dir=/ttf/bottlenecks \
        --model_dir=/ttf/model \
        --image_dir=/ttf/data \
        --how_many_training_steps=500

# Download a _new_ image to try for validation to ~/Projects/ttf/validation

python /tensorflow/tensorflow/examples/image_retraining/label_image.py \
  --graph=/ttf/retrained_graph.pb \
  --labels=/ttf/retrained_labels.txt \
  --image=/ttf/validation/vader-pumping-iron.jpg

# =>
# vader (score = 0.97595)
# jabba (score = 0.02405)

Sources