0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AlphaPoseを動かす

Posted at

概要

今からAlphaPoseを動かそうとしたとき、色々苦戦したのでまとめました。
GPUなしで動かそうとしましたが、面倒なことになったのでGPUを使います。

環境

  • Ubuntu 24.04(Proxmox上)
  • GTX 1070
  • Python 3.8
  • CUDA 12.9

前準備

CUDAのインストール

ここからCUDAをダウンロードしてください。
いろいろ試しましたがCUDA 12.1と2はインストール段階で引っかかって動きませんでした。
ちなみに、aptなどを使ってインストールしようとしても/usr/local/cuda/binに必要なファイルが設置されないため後々エラーになります。
今のところ12.9が一番安定しています。

インストール

1.venvを作成

このとき、Python3.8以上のバージョンを使うと後々面倒なことになります。

python3 -m venv venv

2.GitHubからリポジトリをクローン

gitで拾ってきます。

git clone https://github.com/MVIG-SJTU/AlphaPose

3.torch系のパッケージをインストール

CUDA 12.1を使っていますが、CUDA.xであれば動作すると思います。

pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121

4.パスを通して更に必要になりそうなパッケージをインストール

export PATH=/usr/local/cuda/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH

cythonのバージョンが特定のものでないとエラーがでます。
https://github.com/MVIG-SJTU/AlphaPose/issues/1188

python3 -m pip install cython==0.29.20 git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI matplotlib scipy

aptからインストール

sudo apt install libyaml-dev

5.setup.pyの実行

しばらく待機

python3 setup.py build develop

6.パッケージの上書き

setup.pyにてcython_bboxというパッケージがインストールされます。しかし、このパッケージは現在のnumpyのバージョンに対応しておらず動きません。
そこで、フォークされたパッケージを使用することで回避します。
https://github.com/MVIG-SJTU/AlphaPose/issues/1148

pip uninstall cython_bbox
pip install git+https://github.com/valentin-fngr/cython_bbox.git 

7.モデルをダウンロードする

推定モデル

自分にあったモデルをダウンロードしてディレクトリに配置してください。
https://github.com/MVIG-SJTU/AlphaPose/blob/master/docs/MODEL_ZOO.md
今回はHalpe datasetのFastPoseを使います。
モデルをダウンロードしたら、所定のディレクトリにコピーします。

scp halpe26_fast_res50_256x192.pth pose@192.168.0.12:~/AlphaPose/pretrained_models

必要に応じてConfigもダウンロードし、~/AlphaPose/configs/にコピーしてください。

検出器

デフォルトでは入っていないため、各自でダウンロードする必要があります。
今回はYOLO v3を使います。
https://github.com/MVIG-SJTU/AlphaPose/issues/1231
ダウンロードが完了したら、所定のディレクトリにコピーします。

scp yolov3-spp.weights pose@192.168.0.12:~/AlphaPose/detector/yolo/data/

実行

ダウンロードした推定モデルと検出器で推論してみます。

python scripts/demo_inference.py --cfg configs/halpe_26/resnet/256x192_res50_lr1e-3_1x.yaml --checkpoint pretrained_models/halpe26_fast_res50_256x192.pth --indir examples/demo/

このように表示されれば成功です。

Results have been written to json.
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?