-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SRGAN doesn't work without pretraining a SRResNet (How to fix) #43
Comments
do you have the code for this? I am currently stuck trying to implement this. It seems as though it is working but when I predict on the generator I am only getting a black image (all zeros), even when I denormalize. I also tried using the MSE optimizer like you have a above but the loss output is negative which should not be the case. Your help is greatly appreciated!!! |
All you need to change is get_gan_network() to be -
And then remove all of this (the training of the discriminator in the training loop) -
And set the line that trains the generator to just try to turn LR into HR without any gan loss - |
thank you so much!!! You are a life saver |
Thanks for the code. So you are basically training a non-GAN this way? Once this part is trained, do you save and re-load the weights and then continue training the GAN model? |
Yes. Fast.ai calls this "NoGan training" |
The GAN losses don't stabilize unless you first pretrain the generator. The network will still end up being able to improve image quality if you don't, but it will be only from the VGG loss and the GAN part will be basically useless (at least in my experience)
The fix is extremely easy. In "get_gan_network" change the compilation to be
gan = Model(gan_input, x) gan.compile(loss='mse', optimizer=optimizer)
and in the training loop just comment out the training of the discriminator.
This trains the generator to minimize the MSE between the training inputs and the training targets with no GAN.
Once this model is trained, removed these changes and continue training (using VGG perceptual loss + GAN loss and training the descriminator in the training loop)
The text was updated successfully, but these errors were encountered: