Image Restoration Toolbox (PyTorch). Training and testing codes for DPIR, USRNet, DnCNN, FFDNet, SRMD, DPSR, BSRGAN, SwinIR

Overview

Training and testing codes for USRNet, DnCNN, FFDNet, SRMD, DPSR, MSRResNet, ESRGAN, BSRGAN, SwinIR

Kai Zhang

Computer Vision Lab, ETH Zurich, Switzerland


Real-World Image (x4) BSRGAN, ICCV2021 Real-ESRGAN SwinIR (ours)
  • News (2021-08-31): We upload the training code of BSRGAN.

  • News (2021-08-24): We upload the BSRGAN degradation model.

  • News (2021-08-22): Support multi-feature-layer VGG perceptual loss and UNet discriminator.

  • News (2021-08-18): We upload the extended BSRGAN degradation model. It is slightly different from our published version.

  • News (2021-06-03): Add testing codes of GPEN (CVPR21) for face image enhancement: main_test_face_enhancement.py

from utils.utils_modelsummary import get_model_activation, get_model_flops
input_dim = (3, 256, 256)  # set the input dimension
activations, num_conv2d = get_model_activation(model, input_dim)
logger.info('{:>16s} : {:<.4f} [M]'.format('#Activations', activations/10**6))
logger.info('{:>16s} : {:
   .format('#Conv2d', num_conv2d))
flops = get_model_flops(model, input_dim, False)
logger.info('{:>16s} : {:<.4f} [G]'.format('FLOPs', flops/10**9))
num_parameters = sum(map(lambda x: x.numel(), model.parameters()))
logger.info('{:>16s} : {:<.4f} [M]'.format('#Params', num_parameters/10**6))

Clone repo

git clone https://github.com/cszn/KAIR.git
pip install -r requirement.txt

Training

You should modify the json file from options first, for example, setting "gpu_ids": [0,1,2,3] if 4 GPUs are used, setting "dataroot_H": "trainsets/trainH" if path of the high quality dataset is trainsets/trainH.

  • Training with DataParallel - PSNR
python main_train_psnr.py --opt options/train_msrresnet_psnr.json
  • Training with DataParallel - GAN
python main_train_gan.py --opt options/train_msrresnet_gan.json
  • Training with DistributedDataParallel - PSNR - 4 GPUs
python -m torch.distributed.launch --nproc_per_node=4 --master_port=1234 main_train_psnr.py --opt options/train_msrresnet_psnr.json  --dist True
  • Training with DistributedDataParallel - PSNR - 8 GPUs
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1234 main_train_psnr.py --opt options/train_msrresnet_psnr.json  --dist True
  • Training with DistributedDataParallel - GAN - 4 GPUs
python -m torch.distributed.launch --nproc_per_node=4 --master_port=1234 main_train_gan.py --opt options/train_msrresnet_gan.json  --dist True
  • Training with DistributedDataParallel - GAN - 8 GPUs
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1234 main_train_gan.py --opt options/train_msrresnet_gan.json  --dist True
  • Kill distributed training processes of main_train_gan.py
kill $(ps aux | grep main_train_gan.py | grep -v grep | awk '{print $2}')

Method Original Link
DnCNN https://github.com/cszn/DnCNN
FDnCNN https://github.com/cszn/DnCNN
FFDNet https://github.com/cszn/FFDNet
SRMD https://github.com/cszn/SRMD
DPSR-SRResNet https://github.com/cszn/DPSR
SRResNet https://github.com/xinntao/BasicSR
ESRGAN https://github.com/xinntao/ESRGAN
RRDB https://github.com/xinntao/ESRGAN
IMDB https://github.com/Zheng222/IMDN
USRNet https://github.com/cszn/USRNet
DRUNet https://github.com/cszn/DPIR
DPIR https://github.com/cszn/DPIR
BSRGAN https://github.com/cszn/BSRGAN
SwinIR https://github.com/JingyunLiang/SwinIR

Network architectures

  • FFDNet

  • SRMD

  • SRResNet, SRGAN, RRDB, ESRGAN

  • IMDN

    -----

Testing

Method model_zoo
main_test_dncnn.py dncnn_15.pth, dncnn_25.pth, dncnn_50.pth, dncnn_gray_blind.pth, dncnn_color_blind.pth, dncnn3.pth
main_test_ircnn_denoiser.py ircnn_gray.pth, ircnn_color.pth
main_test_fdncnn.py fdncnn_gray.pth, fdncnn_color.pth, fdncnn_gray_clip.pth, fdncnn_color_clip.pth
main_test_ffdnet.py ffdnet_gray.pth, ffdnet_color.pth, ffdnet_gray_clip.pth, ffdnet_color_clip.pth
main_test_srmd.py srmdnf_x2.pth, srmdnf_x3.pth, srmdnf_x4.pth, srmd_x2.pth, srmd_x3.pth, srmd_x4.pth
The above models are converted from MatConvNet.
main_test_dpsr.py dpsr_x2.pth, dpsr_x3.pth, dpsr_x4.pth, dpsr_x4_gan.pth
main_test_msrresnet.py msrresnet_x4_psnr.pth, msrresnet_x4_gan.pth
main_test_rrdb.py rrdb_x4_psnr.pth, rrdb_x4_esrgan.pth
main_test_imdn.py imdn_x4.pth

