Página generada en Oct 17, 2018 7:53:17 AM

WatchStarForkSeguir @josechavarriacr

Dec 5, 2017

Image Recognition with TensorFlow

# Install TensorFlow

# Clone the git repository

git clone https://github.com/googlecodelabs/tensorflow-for-poets-2
cd tensorflow-for-poets-2

# Download the training images

curl http://download.tensorflow.org/example_images/flower_photos.tgz \ | tar xz -C tf_files

# (Re)training the network

The retrain script can retrain eitherInception V3 model or a MobileNet. In this exercise, we will use a MobileNet. The principal difference is that Inception V3 is optimized for accuracy, while the MobileNets are optimized to be small and efficient, at the cost of some accuracy.

# Config Linux


# Start TensorBoard

tensorboard --logdir tf_files/training_summaries &

You can open TensorBoard in your browser

# Run the training

python -m scripts.retrain \
  --bottleneck_dir=tf_files/bottlenecks \
  --how_many_training_steps=500 \
  --model_dir=tf_files/models/ \
  --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}" \
  --output_graph=tf_files/retrained_graph.pb \
  --output_labels=tf_files/retrained_labels.txt \
  --architecture="${ARCHITECTURE}" \

# The retraining script writes data to the following two files:

  • tf_files/retrained_graph.pb, which contains a version of the selected network with a final layer retrained on your categories.
  • tf_files/retrained_labels.txt, which is a text file containing labels.

# Classifying an image

python -m scripts.label_image \
    --graph=tf_files/retrained_graph.pb  \

# Result

daisy (score = 0.99071) 
sunflowers (score = 0.00595) 
dandelion (score = 0.00252) 
roses (score = 0.00049) 
tulips (score = 0.00032)

comentarios proporcionados por Disqus