Tensorflow related

How to Retrain Inception's Final Layer for New Categories

步驟:

一 Installing TensorFlow on Ubuntu   

https://www.tensorflow.org/install/install_linux

二 Install Bazel on Ubuntu

https://bazel.build/versions/master/docs/install-ubuntu.html


三 下載代碼 

git clone https://github.com/tensorflow/tensorflow.git

~/tensorflow$  ./configure

四 編譯

bazel build tensorflow/examples/image_retraining:retrain

五 注意事項:

1  bazel-bin/tensorflow/examples/label_image/label_image --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt --output_layer=final_result --image=/home/camille/Desktop/timg.jpg


命令報錯:

017-06-20 12:52:52.774446: E tensorflow/examples/label_image/main.cc:350] Running model failed: Not found: FeedInputs: unable to find feed output input

解決方案:在後面加一句 --input_layer=Mul //this parameter update the input and output layer names to "Mul" and "final_result" respectively

2下載tensorflow 代碼時,

git clone https://github.com/tensorflow/tensorflow.git

直接執行 bazel build tensorflow/examples/image_retraining:retrain

報錯 build aborted

解決方案: 執行 ./configure 

再執行 bazel build tensorflow/examples/image_retraining:retrain 就沒問題了。

3  Bazel 安裝之前一定要安裝jdk


sudo apt-get install oracle-java8-installer

I recommend you to use Webup8 Oracle Java8 Installer


sudo add-apt-repository ppa:webupd8team/java

sudo apt update; sudo apt-get install oracle-java8-installer

or 

sudo apt update; sudo apt-get install oracle-java8-set-default


4 執行 


bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir ~/flower_photos

時報錯:1)

   File "/home/karthik/tensorflow/bazel-bin/tensorflow/examples/image_retraining/retrain.runfiles/org_tensorflow/tensorflow/python/util/tf_should_use.py", line 28, in <module>
       from backports import weakref  # pylint: disable=g-bad-import-order
   ImportError: No module named backports

解決方案:安裝所需module

sudo pip install backports.weakref
sudo pip3 install backports.weakref

報錯2) 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy
Is numpy installed?

解決方案: sudo apt-get install python-numpy

5 ImportError: No module named mock

實際上安裝了,所以只能先刪除再安裝了

解決方案: 

$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/mock
$ sodo rm -rf /usr/local/lib/python2.7/dist-packages/mock-2.0.0.dist-info

then type the following command to install mock

$ sudo pip install --upgrade mock


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章