model_zoo

trainsets

testsets

References

@inproceedings{liang2021swinir,
title={SwinIR: Image Restoration Using Swin Transformer},
author={Liang, Jingyun and Cao, Jiezhang and Sun, Guolei and Zhang, Kai and Van Gool, Luc and Timofte, Radu},
booktitle={IEEE International Conference on Computer Vision Workshops},
year={2021}
}
@inproceedings{zhang2021designing,
title={Designing a Practical Degradation Model for Deep Blind Image Super-Resolution},
author={Zhang, Kai and Liang, Jingyun and Van Gool, Luc and Timofte, Radu},
booktitle={IEEE International Conference on Computer Vision},
year={2021}
}
@article{zhang2021plug, % DPIR & DRUNet & IRCNN
  title={Plug-and-Play Image Restoration with Deep Denoiser Prior},
  author={Zhang, Kai and Li, Yawei and Zuo, Wangmeng and Zhang, Lei and Van Gool, Luc and Timofte, Radu},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
  year={2021}
}
@inproceedings{zhang2020aim, % efficientSR_challenge
  title={AIM 2020 Challenge on Efficient Super-Resolution: Methods and Results},
  author={Kai Zhang and Martin Danelljan and Yawei Li and Radu Timofte and others},
  booktitle={European Conference on Computer Vision Workshops},
  year={2020}
}
@inproceedings{zhang2020deep, % USRNet
  title={Deep unfolding network for image super-resolution},
  author={Zhang, Kai and Van Gool, Luc and Timofte, Radu},
  booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
  pages={3217--3226},
  year={2020}
}
@article{zhang2017beyond, % DnCNN
  title={Beyond a gaussian denoiser: Residual learning of deep cnn for image denoising},
  author={Zhang, Kai and Zuo, Wangmeng and Chen, Yunjin and Meng, Deyu and Zhang, Lei},
  journal={IEEE Transactions on Image Processing},
  volume={26},
  number={7},
  pages={3142--3155},
  year={2017}
}
@inproceedings{zhang2017learning, % IRCNN
title={Learning deep CNN denoiser prior for image restoration},
author={Zhang, Kai and Zuo, Wangmeng and Gu, Shuhang and Zhang, Lei},
booktitle={IEEE conference on computer vision and pattern recognition},
pages={3929--3938},
year={2017}
}
@article{zhang2018ffdnet, % FFDNet, FDnCNN
  title={FFDNet: Toward a fast and flexible solution for CNN-based image denoising},
  author={Zhang, Kai and Zuo, Wangmeng and Zhang, Lei},
  journal={IEEE Transactions on Image Processing},
  volume={27},
  number={9},
  pages={4608--4622},
  year={2018}
}
@inproceedings{zhang2018learning, % SRMD
  title={Learning a single convolutional super-resolution network for multiple degradations},
  author={Zhang, Kai and Zuo, Wangmeng and Zhang, Lei},
  booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
  pages={3262--3271},
  year={2018}
}
@inproceedings{zhang2019deep, % DPSR
  title={Deep Plug-and-Play Super-Resolution for Arbitrary Blur Kernels},
  author={Zhang, Kai and Zuo, Wangmeng and Zhang, Lei},
  booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
  pages={1671--1681},
  year={2019}
}
@InProceedings{wang2018esrgan, % ESRGAN, MSRResNet
    author = {Wang, Xintao and Yu, Ke and Wu, Shixiang and Gu, Jinjin and Liu, Yihao and Dong, Chao and Qiao, Yu and Loy, Chen Change},
    title = {ESRGAN: Enhanced super-resolution generative adversarial networks},
    booktitle = {The European Conference on Computer Vision Workshops (ECCVW)},
    month = {September},
    year = {2018}
}
@inproceedings{hui2019lightweight, % IMDN
  title={Lightweight Image Super-Resolution with Information Multi-distillation Network},
  author={Hui, Zheng and Gao, Xinbo and Yang, Yunchu and Wang, Xiumei},
  booktitle={Proceedings of the 27th ACM International Conference on Multimedia (ACM MM)},
  pages={2024--2032},
  year={2019}
}
@inproceedings{zhang2019aim, % IMDN
  title={AIM 2019 Challenge on Constrained Super-Resolution: Methods and Results},
  author={Kai Zhang and Shuhang Gu and Radu Timofte and others},
  booktitle={IEEE International Conference on Computer Vision Workshops},
  year={2019}
}
@inproceedings{yang2021gan,
    title={GAN Prior Embedded Network for Blind Face Restoration in the Wild},
    author={Tao Yang, Peiran Ren, Xuansong Xie, and Lei Zhang},
    booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
    year={2021}
}
Comments
  • train real-world swinIR with the given running sentence

    train real-world swinIR with the given running sentence

    Hello, when I was using "#003 Real-World Image SR" to train my own super-resolution model, I found this sentence in the KAIR/docs/README_SwinIR.md file: "# before training gan, put the PSNR-oriented model into superresolution /swinir_sr_realworld_x4_gan/models/", what is this for? Will there be any impact on training if you do not follow this operation? I did not find the PSNR-oriented model, and I did not find a place to use it in the training code.

    opened by aiaini66 27
  • USRNET training

    USRNET training

    Hi I am a beginner with Super Resolution task I was trying the usrnet.py as given in the repo, I created a similar .json file for usrnet by taking hints from other models. I am having issue with the training. Please provide directions on how to train the model correctly. Screenshot from 2020-08-21 17-39-40

    question 
    opened by Zepharchit 14
  • SwinIR classical Image SR Training using dataparallel

    SwinIR classical Image SR Training using dataparallel

    While training the SwinIR classical Image SR, using dataparallel : **python main_train_psnr.py --opt options/swinir/train_swinir_sr_classical.json**

    file::main_train_psnr.py has training loop. Call to model.test(), gives error:

    Traceback (most recent call last):
      File "main_train_psnr.py", line 256, in <module>
        main()
      File "main_train_psnr.py", line 228, in main
        model.test()
      File "F:\models\model_plain.py", line 186, in test
        self.netG_forward()
      File "F:\models\model_plain.py", line 143, in netG_forward
        self.E = self.netG(self.L)
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
        result = self.forward(*input, **kwargs)
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\parallel\data_parallel.py", line 154, in forward
        return self.module(*inputs[0], **kwargs[0])
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
        result = self.forward(*input, **kwargs)
      File "F:\models\network_swinir.py", line 807, in forward
        x = self.conv_after_body(self.forward_features(x)) + x
      File "F:\models\network_swinir.py", line 793, in forward_features
        x = layer(x, x_size)
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
        result = self.forward(*input, **kwargs)
      File "F:\models\network_swinir.py", line 485, in forward
        return self.patch_embed(self.conv(self.patch_unembed(self.residual_group(x, x_size), x_size))) + x
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
        result = self.forward(*input, **kwargs)
      File "F:\models\network_swinir.py", line 405, in forward
        x = blk(x, x_size)
      File "C:\Users\Anaconda3\envs\pytorch_gpu\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
        result = self.forward(*input, **kwargs)
      File "F:\models\network_swinir.py", line 258, in forward
        x_windows = window_partition(shifted_x, self.window_size)  # nW*B, window_size, window_size, C
      File "F:\models\network_swinir.py", line 43, in window_partition
        x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
    RuntimeError: shape '[1, 84, 8, 127, 8, 180]' is invalid for input of size 124480800
    

    The header of file has comment 'training code for MSRResNet'. Seems like the file needs to be modified.

    opened by paragon1234 11
  • Cannot reproduce SwinIR results

    Cannot reproduce SwinIR results

    Dear authors, I ran SwinIR classical super-resolution with python -m torch.distributed.launch --nproc_per_node=8 --master_port=1234 main_train_psnr.py --opt options/swinir/train_swinir_sr_classical.json --dist True, and add test code in it. But the final result for Set5 is 38.25~38.26, which is 0.1 dB lower than reported in Table2 in the paper.

    image

    Do you have any ideas about it? Thanks!

    opened by Pexure 9
  • Training Datasets for VRT

    Training Datasets for VRT

    I'm running main_train_vrt.py and would like to use the default dataset used in the options.json file. Where can I find the lmdb files for the GT and the low resolution/low-quality images, or is there a way to recreate these files using the REDS dataset?

    'dataroot_gt': 'trainsets/REDS/train_sharp_with_val.lmdb', 'dataroot_lq': 'trainsets/REDS/train_sharp_bicubic_with_val.lmdb'

    thanks

    opened by ArfaSaif 6
  • Why the train is so slow?

    Why the train is so slow?

    My train log is:

    21-04-08 09:20:55.248 :   task: srmd
      model: plain
      gpu_ids: [0]
      scale: 4
      n_channels: 3
      sigma: [0, 50]
      sigma_test: 0
      merge_bn: False
      merge_bn_startpoint: 400000
      path:[
        root: superresolution
        pretrained_netG: None
        task: superresolution/srmd
        log: superresolution/srmd
        options: superresolution/srmd/options
        models: superresolution/srmd/models
        images: superresolution/srmd/images
      ]
      datasets:[
        train:[
          name: train_dataset
          dataset_type: srmd
          dataroot_H: trainsets/trainH
          dataroot_L: None
          H_size: 96
          dataloader_shuffle: True
          dataloader_num_workers: 8
          dataloader_batch_size: 64
          phase: train
          scale: 4
          n_channels: 3
        ]
        test:[
          name: test_dataset
          dataset_type: srmd
          dataroot_H: testsets/set5
          dataroot_L: None
          phase: test
          scale: 4
          n_channels: 3
        ]
      ]
      netG:[
        net_type: srmd
        in_nc: 19
        out_nc: 3
        nc: 128
        nb: 12
        gc: 32
        ng: 2
        reduction: 16
        act_mode: R
        upsample_mode: pixelshuffle
        downsample_mode: strideconv
        init_type: orthogonal
        init_bn_type: uniform
        init_gain: 0.2
        scale: 4
      ]
      train:[
        G_lossfn_type: l1
        G_lossfn_weight: 1.0
        G_optimizer_type: adam
        G_optimizer_lr: 0.0001
        G_optimizer_clipgrad: None
        G_scheduler_type: MultiStepLR
        G_scheduler_milestones: [200000, 400000, 600000, 800000, 1000000, 2000000]
        G_scheduler_gamma: 0.5
        G_regularizer_orthstep: None
        G_regularizer_clipstep: None
        checkpoint_test: 5000
        checkpoint_save: 5000
        checkpoint_print: 200
      ]
      opt_path: options/train_srmd.json
      is_train: True
    
    21-04-08 09:20:55.248 : loading PCA projection matrix...
    21-04-08 09:20:55.248 : Random seed: 8094
    21-04-08 09:20:55.380 : Number of train images: 3,550, iters: 56
    21-04-08 09:20:57.633 : 
    Networks name: SRMD
    Params number: 1553200
    Net structure:
    SRMD(
      (model): Sequential(
        (0): Conv2d(19, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (1): ReLU(inplace=True)
        (2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (3): ReLU(inplace=True)
        (4): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (5): ReLU(inplace=True)
        (6): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (7): ReLU(inplace=True)
        (8): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (9): ReLU(inplace=True)
        (10): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (11): ReLU(inplace=True)
        (12): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (13): ReLU(inplace=True)
        (14): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (15): ReLU(inplace=True)
        (16): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (17): ReLU(inplace=True)
        (18): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (19): ReLU(inplace=True)
        (20): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (21): ReLU(inplace=True)
        (22): Conv2d(128, 48, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (23): PixelShuffle(upscale_factor=4)
      )
    )
    
    21-04-08 09:20:57.636 : 
     |  mean  |  min   |  max   |  std   || shape               
     | -0.000 | -0.058 |  0.064 |  0.015 | torch.Size([128, 19, 3, 3]) || model.0.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.0.bias
     |  0.000 | -0.024 |  0.025 |  0.006 | torch.Size([128, 128, 3, 3]) || model.2.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.2.bias
     | -0.000 | -0.025 |  0.025 |  0.006 | torch.Size([128, 128, 3, 3]) || model.4.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.4.bias
     | -0.000 | -0.027 |  0.024 |  0.006 | torch.Size([128, 128, 3, 3]) || model.6.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.6.bias
     | -0.000 | -0.029 |  0.024 |  0.006 | torch.Size([128, 128, 3, 3]) || model.8.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.8.bias
     |  0.000 | -0.025 |  0.024 |  0.006 | torch.Size([128, 128, 3, 3]) || model.10.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.10.bias
     |  0.000 | -0.029 |  0.027 |  0.006 | torch.Size([128, 128, 3, 3]) || model.12.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.12.bias
     | -0.000 | -0.025 |  0.025 |  0.006 | torch.Size([128, 128, 3, 3]) || model.14.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.14.bias
     | -0.000 | -0.026 |  0.025 |  0.006 | torch.Size([128, 128, 3, 3]) || model.16.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.16.bias
     | -0.000 | -0.025 |  0.027 |  0.006 | torch.Size([128, 128, 3, 3]) || model.18.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.18.bias
     |  0.000 | -0.027 |  0.027 |  0.006 | torch.Size([128, 128, 3, 3]) || model.20.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([128]) || model.20.bias
     | -0.000 | -0.023 |  0.024 |  0.006 | torch.Size([48, 128, 3, 3]) || model.22.weight
     |  0.000 |  0.000 |  0.000 |  0.000 | torch.Size([48]) || model.22.bias
    
    21-04-08 10:12:27.138 : <epoch:  3, iter:     200, lr:1.000e-04> G_loss: 1.228e-01 
    21-04-08 11:03:26.168 : <epoch:  7, iter:     400, lr:1.000e-04> G_loss: 1.004e-01 
    21-04-08 11:55:42.532 : <epoch: 10, iter:     600, lr:1.000e-04> G_loss: 8.437e-02 
    21-04-08 12:46:08.205 : <epoch: 14, iter:     800, lr:1.000e-04> G_loss: 7.818e-02 
    21-04-08 13:38:28.291 : <epoch: 18, iter:   1,000, lr:1.000e-04> G_loss: 5.932e-02 
    21-04-08 14:28:32.066 : <epoch: 21, iter:   1,200, lr:1.000e-04> G_loss: 6.853e-02 
    21-04-08 15:20:37.527 : <epoch: 25, iter:   1,400, lr:1.000e-04> G_loss: 5.390e-02 
    21-04-08 16:11:03.519 : <epoch: 29, iter:   1,600, lr:1.000e-04> G_loss: 5.861e-02 
    21-04-08 17:01:57.788 : <epoch: 32, iter:   1,800, lr:1.000e-04> G_loss: 5.812e-02 
    21-04-08 17:54:55.700 : <epoch: 36, iter:   2,000, lr:1.000e-04> G_loss: 4.487e-02 
    21-04-08 18:45:43.054 : <epoch: 39, iter:   2,200, lr:1.000e-04> G_loss: 5.985e-02 
    21-04-08 19:38:15.152 : <epoch: 43, iter:   2,400, lr:1.000e-04> G_loss: 6.035e-02 
    21-04-08 20:28:46.777 : <epoch: 47, iter:   2,600, lr:1.000e-04> G_loss: 5.407e-02 
    21-04-08 21:21:19.155 : <epoch: 50, iter:   2,800, lr:1.000e-04> G_loss: 5.800e-02 
    21-04-08 22:12:26.084 : <epoch: 54, iter:   3,000, lr:1.000e-04> G_loss: 4.669e-02 
    21-04-08 23:04:49.046 : <epoch: 58, iter:   3,200, lr:1.000e-04> G_loss: 5.707e-02 
    21-04-08 23:55:42.746 : <epoch: 61, iter:   3,400, lr:1.000e-04> G_loss: 5.521e-02 
    21-04-09 00:48:11.666 : <epoch: 65, iter:   3,600, lr:1.000e-04> G_loss: 5.583e-02 
    21-04-09 01:39:08.950 : <epoch: 69, iter:   3,800, lr:1.000e-04> G_loss: 4.659e-02 
    21-04-09 02:30:07.278 : <epoch: 72, iter:   4,000, lr:1.000e-04> G_loss: 6.075e-02 
    21-04-09 03:22:56.870 : <epoch: 76, iter:   4,200, lr:1.000e-04> G_loss: 5.796e-02 
    21-04-09 04:13:49.914 : <epoch: 79, iter:   4,400, lr:1.000e-04> G_loss: 4.472e-02 
    21-04-09 05:06:26.278 : <epoch: 83, iter:   4,600, lr:1.000e-04> G_loss: 4.891e-02 
    21-04-09 05:56:58.472 : <epoch: 87, iter:   4,800, lr:1.000e-04> G_loss: 5.581e-02 
    21-04-09 06:49:25.905 : <epoch: 90, iter:   5,000, lr:1.000e-04> G_loss: 6.413e-02 
    21-04-09 06:49:25.905 : Saving the model.
    21-04-09 06:49:26.138 : ---1-->   baby.bmp | 26.81dB
    21-04-09 06:49:26.158 : ---2-->   bird.bmp | 22.54dB
    21-04-09 06:49:26.170 : ---3--> butterfly.bmp | 18.75dB
    21-04-09 06:49:26.218 : ---4-->   head.bmp | 26.36dB
    21-04-09 06:49:26.253 : ---5-->  woman.bmp | 22.48dB
    21-04-09 06:49:26.303 : <epoch: 90, iter:   5,000, Average PSNR : 23.39dB
    
    21-04-09 07:40:04.505 : <epoch: 94, iter:   5,200, lr:1.000e-04> G_loss: 5.548e-02 
    21-04-09 08:32:23.308 : <epoch: 98, iter:   5,400, lr:1.000e-04> G_loss: 5.314e-02 
    21-04-09 09:22:56.333 : <epoch:101, iter:   5,600, lr:1.000e-04> G_loss: 5.548e-02 
    

    非常抱歉,说英文比较费事,下面我会用中文描述问题。 我做了如下计算:开始训练是09:20.57,训练出来一个结果是第二天早上06:49.26,总共训练22小时27分,epoch次数是90.平均训练一次花费时间15分钟。程序设定训练1000000次,花费总时间为10,393.5天,即28.5年。 这样的训练速度也太慢了吧。有什么提升速度的方法吗? 而且GPU的占用率一直非常低,不知道是什么原因,请问有没有解决方案。 image

    opened by zapplelove 6
  • DatasetUSRNet

    DatasetUSRNet

    20-09-25 03:21:23.915 : <epoch:  5, iter:   5,000, lr:1.000e-04> G_loss: 3.441e-02 
    20-09-25 03:21:23.916 : Saving the model.
    Traceback (most recent call last):
      File "E:/Work/KAIR/main_train_msrresnet_psnr.py", line 219, in <module>
        main()
      File "E:/Work/KAIR/main_train_msrresnet_psnr.py", line 178, in main
        for test_data in test_loader:
      File "D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 363, in __next__
        data = self._next_data()
      File "D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 989, in _next_data
        return self._process_data(data)
      File "D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1014, in _process_data
        data.reraise()
      File "D:\anaconda3\lib\site-packages\torch\_utils.py", line 395, in reraise
        raise self.exc_type(msg)
    AttributeError: Caught AttributeError in DataLoader worker process 0.
    Original Traceback (most recent call last):
      File "D:\anaconda3\lib\site-packages\torch\utils\data\_utils\worker.py", line 185, in _worker_loop
        data = fetcher.fetch(index)
      File "D:\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "D:\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "E:\Work\KAIR\data\dataset_usrnet.py", line 116, in __getitem__
        return {'L': img_L, 'H': img_H, 'k': k, 'sigma': noise_level, 'sf': self.sf, 'L_path': L_path, 'H_path': H_path}
    AttributeError: 'DatasetUSRNet' object has no attribute 'sf'
    
    
    Process finished with exit code 1
    
    duplicate Solved! 
    opened by zuenko 6
  • Size mismatches and missing keys with testing

    Size mismatches and missing keys with testing

    Hi, so after I've trained for a bit I want to actually use this model in another code. So following the example set in main_test, I run the following snippet:

        denoiser = net(in_nc=1, out_nc=1, nc=64, nb=17, act_mode='R')
        denoiser.load_state_dict(torch.load(os.path.join(args.model_dir, args.model_name)), strict=True)
        denoiser.eval()
    

    However when it loads in the state dict, I get a myriad of size mismatches and missing keys. Admittedly I am terminating training early because its currently taking ~10 days to train a network, but I don't understand why it's able to run this model in the training mode but not in testing mode.

    opened by emmajreid 6
  • When will you publish the training code of SwinIR?

    When will you publish the training code of SwinIR?

    Hi,

    I found the SwinIR very inspiring and the repo says the training code would be released in this repo. May I ask when the training code is going to be released? Thank you.

    Best, Yang

    Solved! 
    opened by yzcv 5
  • Can‘t reproduce the same test results on BSD68 using my own USRNET training model.

    Can‘t reproduce the same test results on BSD68 using my own USRNET training model.

    Hi, I trained the USRNet using the code in this repository recently. I haven't found problems in data and network during training. But I got the worse results than yours in the paper. So I'd like to ask for some hints to train the model correctly. I was wondering whether the mannual seed affecting the results. If so, Can you show me your setting of mannual seed during your training? Thanks for your help.

    微信图片_20201104101808 My results were shown above, the blue ones are results in the paper. I can get the same results using the pretrained model download from drive. The red ones are my results which have a large gap between the ones in papers.

    Solved! 
    opened by pigfather0315 5
  • DPSR Training Error

    DPSR Training Error

    Thanks for @cszn contribution, DPSR is an amazing job. I was tried to train with my own dataset with main_train_dpsr.py by using pretrained_netG. I used pretrained_netG with dpsr repository's model, DPSRx4.pth. But i got runtime error. RuntimeError: Error(s) in loading state_dict for SRResNet: Missing key(s) in state_dict: "model.3.weight", "model.3.bias", "model.6.weight", "model.6.bias". Unexpected key(s) in state_dict: "model.2.weight", "model.2.bias", "model.5.weight", "model.5.bias".

    How can i fix? Hope your kind help. Thanks

    opened by richardminh 5
  • produce unrealistic degration image when use dark image

    produce unrealistic degration image when use dark image

    image I run the code of utils_blindsr.py in /utils,I produce this image which have much unrealistic.How this happen and how constrained the produce image like the following: image thanks!

    opened by buwangchuxin1992 0
  • Dependency issue in using deform_attn for RVRT

    Dependency issue in using deform_attn for RVRT

    There seems to be a dependency issue of cuda kernel while using deform_attn if the current dependencies where followed.

    RuntimeError: Error building extension 'deform_attn': [1/2] c++ -MMD -MF deform_attn_cuda_pt110.o.d -DTORCH_EXTENSION_NAME=deform_attn -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /opt/conda/lib/python3.7/site-packages/torch/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/TH -isystem /opt/conda/lib/python3.7/site-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /opt/conda/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /home/jeyamariajose/projects/RVRT/KAIR/models/op/deform_attn_cuda_pt110.cpp -o deform_attn_cuda_pt110.o 
    FAILED: deform_attn_cuda_pt110.o 
    c++ -MMD -MF deform_attn_cuda_pt110.o.d -DTORCH_EXTENSION_NAME=deform_attn -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /opt/conda/lib/python3.7/site-packages/torch/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/TH -isystem /opt/conda/lib/python3.7/site-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /opt/conda/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /home/jeyamariajose/projects/RVRT/KAIR/models/op/deform_attn_cuda_pt110.cpp -o deform_attn_cuda_pt110.o 
    /home/jeyamariajose/projects/RVRT/KAIR/models/op/deform_attn_cuda_pt110.cpp: In function ‘void deform_attn_cuda_backward(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, int, int, int, int, int, int, int, int, int)’:
    /home/jeyamariajose/projects/RVRT/KAIR/models/op/deform_attn_cuda_pt110.cpp:187:68: error: invalid initialization of reference of type ‘const at::Tensor&’ from expression of type ‘const c10::ScalarType’
         grad_attns = at::_softmax_backward_data(grad_attns, attns, -1, dtype);
                                                                        ^~~~~
    In file included from /opt/conda/lib/python3.7/site-packages/torch/include/ATen/ATen.h:15,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
                     from /opt/conda/lib/python3.7/site-packages/torch/include/torch/extension.h:4,
                     from /home/jeyamariajose/projects/RVRT/KAIR/models/op/deform_attn_cuda_pt110.cpp:4:
    /opt/conda/lib/python3.7/site-packages/torch/include/ATen/Functions.h:5243:29: note: in passing argument 4 of ‘at::Tensor at::_softmax_backward_data(const at::Tensor&, const at::Tensor&, int64_t, const at::Tensor&)’
     TORCH_API inline at::Tensor _softmax_backward_data(const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, const at::Tensor & self) {
                                 ^~~~~~~~~~~~~~~~~~~~~~
    ninja: build stopped: subcommand failed.
    
    opened by jeya-maria-jose 0
  • How to train the deblocking model of DPIR?

    How to train the deblocking model of DPIR?

    We cannot find the training code of the deblocking model of DPIR to train deblocking model. Please provide the training code of the deblocking. Thank you very much!

    opened by StevenTony611 0
  • How can I train swinIR with my own dataset?

    How can I train swinIR with my own dataset?

    I want to train SwinIR using my own HR images and LR images, however it seems that it will raise error about the image size. My own HR and LR has the same size.

    opened by MingyuLau 1
  • Problems occurred during drunet test

    Problems occurred during drunet test

    Hello, author. I found the following error when testing drunet under your project file. How can I solve it? RuntimeError: Error(s) in loading state_dict for UNetRes: Missing key(s) in state_dict: "m_head.bias", "m_down1.0.res.0.bias", "m_down1.0.res.2.bias", "m_down1.1.res.0.bias", "m_down1.1.res.2.bias", "m_down1.2.res.0.bias", "m_down1.2.res.2.bias", "m_down1.3.res.0.bias", "m_down1.3.res.2.bias", "m_down1.4.bias", "m_down2.0.res.0.bias", "m_down2.0.res.2.bias", "m_down2.1.res.0.bias", "m_down2.1.res.2.bias", "m_down2.2.res.0.bias", "m_down2.2.res.2.bias", "m_down2.3.res.0.bias", "m_down2.3.res.2.bias", "m_down2.4.bias", "m_down3.0.res.0.bias", "m_down3.0.res.2.bias", "m_down3.1.res.0.bias", "m_down3.1.res.2.bias", "m_down3.2.res.0.bias", "m_down3.2.res.2.bias", "m_down3.3.res.0.bias", "m_down3.3.res.2.bias", "m_down3.4.bias", "m_body.0.res.0.bias", "m_body.0.res.2.bias", "m_body.1.res.0.bias", "m_body.1.res.2.bias", "m_body.2.res.0.bias", "m_body.2.res.2.bias", "m_body.3.res.0.bias", "m_body.3.res.2.bias", "m_up3.0.bias", "m_up3.1.res.0.bias", "m_up3.1.res.2.bias", "m_up3.2.res.0.bias", "m_up3.2.res.2.bias", "m_up3.3.res.0.bias", "m_up3.3.res.2.bias", "m_up3.4.res.0.bias", "m_up3.4.res.2.bias", "m_up2.0.bias", "m_up2.1.res.0.bias", "m_up2.1.res.2.bias", "m_up2.2.res.0.bias", "m_up2.2.res.2.bias", "m_up2.3.res.0.bias", "m_up2.3.res.2.bias", "m_up2.4.res.0.bias", "m_up2.4.res.2.bias", "m_up1.0.bias", "m_up1.1.res.0.bias", "m_up1.1.res.2.bias", "m_up1.2.res.0.bias", "m_up1.2.res.2.bias", "m_up1.3.res.0.bias", "m_up1.3.res.2.bias", "m_up1.4.res.0.bias", "m_up1.4.res.2.bias", "m_tail.bias".

    opened by wsdashuaibi 0
Releases(v1.1)
Owner
Kai Zhang
Image Restoration; Inverse Problems
Kai Zhang
A `Neural = Symbolic` framework for sound and complete weighted real-value logic

Logical Neural Networks LNNs are a novel Neuro = symbolic framework designed to seamlessly provide key properties of both neural nets (learning) and s

International Business Machines 138 Dec 19, 2022
Official PyTorch implementation of N-ImageNet: Towards Robust, Fine-Grained Object Recognition with Event Cameras (ICCV 2021)

N-ImageNet: Towards Robust, Fine-Grained Object Recognition with Event Cameras Official PyTorch implementation of N-ImageNet: Towards Robust, Fine-Gra

32 Dec 26, 2022
Tools to create pixel-wise object masks, bounding box labels (2D and 3D) and 3D object model (PLY triangle mesh) for object sequences filmed with an RGB-D camera.

Tools to create pixel-wise object masks, bounding box labels (2D and 3D) and 3D object model (PLY triangle mesh) for object sequences filmed with an RGB-D camera. This project prepares training and t

305 Dec 16, 2022
Segmentation-Aware Convolutional Networks Using Local Attention Masks

Segmentation-Aware Convolutional Networks Using Local Attention Masks [Project Page] [Paper] Segmentation-aware convolution filters are invariant to b

144 Jun 29, 2022
Adversarial Texture Optimization from RGB-D Scans (CVPR 2020).

AdversarialTexture Adversarial Texture Optimization from RGB-D Scans (CVPR 2020). Scanning Data Download Please refer to data directory for details. B

Jingwei Huang 153 Nov 28, 2022
Official implementation for paper: A Latent Transformer for Disentangled Face Editing in Images and Videos.

A Latent Transformer for Disentangled Face Editing in Images and Videos Official implementation for paper: A Latent Transformer for Disentangled Face

InterDigital 108 Dec 09, 2022
KwaiRec: A Fully-observed Dataset for Recommender Systems (Density: Almost 100%)

KuaiRec: A Fully-observed Dataset for Recommender Systems (Density: Almost 100%) KuaiRec is a real-world dataset collected from the recommendation log

Chongming GAO (高崇铭) 70 Dec 28, 2022
An Ensemble of CNN (Python 3.5.1 Tensorflow 1.3 numpy 1.13)

An Ensemble of CNN (Python 3.5.1 Tensorflow 1.3 numpy 1.13)

0 May 06, 2022
[ECE NTUA] 👁 Computer Vision - Lab Projects & Theoretical Problem Sets (2020-2021)

Computer Vision - NTUA (2020-2021) This repository hosts the lab projects and theoretical problem sets of the Computer Vision course held by ECE NTUA

Dimitris Dimos 6 Jul 21, 2022
RGB-stacking 🛑 🟩 🔷 for robotic manipulation

RGB-stacking 🛑 🟩 🔷 for robotic manipulation BLOG | PAPER | VIDEO Beyond Pick-and-Place: Tackling Robotic Stacking of Diverse Shapes, Alex X. Lee*,

DeepMind 95 Dec 23, 2022
Python code to fuse multiple RGB-D images into a TSDF voxel volume.

Volumetric TSDF Fusion of RGB-D Images in Python This is a lightweight python script that fuses multiple registered color and depth images into a proj

Andy Zeng 845 Jan 03, 2023
Face Mask Detection on Image and Video using tensorflow and keras

Face-Mask-Detection Face Mask Detection on Image and Video using tensorflow and keras Train Neural Network on face-mask dataset using tensorflow and k

Nahid Ebrahimian 12 Nov 11, 2022
TensorFlow implementation of original paper : https://github.com/hszhao/PSPNet

Keras implementation of PSPNet(caffe) Implemented Architecture of Pyramid Scene Parsing Network in Keras. For the best compability please use Python3.

VladKry 386 Dec 29, 2022
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
A Flexible Generative Framework for Graph-based Semi-supervised Learning (NeurIPS 2019)

G3NN This repo provides a pytorch implementation for the 4 instantiations of the flexible generative framework as described in the following paper: A

Jiaqi Ma 14 Oct 11, 2022
LeViT a Vision Transformer in ConvNet's Clothing for Faster Inference

LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference This repository contains PyTorch evaluation code, training code and pretrained

Facebook Research 504 Jan 02, 2023
DiAne is a smart fuzzer for IoT devices

Diane Diane is a fuzzer for IoT devices. Diane works by identifying fuzzing triggers in the IoT companion apps to produce valid yet under-constrained

seclab 28 Jan 04, 2023
Space-invaders - Simple Game created using Python & PyGame, as my Beginner Python Project

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc hav

Gaurav Pandey 2 Jan 08, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement Official pytorch implementation of paper "Image-to-image Translation

364 Dec 14, 2022
Alternatives to Deep Neural Networks for Function Approximations in Finance

Alternatives to Deep Neural Networks for Function Approximations in Finance Code companion repo Overview This is a repository of Python code to go wit

15 Dec 17, 2022