Git Product home page Git Product logo

bihand's Introduction

BiHand - 3D Hand Mesh Reconstruction

This repo contains model, demo, training codes for our paper: "BiHand: Recovering Hand Mesh with Multi-stage Bisected Hourglass Networks"(PDF) (BMVC2020)

Get the code

git clone --recursive https://github.com/lixiny/bihand.git
cd bihand

Install Requirements

Install the dependencies listed in environment.yml through conda:

  • We recommend to firstly install Pytorch with cuda enabled.
  • Create a new conda environment: conda env create -f environment.yml
  • Or in an existing conda environment: conda env update -f environment.yml

The above operation works well if you are lucky. However, we found that installing opendr is tricky. We solved the errors by:

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
sudo apt-get install libosmesa6-dev
## then reinstall opendr again
pip install opendr

Download and Prepare Datasets

  • Create a data directory: data

  • Download RHD dataset at the dataset page and extract it in data/RHD.

  • Download STB dataset at the dataset page and extract it in data/STB

  • Download STB_supp dataset at Google Drive or Baidu Pan(v858) and merge it into data/STB. (In STB, We generated aligned and segmented hand depthmap from the original depth image)

Now your data folder structure should like this:

data/
    RHD/
        RHD_published_v2/
            evaluation/
            training/
            view_sample.py
            ...

    STB/
        images/
            B1Counting/
                SK_color_0.png
                SK_depth_0.png
                SK_depth_seg_0.png  <-- merged from STB_supp
                ...
            ...
        labels/
            B1Counting_BB.mat
            ...

Download and Prepare model files

MANO model

  • Go to MANO website
  • Create an account by clicking Sign Up and provide your information
  • Download Models and Code (the downloaded file should have the format mano_v*_*.zip). Note that all code and data from this download falls under the MANO license.
  • unzip and copy the models folder into the manopth/mano folder

Now Your manopth folder structure should look like this:

manopth/
  mano/
    models/
      MANO_LEFT.pkl
      MANO_RIGHT.pkl
      ...
  manopth/
    __init__.py
    ...

BiHand models

  • Download BiHand weights checkpoints.tar.gz from Google Drive | Baidu Pan(w7pq), unzip it.
  • Put the files in checkpoints folder into current released_checkpoints dirctory (ln -s or mkdir)

Now your bihand folder should look like this:

BiHand-test/
    bihand/
    released_checkpoints/
        โ”œโ”€โ”€ ckp_seednet_all.pth.tar
        โ”œโ”€โ”€ ckp_siknet_synth.pth.tar
        โ”œโ”€โ”€ rhd/
        โ”‚ย ย  โ”œโ”€โ”€ ckp_liftnet_rhd.pth.tar
        โ”‚ย ย  โ””โ”€โ”€ ckp_siknet_rhd.pth.tar
        โ””โ”€โ”€ stb/
            โ”œโ”€โ”€ ckp_liftnet_stb.pth.tar
            โ””โ”€โ”€ ckp_siknet_stb.pth.tar
    data/
    ...

Launch Demo & Eval

  • First, add this into current bash or ~/.bashrc:
export PYTHONPATH=/path/to/bihand:$PYTHONPATH
  • to test on RHD dataset:
python run.py \
    --batch_size 8 --fine_tune rhd --checkpoint released_checkpoints --data_root data
  • to test on STB dataset:
python run.py \
    --batch_size 8 --fine_tune stb --checkpoint released_checkpoints  --data_root data
  • add --vis to visualize:

Training

By adopting the multi-stage training scheme, we first train SeedNet for 100 epochs:

python training/train_seednet.py --net_modules seed --datasets stb rhd --ups_loss

and then exploit its outputs to train LiftNet for another 100 epochs:

python training/train_liftnet.py \
    --net_modules seed lift \
    --datasets stb rhd \
    --resume_seednet_pth ${path_to_your_SeedNet_checkpoints (xxx.pth.tar)} \
    --ups_loss \
    --train_batch 16

For SIKNet:

  • We firstly train SIKNet on SIK-1M dataset for <=100 epochs.

    Download SIK-1M Dataset at Google Drive or Baidu Pan (dc4g) and extract SIK-1M.zip to data/SIK-1M, then run:

python training/train_siknet_sik1m.py
  • Then we fine-tune the SIKNet on the predicted 3D joints from the LiftNet. During train_siknet, the params of SeedNet and LiftNet are freezed.
python training/train_siknet.py \
    --fine_tune ${stb, rhd} \
    --frozen_seednet_pth ${path_to_your_SeedNet_checkpoints} \
    --frozen_liftnet_pth ${path_to_your_LiftNet_checkpoints} \
    --resume_siknet_pth ${path_to_your_SIKNet_SIK-1M_checkpoints}

# e.g.
python training/train_siknet.py \
    --fine_tune rhd \
    --frozen_seednet_pth released_checkpoints/ckp_seednet_all.pth.tar \
    --frozen_liftnet_pth released_checkpoints/rhd/ckp_liftnet_rhd.pth.tar \
    --resume_siknet_pth released_checkpoints/ckp_siknet_synth.pth.tar

Limitation

Currently the released version of bihand requires camera intrinsics, root depth and bone length as inputs, thus cannot be applied in the wild.

Citation

If you find this work helpful, please consider citing us:

@inproceedings{yang2020bihand,
  title     = {BiHand: Recovering Hand Mesh with Multi-stage Bisected Hourglass Networks},
  author    = {Yang, Lixin and Li, Jiasen and Xu, Wenqiang and Diao, Yiqun and Lu, Cewu},
  booktitle = {BMVC},
  year      = {2020}
}

Acknowledgement

  • Code of Mano Pytorch Layer in manopth was adapted from manopth.

  • Code for evaluating the hand PCK and AUC in bihand/eval/zimeval.py was adapted from hand3d.

  • Code of data augmentation in bihand/datasets/handataset.py was adapted from obman.

  • Code of STB datasets bihand/datasets/stb.py was adapted from hand-graph-cnn.

  • Code of the original Hourglass Network bihand/models/hourglass.py was adapted from pytorch-pose.

  • Thanks Yuxiao Zhou for helpful discussions and suggestions when solving IK problem.

bihand's People

Contributors

lixiny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.