XPixelGroup / BasicSR

Open Source Image and Video Restoration Toolbox for Super-resolution, Denoise, Deblurring, etc. Currently, it includes EDSR, RCAN, SRResNet, SRGAN, ESRGAN, EDVR, BasicVSR, SwinIR, ECBSR, etc. Also support StyleGAN2, DFDNet.
https://basicsr.readthedocs.io/en/latest/
Apache License 2.0
6.79k stars 1.19k forks source link

Error in training wgan-gp #126

Closed BK1024 closed 5 years ago

BK1024 commented 5 years ago

Hi xinntao, in optimize_parameters(self, step)from /BasicSR/codes/models/SRGAN_model.py, , I found python complaining about the following line from your implementation of wgan-gp: interp_crit, _ = self.netD(interp). self.netD(interp) will only return one value for the randomly interpolated image. Is it just a typo or the wgan-gp part is yet to be completed?

Also, I found this line below the above line: l_d_gp = self.l_gp_w * self.cri_gp(interp, interp_crit) # maybe wrong in cls?. This concerns me...would you mind explaining what might be wrong? Thank you!

xinntao commented 5 years ago

In the file https://github.com/xinntao/BasicSR/blob/master/codes/models/SRGAN_model.py (SRGAN model), the wgan-gp could work. The interp_crit, _ = self.netD(interp) you mentioned is in the SFTGAN_ACD_model. And SFTGAN does not support WAGN-GP.

BK1024 commented 5 years ago

The following lines are the code snippet I am referring to: https://github.com/xinntao/BasicSR/blob/36984e8bb1cd4269397bb15361a4221d26d4235a/codes/models/SRGAN_model.py#L148-L157

In line 155 is the code I am referring to: interp_crit, _ = self.netD(interp). Are you saying that this part of the code will not be utilized in when training with SRGAN_model.py

xinntao commented 5 years ago

Emmm, I made a mistake....+_+

It should be interp_crit = self.netD(interp) in SRGAN model. # maybe wrong in cls? I mean that it may be wrong in SFTGAN model.

A long time ago, I use this code to run SRGAN with WGAN-GP and it could run. But I did not observe improvements compared to vanilla GAN.

I will correct these codes. Thanks~

BK1024 commented 5 years ago

Got it! Hope this helps.