在anaconda環境下安裝 google的object_detecthon,主要涉及Protoc的配置,object_detecthon環境變量配置等工作。
前期準備工作:
(1)在anaconda環境下安裝配置好TensorFlow,並且設置好並進入TensorFlow環境。由於機器原因,我使用的CPU版的TensorFlow。
A:檢查Python的支持:conda search --full --name python
B:安裝TensorFlow環境(我使用的是最新版Python3.7):conda create –-name tensorflow python=3.7,根據提示進行安裝對應的包。安裝成功後會出現:提示。
C:使用命令activate TensorFlow激活TensorFlow工作環境。
D:安裝TensorFlow-cpu版:pip install tensorflow,根據網絡情況等待安裝完成。
F:測試:打開anaconda navigation,找到TensorFlow環境,並打開jupyter notebook(或者直接在命令行下輸入jupyter notebook)啓動編輯器,輸入代碼:
import tensorflow as tf
hello =tf.constant("Hello")
sess=tf.Session()
print(sess.run(hello))
運行成功,則tensorflow安裝正確。
(2)通過git桌面版下載object_detecthon源碼(https://github.com/tensorflow/models)。最好使用git桌面版下載,網頁版下載超級慢。下載完成後,配置models的系統環境變量。環境變量名爲PYTHONPATH,變量值根據自己的環境進行修改。
(3)下載並配置Protoc(https://github.com/protocolbuffers/protobuf/releases,同樣建議用git桌面版下載)。然後將Protoc。exe放到C:\Windows\system32目錄下,然後進入到models\research\目錄下按住shif+鼠標右鍵,打開powershell窗口,運行:Get-ChildItem object_detection/protos/*.proto |Resolve-Path -Relative | %{protoc $_ --python_out=.}命令。運行成功,就會發現F:\OD\models\research\object_detection\protos文件增加.py文件。
(4)測試:詳情見:https://blog.csdn.net/dy_guox/article/details/79081499
測試代碼參考:https://blog.csdn.net/dy_guox/article/details/79111949