LoginSignup
2
0

More than 3 years have passed since last update.

OpenVINO の名付け有り顔認識デモを Docker でそのまま使うだけ

Posted at

前は interactive_face_detection_demo を動かしましたが、同様に face_recognition_demo を動かします。OpenVINO 2020.3 にはあったデモですが、OpenVINO 2020.4 には入ってなさそうでした。なので 2020.3 で実行します。

output-palette.gif

Docker で実行

2020.4 にしたり 2020.3 にしたりが便利なので Docker で実行します。(GUI を操作するのが大変そうなため、Google Colab では試していません。)

X11 サーバのインストール

このデモは不明な顔が出た時、名前を入力するとその場で顔画像と共に保存される機能があります。GUI から入力するため、Docker から窓を立ち上げられるよう設定します。

今回はホスト OS (Windows 10) 側で X11 サーバを立ち上げ、コンテナ (Ubuntu 18) の窓を Windows 10 上に飛ばせるようにしました。Windows 10 なので、VcXsrv の 1.20.8.1 をインストール・起動し、Windows ファイアウォールの設定でプライベートネットワークを許可しておきました。docker コンテナからホスト OS への接続アドレスは localhost ではないので、ipconfig で確認しておきます。

ipconfig
~~~
イーサネット アダプター vEthernet (WSL):

   接続固有の DNS サフィックス . . . . .:
   リンクローカル IPv6 アドレス. . . . .: fe80::6ca1:e659:80eb:a804%18
   IPv4 アドレス . . . . . . . . . . . .: 172.25.64.1 (ココが DISPLAY 接続先)
   サブネット マスク . . . . . . . . . .: 255.255.240.0
   デフォルト ゲートウェイ . . . . . . .:

上記の例だと 172.25.64.1 が DISPLAY 接続先になります。

Docker 起動・デモの実行

docker run \
  -v /c/Users/${USER}/Downloads:/Downloads \
  -u root \
  -it \
  --rm \
  -e DISPLAY=172.25.64.1:0.0 \
  openvino/ubuntu18_dev:2020.3

172.25.64.1 の部分は↑↑で確認したアドレスです。ライブラリの追加やビルドは不要なため、root じゃなくても動くかもですが、モデルパス等を前回同様にしたかったので root になっています。2020.4 にないデモなので 2020.3 を立ち上げています。

以下コンテナ内で作業

${INTEL_CVSDK_DIR}/deployment_tools/tools/model_downloader/downloader.py \
  --name face-detection-retail-0004,landmarks-regression-retail-0009,face-reidentification-retail-0095 \
  --output_dir /content/model/ \
  --precisions FP32

face_recognition_demo で使いたい学習済モデルを、付属のダウンローダーで落としてきます。

mkdir -p /Downloads/face_gallery/
cd ${INTEL_CVSDK_DIR}/inference_engine/demos/python_demos/face_recognition_demo/
python3 ./face_recognition_demo.py \
  -m_fd /content/model/intel/face-detection-retail-0004/FP32/face-detection-retail-0004.xml \
  -m_lm /content/model/intel/landmarks-regression-retail-0009/FP32/landmarks-regression-retail-0009.xml \
  -m_reid /content/model/intel/face-reidentification-retail-0095/FP32/face-reidentification-retail-0095.xml \
  --input /Downloads/input.mp4 \
  --output /Downloads/output.mp4 \
  -fg /Downloads/face_gallery/ \
  --allow_grow

Python なのでビルドは不要です。また、マニュアルに pip3 install -r requirements.txt の記載がありますが、依存モジュールも既に入っているので不要でした。起動後、--allow_grow をつけているので、不明な顔があれば適宜訊かれるようになります。その際、顔画像は face_gallery に保存されます。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0