Coder Social home page Coder Social logo

xdweixia / cpem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deepmo24/cpem

1.0 0.0 0.0 24.05 MB

PyTorch implementation of "Towards Accurate Facial Motion Retargeting with Identity-Consistent and Expression-Exclusive Constraints" (AAAI2022)

Shell 0.04% C++ 14.04% Python 79.90% CMake 0.21% Cython 5.81%

cpem's Introduction

CPEM: Consistent Parameter Estimation Model

This repository contains the code and supplementary material for our AAAI paper: "Towards Accurate Facial Motion Retargeting with Identity-Consistent and Expression-Exclusive Constraints".

facial motion retargeting
A demo showing facial motion retargeting results of our CPEM

Paper

Towards Accurate Facial Motion Retargeting with Identity-Consistent and Expression-Exclusive Constraints
[Supplementary material]
Langyuan Mo, Haokun Li, Chaoyang Zou, Yubing Zhang, Ming Yang, Yihong Yang, Mingkui Tan
Proceedings of the AAAI Conference on Artificial Intelligence(AAAI), 2022

Dependencies

Getting Started

Installation

  1. Clone this repo:

     git clone https://github.com/deepmo24/CPEM.git
     cd CPEM/
    
  2. install the dependencies above.

  3. install face detector FaceBoxes:

     cd FaceBoxes/
     sh ./build_cpu_nms.sh
     pip install onnxruntime # if use onnxruntime to speed up inference
    

Model

  1. 3DMM model + pretrained model

    • We use the BFM09 model processed by Deep3DFaceReconstruction for face identity and texture model, while the expression model is obtained by using deformation transfor technology to transfer the expression blendshapes from FaceWarehouse to BFM09.

    • Download link: Dropbox or BaiduNetdisk(extraction code: 7i7u)

    • Put the 3DMM model in ./data/BFM directory

    • Put the pretrained model in ./data/pretrained_model directory

Testing

  • Run general demo:

      python test.py --mode demo \
          --checkpoint_path ./data/pretrained_model/resnet50-id-exp-300000.ckpt \
          --image_path <path-to-image> --save_path <path-to-save>
    
  • Run facial motion retargeting:

      CUDA_VISIBLE_DEVICES=1 python test.py --mode retarget \
      --checkpoint_path ./data/pretrained_model/resnet50-id-exp-300000.ckpt \
      --source_coeff_path <path-to-coefficient> --target_image_path <path-to-image> \
      --save_path <path-to-save>
    
  • Render 3D face shape on the input image:

    • install rendering library Sim3DR:

        cd Sim3DR/
        sh ./build_sim3dr.sh
      
    • Rendering shape on the image plane:

        python test.py --mode render_shape \
            --checkpoint_path ./data/pretrained_model/resnet50-id-exp-300000.ckpt \
            --image_path <path-to-image> --save_path <path-to-save>
      

Training

1. Data preparation

We train our model with three datasets VoxCeleb2, Feafa(need to apply) and 300W-LP.

  1. Download the above datasets.

  2. Construct the dataset like below:

     <train dataset>
     ├── data
     │   └── <person_id>/<video_clips>/<images>
     ├── face_mask
     │   └── <person_id>/<video_clips>/<images>
     ├── landmarks
     │   └── <person_id>/<video_clips>/<landmarks>
     ├── landmarks2d
     │   └── <person_id>/<video_clips>/<landmarks>
     └── front_face_flag.csv
    
    • data folder contains the raw images.
    • face_mask folder contains the face skin masks w.r.t. images, which can be genereted using face-parsing.PyTorch.
    • landmarks folder contains the 3D facical landmarks w.r.t. images, which can be generated using face_alignment.
    • landmarks2d folder contains the 2D facical landmarks w.r.t. images, which can be generated using dlib.
    • front_face_flag.csv file saves the front face flag, which can be generated using preprocess/cal_yaw_angle.py.
  3. We supply a demo dataset in ./data/demo_dataset to help preprare your own datasets.

2. Training the model

  • (Try) training the model using demo dataset:

      python train.py --result_root results/cpem_demo \
          --voxceleb2_root data/demo_dataset/voxceleb2 \
          --lp_300w_root data/demo_dataset/300w_lp
    
  • training the model using full dataset:

      python train.py --result_root results/<experiment-name> \
          --voxceleb2_root <path-to-voxceleb2> \
          --feafa_root <path-to-feafa> \
          --lp_300w_root <path-to-300w_lp>
    

Others

  • We supply the FACS names of the the expression blendshapes here.

Citation

If this work is useful for your research, please star our repo and cite our paper.

@inproceedings{mo2022cpem,
    title={Towards Accurate Facial Motion Retargeting with Identity-Consistent and Expression-Exclusive Constraints},
    author={Mo, Langyuan and Li, Haokun and Zou, Chaoyang and Zhang, Yubing and Yang, Ming and Yang, Yihong and Tan, Mingkui}
    booktitle = {Proceedings of the AAAI Conference on Artificial Intelligence (AAAI)},
    year={2022}
}

cpem's People

Contributors

deepmo24 avatar

Stargazers

ManshengChen 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.