Coder Social home page Coder Social logo

saeed-anwar / ridnet Goto Github PK

View Code? Open in Web Editor NEW
335.0 6.0 57.0 16.74 MB

Pytorch code for "Real image denoising with feature attention", ICCV (Oral), 2019.

Home Page: https://saeed-anwar.github.io/publications/

Python 100.00%
image-denoising feature-attention

ridnet's Introduction

Real Image Denoising with Feature Attention

This repository is for Real Image Denoising with Feature Attention (RIDNet) introduced in the following paper

Saeed Anwar, [Nick Barnes], "Real Image Denoising with Feature Attention", ICCV (Oral), 2019

The model is built in PyTorch 0.4.0, PyTorch 0.4.1 and tested on Ubuntu 14.04/16.04 environment (Python3.6, CUDA9.0, cuDNN5.1).

Contents

  1. Introduction
  2. Network
  3. Train
  4. Test
  5. Results
  6. Citation
  7. Acknowledgements

Introduction

Deep convolutional neural networks perform better on images containing spatially invariant noise (synthetic noise); however, their performance is limited on real-noisy photographs and requires multiple stage network modeling. To advance the practicability of denoising algorithms, this paper proposes a novel single-stage blind real image denoising network (RIDNet) by employing a modular architecture. We use a residual on the residual structure to ease the flow of low-frequency information and apply feature attention to exploit the channel dependencies. Furthermore, the evaluation in terms of quantitative metrics and visual quality on three synthetic and four real noisy datasets against 19 state-of-the-art algorithms demonstrate the superiority of our RIDNet.

Sample results on a real noisy face image from RNI15 dataset.

Network

Network The architecture of the proposed network. Different green colors of the conv layers denote different dilations while the smaller size of the conv layer means the kernel is 1x1. The second row shows the architecture of each EAM.

The feature attention mechanism for selecting the essential features.

Train

Will be added later

Test

Quick start

  1. Download the trained models for our paper and place them in '/TestCode/experiment'.

    The real denoising model can be downloaded from Google Drive or here. The total size for all models is 5MB.

  2. Cd to '/TestCode/code', run the following scripts.

    You can use the following script to test the algorithm

    #RIDNET
    CUDA_VISIBLE_DEVICES=0 python main.py --data_test MyImage --noise_g 1 --model RIDNET --n_feats 64 --pre_train ../experiment/ridnet.pt --test_only --save_results --save 'RIDNET_RNI15' --testpath ../LR/LRBI/ --testset RNI15

Results

All the results for RIDNET can be downloaded from GoogleDrive from SSID, RNI15 and DnD. The size of the results is 65MB

Quantitative Results

The performance of state-of-the-art algorithms on widely used publicly available DnD dataset in terms of PSNR (in dB) and SSIM. The best results are highlighted in bold.

The quantitative results (in PSNR (dB)) for the SSID and Nam datasets.. The best results are presented in bold.

For more information, please refer to our paper

Visual Results

Visual_PSNR_DnD1 A real noisy example from DND dataset for comparison of our method against the state-of-the-art algorithms.

Visual_PSNR_DnD2 Visual_PSNR_Dnd3 Comparison on more samples from DnD. The sharpness of the edges on the objects and textures restored by our method is the best.

A real high noise example from RNI15 dataset. Our method is able to remove the noise in textured and smooth areas without introducing artifacts

A challenging example from SSID dataset. Our method can remove noise and restore true colors

Visual_PSNR_SSIM_BI Visual_PSNR_SSIM_BI Few more examples from SSID dataset.

Citation

If you find the code helpful in your resarch or work, please cite the following papers.

@article{anwar2019ridnet,
  title={Real Image Denoising with Feature Attention},
  author={Anwar, Saeed and Barnes, Nick},
  journal={IEEE International Conference on Computer Vision (ICCV-Oral)},
  year={2019}
}

@article{Anwar2020IERD,
  author = {Anwar, Saeed and Huynh, Cong P. and Porikli, Fatih },
    title = {Identity Enhanced Image Denoising},
    journal={IEEE Computer Vision and Pattern Recognition Workshops (CVPRW)},
    year={2020}
}

Acknowledgements

This code is built on DRLN (PyTorch)

ridnet's People

Contributors

saeed-anwar 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

ridnet's Issues

train/valid sets

Hi Saeed,

Could you share your RIDNet training environment?

  • Synthetic noise generation: AWGN only?
  • Training configuration: One epoch for synthetic noise followed by another epoch of real noise?
  • Total number of 80x80 patches for synthetic noise images and real-noise patches (respectively)?
  • Total number of epochs for training?

