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
Multi-modal co-attention for drug-target interaction annotation and Its Application to SARS-CoV-2

CoaDTI Multi-modal co-attention for drug-target interaction annotation and Its Application to SARS-CoV-2 Abstract Environment The test was conducted i

Layne_Huang 7 Nov 14, 2022
Riemannian Convex Potential Maps

Modeling distributions on Riemannian manifolds is a crucial component in understanding non-Euclidean data that arises, e.g., in physics and geology. The budding approaches in this space are limited b

Facebook Research 61 Nov 28, 2022
ivadomed is an integrated framework for medical image analysis with deep learning.

Repository on the collaborative IVADO medical imaging project between the Mila and NeuroPoly labs.

144 Dec 19, 2022
A Tensorfflow implementation of Attend, Infer, Repeat

Attend, Infer, Repeat: Fast Scene Understanding with Generative Models This is an unofficial Tensorflow implementation of Attend, Infear, Repeat (AIR)

Adam Kosiorek 82 May 27, 2022
GemNet model in PyTorch, as proposed in "GemNet: Universal Directional Graph Neural Networks for Molecules" (NeurIPS 2021)

GemNet: Universal Directional Graph Neural Networks for Molecules Reference implementation in PyTorch of the geometric message passing neural network

Data Analytics and Machine Learning Group 124 Dec 30, 2022
Implementation for Paper "Inverting Generative Adversarial Renderer for Face Reconstruction"

StyleGAR TODO: add arxiv link Implementation of Inverting Generative Adversarial Renderer for Face Reconstruction TODO: for test Currently, some model

155 Oct 27, 2022
Code for paper "ASAP-Net: Attention and Structure Aware Point Cloud Sequence Segmentation"

ASAP-Net This project implements ASAP-Net of paper ASAP-Net: Attention and Structure Aware Point Cloud Sequence Segmentation (BMVC2020). Overview We i

Hanwen Cao 26 Aug 25, 2022
Data and Code for ACL 2021 Paper "Inter-GPS: Interpretable Geometry Problem Solving with Formal Language and Symbolic Reasoning"

Introduction Code and data for ACL 2021 Paper "Inter-GPS: Interpretable Geometry Problem Solving with Formal Language and Symbolic Reasoning". We cons

Pan Lu 81 Dec 27, 2022
A fast poisson image editing implementation that can utilize multi-core CPU or GPU to handle a high-resolution image input.

Poisson Image Editing - A Parallel Implementation Jiayi Weng (jiayiwen), Zixu Chen (zixuc) Poisson Image Editing is a technique that can fuse two imag

Jiayi Weng 110 Dec 27, 2022
Collection of machine learning related notebooks to share.

ML_Notebooks Collection of machine learning related notebooks to share. Notebooks GAN_distributed_training.ipynb In this Notebook, TensorFlow's tutori

Sascha Kirch 14 Dec 22, 2022
This is the official PyTorch implementation of the CVPR 2020 paper "TransMoMo: Invariance-Driven Unsupervised Video Motion Retargeting".

TransMoMo: Invariance-Driven Unsupervised Video Motion Retargeting Project Page | YouTube | Paper This is the official PyTorch implementation of the C

Zhuoqian Yang 330 Dec 11, 2022
Official implementation of the paper 'Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution'

DASR Paper Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution Jie Liang, Hui Zeng, and Lei Zhang. In arxiv preprint. Abs

81 Dec 28, 2022
UAV-Networks-Routing is a Python simulator for experimenting routing algorithms and mac protocols on unmanned aerial vehicle networks.

UAV-Networks Simulator - Autonomous Networking - A.A. 20/21 UAV-Networks-Routing is a Python simulator for experimenting routing algorithms and mac pr

0 Nov 13, 2021
Distributed Asynchronous Hyperparameter Optimization in Python

Hyperopt: Distributed Hyperparameter Optimization Hyperopt is a Python library for serial and parallel optimization over awkward search spaces, which

6.5k Jan 01, 2023
Changing the Mind of Transformers for Topically-Controllable Language Generation

We will first introduce the how to run the IPython notebook demo by downloading our pretrained models. Then, we will introduce how to run our training and evaluation code.

IESL 20 Dec 06, 2022
Run containerized, rootless applications with podman

Why? restrict scope of file system access run any application without root privileges creates usable "Desktop applications" to integrate into your nor

119 Dec 27, 2022
Streamlit App For Product Analysis - Streamlit App For Product Analysis

Streamlit_App_For_Product_Analysis Здравствуйте! Перед вами дашборд, позволяющий

Grigory Sirotkin 1 Jan 10, 2022
Pytorch port of Google Research's LEAF Audio paper

leaf-audio-pytorch Pytorch port of Google Research's LEAF Audio paper published at ICLR 2021. This port is not completely finished, but the Leaf() fro

Dennis Fedorishin 80 Oct 31, 2022
using yolox+deepsort for object-tracker

YOLOX_deepsort_tracker yolox+deepsort实现目标跟踪 最新的yolox尝尝鲜~~(yolox正处在频繁更新阶段,因此直接链接yolox仓库作为子模块) Install Clone the repository recursively: git clone --rec

245 Dec 26, 2022
PyTorch implementation of CloudWalk's recent work DenseBody

densebody_pytorch PyTorch implementation of CloudWalk's recent paper DenseBody. Note: For most recent updates, please check out the dev branch. Update

Lingbo Yang 401 Nov 19, 2022