Temporally Consistent Semantic Video Editing

Yiran Xu, Badour AlBahar, Jia-Bin Huang

TL;DR

VideoEditGAN introduces a two-phase optimization strategy to bring the power of StyleGAN-based image editing to the world of video. By optimizing latent codes through an MLP and fine-tuning the generator with flow-based consistency losses, the method eliminates the "flickering" artifacts typical of per-frame editing while preserving the subject's identity and fine details.

Introduction: The Challenge of Video Editing

Generative Adversarial Networks (GANs), particularly StyleGAN, have revolutionized image editing. Tools like StyleCLIP allow users to change a person's expression, add eyeglasses, or even transform them into a "Disney Princess" using simple text prompts. However, extending these techniques to video is notoriously difficult.

The primary challenge is temporal inconsistency. If you invert and edit each video frame independently, the resulting video suffers from distracting flickering. This happens because the GAN's latent space isn't perfectly disentangled, and small variations in per-frame inversion lead to visible jumps in appearance, lighting, or background details. Existing "blind" video consistency methods often over-smooth the video, resulting in a loss of sharpness and detail.

Methods

The authors propose VideoEditGAN, a framework that ensures edits remain stable across time. Their approach follows a three-step pipeline:

  1. Initialization: They align the video frames and use standard GAN inversion techniques (like PTI or Restyle) to find the latent codes ($W$) for each frame. They then apply the desired edit (e.g., "make angry") to these codes.
  2. Two-Phase Optimization: This is the core innovation.
  3. Phase 1 (Latent Code Update): Instead of optimizing the latent codes directly—which can be unstable—they train a Multi-layer Perceptron (MLP) to predict residuals for the latent codes. They use a bi-directional photometric loss (calculated using optical flow from the RAFT network) to ensure that pixels move consistently between frames.
  4. Phase 2 (Generator Update): Even with optimized latents, some identity details (like the exact shape of the mouth) might shift. To fix this, they fine-tune the weights of the StyleGAN generator itself. They use a "perceptual difference mask" to ensure the generator only changes the edited parts (like the new glasses) while keeping the rest of the face identical to the original input.
  5. Unalign: Finally, they "unalign" the frames to put the edited face back into the original video context.

Datasets

The researchers evaluated their method using:

  • RAVDESS: The Ryerson Audio-Visual Database of Emotional Speech and Song. This provides high-quality facial video for testing in-domain edits (attributes like "beard" or "angry").
  • Internet Videos: Real-world footage of public figures (e.g., talk show clips) to demonstrate the robustness of the method on unconstrained data.
  • StyleGAN-NADA / StyleCLIP: Used to generate the semantic editing directions for both in-domain (attribute) and out-of-domain (style) transformations.

Key Insights and Ideas

  • Implicit is Better than Explicit: One of the "aha moments" was finding that updating latent codes via an MLP (implicit optimization) produces much smoother results than updating the codes directly. The MLP acts as a regularizer, preventing the optimization from falling into noisy, per-frame local minima.
  • The Identity Rescue: The authors realized that latent-space editing alone often "leaks" into other attributes. By fine-tuning the generator in Phase 2 with a mask, they can "anchor" the unedited parts of the face to the original input, effectively decoupling the edit from the person's identity.
  • Agnostic Framework: The method doesn't care how you got your initial edit. Whether you used StyleCLIP, InterfaceGAN, or StyleGAN-NADA, VideoEditGAN can be applied on top to stabilize the results.

Key Results

The paper compares VideoEditGAN against baselines like Deep Video Prior (DVP) and Latent Transformer (LT).

Comparison of original input frames with "angry" and "eyeglasses" semantic edits across a video sequence.
  • Quantitative: In both in-domain and out-of-domain tasks, VideoEditGAN achieved significantly lower Warping Error ($E_{warp}$), meaning the video was more temporally stable. Crucially, it maintained much lower LPIPS scores (perceptual distance) compared to the original edited frames, indicating it stayed truer to the intended edit than DVP, which tended to blur details.
  • Qualitative: Visual results show that while DVP often changes the style of eyeglasses frame-by-frame or blurs the face into a "Disney Princess" smudge, VideoEditGAN keeps the glasses' shape and the princess's features sharp and consistent throughout the sequence.

Limitations and Future Work

While powerful, the method has a few hurdles:

  • Computational Cost: Because it requires a two-phase optimization for every video, it is not yet "real-time."
  • Out-of-Domain Constraints: For extreme style changes (like turning a person into a sketch), the "unalign" step (Phase 3) is difficult because the edited face no longer matches the original background's texture and lighting.
  • Ethical Concerns: The authors explicitly acknowledge the potential for misuse. High-quality, consistent video editing could be used to create misinformation or deepfakes, highlighting the need for robust detection tools.

Future work may involve speeding up the optimization process or developing better blending techniques for extreme out-of-domain style transfers.

Summary updated

BibTeX
@inproceedings{xu2022temporally,
  author = {Yiran Xu and Badour AlBahar and Jia-Bin Huang},
  title = {{Temporally Consistent Semantic Video Editing}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19784-0\_21},
}
Figure