• Stars
    star
    110
  • Rank 316,712 (Top 7 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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 + cudnn 8.0.4

  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

Quick Start

Download examples from [Google Drive]. This Link contains 10 examples which are used in our user study and can be used for further comparsions. 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
โ”‚
โ””โ”€โ”€โ”€ example2
    โ””โ”€โ”€โ”€ XXX.mp4
    โ””โ”€โ”€โ”€ edit
         โ””โ”€โ”€โ”€ baseShape
         |    โ””โ”€โ”€โ”€ edit1
         |    โ”‚    โ””โ”€โ”€โ”€ img.jpg
         |    โ”‚    โ””โ”€โ”€โ”€ sketch_edit.jpg
         |    โ”‚    โ””โ”€โ”€โ”€ mask_edit.jpg
         |    โ””โ”€โ”€โ”€ edit2
         |    โ””โ”€โ”€โ”€ ...
         โ””โ”€โ”€โ”€ window
         โ””โ”€โ”€โ”€ exp
    |
    โ””โ”€โ”€โ”€ ...

Running video editing examples

Edit example2 with 3 editing operations. Results are saved as merge.mp4:

./video_editings/example2/running_script/edit_video.sh

Other examples can be edited in the similar way by replacing the 'example2' with other directory.

Video Editing

The following describes the details of video editing.

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 example2)

Preprocess videos

Extract and align all frames from input video.

python video_align.py

The generated aligned frames will be in align_frames directory for each example.

PTI training

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

python run_pti_stylegan3.py

PTI weights will be generated in example directory and pti results for 1st frame will be generated in pti_results directory.

Sketch editing

Generate sketch optimization results for single frame:

python run_sketch.py --inversion_edit_path XXX

Option --inversion_edit_path is the sketch editing directory which contains image, sketch and mask.

The edit frame is named img.jpg, drawn sketch is named sketch_edit.jpg and drawn mask is named mask_edit.jpg.

Note:

-- The sketch weights and RGB weights could be tuned to generate the best results.

-- For each editing operations, this script should be run with different --inversion_edit_path. For example, this script should be run 3 times if 3 editing operations are applied for a single video.

Editing propagation

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

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

Edited frames will be saved in edit/edit_video directory.

Face Merging and realignment

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

python video_merge.py

Merged frames will be saved in merge_images directory. Final edited videos will be generated named as merged.mp4.

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
}

More Repositories

1

DeepFaceDrawing-Jittor

Python
756
star
2

DeepFaceEditing-Jittor

Python
282
star
3

NeRF-Editing

[CVPR 2022] Code for "NeRF-Editing: Geometry Editing of Neural Radiance Fields"
C++
186
star
4

NeUDF

The code for "NeUDF: Leaning Neural Unsigned Distance Fields with Volume Rendering (CVPR 2023)"
Python
153
star
5

StylizedNeRF

[CVPR 2022] Code for StylizedNeRF: Consistent 3D Scene Stylization as Stylized NeRF via 2D-3D mutual learning
Python
142
star
6

SketchFaceNeRF

Python
102
star
7

DSG-Net

Code for 'DSG-Net: Learning Disentangled Structure and Geometry for 3D Shape Generation'
Python
84
star
8

NeRFFaceLighting

[TOG'23] NeRFFaceLighting: Implicit and Disentangled Face Lighting Representation Leveraging Generative Prior in Neural Radiance Fields
Jupyter Notebook
76
star
9

OctField

Code for "OctField: Hierarchical Implicit Functions for 3D Modeling (NeurIPS 2021)"
Python
61
star
10

IBSR_jittor

Code for 'Single Image 3D Shape Retrieval via Cross-Modal Instance and Category Contrastive Learning', ICCV 2021
Python
52
star
11

SketchDream

Python
43
star
12

RisaNET

Code for "RISA-Net: Rotation-Invariant and Structure-Aware Network for Fine-grained 3D Shape Retrieval"
Python
40
star
13

PRS-Net

Python
34
star
14

TM-NET

Python
33
star
15

MeshPooling

Code for 'Mesh Variational Autoencoders with Edge Contraction Pooling'
Python
33
star
16

RGBDNeRF

Code for "Neural Radiance Fields from Sparse RGB-D Images for High-Quality View Synthesis"
Python
27
star
17

NeRFFaceEditing

[SIGGRAPH Asia'22] NeRFFaceEditing: Disentangled Face Editing in Neural Radiance Fields
Jupyter Notebook
25
star
18

MeshVAE_neural_editing

Python
24
star
19

NEURALSLICE

The code of "NEURALSLICE: Neural 3D Triangle Mesh Reconstruction via Slicing 4D Tetrahedral Meshes (ICML 2023)"
Roff
23
star
20

TM-NET-Jittor

Python
20
star
21

PRS-NET-Jittor

Python
20
star
22

Stylemotion

Python
19
star
23

Farthestsampling

Furthest sampling and Voronoi sampling on 3D mesh
C++
19
star
24

DynamicHumanGeneration_Jittor

Python
17
star
25

intrinsicSym-Jittor

C++
17
star
26

HSDF-Net

The code for "HSDF: Hybrid Sign and Distance Field for Modeling Surfaces with Arbitrary Topologies (NeurIPS 2022)"
Python
15
star
27

MT_DE-Jittor

Python
13
star
28

PRS-Net_stamp

Python
12
star
29

GLIM-Net

Python
2
star
30

Fungal_Keratitis_Classification

Python
1
star