“TensorFlow for poets” command line setup in linux
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0
This setup has been tested e.g. with the University of Helsinki’s virtual environment, from which you can find more here.
Create virtual environment
Virtual environment is especially useful if you use virtual desktop – e.g. the tensorboard tries to install itself to common environment, which will not succeed.
virtualenv tepoet
Activate the virtual environment . Note this changes e.g. path so it uses the one under the tepoet/bin -directory
source tepoet/bin/activate
TensorFlow details:
(Skipped tensorboard due to above mentioned environment issue, but within virtualenv using tensorboard should be fine).
Install tensorflow and get the scripts from the tensorflow github.
pip install --upgrade tensorflow git clone https://github.com/googlecodelabs/tensorflow-for-poets-2 cd tensorflow-for-poets-2/ curl http://download.tensorflow.org/example_images/flower_photos.tgz \ | tar xz -C tf_files ls tf_files/flower_photos/
Next thing is to to create the model and run the actual classifier to a image used in this post.
export IMAGE_SIZE=224 export ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}" python -m scripts.retrain -h 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}" --image_dir=tf_files/flower_photos python -m scripts.label_image -h python -m scripts.label_image --graph=tf_files/retrained_graph.pb \ --image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg python -m scripts.label_image --graph=tf_files/retrained_graph.pb\ --image=tf_files/flower_photos/roses/2414954629_3708a1a04d.jpg
And finally run the classifier against your own image
python -m scripts.label_image --graph=tf_files/retrained_graph.pb \ --image=995706_kukka_1905.png
The results should be :
Evaluation time (1-image): 0.501s roses 0.4427891 dandelion 0.36607185 sunflowers 0.1426634 tulips 0.0484466 daisy 2.9001703e-05
Remember to register to the DHN18 , and pick “Miniature histories – Digitized newspapers and cultural heritage assets as source for the local history” as your workshop!
Pingback: Sanomalehtikuvitusten luokittelusta | Digitalia
Pingback: TensorFlow setup for image classification example in Windows | Digitalia