---
title: 'AdaWPT: Adaptive Window Pruning for Deblurring'
url: https://www.emergentmind.com/topics/adawpt-window-pruning
type: topic
---

# AdaWPT: Adaptive Window Pruning for Deblurring

AdaWPT (Adaptive Window Pruning Transformer) is a mechanism designed to enhance the efficiency and fidelity of local motion deblurring in high-resolution images by dynamically selecting computation regions within a vision Transformer architecture. Local motion blur, characterized by spatially varying blur patterns due to moving objects and static backgrounds, presents challenges for contemporary deblurring networks that predominantly perform global operations. AdaWPT addresses this inefficiency by pruning non-blurred spatial windows during processing, focusing Transformer capacity on genuinely degraded regions. Developed in the context of the Local Motion Deblurring Vision Transformer (LMD-ViT), AdaWPT integrates window-based attention, blur-aware confidence prediction, Gumbel-Softmax-based discrete window selection, and loss functions guided by annotated blur masks [2306.14268].

## 1. Structural Overview and Context

LMD-ViT employing AdaWPT follows a U-shaped encoder–decoder architecture with skip connections. AdaWPT blocks are inserted at various resolution levels, both in the encoder, bottleneck, and decoder pathways. The input image $B\in\mathbb{R}^{H\times W\times 3}$ is projected to an initial feature map $X_0$. Each encoder stage includes a down-sampling operation followed by $n_i$ AdaWPT blocks, generating successively lower-resolution ($X_i$) feature maps. After a two-block AdaWPT bottleneck, the decoder symmetrically upsamples the features, integrating encoder features via skip connections. The network outputs a residual image $R$, added to the input $B$ to yield the final sharp prediction $S' = B + R$. Only AdaWPT blocks conduct adaptive window pruning; other layers use standard convolutional or sampling operations [2306.14268].

## 2. Window Partitioning and Feature Tokenization

An input feature map $X\in\mathbb{R}^{H\times W\times C}$ entering an AdaWPT block is partitioned into a grid of non-overlapping $P \times P$ spatial windows:
$$
N = \frac{H}{P} \times \frac{W}{P}, \quad \{W_i\}_{i=1}^{N}, \quad W_i \in \mathbb{R}^{P \times P \times C}
$$
Each window $W_i$ is flattened and/or linearly projected to a token vector:
$$
x_i = \mathrm{Flatten}(W_i) \in \mathbb{R}^{P^2C} \xrightarrow{\ W\in\mathbb{R}^{d\times(P^2C)} \ } \mathbb{R}^d
$$
This yields a set of tokens $\{x_i\}$ representing local regions, forming the computational units for adaptivity.

## 3. Blurriness Confidence Prediction and Gumbel-Softmax Pruning

