LoginSignup
4
6

More than 3 years have passed since last update.

OpenVINO の顔検出デモを (Google Colab|Docker) でそのまま使うだけ

Last updated at Posted at 2020-09-15

Intel 入ってたら動く OpenVINO の Toolkit についてくる interactive_face_detection_demo が、そのまま動かすだけでそこそこ使えて嬉しかったのでメモです。以下 OpenVINO 2020.4 での情報になります。

openvino_demo_input.gif

openvino_demo_output.gif

Google Colab を利用する場合

Google Colab はIntel CPU を利用しているようなので、Colab 上で動かせます。

実際に動かした Notebook はこちらです。

インストールはLinux 用のインストール手順を実施していくだけ、demo のビルド・実行は下記 Docker を利用する部分と同じなので、解説は割愛しています。

ただ、Colab を起動する度にインストールを待つのが面倒なのと、特性上出力ファイルがかなり大きくなるのでファイルのダウンロードが面倒なのと、そもそも Colab の CPU はそんなに早くないことが微妙なところです。Intel 入ってる環境があるなら、ローカルにファイルを直接書き込める 以下 Docker を使った方法が楽かも知れません。

ローカルに直接環境を構築する場合

既存環境と干渉するらしい記事を見たのでなんとなく避けました。インストールの項を実施していけば問題ないと思います。

Docker を利用する場合

docker run -v /c/Users/${USER}/Downloads:/Downloads -u root -it --rm openvino/ubuntu18_dev:2020.4

demo を使いたいので demo 入りの _dev を使います
ファイルをやり取りするのでダウンロードディレクトリをマウントして、インストールファイルをイジりたいので root になります。自分は Windows 10 上で動かしているので CPU only しか対応してなかったですが、対応環境では docker にオプションを渡すことで GPU などにも対応するようです。

以下コンテナ内で作業

cd ${INTEL_CVSDK_DIR}/inference_engine/demos/
sed -i 's/*)/interactive_face_detection_demo)/g' CMakeLists.txt
./build_demos.sh

そのままだと他 demo のビルドも待たないといけないので、使いたい interactive_face_detection_demo だけに絞っています。他 demo も使ってみたい方は sed を抜いてください。

${INTEL_CVSDK_DIR}/deployment_tools/tools/model_downloader/downloader.py \
  --name face-detection-adas-0001,age-gender-recognition-retail-0013,head-pose-estimation-adas-0001,emotions-recognition-retail-0003,facial-landmarks-35-adas-0002 \
  --output_dir /content/model/ \
  --precisions FP32

interactive_face_detection_demo で使いたい学習済モデルを、付属のダウンローダーで落としてきます。face-detection などモデルがいくつもあるやつはどれを使えばいいのか迷いますが、適当に変えたら死ぬほど遅くなったりした(100倍ぐらい)ので注意です。とりあえず上記はドキュメントで指定があったものです。

/root/omz_demos_build/intel64/Release/interactive_face_detection_demo \
  -i /Downloads/input.mp4 \
  -m /content/model/intel/face-detection-adas-0001/FP32/face-detection-adas-0001.xml \
  -m_ag /content/model/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013.xml \
  -m_hp /content/model/intel/head-pose-estimation-adas-0001/FP32/head-pose-estimation-adas-0001.xml \
  -m_em /content/model/intel/emotions-recognition-retail-0003/FP32/emotions-recognition-retail-0003.xml \
  -m_lm /content/model/intel/facial-landmarks-35-adas-0002/FP32/facial-landmarks-35-adas-0002.xml \
  -no_show \
  -no_wait \
  -async \
  -o /Downloads/output.mp4

オプションは他にもありますが、とりあえず上記で動画を変換できました。

4
6
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
4
6