Giter Site home page Giter Site logo

stevewongv / spanet Goto Github PK

View Code? Open in Web Editor NEW
200.0 12.0 53.0 3.12 MB

Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset (CVPR'19)

License: Other

Python 16.84% Cuda 3.66% Jupyter Notebook 79.51%
cvpr2019 computer-vision low-level-vision deraining pytorch cuda cupy pytorch-extension

spanet's Introduction

Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset (CVPR'19)

Tianyu Wang*, Xin Yang*, Ke Xu, Shaozhe Chen, Qiang Zhang, Rynson W.H. Lau † (* Joint first author. † Rynson Lau is the corresponding author.)

[Arxiv]

Abstract

Removing rain streaks from a single image has been drawing considerable attention as rain streaks can severely degrade the image quality and affect the performance of existing outdoor vision tasks. While recent CNN-based derainers have reported promising performances, deraining remains an open problem for two reasons. First, existing synthesized rain datasets have only limited realism, in terms of modeling real rain characteristics such as rain shape, direction and intensity. Second, there are no public benchmarks for quantitative comparisons on real rain images, which makes the current evaluation less objective. The core challenge is that real world rain/clean image pairs cannot be captured at the same time. In this paper, we address the single image rain removal problem in two ways. First, we propose a semi-automatic method that incorporates temporal priors and human supervision to generate a high-quality clean image from each input sequence of real rain images. Using this method, we construct a large-scale dataset of ∼29.5K rain/rain-free image pairs that cover a wide range of natural rain scenes. Second, to better cover the stochastic distributions of real rain streaks, we propose a novel SPatial Attentive Network (SPANet) to remove rain streaks in a local-to-global manner. Extensive experiments demonstrate that our network performs favorably against the state-of-the-art deraining methods.

Citation

If you use this code or our dataset(including test set), please cite:

@InProceedings{Wang_2019_CVPR,
  author = {Wang, Tianyu and Yang, Xin and Xu, Ke and Chen, Shaozhe and Zhang, Qiang and Lau, Rynson W.H.},
  title = {Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  month = {June},
  year = {2019}
}

Dataset

See my personal site

UPDATE We release the code of clean image generation. We also provide some synthesize and real video examples for researchers to try. Note that we only implemented the code using 8 threads.

Requirements

  • PyTorch == 0.4.1 (1.0.x may not work for training)
  • cupy (Installation Guide)
  • opencv-python
  • TensorBoardX
  • Python3.6
  • progressbar2
  • scikit-image
  • ffmpeg >= 4.0.1
  • python-ffmpeg

Setup

  • Clone this repo:
$ git clone ...
$ cd SPANet

Train & Test

Train:

  • Download the dataset(~44GB) and unpack it into code folder (See details in Train_Dataset_README.md). Then, run:
$ python main.py -a train -m latest

Test:

  • Download the test dataset(~455MB) and unpack it into code folder (See details in Test_Dataset_README.md). Then, run:
$ python main.py -a test -m latest

Performance Change

PSNR 38.02 -> 38.53

SSIM 0.9868 -> 0.9875

For generalization, we here stop at 40K steps.

All PSNR and SSIM of results are computed by using skimage.measure. Please use this to evaluate your works.

License

Please see License.txt file.

Acknowledgement

Code borrows from RESCAN by Xia Li. The CUDA extension references pyinn by Sergey Zagoruyko and DSC(CF-Caffe) by Xiaowei Hu. Thanks for sharing!

Contact

E-Mail: [email protected]

spanet's People

Contributors

stevewongv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spanet's Issues

NameError: name 'obj' is not defined

When I want to test your model with your test data set (Real_Internet, real_test_1000), I get this error:
2019-08-11 21:25:44,906 - INFO - set log dir as ./logdir
2019-08-11 21:25:44,906 - INFO - set model dir as ./model
Traceback (most recent call last):
File "main.py", line 297, in
run_test(args.model)
File "main.py", line 251, in run_test
sess.load_checkpoints(ckp_name,'test')
File "main.py", line 121, in load_checkpoints
self.step = obj['clock']
NameError: name 'obj' is not defined

Could you please tell me how can I solve this problem

Change the path and PSNR of the training and test datasets

Thank you for your contribution, I have finished reading your thesis, and now using your code, I find that I can't find in which .py file to change the path of the training dataset and test dataset, if you know please tell me. In addition, I found that the evaluation does not have a PSNR code. Could you post it? thank you.

Training Problems

When I train your model with your training data set , I get this error:
2019-08-16 21:04:48,300 - INFO - set log dir as ./logdir
2019-08-16 21:04:48,300 - INFO - set model dir as ./model
hhaha: <torch.utils.data.dataloader._DataLoaderIter object at 0x7f199e9516a0>
Traceback (most recent call last):
File "main.py", line 300, in
run_train_val(args.model)
File "main.py", line 228, in run_train_val
batch_t = next(dt_train)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
AttributeError: Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 106, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/ubuntu/ZY/SPANet-master/dataset.py", line 28, in getitem
O = Image.fromarray(O)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/PIL/Image.py", line 2642, in fromarray
arr = obj.array_interface
AttributeError: 'NoneType' object has no attribute 'array_interface'

As a green hand, I did a lot of research, but all failed.
Could you take a look at this problem for me? Thanks a lot!

训练数据的数量

论文中说有28500对数据用来训练,但是为什么解压后有638500张训练图片,而且real_world.txt中只有638493对训练样本。请问究竟以哪个为准?

reprodure issues

hello , i have a question , how can i reproduce your model by my datasets ? thanks a lot

the structure of Percentile filter

Thanks for the great repo.
The paper didn't tell the Percentile filter in detail,could you release the code of Percentile filter,or tell us the theory of Percentile filter. Thanks again.

a question about your model

您好,请问您的模型用了多少显存?我跑代码的时候一直是cuda out of memory 感觉您的模型太大了,是不是移位操作占用的显存太大了?谢谢

模型加载

作者您好,我在测试的时候模型加载没问题,但是当训练的时候加载报错,加载net没问题,加载优化函数Adam报错self.opt.load_state_dict(obj['opt']) ,报错,loaded state dict contains a parameter group that doesn't match the size of optimizer's group

Pretrained Weight

Hi, Could you release your pretrained weight on Rain1200 ? Look forward to your response.

libpng error: Read Error

Hi ~
Thanks to share this model ~ And I run this model with error like
image

how can I solve this ? Thank you ~

SAM 和 SAB

作者您好,想要问您一个问题,关于您SAB模块的设计,是只算一次attention map,然后×bottleneck还是对SARB模块输出再重新计算一次attention map呢?

Error in beginning of the training

When I try to start training I have encountered this error:

2020-08-19 10:18:42,483 - INFO - set log dir as ./logdir
2020-08-19 10:18:42,483 - INFO - set model dir as ./model
2020-08-19 10:18:55,600 - INFO - train_derain--l1_loss:0.01721 mask_loss:0.02403 ssim_loss:0.9961 all_loss:0.04513 lr:0.0005 step:4e+04
2020-08-19 10:18:57,353 - INFO - val_derain--l1_loss:0.01398 mask_loss:0.01736 ssim_loss:0.9957 all_loss:0.03568 lr:0.0005 step:4e+04
2020-08-19 10:18:58,377 - INFO - save image as step_40000
2020-08-19 10:18:58,413 - INFO - save model as step_40000
Exception ignored in: <bound method _DataLoaderIter.del of <torch.utils.data.dataloader._DataLoaderIter object at 0x7f9809fadfd0>>
Traceback (most recent call last):
File "/home/erdem/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 399, in del
self._shutdown_workers()
File "/home/erdem/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 378, in _shutdown_workers
self.worker_result_queue.get()
File "/usr/lib/python3.6/multiprocessing/queues.py", line 337, in get
return _ForkingPickler.loads(res)
File "/home/erdem/.local/lib/python3.6/site-packages/torch/multiprocessing/reductions.py", line 151, in rebuild_storage_fd
fd = df.detach()
File "/usr/lib/python3.6/multiprocessing/resource_sharer.py", line 57, in detach
with _resource_sharer.get_connection(self._id) as conn:
File "/usr/lib/python3.6/multiprocessing/resource_sharer.py", line 87, in get_connection
c = Client(address, authkey=process.current_process().authkey)
File "/usr/lib/python3.6/multiprocessing/connection.py", line 493, in Client
answer_challenge(c, authkey)
File "/usr/lib/python3.6/multiprocessing/connection.py", line 737, in answer_challenge
response = connection.recv_bytes(256) # reject large message
File "/usr/lib/python3.6/multiprocessing/connection.py", line 216, in recv_bytes
buf = self._recv_bytes(maxlength)
File "/usr/lib/python3.6/multiprocessing/connection.py", line 407, in _recv_bytes
buf = self._recv(4)
File "/usr/lib/python3.6/multiprocessing/connection.py", line 379, in _recv
chunk = read(handle, remaining)
ConnectionResetError: [Errno 104] Connection reset by peer

But when I try to train again in different times, sometimes it gave no error but sometimes gave different ConnectionResetError. I can't understand why it is happening. Since I am working with only one GPU I set my batch size and num_workers to 1. When I set batch size bigger than 1, it gave "CUDA error:out of memory". Is the error caused by my GPU? I hope you can help me, thank you.

I am using python 3.6, pytorch0.4.1.

训练数据

您好,是否可以先上传一小部分训练数据?谢谢

关于ssim计算问题

你好,代码中的ssim计算代码,我看在rescan里面也是使用这个代码,但是经过实测,同样的训练好的文件和测试图片,如果计算出的ssim结果会随着batch_size的增大而增大

Train mode issue - latest pth error.

Can not use the 'latest' model for training or testing.

When i try this code in terminal :
python main.py -a test -m latest

It will happen " state_dict missing key(s) " ERROR :
RuntimeError: Error(s) in loading state_dict for SPANet: Missing key(s) in state_dict: "SAM1.irnn1.right_weight.weight", "SAM1.irnn1.right_weight.bias"...... (ignored error message) Unexpected key(s) in state_dict: "SAM1.irnn1.right_wight.weight", "SAM1.irnn1.right_wight.bias"...... (ignored error message)

So i tried to fix some variables scope name errors in SPANet.py
e.g.
right_weight -> right_wight
up_weight -> up_wight
down_weight -> down_wight
left_wight -> left_weight

But, the (other) error happens again in the training phase (testing phase error fixed!):
ValueError: loaded state dict contains a parameter group that doesn't match the size of optimizer's group

I hope you can solve this problem as soon as possible! Thx!

problem.

我的环境:
pytorch==0.4.1
python==3.6.13
错误代码:
def forward(self,input):
return irnn()(input,self.up_weight.weight,
self.right_weight.weight,self.down_weight.weight,
self.left_weight.weight, self.up_weight.bias,self.right_weight.bias,
self.down_weight.bias,self.left_weight.bias)
是不是这个版本不支持这么调用
我改成 o= irnn.forward(self,input,self.up_weight.weight,
self.right_weight.weight,self.down_weight.weight,
self.left_weight.weight, self.up_weight.bias,self.right_weight.bias,
self.down_weight.bias,self.left_weight.bias
AttributeError: 'Spacial_IRNN' object has no attribute 'save_for_backward'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.