LoginSignup
3
1

More than 3 years have passed since last update.

DockerでOpenPoseをインストールするメモ(仮)

Posted at

概要

  1. OpenCVをインストールしたDocker imageの準備
  2. CMakeのアップデート
  3. openposeのインストール

前提

  • Docker(Ubuntu18.04+CUDA10.1+cudnn7)でOpenCV4.1.1インストールするメモで作成したOpenCV4.1.1をインストールしたDocker imageを使用します。
  • OpenPoseは、CMUが公開しているCaffe実装のPython APIを利用できるようにします。
  • コピペで動くようにコマンドはそのまま貼りつけています。
    • historyから抽出して貼り付けているので、間違っているかも...
  • 不要なパッケージも入るけれどとりあえず動けばOK。

環境

  • 環境は下表の通り。

ホストPC

Name Version
OS Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU Intel® Core™ i5-8300H CPU @ 2.30GHz × 8
kernel Linux 5.0.0-23-generic
GPU NVIDIA GeForce GTX 1050

Docker image

Name Version
OS Ubuntu 18.04.2 LTS (Bionic Beaver)
LIB1 CUDA 10.1
LIB2 cudnn 7.6.2
LIB3 OepnCV 4.1.1

OpenPoseのインストール

  • Docker imageはこちらで作成したtest/opencv:4.1.1-ubuntu1804を使用
  • ソースコードはホスト側に保存してvolumeで共有
    • ホスト側の共有ディレクトリのパス/data

ソースコードのダウンロード

sudo apt install git
cd /data
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git

containerの起動

  • GUIを使えるようにオプションを指定
docker run --gpus 1 -it --rm --name opencv -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v /data/:/data test/opencv:4.1.1-ubuntu1804

CMakeのアップデート

ダウンロード

  • Download | CMakeから.shファイルをダウンロード
    • 作業時点ではcmake-3.15.2-Linux-x86_64.shでした。

(container内)install

apt remove cmake cmake-data
mv cmake-3.15.2-Linux-x86_64.sh /opt/
cd /opt/
bash ./cmake-3.15.2-Linux-x86_64.sh 
hash -r
ln -s /opt/cmake-3.15.2-Linux-x86_64/bin/* /usr/local/bin/
cmake --version

modelの事前ダウンロード

apt install curl
curl http://posefs1.perception.cs.cmu.edu/OpenPose/models/pose/body_25/pose_iter_584000.caffemodel -o pose_iter_584000.caffemodel
curl http://posefs1.perception.cs.cmu.edu/OpenPose/models/pose/coco/pose_iter_440000.caffemodel -o pose_iter_440000.caffemodel
curl http://posefs1.perception.cs.cmu.edu/OpenPose/models/face/pose_iter_116000.caffemodel -o pose_iter_116000.caffemodel
curl http://posefs1.perception.cs.cmu.edu/OpenPose/models/hand/pose_iter_102000.caffemodel -o pose_iter_102000.caffemodel
curl http://posefs1.perception.cs.cmu.edu/OpenPose/models/pose/mpi/pose_iter_160000.caffemodel -o pose_iter_160000.caffemodel
cp pose_iter_584000.caffemodel openpose/models/pose/body_25/
cp pose_iter_440000.caffemodel openpose/models/pose/coco/
cp pose_iter_160000.caffemodel openpose/models/pose/mpi/
cp pose_iter_116000.caffemodel openpose/models/face/
cp pose_iter_102000.caffemodel openpose/models/hand/

関連パッケージのインストール

apt-get install -yq --no-install-recommends --no-upgrade software-properties-common curl  python3-dev python3-tk  locales  libatlas-base-dev libprotobuf-dev libleveldb-dev  libsnappy-dev libhdf5-serial-dev protobuf-compiler libboost-all-dev libgflags-dev libgoogle-glog-dev liblmdb-dev opencl-headers ocl-icd-opencl-dev libviennacl-dev
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
pip install --no-cache-dir Cython
pip install --no-cache-dir numpy protobuf

install

cd openpose/
mkdir build && cd build
cmake -D BUILD_PYTHON=ON ..
make -j4
make install
cd python/
make install

確認

  • python APIのサンプルコードを実行する
cd /data/openpose/build/examples/tutorial_api_python/
python3 01_body_from_image.py 
3
1
1

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