BR/ East

self.ckp.log[-1, idx_scale] = eval_acc / len(self.loader_test) ZeroDivisionError: division by zero

Making model...
Loading model from ../experiment/ridnet.pt

Evaluation:
0it [00:00, ?it/s]
Traceback (most recent call last):
File "main.py", line 20, in
while not t.terminate():
File "/home/User/Documents/ridnet/RIDNet/TestCode/code/trainer.py", line 139, in terminate
self.test()
File "/home/User/Documents/ridnet/RIDNet/TestCode/code/trainer.py", line 110, in test
self.ckp.log[-1, idx_scale] = eval_acc / len(self.loader_test)
ZeroDivisionError: division by zero

I noticed this error had been brought up earlier, but there was no fix that I could find in the thread. Could you please let me know how I could go about fixing this error?

PyTorch : 0.4.1
Python : 3.6.3
CPU

runningtime error

when I am running the 'test code', telling me 'AttributeError: 'RIDNET' object has no attribute 'module'?
the 'module' is not a member of the Class of RIDNET ? why?

ZeroDivisionError: division by zero

There is something went wrong with current code in branch master.
Is there anyone who can help me solve this problem.
Thank you very much.

  1. hardwares
CPU: i7-6700K
GPU: GTX1070
  1. vendors
> conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\pytorch:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
ca-certificates           2023.01.10           haa95532_0
certifi                   2022.12.7        py37haa95532_0
cffi                      1.15.1           py37h2bbff1b_3
colorama                  0.4.6                    pypi_0    pypi
coqpit                    0.0.17                   pypi_0    pypi
cuda90                    1.0                           0    pytorch
cycler                    0.11.0                   pypi_0    pypi
fonttools                 4.38.0                   pypi_0    pypi
freetype                  2.12.1               ha860e81_0
fsspec                    2023.1.0                 pypi_0    pypi
imageio                   2.25.0                   pypi_0    pypi
intel-openmp              2021.4.0          haa95532_3556
jpeg                      9e                   h2bbff1b_0
kiwisolver                1.4.4                    pypi_0    pypi
lerc                      3.0                  hd77b12b_0
libdeflate                1.8                  h2bbff1b_5
libpng                    1.6.37               h2a8f88b_0
libtiff                   4.5.0                h6c2663c_1
libwebp                   1.2.4                h2bbff1b_0
libwebp-base              1.2.4                h2bbff1b_0
lz4-c                     1.9.4                h2bbff1b_0
matplotlib                3.5.3                    pypi_0    pypi
mkl                       2021.4.0           haa95532_640
mkl-service               2.4.0            py37h2bbff1b_0
mkl_fft                   1.3.1            py37h277e83a_0
mkl_random                1.2.2            py37hf11a4ad_0
networkx                  2.6.3                    pypi_0    pypi
numpy                     1.21.5           py37h7a0a035_3
numpy-base                1.21.5           py37hca35cd5_3
openssl                   1.1.1s               h2bbff1b_0
packaging                 23.0                     pypi_0    pypi
pillow                    9.3.0            py37hd77b12b_2
pip                       22.3.1           py37haa95532_0
protobuf                  3.19.6                   pypi_0    pypi
psutil                    5.9.4                    pypi_0    pypi
pycparser                 2.21               pyhd3eb1b0_0
pyparsing                 3.0.9                    pypi_0    pypi
python                    3.7.16               h6244533_0
python-dateutil           2.8.2                    pypi_0    pypi
pytorch                   0.4.1           py37_cuda90_cudnn7he774522_1    pytorch
pywavelets                1.3.0                    pypi_0    pypi
scikit-image              0.19.3                   pypi_0    pypi
scipy                     1.7.3                    pypi_0    pypi
setuptools                65.6.3           py37haa95532_0
six                       1.16.0             pyhd3eb1b0_1
soundfile                 0.11.0                   pypi_0    pypi
sqlite                    3.40.1               h2bbff1b_0
tensorboardx              2.5.1                    pypi_0    pypi
tifffile                  2021.11.2                pypi_0    pypi
tk                        8.6.12               h2bbff1b_0
torch                     1.13.1                   pypi_0    pypi
torchvision               0.2.1                      py_2    pytorch
tqdm                      4.64.1                   pypi_0    pypi
trainer                   0.0.22                   pypi_0    pypi
typing-extensions         4.4.0                    pypi_0    pypi
utility                   1.0                      pypi_0    pypi
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.1             pyhd3eb1b0_0
wincertstore              0.2              py37haa95532_2
xz                        5.2.10               h8cc25b3_1
zlib                      1.2.13               h8cc25b3_0
zstd                      1.5.2                h19a0ad4_0
  1. exec commands
