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?

More than 5 years have passed since last update.

3DDFA動作手順メモ

Posted at

https://github.com/cleardusk/3DDFA.git
顔面の3Dソリューション,3DDFAの動作メモ

NVIDIAでの環境構築

事前にminicondaで環境構築をしておく.

conda create -n 3ddfa python=3.6
conda activate 3ddfa
sudo apt-get install -y --fix-missing \
    build-essential \
    cmake \
    gfortran \
    git \
    wget \
    curl \
    libjpeg-dev \
    liblapack-dev \
    libswscale-dev \
    pkg-config \
    python3-numpy \
    zip \
    libboost-dev \
    libboost-all-dev \
    libsm6 \
    libxext6 \
    libfontconfig1 \
    libxrender1 \

RepositoryのcloneとcythonのBuild

git clone https://github.com/cleardusk/3DDFA.git
cd ./3DDFA
pip install -r requirements.txt 

本来はこれでいいはずなのですが requirements.txt に指定されているdlib versionだとビルドエラーが発生して先に勧めなかったので

pip install dilbで最新バージョンを入れてテストしました.

推論テスト

python ./main.py -f samples/emma_input.jpg --bbox_init=two --dlib_bbox=false

Figure_1.png

推論速度テスト

$ python ./speed_cpu.py 

Inference speed: 24.69±4.11 ms

以上のスクリプトでCPUでの推論速度が確認できます.`

学習

学習からベンチマークまで

Data Download Link Description
train.configs BaiduYun or Google Drive, 217M The directory contraining 3DMM params and filelists of training dataset
train_aug_120x120.zip BaiduYun or Google Drive, 2.15G The cropped images of augmentation training dataset
test.data.zip BaiduYun or Google Drive, 151M The cropped images of AFLW and ALFW-2000-3D testset

train.configs
train_aug_120x120.zip
test.data.zip

をダウンロードして解凍します.

test.data.zipは~/3DDFA直下にセット,train.configsは既にあるtrain.configsを上書きする形でセット、train_aug_120x120も
traing.configsに保存する形で実施しました

~/3DDFA/training内にある./train_vdc.sh を以下にように書き換えて実行して学習を開始

# !/usr/bin/env bash

LOG_ALIAS=$1
LOG_DIR="logs"
mkdir -p ${LOG_DIR}

LOG_FILE="${LOG_DIR}/${LOG_ALIAS}_`date +'%Y-%m-%d_%H:%M.%S'`.log"
# echo $LOG_FILE

./train.py --arch="mobilenet_1" \
    --start-epoch=1 \
    --loss=vdc \
    --snapshot="snapshot/phase1_vdc" \
    --param-fp-train='../train.configs/param_all_norm.pkl' \
    --param-fp-val='../train.configs/param_all_norm_val.pkl' \
    --warmup=-1 \
    --opt-style=resample \
    --resample-num=132 \
    --batch-size=512 \
    --base-lr=0.00001 \
    --epochs=50 \
    --milestones=30,40 \
    --print-freq=50 \
    --devices-id=0 \
    --workers=8 \
    --filelists-train="../train.configs/train_aug_120x120.list.train" \
    --filelists-val="../train.configs/train_aug_120x120.list.val" \
    --root="/home/rocm/3DDFA/train.configs/train_aug_120x120" \
    --log-file="${LOG_FILE}"

--epochs=50でGTX1080Tiにて6時間ぐらいの学習行程でした

cd ../
 python benchmark.py -c   ./training/snapshot/phase1_vdc_checkpoint_epoch_50.pth.tar

で学習したモデルのベンチマークが可能です.

$ python benchmark.py -c   ./training/snapshot/phase1_vdc_checkpoint_epoch_50.pth.tar
Extracting params take  1.483s
[ 0, 30]	Mean: 3.973, Std: 1.807
[30, 60]	Mean: 5.008, Std: 2.656
[60, 90]	Mean: 6.459, Std: 3.545
[ 0, 90]	Mean: 5.147, Std: 1.019
Extracting params take  7.443s
[ 0, 30]	Mean: 5.696, Std: 4.991
[30, 60]	Mean: 7.062, Std: 5.830
[60, 90]	Mean: 7.853, Std: 7.814
[ 0, 90]	Mean: 6.870, Std: 0.891

学習したモデルで実際に動かしてみる.

main.pyの36行目

  def main(args):
      # 1. load pre-tained model
      checkpoint_fp = 'models/phase1_wpdc_vdc.pth.tar'
      arch = 'mobilenet_1'           

でモデルのPATHを指定できます.

/training/snapshotにチェックポイントが出力されているのでこれを使います

training/snapshot/phase1_vdc_checkpoint_epoch_50.pth.tar
python ./premain.py -f samples/emma_input.jpg --bbox_init=two --dlib_bbox=false

Screenshot from 2019-12-23 02-54-29.png

epoch50 6時間ほどの学習タスクでこの程度のランドマーク処理が出来ました.

ROCm-Dockerでのテストについて

AMDのGPUでも動作を確認したかったのでDockerを立てて環境構築を行ったのですが.

ROCm-Pytorch-Dockerの環境構築がいつの間にか楽になってた

追記(2019/10/01) python関連で気になることがあった

 import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

このようになぜかpip3が正常に動作しないと言う事例が発生しており現状ゼロからビルドしないとまともに使えないと言う事象が起きています.
pipのアップグレードなどを試行しましたが解決には至りませんでした.

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?