LoginSignup
1
3

More than 5 years have passed since last update.

MacでOpenPose(tf-pose-estimation)のHelloWorldをしました

Last updated at Posted at 2019-02-06

目的

ポーズ推定をMacで試します。

前提

ポーズ推定と言えばOpenPoseがまず浮かんだのでそれを試そうと思いました。結果的に試すことができました。
特筆する内容はありませんが、公式ページを上から追っただけだと少しひかっかったので、自分が後にやろうとしてまた忘れてひっかかると思うのでメモします。
またvirtualenvを使っている部分については、公式のInstallのセクションにはないように必要ではないです。

環境

macOS High Sierra 10.13.6
python 3.6.5

時期

2019.02.06

手順

作業用ディレクトリを作ります

$ mkdir tf-pose-estimation-test
$ cd tf-pose-estimation-test

仮想環境を作り、起動します

$ virtualenv --system-site-packages -p -python3 testenv
$ source testenv/bin/activate

tf-pose-estimationのリポジトリをcloneします

$ git clone https://www.github.com/ildoonet/tf-pose-estimation
$ cd tf-pose-estimation

必要なモジュールをインストールします

$ pip3 install -r requirements.txt

ポストプロセス用のC++ライブラリをビルドします

$ cd tf_pose/pafprocess
$ swig -python -c++ pafprocess.i && python3 setup.py build_ext --inplace
$ cd ../..

Tensorflowグラフファイルをダウンロードします

$ cd models/graph/cmu
$ bash download.sh

テスト実行します

$ cd ../../..
$ python -c 'import tf_pose; tf_pose.infer(image="./images/p1.jpg")'

不足しているとエラーが出たものを適宜入れます

$ pip3 install opencv-python
$ pip3 install tensorflow

テスト実行します

$ python -c 'import tf_pose; tf_pose.infer(image="./images/p1.jpg")'

a.png

実行できました。

補足

他にも環境面でいくつかつまづいたことがあって

XCodeのコマンドラインツールが入っていなかった

入れました

TensorFlowのインストールでこけた

$ pip3 install tensorflow

のところでこんなエラーが出たので

Collecting tensorflow
  Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

はじめはpython 3.7.xがインストール済みだったんですが、調べると下記参考サイトのようにまだ3.7.xに対応してないようで。

Tensorflowがインストール出来ない症状を解決する方法(Python 3.7.0) - Qiita
https://qiita.com/locktki/items/abb04846f2251f357650

【対処法】Python3.7ではTensorFlowを利用できない..?
https://pycarnival.com/tensorflow_python37/

3.7から3.6にするのにはインストールには以下あたりを参考にした気がします。

macOSでPythonをHomebrewでインストールしている場合にPython 3.6 系を使う方法 - Qiita
https://qiita.com/Ryuichirou/items/44a45170c1b2781367f8

3.6.5にダウンバージョンしたら動きました。

参考

GitHub - ildoonet/tf-pose-estimation: Deep Pose Estimation implemented using Tensorflow with Custom Architectures for fast inference.
https://github.com/ildoonet/tf-pose-estimation

Openposeのインストール(mac) - Qiita
https://qiita.com/piyopiyohiyoko/items/a9220c3b2f0e75e1a460

1
3
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
1
3