> python main.py --data_test MyImage --noise_g 1 --model RIDNET --n_feats 64 --pre_train ../experiment/ridnet.pt --test_only --save_results --save RIDNET_RNI15 --testpath ../LR/LRBI/ --testset RNI15
Making model...
Loading model from ../experiment/ridnet.pt

Evaluation:
0it [00:00, ?it/s]
Traceback (most recent call last):
  File "main.py", line 20, in <module>
    while not t.terminate():
  File "D:\scripts\python\RIDNet\TestCode\code\trainer.py", line 139, in terminate
    self.test()
  File "D:\scripts\python\RIDNet\TestCode\code\trainer.py", line 110, in test
    self.ckp.log[-1, idx_scale] = eval_acc / len(self.loader_test)
ZeroDivisionError: division by zero
  1. Code snippets
    trainer.py:110
self.ckp.log[-1, idx_scale] = eval_acc / len(self.loader_test)

Port to tensorflow.js

Hi @saeed-anwar,
Thank you for this code. I did not test it yet.

Am I right that your denoising model is only 5MB?
If so, it seems to be a very light model and can be ported to javascript.
Can you please check if it is possible to convert your model to tensoflow.js?

I have to admit that I am confused by your code in "RIDNet/TestCode/code/main.py":
t.train()
t.test()
is it a training code?

Please confirm that I can simply denoise my own image with the command you provided to "test the algorithm".

when can you share your code?

I am very encouraged by reading your paper, and I am looking forward to learning more detail through your open code

Error: from torch._C import _set_worker_signal_handlers, _update_worker_pids,

Hi,

First of all, thank you for your work, when I wanted to test your model i faced this error

from torch._C import _set_worker_signal_handlers, _update_worker_pids,
ImportError: cannot import name '_update_worker_pids'

I thought the error may be related to pythorch version so I changed it but the error didn't resolve, can you please guide me on how I can address the problem?

Thanks in advance.

About training

How did you get noisy images in the training step, just adding Gaussain noise?

Log Files from Training

Thank you for your awesome code!

I am hoping you might open-source the log files you have from training. Maybe the training and validation loss as a function of epoch
(and/or batch) with an estimate of the runtime?

The RIDNET input sub_mean and output add_mean?

In the RIDNET forward processing, there are the self.sub_mean(x) and final self.add_mean(res). Whether it is been used to normalize the input image? And by the way, the RGB range of x in self.sub_mean(x) is between 0~255 right?

造假

总感觉作者是在造假,给的代码里面都没有训练好的模型,而作者在readme文件里面又要我们用预训练模型进行测试,如果既然是真的,作者为什么在experiment/文件夹中删除了ridnet.pt预训练模型,而作者在readme文件里面又说用# RIDNET
CUDA_VISIBLE_DEVICES=0 python main.py --data_test MyImage --noise_g 1 --model RIDNET --n_feats 64 --pre_train ../experiment/ridnet.pt --test_only --save_results --save 'RIDNET_RNI15' --testpath ../LR/LRBI/ --testset RNI15
这个代码来进行验证,可是ridnet.pt预训练模型作者在experiment文件夹中都没有提供。

Different results

Dear authors

Using your software I am trying to replicate your result, but I obtain very dissimilar results:
attacched the original image corrupted by sigma=50 gaussian noise and resutl obtained.

0047
0047-x6-SR

data

hi
First, can you provide download links to all training datasets?
Second, can you provide the following details of training data set preprocessing?

EVALUATION 0%

Making model...
Loading model from E:\PycharmProjects\experiment\ridnet.pt

Evaluation:
0%| | 0/10 [00:00<?, ?it/s]

What can I do to solve this problem?
Is there anything wrong with my GPU?

Datasets

Could you provide the links to the train and test datasets?
Thank you very much!

error msg.

Did anyone run the suggested script correctly?
Why do I get the following error?

Making model...
Loading model from ../experiment/ridnet.pt

Evaluation:
0it [00:00, ?it/s]
Traceback (most recent call last):
  File "main.py", line 20, in <module>
    while not t.terminate():
  File "C:\test\RIDNet-pytorch\TestCode\code\trainer.py", line 139, in terminate
    self.test()
  File "C:\test\RIDNet-pytorch\TestCode\code\trainer.py", line 110, in test
    self.ckp.log[-1, idx_scale] = eval_acc / len(self.loader_test)
ZeroDivisionError: division by zero

License

Hey, what is the license of the project?

test

hi, i am testing R2NET remval rain, why the test spend so much time?
image

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.