lingfromSh / DeepFaceVideoEditing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeepFaceVideoEditing: Sketch-based Deep Editing of Face Videos
Official implementation

Teaser image

Abstract

Sketches, which are simple and concise, have been used in recent deep image synthesis methods to allow intuitive generation and editing of facial images. However, it is nontrivial to extend such methods to video editing due to various challenges, ranging from appropriate manipulation propagation and fusion of multiple editing operations to ensure temporal coherence and visual quality. To address these issues, we propose a novel sketch-based facial video editing framework, in which we represent editing manipulations in latent space and propose specific propagation and fusion modules to generate high-quality video editing results based on StyleGAN3. Specifically, we first design an optimization approach to represent sketch editing manipulations by editing vectors, which are propagated to the whole video sequence using a proper strategy to cope with different editing needs. Specifically, input editing operations are classified into two categories: temporally consistent editing and temporally variant editing. The former (e.g., change of face shape) is applied to the whole video sequence directly, while the latter (e.g., change of facial expression or dynamics) is propagated with the guidance of expression or only affects adjacent frames in a given time window. Since users often perform different editing operations in multiple frames, we further present a region-aware fusion approach to fuse diverse editing effects. Our method supports video editing on facial structure and expression movement by sketch, which cannot be achieved by previous works. Both qualitative and quantitative evaluations show the superior editing ability of our system to existing and alternative solutions.

Prerequisites

  1. System

- Ubuntu 16.04 or later

- NVIDIA GPU RTX 3090 + CUDA 11.1

  1. Software

- Python 3.8

- Jittor. More details in Jittor

- Packages. Note: cupy-cuda111 is for CUDA 11.1.

pip install -r requirements.txt
  • (Optional) If get a 'cutt' error, please disable 'cutt'.
export use_cutt=0

Download the pre-trained modules

Video Editing

Download examples from [Google Drive]. Unzip it and put the video directories in ./video_editings/.

For each video example, the original video and editing operations are organized as the following structure:

video_editings
│
└─── example1
    └─── XXX.mp4
    └─── edit
         └─── baseShape
         |    └─── edit1
         |    │    └─── img.jpg
         |    │    └─── sketch_edit.jpg
         |    │    └─── mask_edit.jpg
         |    └─── edit2
         |    └─── ...
         └─── window
         └─── exp
    |
    └─── ...

Modify the ./configs/paths_config.py: change the input_video_path to video example directory and video_name to the name of input video. (Default settings are for example1)

Preprocess videos

Extract and align all frames from input video.

python video_align.py

PTI training

In order to recontruct input video, use PTI method to finetune StyleGAN3 generator.

python run_pti_stylegan3.py

Sketch editing

Generate the sketch editing results for single frame.

Modify the ./configs/paths_config.py: change the inversion_edit_path to sketch editing directory which contains image, sketch and mask.

Then, generate sketch optimization results:

python run_sketch.py

The sketch weights and RGB weights could be tuned in ./configs/hyperparameters.py to generate the better results.

Editing propagation

Before propagating the editing effect, the editing vectors should be generated using the above approach.

Modify the ./configs/paths_config.py, corresponding to 3 directories in ./video_editings/exampleXXX/edit/.

  • BaseShape editing: Set operation directories in shapePath_list
  • Time window editing: Set operation directories in windowPath_list
  • Expression Guidance editing: Set operation directories in expPath_list

The time window parameters are set in ./configs/hyperparameters.py.

Then, generate the propagation results:

python run_editing.py

Face Merging and realignment

Merge the face regions and realign generated frames into original frames.

python video_merge.py

Citation

If you found this code useful please cite our work as:

@article {DeepFaceVideoEditing2022,
author = {Liu, Feng-Lin and Chen, Shu-Yu and Lai, Yu-Kun and Li, Chunpeng and Jiang, Yue-Ren and Fu, Hongbo and Gao, Lin},
title = {{DeepFaceVideoEditing}: Sketch-based Deep Editing of Face Videos},
journal = {ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2022)},
year = {2022},
volume = 41,
pages = {167:1--167:16},
number = 4
}

About

License:Apache License 2.0


Languages

Language:Python 75.3%Language:C++ 24.6%Language:Shell 0.0%