Transfer Learning

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:

docker pull
docker run -it --rm

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 \

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

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

python /tensorflow/tensorflow/examples/image_retraining/ \
  --graph=/ttf/retrained_graph.pb \
  --labels=/ttf/retrained_labels.txt \

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