■ 設定環境
`# | `項目 | `項目値 | `備考 |
補足
Anaconda(アナコンダ)について* Python本体と、Pythonでよく利用されるライブラリを簡単に導入できる * 詳細は以下のサイトを参照のこと。http://programming-study.com/trouble/anaconda/
http://nonbiri-tereka.hatenablog.com/entry/2017/03/07/080000#Anaconda%E3%81%A8%E3%81%AF
■ 構築手順
【1】Anacondaのインストール 【2】Anaconda仮想環境作成 【3】TensorFlowのインストール 【4】確認 ※ 以下のサイトを見ながら、やるといい。https://qiita.com/FukuharaYohei/items/d8f82c827e0bae70096a
【1】Anacondaのインストール
[1-1] 以下のサイトからダウンロード(今回は「Python 3.6 version」の「Anaconda3-5.1.0-Windows-x86_64.exe」)し、 Exeファイルをたたくだけhttps://www.anaconda.com/download/
【2】Anaconda仮想環境作成
[2-1] [Enviroments]-[Create]を選択し、以下を入力し「Create」ボタン押下 + Name : tensorflow + Package : Python3.5 (★注意★ Python3.6ではない) [2-2] [Home]を選択し、「Application on」で[2-1]で作成した「tensorflow」を選択 [2-3]「Jupytor Notebook」の「Install」ボタン押下して、Jupytor Notebookをインストールする
【3】TensorFlowのインストール
[3-1] [Enviroments]を選択し、「Application on」で[2-1]で作成した「tensorflow」の「▶」アイコン→ 「Open Terminal」を選択(コマンドプロンプトが開く) [3-2] コマンドプロンプトで以下を入力し、TensorFlowをインストールする ~~~~~ pip install --ignore-installed --upgrade tensorflow ~~~~~
【4】確認
[4-1] コマンドプロンプトで以下を入力し、Pythonする ~~~~~ python ~~~~~ [4-2] コマンドプロンプトで以下を入力し、TensorFlow のバージョン確認 ~~~~~ import tensorflow as tf tf.__version__ # '1.5.0' と表示 ~~~~~ [4-3] コマンドプロンプトで以下を入力し、Hello World ~~~~~ import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) ~~~~~ [4-4] コマンドプロンプトで以下を入力し、終了 ~~~~~ exit() # 仮想環境から抜けるには「deactivate」コマンドを実行 deactivate exit ~~~~~
■ 画像認識
https://qiita.com/FukuharaYohei/items/3bc6d83f0e24110534b2を参考に、画像認識を行ってみる
手順
[1] 以下のサイトから「classify_image.py」をダウンロードするhttps://github.com/tensorflow/models/blob/master/tutorials/image/imagenet/classify_image.py
[2] [Enviroments]を選択し、「Application on」で[2-1]で作成した「tensorflow」の「▶」アイコン→ 「Open Terminal」を選択し、コマンドプロンプトが開く [3] 以下を入力 ~~~~~ # 仮想環境有効化 activate tensorflow # classify_image.pyを置いたディレクトリに移動 cd C:\Users\User\Downloads # python classify_image.py ~~~~~ [4] 「python classify_image.py --image_file=【画像認識対象の画像ファイル】」で画像認識 ~~~~~ python classify_image.py --image_file=candle.jpg ~~~~~
参考文献
https://qiita.com/FukuharaYohei/items/d8f82c827e0bae70096aTensorFlowのバージョン確認
https://qiita.com/Leonhard/items/a65d146179710f77b40d画像認識
https://qiita.com/FukuharaYohei/items/3bc6d83f0e24110534b2https://qiita.com/egplnt/items/4a27025fc0777c4037fe
https://qiita.com/kenmaz/items/4b60ea00b159b3e00100