Skip to content
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

weird ouput on pre-trained weights #99

Open
HardeyPandya opened this issue Jun 4, 2022 · 2 comments
Open

weird ouput on pre-trained weights #99

HardeyPandya opened this issue Jun 4, 2022 · 2 comments

Comments

@HardeyPandya
Copy link

HardeyPandya commented Jun 4, 2022

I tried to run demo for SRGAN in google colab. Since tensorflow version and keras are quite old as it seems, there is some version compatability issue in colab. So, I switched to tensorflow 1.13.1 version.

I found that in older version, to plot the image tensorflow session should be explicitly coded:
https://stackoverflow.com/questions/55315275/why-am-i-getting-typeerror-image-data-cannot-be-converted-to-float

So, I did it as follows:
`import tensorflow
from model import resolve_single
from utils import load_image,plot_sample

pre_generator = generator()
gan_generator = generator()

pre_generator.load_weights('/content/weights/srgan/pre_generator.h5')
gan_generator.load_weights('/content/weights/srgan/gan_generator.h5')

with tensorflow.Session() as sess:
sess.run(tensorflow.global_variables_initializer())

lr = load_image('/content/super-resolution/demo/0851x4-crop.png')

pre_sr = resolve_single(pre_generator, lr)
gan_sr = resolve_single(gan_generator, lr)

pre_sr = sess.run(tensorflow.convert_to_tensor(pre_sr))
gan_sr = sess.run(tensorflow.convert_to_tensor(gan_sr))

plt.figure(figsize=(20, 20))

images = [lr, pre_sr, gan_sr]

titles = ['LR', 'SR (PRE)', 'SR (GAN)']
positions = [1, 3, 4]

for i, (img, title, pos) in enumerate(zip(images, titles, positions)):
    plt.subplot(2, 2, pos)
    plt.imshow(img)
    plt.title(title)
    plt.xticks([])
    plt.yticks([])

sess.close()

Now, my output is like this::

Capture
index

Can anybody help me understand why is this happening? Thanks.

@atztao
Copy link

atztao commented Nov 30, 2022

+1

@Lee8950
Copy link

Lee8950 commented Jun 20, 2023

The pre-trained weights didn't work well on tensorflow 2.10 in my case. I re-trained the pre-generator.h5 and the output for SR(pre) worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants