super-resolution icon indicating copy to clipboard operation
super-resolution copied to clipboard

weird ouput on pre-trained weights

Open HardeyPandya opened this issue 3 years ago • 2 comments

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.

HardeyPandya avatar Jun 04 '22 17:06 HardeyPandya

+1

atztao avatar Nov 30 '22 00:11 atztao

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.

Lee8950 avatar Jun 20 '23 13:06 Lee8950