FLATTEN: optical FLow-guided ATTENtion for consistent text-to-video editing

Yuren Cong, Mengmeng Xu, christian simon, Shoufa Chen, Jiawei Ren, Yanping Xie, Juan-Manuel Perez-Rua, Bodo Rosenhahn, Tao Xiang, Sen He

Overview and the Consistency Problem

While text-to-image (T2I) generation has reached incredible heights, text-to-video (T2V) editing remains plagued by flickering and temporal inconsistency. Most current methods take a pre-trained T2I model (like Stable Diffusion) and "inflate" its 2D spatial attention into spatio-temporal attention.

The problem with standard spatio-temporal attention is that it is dense. Every patch in every frame attends to every other patch in every other frame. This introduces irrelevant information—a patch of a cat’s ear might accidentally attend to a patch of the background three frames later. This lack of precise temporal correspondence leads to visual inconsistency, where textures, colors, and shapes shift unnaturally as the video progresses.

To solve this, researchers introduce FLATTEN (optical FLow-guided ATTENtion), a training-free, "plug-and-play" attention mechanism. By forcing patches on the same motion path to attend to each other across frames, it eliminates the flickering and structural distortions common in current diffusion-based video editing.

Examples of consistent text-to-video editing using FLATTEN.

How FLATTEN Works

FLATTEN replaces or augments dense attention with a motion-aware alternative, ensuring that the "visual memory" of an object is preserved accurately over time.

  1. Optical Flow Estimation: The system uses a pre-trained model (like RAFT) to calculate the movement of pixels between consecutive frames of the source video.
  2. Patch Trajectory Sampling: These flow fields are downsampled to match the resolution of the diffusion model's latent space. The algorithm then tracks the "trajectory" of specific patches across the entire video sequence.
  3. Flow-Guided Attention: Instead of a patch looking at everything, the FLATTEN module restricts attention so that a query patch only communicates with patches located on its own predicted motion path.
  4. DDIM Inversion & Injection: The method applies FLATTEN during both the inversion process (turning the video into noise) and the sampling process (generating the edited video). Applying it during inversion significantly improves the quality of the estimated latent noise, helping the model "remember" fine details that are often lost.
  5. Training-Free Integration: FLATTEN is integrated into the U-Net of a diffusion model alongside existing spatio-temporal attention. Crucially, it uses the existing weights of the T2I model and requires no fine-tuning on the source video.
The FLATTEN pipeline integrating optical flow into the diffusion model's U-Net.

Key Insights and Performance

The most powerful idea behind FLATTEN is that optical flow provides a "ground truth" for where information should flow. By hard-coding this into the attention mask, the model is forced to be consistent. Furthermore, because it doesn't change the underlying weights, FLATTEN can be added to other T2V methods to instantly improve their temporal stability.

Evaluation and Results

The researchers evaluated their framework using 53 videos from the LOVEU-TGVE benchmark (comprising videos from DAVIS and Videvo datasets). Each 32-frame video was paired with four creative textual prompts.

FLATTEN achieved new state-of-the-art (SOTA) performance across several metrics:

  • Visual Consistency: It achieved the lowest Warping Error ($E_{warp}$), which measures how much the pixels deviate from the expected motion path. On the TGVE-D set, it scored 4.92, compared to 29.23 for Tune-A-Video and 5.36 for TokenFlow.
  • Editing Quality ($S_{edit}$): Combining textual alignment and consistency, FLATTEN scored 57.01 on TGVE-D, significantly higher than the previous best of 50.21 (TokenFlow).
  • User Preference: In a study with 16 participants, FLATTEN was preferred over 41% of the time for both visual consistency and motion preservation, nearly doubling the scores of the next-best competitor.
  • Efficiency: Unlike methods that require 10+ minutes of fine-tuning per video, FLATTEN runs in roughly 3.5 minutes on a single A100 GPU.

Limitations and Future Directions

While FLATTEN excels at style, color, and texture editing (e.g., turning a cat into a tiger), it struggles with dramatic structural changes where the target shape is fundamentally different from the source. Additionally, the method is inherently dependent on the quality of the optical flow estimator. If the flow model fails due to extreme motion blur or occlusions, FLATTEN may introduce artifacts, though it has shown robustness to minor noise in the flow field. Future work may explore integrating more precise flow estimation models or allowing for greater structural deformation while maintaining consistency.

Summary updated

BibTeX
@inproceedings{cong2024flatten,
  author = {Yuren Cong and Mengmeng Xu and christian simon and Shoufa Chen and Jiawei Ren and Yanping Xie and Juan-Manuel Perez-Rua and Bodo Rosenhahn and Tao Xiang and Sen He},
  title = {{FLATTEN: optical FLow-guided ATTENtion for consistent text-to-video editing}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=JgqftqZQZ7},
}
Figure