【目次】
手順の要点: 前準備として,NVIDIA CUDA 10.0, NVIDIA cuDNN 7.6.5, Python 3.7, TensorFlow 1.15.5 等をインストール.
ソフトウェア等の利用条件等は,利用者で確認すること.
謝辞:ソフトウェアの作者に感謝します
Windows での Git のインストール: 別ページ »で説明
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
【Python のインストールでの注意点】
Windows で,ユーザ名が日本語のとき,あとでトラブルが発生するかもしれない. トラブルの回避のため, Python をシステム管理者の領域にインストール(パソコンの全ユーザの共有領域)する.
【Python 3.7 のインストール手順の詳細(別ページ) 】
Windows での Python 3.7 のインストール: 別ページ »で説明
【Python の公式ページ】
【インストール手順の概要】
ページの上の方にある「Downloads」をクリック,「Downloads」の下にメニューが出るので,その中の「Windows」をクリック.
そして,Python 3.7.x (x は数字)を探す.
そして,Windows の 64ビット版のインストーラをダウンロードしたいので,「Windows x86-64 executable installer」を選ぶ
※ すでに Python ランチャーをインストール済みのときは, 「Install launcher for all users (recommended)」がチェックできないようになっている場合がある.そのときは,チェックせずに進む.
Python のインストールディレクトリは,「C:\Program Files\Python37」のように自動設定されることを確認.
「Install」をクリック
py とpip にパスが通っていることの確認である.
where py where pip
where py では「C:\Windows\py.exe」 が表示され, where pip では「C:\Program Files\Python37\Scripts\pip.exe」 が表示されることを確認.
Python の使用は「py -3.7」で行う.
py -3.7 -m pip install -U pip setuptools
コマンドプロンプトを管理者として実行: 別ページ »で説明
次のコマンドを実行する
次のコマンドを実行する
Python の使用は「C:\venv\py37\Scripts\activate.bat」の後,「python」で行う.
C:\venv\py37\Scripts\activate.bat python -m pip install -U pip setuptools jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter
Windows での Visual Studio Community 2017,NVIDIA ドライバ,NVIDIA CUDA ツールキット 10.0,NVIDIA cuDNN 7.6.5 のインストール: 別ページ »で説明
py -3.7 -m pip uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tensorflow-intel tensorflow-text tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer scipy pandas matplotlib # TensorFlow 1.15.5 のため numpy, protobuf の古いバージョンを使用.エラーが出にくいと考えられる numpy 1.16.2, protobuf 3.19.4 を使用 py -3.7 -m pip install -U numpy==1.16.2 protobuf==3.19.4 tensorflow-gpu==1.15.5 keras==2.3.1 scipy==1.5.4 py -3.7 -m pip install git+https://github.com/tensorflow/docs py -3.7 -m pip install git+https://github.com/tensorflow/examples.git py -3.7 -m pip install git+https://www.github.com/keras-team/keras-contrib.git
Windows での手順を下に示す.Ubuntu でも同様の手順になる.
cd %HOMEPATH% rmdir /s /q deepgaze
cd %HOMEPATH% git clone https://github.com/mpatacchiola/deepgaze cd deepgaze py -3.7 setup.py build py -3.7 setup.py install
エラーメッセージが出ていないこと.
Windows での手順を下に示す.Ubuntu でも同様の手順になる.
cd %HOMEPATH% cd deepgaze\examples\ex_cnn_head_pose_estimation_images py -3.7 ex_cnn_head_pose_estimation_images.py
ここで使用する mp4 形式動画ファイル: sample1.mp4
mkdir c:\image cd c:\image curl -O https://www.kkaneko.jp/sample/face/sample1.mp4
ファイルのコピー
cd %HOMEPATH% cd deepgaze\examples\ex_cnn_head_pose_estimation_images copy ex_cnn_head_pose_estimation_images.py a.py
notepad a.py
v = cv2.VideoCapture("c:/image/sample1.mp4") while(v.isOpened()): r, img = v.read() if ( r == False ): break img = cv2.resize(img, (480, 480)) roll = my_head_pose_estimator.return_roll(img) # Evaluate the roll angle using a CNN pitch = my_head_pose_estimator.return_pitch(img) # Evaluate the pitch angle using a CNN yaw = my_head_pose_estimator.return_yaw(img) # Evaluate the yaw angle using a CNN print("roll %s, pitch %s, yaw %s" % ( str(roll[0,0,0]), str(pitch[0,0,0]), str(yaw[0,0,0]) ) ) cv2.imshow("", img) # Press Q to exit if cv2.waitKey(1) & 0xFF == ord('q'): break v.release() cv2.destroyAllWindows()
編集したら,ファイルを「上書き保存」する
py -3.7 a.py
v = cv2.VideoCapture(0) while(v.isOpened()): r, img = v.read() if ( r == False ): break img = cv2.resize(img, (480, 480)) roll = my_head_pose_estimator.return_roll(img) # Evaluate the roll angle using a CNN pitch = my_head_pose_estimator.return_pitch(img) # Evaluate the pitch angle using a CNN yaw = my_head_pose_estimator.return_yaw(img) # Evaluate the yaw angle using a CNN print("roll %s, pitch %s, yaw %s" % ( str(roll[0,0,0]), str(pitch[0,0,0]), str(yaw[0,0,0]) ) ) cv2.imshow("", img) # Press Q to exit if cv2.waitKey(1) & 0xFF == ord('q'): break v.release() cv2.destroyAllWindows()
Python プログラムの実行
py -3.7 a.py