Spatially-Attentive Patch-Hierarchical Network for Adaptive Motion Deblurring
Maitreya Suin, Kuldeep Purohit, A. N. Rajagopalan
Introduction
Motion-blurred images form due to relative motion during sensor exposure and are favored by photographers and artists in many cases for aesthetic purpose, but seldom by computer vision researchers, as many standard vision tools including detectors, trackers, and feature extractors struggle to deal with blur. Blind motion deblurring is an ill-posed problem that aims to recover a sharp image from a given image degraded due to motion-induced smearing of texture and high-frequency details. Due to its diverse applications in surveillance, remote sensing, and cameras mounted on hand-held and vehicle-mounted cameras, deblurring has gathered substantial attention from computer vision and image processing communities in the past two decades.
Majority of traditional deblurring approaches are based on variational model, whose key component is the regularization term. The restoration quality depends on the selection of the prior, its weight, as well as tuning of other parameters involving highly non-convex optimization setups. Non-uniform blind deblurring for general dynamic scenes is a challenging computer vision problem as blurs arise from various sources including moving objects, camera shake and depth variations, causing different pixels to capture different motion trajectories. Such hand-crafted priors struggle while generalizing across different types of real-world examples, where blur is far more complex than modeled .
Recent works based on deep convolutional neural networks (CNN) have studied the benefits of replacing the image formation model with a parametric model that can be trained to emulate the non-linear relationship between blurred-sharp image pairs. Such works directly regress to deblurred image intensities and overcome the limited representative capability of variational methods in describing dynamic scenes. These methods can handle combined effects of camera motion and dynamic object motion and achieve state-of-the-art results on single image deblurring task. They have reached a respectable reduction in model size, but still lack in accuracy and are not real-time.
Existing CNN-based methods have two major limitations: a) Weights of the CNN are fixed and spatially invariant which may not be optimal for different pixels in a dynamically blurred scene (e.g., sky vs. moving car pixels). This issue is generally tackled by learning a highly non-linear mapping by stacking a large number of filters. But this drastically increases the computational cost and memory consumption. b) A geometrically uniform receptive field is sub-optimal for the task of deblurring. Large image regions tend to be used to increase the receptive field even though the blur is small. This inevitably leads to a network with a large number of layers and a high computation footprint which slows down the convergence of the network.
Reaching a trade-off between the inference-speed, receptive field and the accuracy of a network is a non-trivial task (see Fig. 1). Our work focuses on the design of efficient and interpretable filtering modules that offer a better accuracy-speed trade-off as compared to simple cascade of convolutional layers. We investigate motion-dependent adaptability within a CNN to directly address the challenges in single image deblurring. Since motion blur is inherently directional and different for each image instance, a deblurring network can benefit from adapting to the blur present in each input test image. We deploy content-aware modules which adjust the filter to be applied and the receptive field at each pixel. Our analysis shows that the benefits of these dynamic modules for the deblurring task are two-fold: i) Cascade of such layers provides a large and dynamically adaptive receptive field. Directional nature of blur requires a directional receptive field, which a normal CNN cannot achieve within a small number of layers. ii) It efficiently enables spatially varying restoration, since changes in filters and features occur according to the blur in the local region. No previous work has investigated incorporating awareness of blur-variation within an end-to-end single image deblurring model.
Following the state of the art in deblurring, we adopt a multi-patch hierarchical design to directly estimate the restored sharp image. Instead of cascading along the depth, we introduce content-aware feature and filter transformation capability through a global-local attentive module and residual attention across layers to improve performance. These modules learn to exploit the similarity in the motion between different pixels within an image and are also sensitive to position-specific local context.
The efficiency of our architecture is demonstrated through a comprehensive evaluation on two benchmarks and comparisons with the state-of-the-art deblurring approaches. Our model achieves superior performance while being computationally more efficient. The major contributions of this work are:
We propose an efficient deblurring design built on new convolutional modules that learn the transformation of features using global attention and adaptive local filters. We show that these two branches complement each other and result in superior deblurring performance. Moreover, the efficient design of attention-module enables us to use it throughout the network without the need for explicit downsampling.
We further demonstrate the efficacy of learning cross-attention between encode-decoder as well as different levels in our design.
We provide extensive analysis and evaluations on dynamic scene deblurring benchmarks, demonstrating that our approach yields state-of-the-art results while being faster than the nearest competitor .
Proposed Architecture
To date, the driving force behind performance improvement in deblurring has been the use of a large number of layers and larger filters which assist in increasing the ”static” receptive field and the generalization capability of a CNN. However, these techniques offer suboptimal design, since network performance does not always scale with network depth, as the effective receptive field of deep CNNs is much smaller than the theoretical value (investigated in ).
We claim that a superior alternative is a dynamic framework wherein the filtering and the receptive field change across spatial locations and also across different input images. Our experiments show that this approach is a considerably better choice due to its task-specific efficacy and utility for computationally limited environments. It delivers consistent performance across diverse magnitudes of blur.
Although previous multi-scale and scale-recurrent methods have shown good performance in removing non-uniform blur, they suffer from expensive inference time and performance bottleneck while simply increasing model depth. Instead, inspired by , we adopt multi-patch hierarchical structure as our base-model, which compared to multi-scale approach has the added advantage of residual-like architecture that leads to efficient learning and faster processing speed. The overall architecture of our proposed network is shown in Fig. 2. We divide the network into 3 levels instead of 4 as described in . We found that the relative performance gain due to the inclusion of level 4 is negligible compared to the increase in inference time and number of parameters. At the bottom level input sliced into 4 non-overlapping patches for processing, and as we gradually move towards higher levels, the number of patches decrease and lower level features are adaptively fused using attention module as shown in Fig. 2. The output of level 1 is the final deblurred image. Note that unlike , we also avoid cascading of our network along depth, as that adds severe computational burden. Instead, we advocate the use of content-aware processing modules which yield significant performance improvements over even the deepest stacked versions of original DMPHN . Major changes incorporated in our design are described next.
Each level of our network consists of an encoder and a decoder. Both the encoder and the decoder are made of standard convolutional layer and residual blocks where each of these residual blocks contains 1 convolution layer followed by a content-aware processing module and another convolutional layer. The content-aware processing module comprises two branches for global and local level feature processing which are dynamically fused at the end. The residual blocks of decoder and encoder are identical except for the use of cross attention in decoder. We have also designed cross-level attention for effective propagation of lower level features throughout the network. We begin with describing content-aware processing module, then proceed towards the detailed description of the two branches and finally how these branches are adaptively fused at the end.
Content-Aware Processing Module
In contrast to high-level problems such as classification and detection , which can obtain large receptive field by successively down-sampling the feature map with pooling or strided convolution, restoration tasks like deblurring need finer pixel details that can not be achieved from highly downsampled features. Most of the previous deblurring approaches uses standard convolutional layers for local filtering and stack those layers together to increase the receptive field. uses self-attention and standard convolution on parallel branch and shows that best results are obtained when both features are combined together compared to using each feature separately. Inspired by this approach, we design a content-aware “global-local” processing module which depending on the input, deploys two parallel branches to fuse global and local features. The “global” branch is made of attention module. For decoder, this includes both self and cross-encoder-decoder attention whereas for encoder only self-attention is used. For local branch we design a pixel-dependent filtering module which determines the weight and the local neighbourhood to apply the filter adaptively. We describe in detail these two branches and their adaptive fusion strategy in the following sections.
The main drawback of this approach is very high memory requirement due to the matrix multiplication which requires storing a high dimensional matrix of dimension for image domain. This requires a large downsampling operation before applying attention. and use a local memory block instead of global all-to-all for making it practically usable. uses attention only from the layer with the smallest spatial dimension until it hits memory constraints. Also, these works typically resort to smaller batch size and sometimes additionally downsampling the inputs to self-attention layers. Although self attention is implemented in recent video super-resolution work , to reduce memory requirement it resorts to pixel-shuffling. This process is sub-optimal for spatial attention as pixels are transferred to channel domain to reduce the size.
Different from others, we resort to an attention mechanism which is lightweight and fast. If we consider Eq. (1) without the softmax and scaling factor for simplicity, we first do a matrix multiplication and then another matrix multiplication which is responsible for the high memory requirement and has a complexity of . Instead, if we look into this equation differently and first compute which is an matrix multiplication followed by which is an matrix multiplication, this whole process becomes lightweight with a complexity of . We suitably introduce softmax operation at two places which makes this approach intuitively different from standard self-attention but still efficiently gathers global information for each pixel. Empirically we show that it performs better than standard self-attention as discussed in ablation studies. Also due to the light-weight nature, it not only enables us to use this in all the encoder and decoder blocks across levels for self-attention but also across different layers of encoder-decoder and levels for cross attention which results in a significant increase of accuracy.
This efficient and simple matrix multiplication makes this attention module very fast whereas the order of operation (first computing ) results in low memory footprint. Note that, is broadcast along dimension appropriately. We utilize this attention block in both encoder and decoder at each level for self-attention.
1.2 Cross-Attention (CA)
Inspired from the use of cross-attention in , we implement cross encoder-decoder and cross level attention in our model. For cross encoder-decoder attention, we deploy similar attention module where the information to be attended is from different encoder layers and all the attention maps are generated by the decoder. Similarly for cross-level, the attended feature is from a lower level and the attention decisions are made by features from a higher level. We have observed that this helps in the propagation of information across layers and levels compared to simply passing the whole input or doing elementwise sum as done in .
2 Pixel-Dependent Filtering Module (PDF)
The fused output contains global as well as local information distributed adaptively along pixels which helps in handling spatially-varying motion blur effectively.
Experiments
Datasets: We follow the configuration of , which train on 2103 images from the GoPro dataset . For testing, we use two benchmarks: GoPro (1103 HD images), and HIDE (2025 HD images).
Training settings and implementation details: All the convolutional layers within our proposed modules contain filters. The hyper-parameters for our encoder-decoder backbone are , , and , and filter size in PDF modules is . Following , we use batch-size of and patch-size of . Adam optimizer was used with initial leaning rate , halved after every iterations. We use PyTorch library and Titan Xp GPU.
2 Performance comparisons
The main application of our work is efficient deblurring of general dynamic scenes. Due to the complexity of the blur present in such images, conventional image formation model based deblurring approaches struggle to perform well. Hence, we compare with only two conventional methods (which are selected as representative traditional methods for non-uniform deblurring, with publicly available implementations). We provide extensive comparisons with state-of-the-art learning-based methods, namely MS-CNN, DeblurGAN, DeblurGAN-v2, SRN, and Stack(4)-DMPHN. We use official implementation from the authors with default parameters.
Quantitative Evaluation We show performance comparisons on two different benchmark datasets. The quantitative results on GoPro testing set and HIDE Dataset are listed in Table 1 and 2. We evaluate two variants of our model with(b) and without(a) learnable offsets as shown in Table 1.
The average PSNR and SSIM measures obtained on the GoPro test split is provided in Table 1. It can be observed from the quantitative measures that our method performs better compared to previous state-of-the-art. The results shown in Figure 4. shows the large dynamic blur handling capability of our model while preserving sharpness. We further evaluate the run-time of all the methods on a single GPU with images of resolution . The standard-deviation of the PSNR, SSIM, and run-time scores on the GoPro test set are 1.78, 0.018, and 0.0379, respectively. As reported in Table 1, our method takes significantly less time compared to other methods.
We also evaluate our method on the recent HIDE Dataset . Both of GoPro and HIDE datasets contain dominant foreground object motion along with camera motion. We compare against all existing models trained on GoPro train-set for fair comparisons. As shown in Table 2, our approach outperforms all methods including , without requiring any human bounding box supervision. The superiority of our model is owed to the robustness of the proposed adaptive modules.
Qualitative Evaluation: Visual comparisons on different dynamic and 3D scenes are shown in Figs. 4 and 5. Visual comparisons are given in Fig. 4. We observe that the results of prior works suffer from incomplete deblurring or artifacts. In contrast, our network is able to restore scene details more faithfully which are noticeable in the regions containing text, edges, etc. An additional advantage over is that our model waives-off the requirement of parameter tuning during test phase.
On both the datasets, the proposed method achieves consistently better PSNR, SSIM and visual results with lower inference-time than DMPHN and a comparable number of parameters.
3 Ablation studies
In Table 3, we analyse the effect of individual modules on our network’s performance, using test images from GoPro dataset . As shown in Figure 2, the proposed resblock contains one content-aware processing module and two standard convolutional layers. To find the optimal number of resblock in encoder and decoder we trained different versions of our network with varying number of resblocks. Although, the training performance as well as the quantitative results got better with the increase in number of blocks, beyond 3 the improvement was marginal. This led us to the choice of using 3 resblocks in each encoder and decoder and serves as a good balance between efficiency and performance as well.
As the use of local convolution and global attention together or replacing local convolution with attention is explored recently for image recognition tasks, we further analyze it for image restoration tasks like deblurring. As shown in Table 3, we observe that the advantages of SA and PDF modules are complimentary and their union leads to better performance (Net4 vs Net6). For better information flow between different layers of encoder-decoder and also between different levels we used CA, where the advantage of this attentive information flow rather than simple addition can be observed by comparing the performance of Net4 and Net5 compared to Net3. We also analyze the role of both adaptive weights and the adaptive local-neighborhood for PDF module. As shown quantitatively in Table 3 (Net7 and Net8) and visualized in Figure 7, adaptiveness of the offsets along with the weights perform better as it satisfies the need of directional local filters. We have also showed comparisons of the convergence plots of these models in supplementary. We also try to incorporate the attention mechanism used in in our model for fair comparison. Due to high memory requirement, we were only able to use one attention module in the decoder in each level. The resultant PSNR was 30.52 compared to 30.76 of Net3. But, as it already occupied full GPU memory, we were unable to introduce more blocks, or cross attention.
4 Visualization and Analysis
The first row of Fig. 7 contains images from the testing datasets which suffer from complex blur due to large camera and object motion. In the subsequent rows, we visualize the output of different modules of our network and analyze the behavior change while handling different levels of blur due to camera motion, varying depth, moving objects, etc. The second row of Fig. 7 shows one of the attention-maps (, ) corresponding to each image. We can observe the high correlation between estimated attention weights and the dominant motion blurred regions present in the image. This adaptive ability of the network to focus on relevant parts of the image can be considered crucial to the observed performance improvement. The third and fourth rows of Fig. 7 show the spatially-varying nature of filter weights and offsets. Observe that a large horizontal offset is estimated in the regions with high horizontal blur so that the filter shape can spread along the direction of motion. Although the estimated filter wights are not directly interpretable, it can be seen that the variance of the filters correlates with the magnitude of blur. We further visualize the behavior of the fusion mask which adaptively weighs the outputs of the two branches for each pixel location. As shown in Fig. 6, PDF module output is more preferred in regions with moving foreground objects or blurred edges where most of the other regions give almost equal weight to both the branches. On the other hand, homogeneous regions where the effect of blur is negligible, have shown a preference towards the attention branch. To further investigate this behavior, we have visualized the spatial mask (). As we can observe in Fig. 6(c), the mask suppresses these homogeneous regions even before calculating self-attention for each pixel. This shows the robustness and interpretability of our attention module while handling any type of blur.
PDF Module: We synthetically blurred 25 sharp images using synthetic linear PSFs oriented in 4 different directions (0,45,90,135). For these images, we recorded the dominant direction of filter offsets estimated by our PDF module. The values obtained (11,50,81,126) show high correlation between the offset orientations and the PSF angles.
Conclusions
We proposed a new content-adaptive architecture design for the challenging task of removing spatially-varying blur in images of dynamic scenes. Efficient self-attention is utilized in all the encoder-decoder to get better representation whereas cross-attention helps in efficient feature propagation across layers and levels. Proposed dynamic filtering module shows content-awareness for local filtering. The complimentary behaviour of the two branches are shown in Table 3 and Fig. 6. Different from existing deep learning-based methods for such applications, the proposed method is more interpretable which is one of its key strengths. Our experimental results demonstrated that the proposed method achieved better results than state-of-the-art methods on two benchmarks both qualitatively and quantitatively. We showed that the proposed content-adaptive approach achieves an optimal balance of memory, time and accuracy and can be applied to other image-processing tasks.