AdaWPT employs a learned blurriness confidence predictor. In the first block at each scale (AdaWPT-F), each $x_i$ passes through a multi-layer perceptron stack:
$$
h_i = \mathrm{MLP}_1(x_i) \in \mathbb{R}^{d'}, \quad e_i = \mathrm{MLP}_2(h_i) \in \mathbb{R}^2
$$
Softmax is applied to $e_i$ to obtain a blur confidence $c_i \in [0,1]$:
$$
[c_i,\, 1-c_i] = \mathrm{Softmax}(e_i)
$$
Subsequent blocks at the same scale (AdaWPT-P) reuse the same $c_i$ decision map.

During training, binarization of $c_i$ is facilitated by the Gumbel-Softmax re-parameterization. Sampling with Gumbel noise $g_{i,k}\sim\mathrm{Gumbel}(0,1)$ and temperature $\tau$ yields a soft, differentiable discrete decision:
$$
y_{i,k} = \frac{\exp\bigl((\log \pi_{i,k} + g_{i,k})/\tau\bigr)}{\sum_{j=1}^2 \exp\bigl((\log \pi_{i,j} + g_{i,j})/\tau\bigr)}
$$
where $\pi_{i,1}=c_i$, $\pi_{i,2}=1-c_i$. The hard sample $m_i \in \{0,1\}$ is used in the forward pass, with gradients propagated through the soft variable $y_{i,k}$ (straight-through estimator). At inference, $m_i$ is set as $1$ if $c_i \geq \beta$ (a threshold, with $\beta\approx0.5$ used in practice), and $0$ otherwise [2306.14268].

## 4. Pruning Mechanism and Transformer Application

During the forward pass, only windows with $m_i=1$ are retained for subsequent Transformer computation; others are zeroed:
$$
X' \leftarrow \text{assemble_windows}(\{m_i \cdot W_i\})
$$
Retained windows proceed through window-based multi-head self-attention (W-MSA) and local feed-forward (W-LeFF) operations. After processing, outputs are scattered back into the original spatial grid.

The pruning procedure is applied in both encoder and decoder stages, compounding computational savings by focusing on windows corresponding to blurred regions. A single confidence map is predicted and reused within each resolution group, reducing redundant computation [2306.14268].

## 5. Supervision and Loss Functions

End-to-end training of LMD-ViT with AdaWPT is supervised by a composite loss:
- **Reconstruction loss** ($\mathcal{L}_{\rm rec}$): Per-pixel loss (e.g., $L_1$) between deblurred prediction $S'$ and ground truth $S$, potentially emphasizing annotated blur regions defined by mask $M\in\{0,1\}^{H\times W}$.
- **Pruning loss** ($\mathcal{L}_{\rm prune}$): Binary cross-entropy between predicted windowwise $c_i$ and downsampled ground-truth mask $M_i$, enforcing $c_i\approx1$ on blurred regions and $c_i\approx0$ elsewhere:
$$
\mathcal{L}_{\rm prune} = -\sum_{i=1}^N \Big[ M_i\log c_i + (1-M_i)\log(1-c_i)\Big]
$$
The total loss is
$$
\mathcal{L} = \mathcal{L}_{\rm rec} + \lambda\,\mathcal{L}_{\rm prune}
$$
with $\lambda$ tuned to balance deblurring and pruning accuracy ($\lambda\approx0.01$--$0.1$) [2306.14268].

## 6. Computational Complexity and Comparative Results

With $N$ windows and local window FLOPs $F_{\rm win}$, the unpruned network computes $F_{\rm total} = N F_{\rm win}$ operations per block. Window pruning yields
$$
F_{\rm pruned} = (\sum_{i=1}^{N} m_i) F_{\rm win}
$$
with relative FLOPs reduction $1 - \sum_i m_i/N$. Empirically, AdaWPT prunes $\sim66\%$ of windows, leading to a 66\% FLOPs saving and over $2\times$ inference speedup versus global Transformer baselines (Uformer, Restormer), while also increasing PSNR by $+0.28$ dB. Weighted PSNR improves by $0.95$ dB over the best-performing CNNs with comparable or faster inference. Pruning in all 9 AdaWPT blocks provides the optimal trade-off, reducing inference time from 1.30 s to 0.56 s. Refined blur masks enhance pruning precision from 66\% to 97\%, yielding a further $\sim0.1$ dB PSNR increase [2306.14268].

| System                  | FLOPs Reduction | Speedup | PSNR Gain        |
|-------------------------|-----------------|---------|------------------|
| vs. best CNN (ReLoBlur) | n/a             | similar | +0.50 dB         |
| vs. global Transformer  | 66%             | >2×     | +0.28 dB         |

## 7. Limitations and Prospective Enhancements

Operationally, AdaWPT is not yet real-time for very high-resolution images. While pruning precision exceeds 95%, small or subtle blur regions may be missed. A plausible implication is that precise blur-region detection governs deblurring fidelity and computational efficiency. Future extensions proposed include integrating cross-window context into the confidence predictor, employing dynamic window sizes, multi-task deblurring and mask refinement, hardware-aware real-time implementations, and expanding to temporal modules for multi-frame deblurring.

In summation, AdaWPT’s integration of region-aware token selection, blur-confidence prediction, Gumbel-Softmax binarization, and selective Transformer computation efficiently targets the spatially localized nature of real-world motion blur, elevating both restoration accuracy and resource utilization efficiency [2306.14268].

Source: https://www.emergentmind.com/topics/adawpt-window-pruning