BasicSR icon indicating copy to clipboard operation
BasicSR copied to clipboard

Custom Size ESRGAN Training error

Open purijs opened this issue 4 years ago • 5 comments

Trying to train ESRGAN with custom lr/hr size, get the following error:

2020-11-12 19:13:17,807 INFO: Model [ESRGANModel] is created.
2020-11-12 19:13:18,060 INFO: Start training from epoch: 0, iter: 0
Traceback (most recent call last):
  File "train.py", line 252, in <module>
    main()
  File "train.py", line 211, in main
    model.optimize_parameters(current_iter)
  File "../basicsr/models/esrgan_model.py", line 41, in optimize_parameters
    real_d_pred = self.net_d(self.gt).detach()
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "../basicsr/models/archs/discriminator_arch.py", line 57, in forward
    f'Input spatial size must be 128x128, '
AssertionError: Input spatial size must be 128x128, but received torch.Size([16, 3, 32, 32]).

I've already specified 32 size in yaml file, what's the work-around for this?

purijs avatar Nov 12 '20 19:11 purijs

I have the same problem.The solution is to adjust the number of linear mapping nodes of the discriminator.

hhwucn avatar Mar 29 '21 08:03 hhwucn

hello! I have the same problem. How did you modify it?

ArthurT-Hub avatar May 06 '21 05:05 ArthurT-Hub

我有同样的问题,解决方案是调整鉴别器的线性映射节点的数量。

Sorry, can you be more specific

ArthurT-Hub avatar May 06 '21 07:05 ArthurT-Hub

hello! I have the same problem. How did you modify it?

Currently, discriminator used in ESRGAN takes as input only images of size 128 x 128. So you have to modify basicsr/models/archs/discriminator_arch.py file so that it could be able to handle images of the size you need. To do that, remove assert on line 52 and change number of units in linear layer on line 45. It can also be useful to add some more Conv2D blocks.

Markfryazino avatar May 16 '21 18:05 Markfryazino

Thank you very much!

------------------ 原始邮件 ------------------ 发件人: "xinntao/BasicSR" @.>; 发送时间: 2021年5月17日(星期一) 凌晨2:54 @.>; @.@.>; 主题: Re: [xinntao/BasicSR] Custom Size ESRGAN Training error (#329)

hello! I have the same problem. How did you modify it?

Currently, discriminator used in ESRGAN takes as input only images of size 128 x 128. So you have to modify basicsr/models/archs/discriminator_arch.py file so that it could be able to handle images of the size you need. To do that, remove assert on line 52 and change number of units in linear layer on line 45. It can also be useful to add some more Conv2D blocks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

ArthurT-Hub avatar May 17 '21 06:05 ArthurT-Hub