Path-Adaptive Matting for Efficient Inference Under Various Computational Cost Constraints

Qinglin Liu, Zonglin Li, Xiaoqian Lv, Xin Sun, Ru Li, Shengping Zhang

Abstract

Deep image matting models have achieved significant accuracy but often at the cost of high computational complexity, making them unsuitable for real-time deployment on resource-constrained edge devices. Furthermore, existing architectures are static, requiring manual redesign and retraining for different hardware targets. We present Path-Adaptive Matting (PAM), a unified framework that dynamically adjusts its inference path based on input image content and user-defined computational budgets. By introducing a performance-aware path learning strategy and learnable connect layers, PAM achieves state-of-the-art results while significantly reducing FLOPs and parameter counts.

Introduction

Natural image matting—the precise estimation of foreground transparency (alpha matte)—is a critical component in modern video editing, live streaming, and virtual background applications. While deep learning has pushed the boundaries of matting quality, the computational demands have escalated. State-of-the-art models like FBAMatting can require upwards of 680 GFLOPs for a single high-definition frame, presenting a significant barrier for mobile and edge deployment.

Currently, developers must maintain multiple separate models to accommodate varying hardware capabilities. While dynamic routing has been explored in classification tasks, applying it to dense regression tasks like matting is challenging. Standard dynamic networks often suffer from "performance collapse," where the model learns to bypass layers to minimize compute at the expense of pixel-level accuracy. PAM addresses these challenges by providing a single, flexible network capable of adapting to diverse computational constraints on the fly.

Methodology

Path-Adaptive Matting (PAM) Architecture

The PAM architecture is designed to solve a bilevel optimization problem: optimizing network weights for accuracy while simultaneously training a path estimator to select the most efficient route for a given budget. The architecture consists of three primary components:

  1. Cost Constraint Embedding: The target computational budget (e.g., maximum FLOPs) is treated as an input feature. This embedding is integrated into the feature stream, allowing the network to adjust its internal representations based on the strictness of the constraint.
  2. Path Selection Layers: These layers utilize global image semantics via channel attention to predict whether to execute or bypass specific depthwise convolution modules. This ensures that the routing decision is informed by the complexity of the image itself.
  3. Learnable Connect Layers: A major hurdle in dynamic matting is feature mismatch; skipping layers can cause the feature distribution to drift, ruining the final matte. PAM introduces efficient 1x1 convolutions that align bypassed features with the target layer's expected input, maintaining representational consistency.

Performance-Aware Path Learning

To avoid the performance collapse common in gradient-based Neural Architecture Search (NAS), the authors developed a novel training strategy. Instead of relying solely on differentiable routing (like Gumbel-Softmax), PAM uses Monte Carlo simulations to estimate a prior distribution of optimal paths. During training, the system samples candidate paths, evaluates them online, and uses the highest-performing path as a ground-truth label to supervise the path selection layers. This prevents the model from over-aggregating skip connections and ensures that computational savings do not come at the cost of quality.

Experimental Results

Efficiency and Accuracy

PAM was evaluated against several state-of-the-art (SOTA) models under three constraint levels: Mild (<75 GFLOPs), Moderate (<70 GFLOPs), and Aggressive (<60 GFLOPs). On the Adobe Composition-1K dataset, PAM (Moderate) achieved a Sum of Absolute Differences (SAD) of 23.25 using only 69.6 GFLOPs and 7.1M parameters. In contrast, MatteFormer requires 233.3 GFLOPs and 44.9M parameters to achieve a similar SAD of 23.80. This represents a reduction of approximately 70% in FLOPs and 84% in parameter count while slightly improving accuracy.

Inference Speed

The efficiency of PAM translates directly to real-world performance. On an AMD R9 3900X CPU, PAM (Aggressive) processed a 2048x2048 image in 5.23 seconds. This is significantly faster than MatteFormer (14.39 seconds) and LFPNet (45.93 seconds), demonstrating PAM's viability for high-resolution processing on standard hardware.

Generalization and Real-World Performance

When tested on the AIM-500 dataset (real-world images), an interesting phenomenon was observed: the most aggressively constrained version of PAM often outperformed the mildly constrained version. This suggests that for models trained on synthetic data, a higher computational capacity can lead to overfitting on synthetic artifacts. The tighter constraints in PAM appear to act as a form of regularization, improving generalization to real-world photography.

Conclusion

Path-Adaptive Matting (PAM) represents a significant step toward deployable, high-quality image matting. By combining dynamic routing with feature alignment and a performance-aware learning strategy, PAM eliminates the need for multiple hardware-specific models. Future work will focus on narrowing the domain shift between synthetic training environments and real-world applications to ensure that increased computational budgets consistently yield higher fidelity in diverse settings.

Summary updated

BibTeX
@inproceedings{liu2025path,
  author = {Qinglin Liu and Zonglin Li and Xiaoqian Lv and Xin Sun and Ru Li and Shengping Zhang},
  title = {{Path-Adaptive Matting for Efficient Inference Under Various Computational Cost Constraints}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i5.32589},
}
Figure