The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

Overview

Website | ArXiv | Get Start | Video

PIRenderer

The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering" (ICCV2021)

The proposed PIRenderer can synthesis portrait images by intuitively controlling the face motions with fully disentangled 3DMM parameters. This model can be applied to tasks such as:

  • Intuitive Portrait Image Editing

    Intuitive Portrait Image Control

    Pose & Expression Alignment

  • Motion Imitation

    Same & Corss-identity Reenactment

  • Audio-Driven Facial Reenactment

    Audio-Driven Reenactment

News

  • 2021.9.20 Code for PyTorch is available!

Colab Demo

Coming soon

Get Start

1). Installation

Requirements

  • Python 3
  • PyTorch 1.7.1
  • CUDA 10.2

Conda Installation

# 1. Create a conda virtual environment.
conda create -n PIRenderer python=3.6
conda activate PIRenderer
conda install -c pytorch pytorch=1.7.1 torchvision cudatoolkit=10.2

# 2. Install other dependencies
pip install -r requirements.txt

2). Dataset

We train our model using the VoxCeleb. You can download the demo dataset for inference or prepare the dataset for training and testing.

Download the demo dataset

The demo dataset contains all 514 test videos. You can download the dataset with the following code:

./scripts/download_demo_dataset.sh

Or you can choose to download the resources with these links:

Google Driven & BaiDu Driven with extraction passwords ”p9ab“

Then unzip and save the files to ./dataset

Prepare the dataset

  1. The dataset is preprocessed follow the method used in First-Order. You can follow the instructions in their repo to download and crop videos for training and testing.

  2. After obtaining the VoxCeleb videos, we extract 3DMM parameters using Deep3DFaceReconstruction.

    The folder are with format as:

    ${DATASET_ROOT_FOLDER}
    └───path_to_videos
    		└───train
    				└───xxx.mp4
    				└───xxx.mp4
    				...
    		└───test
    				└───xxx.mp4
    				└───xxx.mp4
    				...
    └───path_to_3dmm_coeff
    		└───train
    				└───xxx.mat
    				└───xxx.mat
    				...
    		└───test
    				└───xxx.mat
    				└───xxx.mat
    				...
    
  3. We save the video and 3DMM parameters in a lmdb file. Please run the following code to do this

    python scripts/prepare_vox_lmdb.py \
    --path path_to_videos \
    --coeff_3dmm_path path_to_3dmm_coeff \
    --out path_to_output_dir

3). Training and Inference

Inference

The trained weights can be downloaded by running the following code:

./scripts/download_weights.sh

Or you can choose to download the resources with these links: coming soon. Then save the files to ./result/face

Reenactment

Run the the demo for face reenactment:

python -m torch.distributed.launch --nproc_per_node=1 --master_port 12345 inference.py \
--config ./config/face.yaml \
--name face \
--no_resume \
--output_dir ./vox_result/face_reenactment

The output results are saved at ./vox_result/face_reenactment

Intuitive Control

coming soon

Train

Our model can be trained with the following code

python -m torch.distributed.launch --nproc_per_node=4 --master_port 12345 train.py \
--config ./config/face.yaml \
--name face

Citation

If you find this code is helpful, please cite our paper

@misc{ren2021pirenderer,
      title={PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering}, 
      author={Yurui Ren and Ge Li and Yuanqi Chen and Thomas H. Li and Shan Liu},
      year={2021},
      eprint={2109.08379},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Acknowledgement

We build our project base on imaginaire. Some dataset preprocessing methods are derived from video-preprocessing.

Comments
  • Questions about .mat file when preparing training dataset

    Questions about .mat file when preparing training dataset

    Thank you for the exciting work. When preparing the training dataset, I have questions about the .mat file. The prepare_vox_lmdb.py file indicates that .mat file should contain keys of 'landmark', 'coeff' and 'transform_params', as shown below. image

    However, in Deep3DFaceRecon_pytorch, the keys in .mat file is the predicted 257-dimensional coefficients and 68 projected 2d facial landmarks.

    I would like to know the correspondence between those two kind of 'keys' or exactly how you extract the .mat file corresponding to a mp4 file.

    Thanks in advance!

    opened by DaddyJin 5
  • Bad results on animating wild videos

    Bad results on animating wild videos

    Thanks for your impressive work! I used DeepFaceRecon_pytorch to achieve the 3dmm params. But got bad results. And for same test demo video in the VoxCeleb, the params are different. Can you help me figure it out which procedure in the pre-processing got wrong? Thanks in advance! image

    opened by FeiiYin 4
  • Question about method comparison

    Question about method comparison

    Thanks for sharing your exciting work about portrait editing! I have a question about the comparison between PIRender and StyleRig. As there is no open-source implementation of StyleRig, I'm wondering did you implement it by yourself or asked the authors to conduct the experiment? I'm wondering whether the implementation gaps affect the final outcomes or not. Thanks again for sharing your work!

    opened by xk-huang 3
  • Publishing the weights

    Publishing the weights

    Hi, really great work! I'm wondering, when the models weights will be published? You mentioned scripts/download_weights.sh file in inference example, but this file is missing Thanks!

    opened by Chay23 1
  • ImportError: /../libstdc++.so.6: version `GLIBCXX_3.4.29' not found

    ImportError: /../libstdc++.so.6: version `GLIBCXX_3.4.29' not found

    If you happen to get the error:

    ImportError: /miniconda3/envs/PIRender/lib/python3.6/site-packages/torch/lib/../../../.././libstdc++.so.6: version GLIBCXX_3.4.29 not found (required by .cache/torch_extensions/nvdiffrast_plugin/nvdiffrast_plugin.so)

    then deleting or renaming the file

    /home/jp/miniconda3/envs/torch/lib/libstdc++.so.6.0.28

    helped me and got it to work. Took me some time to figure this out and I woudl be happy if somebody could explan why?

    Cheers

    opened by mrokuss 0
  • Training log

    Training log

    Thanks for your nice work. Could you please share the training log on the Voxceleb dataset. I trained my own model on voxceleb and would like to compare with your log to see whether I can reproduce your results. Thanks.

    opened by harlanhong 0
  • Questions about the training VoxCeleb dataset fps and audio signal

    Questions about the training VoxCeleb dataset fps and audio signal

    Hi,

    I want to ask what the fps of your cropped VoxCeleb dataset? When I run the video-preprocessing to download the VoxCeleb1 dataset, the FPS is 10 by default. What's more, the downloaded dataset has no audio channel.

    So I want to know whether the video fps has any effect when training? And what the FPS of yours dataset when training.

    I hope you could solve my questions.

    opened by zhanghm1995 0
  • voxceleba dataset

    voxceleba dataset

    I encounter a problem when prepare the dataset.I have a dataset of png version, but it does not work? The confusion is that the voxceleba of project is mp4 or png? Thanks.

    opened by ZPzhu 0
  • AttributeError: 'Config' object has no attribute 'device'

    AttributeError: 'Config' object has no attribute 'device'

    F:\ProgramData\Anaconda3\python.exe F:/work/mingxingshipin/test/PIRender-main/intuitive_control.py --config ./config/face_demo.yaml --name face --no_resume --output_dir ./vox_result/face_intuitive --input_name ./demo_images Make folder result\face 2022-01-23 20:13:22.076873: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll Traceback (most recent call last): File "F:/work/mingxingshipin/test/PIRender-main/intuitive_control.py", line 87, in = get_model_optimizer_and_scheduler(opt) File "F:\work\mingxingshipin\test\PIRender-main\util\trainer.py", line 46, in get_model_optimizer_and_scheduler net_G = network(**opt.gen.param).to(opt.device) AttributeError: 'Config' object has no attribute 'device'

    opened by c1a1o1 1
  • About code release of Audio-Driven Facial Reenactment

    About code release of Audio-Driven Facial Reenactment

    Thank you for the great work. Is there any plan for the code release of Audio-Driven Facial Reenactment? The result is really impressive~ Best wishes.

    opened by DaddyJin 0
Owner
Ren Yurui
Ren Yurui
source code of “Visual Saliency Transformer” (ICCV2021)

Visual Saliency Transformer (VST) source code for our ICCV 2021 paper “Visual Saliency Transformer” by Nian Liu, Ni Zhang, Kaiyuan Wan, Junwei Han, an

null 89 Dec 21, 2022
Code and models for ICCV2021 paper "Robust Object Detection via Instance-Level Temporal Cycle Confusion".

Robust Object Detection via Instance-Level Temporal Cycle Confusion This repo contains the implementation of the ICCV 2021 paper, Robust Object Detect

Xin Wang 69 Oct 13, 2022
Official code of ICCV2021 paper "Residual Attention: A Simple but Effective Method for Multi-Label Recognition"

CSRA This is the official code of ICCV 2021 paper: Residual Attention: A Simple But Effective Method for Multi-Label Recoginition Demo, Train and Vali

null 163 Dec 22, 2022
Code for Talk-to-Edit (ICCV2021). Paper: Talk-to-Edit: Fine-Grained Facial Editing via Dialog.

Talk-to-Edit (ICCV2021) This repository contains the implementation of the following paper: Talk-to-Edit: Fine-Grained Facial Editing via Dialog Yumin

Yuming Jiang 221 Jan 7, 2023
Official code for ICCV2021 paper "M3D-VTON: A Monocular-to-3D Virtual Try-on Network"

M3D-VTON: A Monocular-to-3D Virtual Try-On Network Official code for ICCV2021 paper "M3D-VTON: A Monocular-to-3D Virtual Try-on Network" Paper | Suppl

null 109 Dec 29, 2022
Code for ICCV2021 paper SPEC: Seeing People in the Wild with an Estimated Camera

SPEC: Seeing People in the Wild with an Estimated Camera [ICCV 2021] SPEC: Seeing People in the Wild with an Estimated Camera, Muhammed Kocabas, Chun-

Muhammed Kocabas 187 Dec 26, 2022
Implementation of ICCV2021(Oral) paper - VMNet: Voxel-Mesh Network for Geodesic-aware 3D Semantic Segmentation

VMNet: Voxel-Mesh Network for Geodesic-Aware 3D Semantic Segmentation Created by Zeyu HU Introduction This work is based on our paper VMNet: Voxel-Mes

HU Zeyu 82 Dec 27, 2022
Implementation for our ICCV2021 paper: Internal Video Inpainting by Implicit Long-range Propagation

Implicit Internal Video Inpainting Implementation for our ICCV2021 paper: Internal Video Inpainting by Implicit Long-range Propagation paper | project

null 202 Dec 30, 2022
This is the pytorch implementation for the paper: Generalizable Mixed-Precision Quantization via Attribution Rank Preservation, which is accepted to ICCV2021.

GMPQ: Generalizable Mixed-Precision Quantization via Attribution Rank Preservation This is the pytorch implementation for the paper: Generalizable Mix

null 18 Sep 2, 2022
PyTorch implementation of our ICCV2021 paper: StructDepth: Leveraging the structural regularities for self-supervised indoor depth estimation

StructDepth PyTorch implementation of our ICCV2021 paper: StructDepth: Leveraging the structural regularities for self-supervised indoor depth estimat

SJTU-ViSYS 112 Nov 28, 2022
This is an official implementation of the paper "Distance-aware Quantization", accepted to ICCV2021.

PyTorch implementation of DAQ This is an official implementation of the paper "Distance-aware Quantization", accepted to ICCV2021. For more informatio

CV Lab @ Yonsei University 36 Nov 4, 2022
ICCV2021 Paper: AutoShape: Real-Time Shape-Aware Monocular 3D Object Detection

ICCV2021 Paper: AutoShape: Real-Time Shape-Aware Monocular 3D Object Detection

Zongdai 107 Dec 20, 2022
This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation

SO-Pose This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation This paper is basically an

shangbuhuan 52 Nov 25, 2022
Official Repo for ICCV2021 Paper: Learning to Regress Bodies from Images using Differentiable Semantic Rendering

[ICCV2021] Learning to Regress Bodies from Images using Differentiable Semantic Rendering Getting Started DSR has been implemented and tested on Ubunt

Sai Kumar Dwivedi 83 Nov 27, 2022
Official code for "Simpler is Better: Few-shot Semantic Segmentation with Classifier Weight Transformer. ICCV2021".

Simpler is Better: Few-shot Semantic Segmentation with Classifier Weight Transformer. ICCV2021. Introduction We proposed a novel model training paradi

Lucas 103 Dec 14, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official PyTorch code for Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021)

Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021) This repository is the official PyTorc

Jingyun Liang 139 Dec 29, 2022
[ICCV2021] Official code for "Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition"

CTR-GCN This repo is the official implementation for Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition. The pap

Yuxin Chen 148 Dec 16, 2022