Trans-Adapter: A Plug-and-Play Framework for Transparent Image Inpainting

Yuekun Dai, Haitian Li, Shangchen Zhou, Chen Change Loy

TL;DR

This paper introduces Trans-Adapter, a novel plug-and-play framework that enables existing text-to-image diffusion models to perform inpainting on transparent (RGBA) images. This is a significant advancement as current inpainting methods are primarily designed for RGB images, and Trans-Adapter ensures alignment between the generated RGB and alpha channels, leading to more natural results.

What Problem Does This Paper Address?

Transparent images, characterized by an alpha channel, are fundamental in various creative industries like film, animation, and game development. They allow for complex layering and compositing. However, existing AI-powered image inpainting tools are largely limited to standard RGB images. This forces artists to manually edit transparent images, a tedious process that struggles to maintain visual coherence, especially around transparency boundaries. Current approaches to transparent image inpainting often involve a two-stage pipeline (inpainting followed by matting), which can lead to inconsistencies and jagged edges. This paper aims to bridge this gap by enabling direct, high-quality inpainting of transparent images using diffusion models.

Methods

The core innovation is Trans-Adapter, a plug-and-play module designed to integrate seamlessly with existing diffusion-based inpainting frameworks like Stable Diffusion. The approach decomposes RGBA images into separate RGB and alpha channels, treating them as a two-frame video. This allows the model to process them jointly.

Key components of Trans-Adapter include:

  • Spatial Alignment Module: Incorporated into the shallower layers of the diffusion model's U-Net, this module uses convolutional layers to enforce spatial synchronization between the alpha and RGB latent representations. This helps maintain alignment even after the VAE decoder.
  • Cross-Domain Self-Attention: Added to the U-Net's bottleneck, this module allows the model to reference surrounding regions for inpainting, particularly beneficial for high-frequency details in the alpha channel that are hard to predict.
  • Alpha Map LoRA: A Low-Rank Adaptation module is introduced to specifically equip the diffusion model with the ability to inpaint the alpha map. This module is trained to learn residuals for alpha map generation, and during training, it uses distinct text prompts for RGB and alpha content to guide the model.

The training strategy involves a two-stage process: first, training the Alpha Map LoRA, and then jointly fine-tuning the spatial alignment module, cross-domain self-attention module, and the alpha map LoRA.

Datasets

  • Training Data: The authors created a new dataset by purchasing transparent images from online PNG stocks and manually filtering them. This dataset, combined with a subset of MAGICK [5], forms the training data. They also mention using LLaVA [19] for generating text prompts.
  • Benchmark: The paper introduces LayerBench, a new benchmark specifically designed for evaluating transparent image inpainting. It consists of 400 natural images and 400 generated images, with a focus on masks that overlap with alpha channel boundaries to rigorously test RGB-alpha alignment. LayerBench is divided into two subsets: LayerBench-Natural and LayerBench-Generated.

Key Insights and Ideas

  • Direct RGBA Inpainting is Crucial: The paper highlights that simply inpainting RGB and then matting the alpha channel is insufficient for high-quality results. Direct, aligned inpainting of both channels is necessary.
  • Spatial and Cross-Domain Alignment is Key: The proposed spatial alignment module and cross-domain self-attention are critical for ensuring that the generated RGB and alpha content are consistent and spatially coherent, preventing artifacts.
  • Alpha Map LoRA for Targeted Learning: Introducing a specific LoRA module for alpha map generation allows the model to learn the nuances of alpha channel inpainting without disrupting the pre-trained RGB inpainting capabilities.
  • New Benchmark for a New Problem: The creation of LayerBench is essential because existing RGB inpainting benchmarks are inadequate for evaluating transparent image inpainting, particularly concerning RGB-alpha alignment.
  • Novel AEQ Metric: The development of the Alpha Edge Quality (AEQ) metric provides a much-needed quantitative way to assess the alignment between RGB and alpha channels, addressing a gap in evaluation.

Key Results

  • Trans-Adapter achieves competitive or superior results compared to existing two-stage pipelines (image inpainting + matting/segmentation) on their proposed LayerBench benchmark.
  • Qualitative results show Trans-Adapter's ability to reconstruct details in the alpha channel and avoid misalignment between RGB and alpha channels, even in challenging regions.
  • The paper introduces a new non-reference metric, AEQ, which effectively quantifies RGB-alpha alignment.
  • Ablation studies demonstrate the importance of both the spatial alignment module and the cross-domain self-attention for achieving high-quality results.

Limitations and Future Work

  • Dataset Size: While the authors created a new dataset, they acknowledge that existing transparent image datasets are limited in size and quality compared to large-scale RGB datasets.
  • Computational Cost: Training and inference for diffusion models can be computationally intensive, though the plug-and-play nature of Trans-Adapter aims to mitigate this by leveraging pre-trained models.
  • Future Work: The paper suggests that further exploration of controllable editing via ControlNet and seamless integration into various community models are promising directions. The authors also implicitly suggest that expanding the training dataset and exploring more advanced alignment techniques could further improve performance.

Summary updated

BibTeX
@inproceedings{dai2025trans,
  author = {Yuekun Dai and Haitian Li and Shangchen Zhou and Chen Change Loy},
  title = {{Trans-Adapter: A Plug-and-Play Framework for Transparent Image Inpainting}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure