liunx
sudo apt-get install python-pip python-dev
python2.X -> pip
python3.X -> pip3
pip --version
pip install --upgrade pip
pip --version
pip3 --version
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
pip uninstall tensorflow
或者pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
第一個實例:
1。按上面,先安裝好tensorflow
2.安裝Inception-V3模型到任意目錄中,並解壓出來:
mkdir /mnt/tensorflow/model
cd /mnt/tensorflow/model
wget http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz
tar -zxvf inception-2015-12-05.tgz
3.把要識別的jpg放到一個目錄下面:
例如:/mnt/tensorflow/test-images/1.jpg
4.執行
cd /usr/lib/python2.7/site-packages/tensorflow/models/image/imagenet
python classify_image.py --model_dir /mnt/tensorflow/model --image_file /mnt/tensorflow/test-images/1.jpg
5.看輸出結果,得出評分比較大的那個選項:
[root@izuf63bjp8ts8nkl13pxh1z imagenet]# python classify_image.py --model_dir /mnt/tensorflow/model --image_file /mnt/tensorflow/test-images/1.jpg
W tensorflow/core/framework/op_def_util.cc:332] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().
mountain bike, all-terrain bike, off-roader (score = 0.56188)
tricycle, trike, velocipede (score = 0.12604)
bicycle-built-for-two, tandem bicycle, tandem (score = 0.08763)
lawn mower, mower (score = 0.00637)
alp (score = 0.00387)
我圖像識別的是一輛自行車。
第二個實例:
TensorBoard是Tensorflow的可視化工具。Tensorflow安裝好后,TensorBoard自然就裝好了。於是,下面只剩下怎么啟動它的問題。
tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries
其中,--logdir參數指定的目錄,TensorBoard會從這個路徑下讀取數據並可視化展示在web頁面中。
過一會就會看到命令行提示: