FreeMask: Rethinking the Importance of Attention Masks for Zero-Shot Video Editing

Lingling Cai, Kang Zhao, Hangjie Yuan, Yingya Zhang, Shiwei Zhang, Kejie Huang

Abstract

Zero-shot video editing aims to modify video content through text prompts without retraining models. While cross-attention masks are commonly used to guide these edits, their quality is often inconsistent across the generation process, leading to visual artifacts like flickering and ghosting. This paper introduces FreeMask, a training-free method that rethinks mask utilization. By identifying that mask precision varies dynamically across U-Net layers and denoising timesteps, FreeMask employs a Mask Matching Cost (MMC) metric to adaptively select optimal masks. Furthermore, it introduces a comprehensive masked fusion strategy across temporal, self, and cross-attention modules. Experimental results demonstrate that FreeMask significantly improves structural control and temporal consistency compared to existing state-of-the-art methods.

Introduction

Zero-shot video editing—modifying a video using a text prompt without retraining the model—is a major goal in generative AI. Current methods often rely on "cross-attention masks" to localize edits (e.g., changing a "jeep" to a "Porsche"). However, these masks are often noisy, blurry, or imprecise, leading to artifacts where the original object's shape persists in the edited version. Previous research largely treated these masks as uniform. This paper addresses this gap by proving that mask quality is highly dynamic, changing depending on the specific neural network layer and the denoising timestep.

Methodology

FreeMask operates on a standard "inversion-then-denoising" pipeline and introduces three core innovations to improve structural fidelity.

The FreeMask pipeline, illustrating the integration of Mask Matching Cost (MMC) selection and the M-Fusion module within the denoising process.

1. Mask Matching Cost (MMC)

The authors propose MMC, a metric based on Mean Intersection over Union (MIoU), to quantify the precision of internal attention masks against ground-truth segmentation.

  • LMMC (Layer-wise): Measures precision across different layers of the U-Net.
  • TMMC (Timestep-wise): Measures how precision evolves as the video is denoised from random noise into a clear image.

2. Adaptive Mask Selection

Based on the specific editing task, FreeMask adaptively selects masks. For shape editing (e.g., dog to cat), it utilizes "time-aware" masks that allow the object's geometry to evolve. For style or attribute editing (e.g., applying a "Ukiyo-e style"), it uses "time-agnostic" precise masks to lock in the existing structure.

3. Comprehensive Masked Fusion (M-Fusion)

Unlike previous methods that primarily mask cross-attention, FreeMask applies its selected masks across all major attention modules: Temporal Attention (TA), Self-Attention (SA), and Cross-Attention (CA). This ensures that motion, structure, and semantic details are correctly decoupled between the original and edited versions.

Key Insights

Analysis of mask quality: (a) visual heatmaps across layers and timesteps, (b) Timestep-wise MMC (TMMC) showing improvement during denoising, and (c) Layer-wise MMC (LMMC) revealing the "Goldilocks zone" in middle layers.
  • The "Goldilocks Zone" of Layers: Mask precision follows a U-shaped cost curve across layers. The middle layers of the diffusion model provide the highest quality masks; outer layers are too noisy, and inner layers lack sufficient resolution.
  • Coarse-to-Fine Denoising: Semantic matching accuracy (TMMC) improves as the denoising process moves from $T=max$ to $T=0$. Early-stage masks are less reliable for fine details but are effective for guiding broad shape changes.
  • The Over-Constraint Trap: Excessive fusion of temporal features can hinder edits. By masking Temporal Attention, FreeMask prevents the motion of the original object from "bleeding" into the edited region, which is critical for shape-altering tasks.

Experimental Results

FreeMask was evaluated against state-of-the-art (SOTA) methods including FateZero, TokenFlow, and Video-P2P using the DAVIS and Pexels datasets.

  • Quantitative Performance: FreeMask achieved superior scores in Temporal Consistency (0.952) and Video-Text Alignment (CLIP score of 0.282). It also led in structure preservation metrics such as M.PSNR and LPIPS.
  • Qualitative Performance: In complex tasks like "Jeep to Porsche" shape editing, FreeMask produced cleaner transitions and more realistic details, avoiding the "ghosting" artifacts common in competing methods.
  • Efficiency: As a zero-shot, training-free method, it requires no parameter fine-tuning and can be easily integrated into existing diffusion-based frameworks.

Conclusion

FreeMask demonstrates that rethinking the role of attention masks—specifically their layer-wise and timestep-wise dynamics—is key to high-fidelity video editing. By adaptively selecting and fusing these masks, the framework achieves a new level of structural control and temporal stability in zero-shot scenarios. Future work may extend this structural-aware approach to multi-object editing and more complex motion synthesis.

Summary updated

BibTeX
@inproceedings{cai2025freemask,
  author = {Lingling Cai and Kang Zhao and Hangjie Yuan and Yingya Zhang and Shiwei Zhang and Kejie Huang},
  title = {{FreeMask: Rethinking the Importance of Attention Masks for Zero-Shot Video Editing}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  url = {https://openreview.net/forum?id=OCdJfbs3zN},
}
Figure