Home

Awesome

PWC PWC

<div align="center"> <h1> :umbrella: RainMamba [ACM MM'24 Oral] </h1> <img src="./img/Profile.jpg" width="100" height="100"> <h2>RainMamba: Enhanced Locality Learning with State Space Models <br> for Video Deraining</h2> </div> <p align="center">Hongtao Wu, Yijun Yang, Huihui Xu, Weiming Wang, Jinni Zhou, Lei Zhu<sup>:email:</sup></p> <p align="center"> <a href="https://arxiv.org/abs/2407.21773">ArXivPreprint</a> | <a href="https://openreview.net/forum?id=SQreBrpK2c">OpenReview</a> </p>

This repository is the official implementation of the paper titled 'RainMamba: Enhanced Locality Learning with State Space Models for Video Deraining'.

RainMamba achieves state-of-the-art results on multiple video deraining benchmarks with 3D Hilbert scanning mechanism, offering superior computational efficiency and enhanced restoration quality.

If you like this work, please give us a star ⭐ on GitHub.

<hr /> <p align="justify"> <b>Abstract:</b> <i>The outdoor vision systems are frequently contaminated by rain streaks and raindrops, which significantly degenerate the performance of visual tasks and multimedia applications. The nature of videos exhibits redundant temporal cues for rain removal with higher stability. Traditional video deraining methods heavily rely on optical flow estimation and kernel-based manners, which have a limited receptive field. Yet, transformer architectures, while enabling long-term dependencies, bring about a significant increase in computational complexity. Recently, the linear-complexity operator of the state space models (SSMs) has contrarily facilitated efficient long-term temporal modeling, which is crucial for rain streaks and raindrops removal in videos. Unexpectedly, its uni-dimensional sequential process on videos destroys the local correlations across the spatio-temporal dimension by distancing adjacent pixels. To address this, we present an improved SSMs-based video deraining network (RainMamba) with a novel Hilbert scanning mechanism to better capture sequence-level local information. We also introduce a difference-guided dynamic contrastive locality learning strategy to enhance the patch-level self-similarity learning ability of the proposed network. Extensive experiments on four synthesized video deraining datasets and real-world rainy videos demonstrate the superiority of our network in the removal of rain streaks and raindrops.</i> </p> <hr />

• Framework

image

• Spatio-temporal scanning mechanisms

image image

• Model efficiency and effectiveness

image

📧 News

:bookmark_tabs: Contents

<h2 id="environment-installation">🔨 Environment Installation</h2>

This implementation is based on MMEditing, which is an open-source image and video editing toolbox.

Below are quick steps for installation.

1️⃣ Make conda environment and install PyTorch following official instructions.

conda create -n RainMamba python=3.9
conda activate RainMamba
conda install pytorch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 pytorch-cuda=12.1 -c pytorch -c nvidia

2️⃣ Install MMCV with MIM.

pip3 install openmim timm
mim install mmcv-full==1.7.2

3️⃣ Install RainMamba from source.

git clone https://github.com/TonyHongtaoWu/RainMamba.git
cd RainMamba/code/VRDS
pip3 install -e .

Please refer to MMEditing Installation for more detailed instruction.

4️⃣ Install Bi-Mamba layer

Install causal-conv1d

cd causal-conv1d

python setup.py install

Install mamba

cd ../mamba

python setup.py install
<h2 id="datasets-preparation-and-pretrained-models">🚀 Datasets Preparation and Pretrained Models</h2>

Download four datasets from their websites and modify the training dataset path in the config file of each dataset code.

DatasetSourceDescriptionDataset LinkPretrained Model
VRDSACM MM 2023Rain streaks and raindrops datasetDownloadDownload
LWDDSICRA 2023Raindrops datasetDownloadDownload
RainVID&SSTIP 2023Rain streaks datasetDownloadDownload
RainSynAll100TPAMI 2021Rain streaks datasetDownloadDownload
<h2 id="training">🏋️ Training</h2>

:pushpin: You can train RainMamba on these datasets using the below commands with 4 GPUs:

1️⃣ VRDS dataset

cd code/VRDS
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./tools/dist_train.sh configs/derainers/RainMamba/VRDS.py 4

2️⃣ LWDDS dataset

cd code/LWDDS
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./tools/dist_train.sh configs/derainers/RainMamba/Waterdrop.py 4

3️⃣ RainVID&SS dataset

cd  code/RainVIDSS
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./tools/dist_train.sh configs/derainers/RainMamba/RainVIDSS.py 4

4️⃣ RainSynAll100 dataset

cd code/RainSynAll100
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./tools/dist_train.sh configs/derainers/RainMamba/RainSynAll100.py 4
<h2 id="testing">⚡ Testing</h2>

:pushpin: Modify the path of pretrained model and the testing dataset in the config file of each dataset code.

You can use the following command with 1 GPU to test your trained model xxx.pth:

1️⃣ VRDS dataset

cd code/VRDS
CUDA_VISIBLE_DEVICES=0 bash ./tools/dist_test.sh configs/derainers/RainMamba/VRDS.py "VRDS.pth" 1 --save-path '../results/VRDS/'

2️⃣ LWDDS dataset

cd code/LWDDS
CUDA_VISIBLE_DEVICES=0 bash ./tools/dist_test.sh configs/derainers/RainMamba/Waterdrop.py "LWDDS.pth" 1 --save-path '../results/LWDDS/'

3️⃣ RainVID&SS dataset

cd  code/RainVIDSS
CUDA_VISIBLE_DEVICES=0 bash ./tools/dist_test.sh configs/derainers/RainMamba/RainVIDSS.py "RainVIDSS.pth" 1 --save-path '../results/RainVIDSS/'

4️⃣ RainSynAll100 dataset

cd code/RainSynAll100
CUDA_VISIBLE_DEVICES=0 bash ./tools/dist_test.sh configs/derainers/RainMamba/RainSynAll100.py "RainSynAll100.pth" 1 --save-path '../results/RainSynAll100/'

5️⃣ Demo code for video

You can use the following commands to test a rainy video. This code can be used to test a video or a folder of frames.

cd code/VRDS
python demo/restoration_video_demo.py \
configs/derainers/RainMamba/VRDS.py \
"VRDS.pth" \
input/rainy.mp4 \
output/derained.mp4 
<h2 id="results">📊 Results</h2>

RainMamba achieved state-of-the-art on four video deraining datasets.

Quantitative comparisons

<details> <summary><strong>VRDS dataset</strong> (click to expand)</summary>
MethodsCCNPreNetDRSformerMPRNetRestormerS2VDSLDNetESTINetRDDRVRTBasicVSR++ViMP-NetOurs
PSNR $\uparrow$23.7527.1328.5429.5329.5918.9523.6527.1728.3928.2429.7531.0232.04
SSIM $\uparrow$0.84100.90140.90750.91750.92060.66300.87360.84360.90960.88570.91710.92830.9366
LPIPS $\downarrow$0.20910.12660.11430.09870.09250.28330.17900.22530.11680.14380.10230.08620.0684
</details> <details> <summary><strong>RainVID&SS dataset</strong> (click to expand)</summary>

ImageNet-VID+

MethodsMSCSCFastDrainPReNetS2VDMPEVNetOurs
PSNR $\uparrow$18.4117.0824.7329.9233.8335.07
SSIM $\uparrow$0.51480.43810.73930.92280.94520.9561

Cam-Vid+

MethodsMSCSCFastDrainPReNetSLDNetS2VDMPEVNetOurs
PSNR $\uparrow$21.2219.9425.3318.9729.1132.5532.65
SSIM $\uparrow$0.55150.48300.76470.62670.88990.92340.9328
</details> <details> <summary><strong>RainSynAll100 dataset</strong> (click to expand)</summary>
MethodsFastDerainFCRVDRMFDBasicVSR++NCFLSALNOurs
PSNR $\uparrow$17.0921.0625.1427.6728.1129.7832.16
SSIM $\uparrow$0.58240.74050.91720.91350.92350.93150.9446
</details> <details> <summary><strong> LWDDS dataset</strong> (click to expand)</summary>
MethodsCCNVid2VidVWRBasicVSR++ViMP-NetSALNOurs
PSNR $\uparrow$27.5328.7330.7232.3734.2236.5737.21
SSIM $\uparrow$0.9220.95420.97260.97920.97840.98020.9816
</details> <details> <summary><strong> NTURain dataset</strong> (click to expand)</summary>
MethodMSCSCJ4RNetSPACFCRNetSLDNetMPRNetS2VDESTINetOurs
PSNR$\uparrow$27.3132.1433.1136.0534.8936.1137.3737.4837.87
SSIM$\uparrow$0.78700.94800.94740.96760.95400.96370.96830.97000.9738
</details>

Qualitative comparisons

<details> <summary><strong>VRDS dataset</strong> (click to expand)</summary> <div align="center"> <img src="./img/VRDSResults.png"> </div> </details> <details> <summary><strong>Other datasets</strong> (please refer to the supplementary materials)</summary> </details>

All visual results can be downloaded here.

DatasetLink :file_folder:Link :open_file_folder:
VRDSGoogle DriveOneDrive
LWDDSGoogle DriveOneDrive
RainVID&SSGoogle DriveOneDrive
RainSynAll100Google DriveOneDrive
NTURainGoogle DriveOneDrive

Real-world visual results

https://private-user-images.githubusercontent.com/141260395/365448327-36b19ed6-5f54-42cd-ba6c-49c1d0ad7328.mp4

<h2 id="citation">🎓 Citation</h2>

If you find this repository helpful to your research, please consider citing the following:

@article{wu2024rainmamba,
  title={RainMamba: Enhanced Locality Learning with State Space Models for Video Deraining},
  author={Wu, Hongtao and Yang, Yijun and Xu, Huihui and Wang, Weiming and Zhou, Jinni and Zhu, Lei},
  journal={arXiv preprint arXiv:2407.21773},
  year={2024}
}

If you have any questions or suggestion about our project, please feel free to contact us by email at hwu375@connect.hkust-gz.edu.cn.

<h2 id="acknowledgement">🤗 Acknowledgement</h2>

This code is based on MMEditing, Vim, Vivim , gilbert, LGRNet. Thank them for their outstanding work.

Thank Huihui Xu and Yijun Yang for their help in this work.

<h2 id="license">🎫 License</h2>

This project is released under the MIT license. Please refer to the acknowledged repositories for their licenses.