• Stars
    star
    160
  • Rank 233,389 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 3 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pytorch Code for the paper TransWeather - CVPR 2022

TransWeather

Code for the paper TransWeather: Transformer-based Restoration of Images Degraded by Adverse Weather Conditions, CVPR 2022

Note: This code base is still not complete. The Transweather model can be found in this code-base. Please feel free to take the model file and run it with your train/eval. Train and Eval scripts for this code-base will be updated later when I have time. Sorry for the incovenience.

Paper | Website

About this repo:

This repo hosts the implentation code for the paper "TransWeather". We also provide code for a strong transformer baseline for weather removal tasks.

Introduction

Removing adverse weather conditions like rain, fog, and snow from images is an important problem in many applications. Most methods proposed in the literature have been designed to deal with just removing one type of degradation. Recently, a CNN-based method using neural architecture search (All-in-One) was proposed to remove all the weather conditions at once. However, it has a large number of parameters as it uses multiple encoders to cater to each weather removal task and still has scope for improvement in its performance. In this work, we focus on developing an efficient solution for the all adverse weather removal problem. To this end, we propose TransWeather, a transformer-based end-to-end model with just a single encoder and a decoder that can restore an image degraded by any weather condition. Specifically, we utilize a novel transformer encoder using intra-patch transformer blocks to enhance attention inside the patches to effectively remove smaller weather degradations. We also introduce a transformer decoder with learnable weather type embeddings to adjust to the weather degradation at hand. TransWeather achieves significant improvements across multiple test datasets over both All-in-One network as well as methods fine-tuned for specific tasks.

News [Update]:

A change in the PSNR values are observed as the calulation is done before saving the image which is not adept with previous works. However, we still get a better performance in most datasets (27.96 vs All-in-One's 24.71). It can also be noted that the TransWeather model can be further finetuned to get a better performance on individual datasets. These updates will be reflected on the new arxiv version.

Using the code:

The code is stable while using Python 3.6.13, CUDA >=10.1

  • Clone this repository:
git clone https://github.com/jeya-maria-jose/TransWeather
cd TransWeather

To install all the dependencies using conda:

conda env create -f environment.yml
conda activate transweather

If you prefer pip, install following versions:

timm==0.3.2
mmcv-full==1.2.7
torch==1.7.1
torchvision==0.8.2
opencv-python==4.5.1.48

Datasets:

Train Data:

TransWeather is trained on a combination of images sampled from Outdoor-Rain, Snow100K, and Raindrop datasets (similar to All-in-One (CVPR 2020)), dubbed as "All-Weather", containing 18069 images. It can be downloaded from this link.

Dataset format:

Download the datasets and arrange them in the following format. T

    TransWeather
    ├── data 
    |   ├── train # Training  
    |   |   ├── <dataset_name>   
    |   |   |   ├── input         # rain images 
    |   |   |   └── gt            # clean images
    |   |   └── dataset_filename.txt
    |   └── test  # Testing         
    |   |   ├── <dataset_name>          
    |   |   |   ├── input         # rain images 
    |   |   |   └── gt            # clean images
    |   |   └── dataset_filename.txt

Text Files:

Link

Extensions:

Note that Transweather is built to solve all adverse weather problem with a single model. We observe that, additionally TransWeather can be easilty modified (removing the transformer decoder) to just focus on an individual restoration task. To train just the Transweather-encoder on other datasets (like Rain-800), organize the dataset similar to all-weather and run the following command:

python train-individual.py  -train_batch_size 32 -exp_name Transweather-finetune -epoch_start 0 -num_epochs 250

Change train-individual.py with the necesarry details of the data to be trained on. Note that the network used there is a sub-section of our original Transweather architecture without the weather queries.

Acknowledgements:

This code-base uses certain code-blocks and helper functions from Syn2Real, Segformer, and ViT.

Citation:

@misc{valanarasu2021transweather,
      title={TransWeather: Transformer-based Restoration of Images Degraded by Adverse Weather Conditions}, 
      author={Jeya Maria Jose Valanarasu and Rajeev Yasarla and Vishal M. Patel},
      year={2021},
      eprint={2111.14813},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

More Repositories

1

Medical-Transformer

Official Pytorch Code for "Medical Transformer: Gated Axial-Attention for Medical Image Segmentation" - MICCAI 2021
Python
797
star
2

UNeXt-pytorch

Official Pytorch Code base for "UNeXt: MLP-based Rapid Medical Image Segmentation Network", MICCAI 2022
Python
462
star
3

KiU-Net-pytorch

Official Pytorch Code of KiU-Net for Image/3D Segmentation - MICCAI 2020 (Oral), IEEE TMI
Python
356
star
4

Cuff_less_BP_Prediction

Prediction of Blood Pressure from ECG and PPG signals using regression methods.
Python
146
star
5

Interactive-Portrait-Harmonization

Code Base for the work "Interactive Portrait Harmonization"
28
star
6

On-The-Fly-Adaptation

Code base for "On-the-Fly Test-time Adaptation for Medical Image Segmentation"
Python
26
star
7

Derain_OUCD_Net

Official Pytorch Code for "Exploring Overcomplete Representations for Single Image Deraining using CNNs" - IEEE Journal of STSP
Python
14
star
8

Overcomplete-Deep-Subspace-Clustering

Official Tensorflow Code for the paper "Overcomplete Deep Subspace Clustering Networks" - WACV 2021
Python
13
star
9

Image-Recovery-Using-Conditional-Adversarial-Networks

Analyzing Conditional Adversarial Networks to solve image recovery problems like shadow recovery, denoising and deblurring - CVIP 2019
Python
10
star
10

Unet_DWT

Unet based on Wavelet coefficients for segmentation
Python
8
star
11

essential_codes

Just a collection of essential set of codes that can be plugged in at needed places
Python
3
star
12

rebotnet-web

Website for Rebotnet
JavaScript
3
star
13

sparseSGD

Tweaking SGD by imposing sparsity to improve opimization for deep learning tasks.
Python
3
star
14

transweather-web

Website for TransWeather paper: https://jeya-maria-jose.github.io/transweather-web/
HTML
2
star
15

Vision-Based-Texting

Approach towards texting using eye gestures taken from a camera.
Python
1
star
16

Wind_LandArea_Aerial_Seg

Supporting Code for the paper "A novel application of deep learning to determine the actual land transformed by wind power"
Python
1
star
17

IPH-web

Website for "Interactive Portrait Harmonization"
JavaScript
1
star
18

quad-pid-control-

Python
1
star
19

Performance_Metrics

Python
1
star