Home

Awesome

SAPNet for image deraining

This repository contains the official Pytorch implementation of the paper:

"SAPNet: Segmentation-Aware Progressive Network for Perceptual Contrastive Image Deraining"

Updates:

Abstract

Deep learning algorithms have recently achieved promising deraining performances on both the natural and synthetic rainy datasets. As an essential low-level pre-processing stage, a deraining network should clear the rain streaks and preserve the fine semantic details. However, most existing methods only consider low-level image restoration. That limits their performances at high-level tasks requiring precise semantic information. To address this issue, in this paper, we present a segmentation-aware progressive network (SAPNet) based upon contrastive learning for single image deraining. We start our method with a lightweight derain network formed with progressive dilated units (PDU). The PDU can significantly expand the receptive field and characterize multi-scale rain streaks without the heavy computation on multi-scale images. A fundamental aspect of this work is an unsupervised background segmentation (UBS) network initialized with ImageNet and Gaussian weights. The UBS can faithfully preserve an image's semantic information and improve the generalization ability to unseen photos. Furthermore, we introduce a perceptual contrastive loss (PCL) and a learned perceptual image similarity loss (LPISL) to regulate model learning. By exploiting the rainy image and groundtruth as the negative and the positive sample in the VGG-16 latent space, we bridge the fine semantic details between the derained image and the groundtruth in a fully constrained manner. Comprehensive experiments on synthetic and real-world rainy images show our model surpasses top-performing methods and aids object detection and semantic segmentation with considerable efficacy.

Model Architecture

Click this following link to view the pdf.

Model Architecture Figure

Comparison on Synthetic Rainy Images

From left to right, Rainy, PreNet (CVPR 2019), MSPFN (CVPR 2020), MPRNet (CVPR 2021), SAPNet (Ours)

<p float="left"> <p align="middle"> <img src="resources/rain-064.jpg" width="170" /> <img src="resources/PreNet-064.jpg" width="170" /> <img src="resources/MSPFN-064.jpg" width="170" /> <img src="resources/MPRNet-064.png" width="170" /> <img src="resources/Ours-064.jpg" width="170" /> </p>

Comparison on Real-World Rainy Images

From left to right, Rainy, PreNet (CVPR 2019), MSPFN (CVPR 2020), MPRNet (CVPR 2021), SAPNet (Ours)

<p float="left"> <p align="middle"> <img src="resources/rainy_.jpg" width="170" /> <img src="resources/PreNet.jpg" width="170" /> <img src="resources/MSPFN.jpg" width="170" /> <img src="resources/MPRNet.png" width="170" /> <img src="resources/ours.jpg" width="170" /> </p>

Prerequisites

Preparing Dataset

Training

Run the following script in terminal

python train.py

Testing

Run the following script in terminal

bash main.sh

You can modify the content of main.sh according to your hyperparameters. For example.

python test.py \
      --save_path logs/SAPNet/Model11 \
      --test_data_path datasets/test/Rain100H \
      --output_path results/Rain100H/Model11 \
      --use_dilation True

Hyperparameters

General Hyperparameters

NameTypeDefaultDescription
preprocessboolFalseWhether to preprocess the training images as h5 file
batch_sizeint12training batch size
epochsint100training epochs
milestoneint[30,50,80]when to decay the learning rate
lrfloat0.001learning rate
save_pathstrlogs/SAPNet/Model11where to save the weight
save_freqint1frequency for saving the weight

Train/Test Hypeparameters

NameTypeDefaultDescription
test_data_pathstrdatasets/test/Rain100Htesting data path
output_pathstrresults/Rain100H/Model11testing result path
data_pathstrdatasets/train/RainTrainHtraining data path
use_contrastboolTruewhether to use contrast learning
use_seg_stage1boolTruewhether to use segmentation
use_stage1boolTruewhether to use deraining
use_dilationboolTruewhether to use dilation
recurrent_iterint6numbers of recurrence
num_of_SegClassint21numbers of segmentation classes

Citations

Please cite the following if you find this repository helpful.

@inproceedings{zheng2022sapnet,
  title={SAPNet: Segmentation-Aware Progressive Network for Perceptual Contrastive Deraining},
  author={Zheng, Shen and Lu, Changjie and Wu, Yuxiong and Gupta, Gaurav},
  booktitle={Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision},
  pages={52--62},
  year={2022}
}

Contact

Please reach zhengsh@kean.edu for further questions. You can also open an issue (prefered) or a pull request in this Github repository

Acknowledgement

This repository is borrowed heavily from PreNet. Thanks for sharing!

TODO List