Learning A Sparse Transformer Network for Effective Image Deraining

Xiang Chen, Hao Li, Mingqiang Li, Jinshan Pan

Abstract

Single-image deraining is a challenging task due to the complex and diverse patterns of rain streaks. While Transformer-based methods have shown promise in capturing long-range dependencies, their standard dense self-attention mechanism often introduces irrelevant noise from rainy regions, hindering the restoration of fine details. In this paper, we present the DeRaining Sparse Transformer (DRSformer), which utilizes a learnable Top-k Sparse Attention (TKSA) mechanism to selectively aggregate the most relevant features. Combined with a Mixed-Scale Feed-Forward Network (MSFN) and a Mixture of Experts Feature Compensator (MEFC), the proposed model effectively restores high-quality images with sharp textures. Extensive experiments on synthetic and real-world datasets demonstrate that DRSformer achieves state-of-the-art performance.

Introduction

Single-image deraining is a classic ill-posed inverse problem where the goal is to recover a clean background from an image degraded by rain streaks. Early solutions relied on handcrafted statistical priors, which often struggled with the complexity of real-world rain patterns. The advent of Deep Learning brought Convolutional Neural Networks (CNNs) into the fold. While CNNs excel at capturing local textures, their limited receptive fields make it difficult to model the long-range dependencies necessary to understand global rain patterns.

Transformers addressed this limitation by using self-attention to model global dependencies. However, standard Transformers employ "dense" attention, where every pixel (token) interacts with every other pixel. In the context of image restoration, this can be counterproductive; interactions between a clean patch and a heavily degraded rainy patch can introduce noise, interfering with the restoration of fine details. The DRSformer addresses this by introducing content-based sparsity into the attention mechanism.

Proposed Method: DRSformer

The DRSformer architecture is designed to filter out degradations while preserving multi-scale local details. It introduces three primary innovations to the standard Transformer block:

1. Top-k Sparse Attention (TKSA)

Instead of aggregating features from all possible tokens, TKSA employs a learnable operator to identify and retain only the $k$ most important attention scores for each query. This "content-based sparsity" acts as a relevance filter, ensuring the model focuses on the most useful features for restoration while ignoring noisy, rain-affected tokens.

2. Mixed-Scale Feed-Forward Network (MSFN)

Rain streaks vary significantly in size and density. To account for this, the MSFN replaces the standard feed-forward layer with parallel depth-wise convolutions (3x3 and 5x5). This allows the network to extract and fuse multi-scale local information, capturing both fine and coarse rain patterns.

3. Mixture of Experts Feature Compensator (MEFC)

To further refine the output, the model utilizes a set of "experts"—CNN operators with varying receptive fields, such as dilated convolutions and average pooling. A gating mechanism adaptively selects the most appropriate experts to compensate for lost details based on the specific characteristics of the input image.

The overall architecture of DRSformer, featuring the Top-k Sparse Attention (TKSA), Mixed-scale Feed-forward Network (MSFN), and Mixture of Experts Feature Compensator (MEFC).

Experiments and Results

The DRSformer was evaluated against several state-of-the-art (SOTA) models, including Restormer, Uformer, and IDT, across multiple synthetic and real-world benchmarks.

Quantitative Evaluation

On the challenging Rain200H synthetic dataset, DRSformer achieved a PSNR of 32.18 dB, outperforming the previous best (IDT) by 0.08 dB and CNN-based methods by over 1.0 dB. On the real-world SPA-Data, which contains over 638,000 training pairs, the model reached a PSNR of 48.53 dB, demonstrating its robustness in practical scenarios.

Qualitative Comparison

Visual results highlight the effectiveness of the sparse attention mechanism. While competing methods often leave behind blurring or ghosting artifacts—particularly around high-frequency textures like boat masts or building edges—DRSformer produces significantly sharper results with more accurate color reproduction.

Visual comparison of deraining results on a sample image. DRSformer (Ours) recovers sharper details and fewer artifacts compared to Uformer, Restormer, and IDT.

Conclusion

The DRSformer demonstrates that sparsity is a powerful tool for image restoration. By forcing the Transformer to focus only on relevant features via Top-k Sparse Attention, the model effectively filters out rain-induced noise. While the model achieves state-of-the-art results, its high computational complexity (33.7M parameters) remains a challenge. Future research will focus on model compression techniques like pruning and distillation to enable real-time deployment on resource-constrained devices.

Summary updated

BibTeX
@inproceedings{chen2023learning,
  author = {Xiang Chen and Hao Li and Mingqiang Li and Jinshan Pan},
  title = {{Learning A Sparse Transformer Network for Effective Image Deraining}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure