Abstract
Video inpainting requires maintaining both spatial plausibility and temporal consistency, a task often hindered by the "blurry average" effect of continuous feature space models. We present DLFormer (Discrete Latent Transformer), a novel framework that treats video inpainting as a discrete code inference problem. By learning a video-specific codebook and utilizing a Transformer to predict missing regions in a discrete latent space, DLFormer produces sharper textures and superior temporal stability compared to state-of-the-art continuous-feature methods. Our approach achieves leading performance on YouTube-VOS and DAVIS benchmarks, significantly reducing visual artifacts and flickering.
Introduction
Video inpainting—the process of filling in missing or corrupted regions in a video sequence—is a fundamental challenge in computer vision. A successful model must ensure that inpainted patches are spatially realistic while remaining temporally consistent across frames to avoid flickering or "ghosting" artifacts.
Existing state-of-the-art methods typically operate in a continuous feature space using Convolutional Neural Networks (CNNs) or Transformers. However, because the space of continuous values is infinite, these models often struggle with hallucinating sharp details, frequently settling on a blurry average of possible outcomes. DLFormer addresses this by shifting the problem into a discrete latent space, where the model selects from a finite set of learned visual prototypes, effectively regularizing the output and preventing blurriness.
Methodology
DLFormer reimagines inpainting as a sequence prediction problem over discrete visual codes. The architecture is built upon three primary components:
1. Video-Specific Discrete Code Learning
Inspired by Vector Quantized Variational AutoEncoders (VQ-VAE), DLFormer represents a video using a compact codebook of discrete visual prototypes. Unlike standard VQ-VAEs that use a static, general-purpose codebook, DLFormer refines its codebook specifically for the target video. This ensures the "vocabulary" of the model is tailored to the unique textures and details of the specific scene, such as specific foliage or architectural patterns.
2. Discrete Latent Transformer
Once the video is mapped to a grid of discrete codes, the inpainting task becomes a sequence prediction problem. The Transformer employs a self-attention mechanism to analyze valid regions across the entire video sequence, allowing it to "borrow" information from distant frames to accurately predict the missing codes in masked areas.
3. Temporal Aggregation Block (TAB)
To mitigate potential jitters caused by discrete predictions, a Temporal Aggregation Block (TAB) is introduced. This component performs residual refinement by looking at adjacent frames, smoothing transitions and ensuring short-term temporal flow is preserved.
Experiments and Results
Datasets
The model was evaluated on two industry-standard benchmarks:
- YouTube-VOS: A large-scale dataset with 541 test sequences featuring diverse dynamic scenes.
- DAVIS: A high-quality dataset of 150 videos, with 90 selected for testing complex object removal and restoration.
Quantitative Performance
DLFormer consistently outperformed existing models like STTN and FuseFormer. On the YouTube-VOS dataset, it achieved a PSNR of 33.95 and an SSIM of 0.970. Notably, it recorded the lowest VFID (0.082), a metric specifically designed to measure human-perceived video realism and consistency.
Qualitative Analysis
Visual comparisons demonstrate that while competing models often leave ghostly artifacts or blurry patches, DLFormer reconstructs sharp edges and believable textures. In a user study involving 32 volunteers, DLFormer was ranked highest for both individual frame quality and overall video smoothness.
Discussion and Key Insights
The primary advantage of DLFormer lies in the observation that discrete inference is more robust than continuous estimation. By limiting the model's choices to a learned library of codes, discretization acts as a powerful regularizer. Furthermore, the use of video-specific context allows the model to capture fine-grained details that general-purpose models overlook. Finally, the Transformer's global reasoning capability enables it to maintain long-term consistency by referencing information from frames far removed from the current hole.
Conclusion and Future Work
DLFormer demonstrates that thinking in discrete steps is a highly effective strategy for video editing. While the model sets a new state-of-the-art, future work will focus on reducing the computational overhead of the self-attention mechanism for very long sequences and streamlining the two-stage training process into a more end-to-end, real-time pipeline. Despite these challenges, DLFormer represents a significant step toward artifact-free, high-fidelity video inpainting.
Summary updated