titu1994 / Super-Resolution-using-Generative-Adversarial-Networks

An implementation of SRGAN model in Keras
283 stars 85 forks source link

Which version of Theano and Keras are you using? #23

Closed Jim61C closed 7 years ago

Jim61C commented 7 years ago

Hi,

Firstly, thanks for open source your work. I am trying to run benchmark.py with the provided weights, however I keep running into this error of ValueError: could not broadcast input array from shape (1,256,64,1,64) into shape (1,128,64,2,64) at the line of output_image_batch = model.predict_on_batch(x_generator)

it seems to be a problem with the input output shape matching at x = UpSampling2D(name='sr_res_upscale_%d' % id)(x) in function ` def _upscale_block(self, ip, id):

    init = ip

    x = Convolution2D(128, 3, 3, activation="linear", border_mode='same', name='sr_res_upconv1_%d' % id,
                      init=self.init)(init)
    x = LeakyReLU(alpha=0.25, name='sr_res_up_lr_%d_1_1' % id)(x)
    x = UpSampling2D(name='sr_res_upscale_%d' % id)(x)
    print('UpSampling2D id:', id, ", shape:", x._keras_shape)
    #x = SubPixelUpscaling(r=2, channels=32)(x)
    x = Convolution2D(128, 3, 3, activation="linear", border_mode='same', name='sr_res_filter1_%d' % id,
                      init=self.init)(x)
    x = LeakyReLU(alpha=0.3, name='sr_res_up_lr_%d_1_2' % id)(x)

    return x`

I am suspecting that this might an issue with the Theano backend version I am using? I have tested on both 0.9.0 and 0.8.2 with Keras 1.2.1 but in both cases, the error preserves. Thus, may I know which version of Theano and Keras are you currently using? Thanks!

titu1994 commented 7 years ago

Never seen a 5 tuple output shape like that. I think it's not a problem with the theano version but isntead the dim ordering in Keras.

Please ensure you are using 'th' dim ordering in Keras 1.2.2, which is what I am currently using. When I was developing this code I used 1.1.1, bit have tested it on 1.2.2 correctly as well.

My thank was 0.8.2 at that time (the master version, not the pip install 0.8.2).

Jim61C commented 7 years ago

Hi,

It seems that the original sr_resnet_weights.h5 is out of dated and if I load from SRGAN.h5 with only layers with same name, the testing runs fine now.

titu1994 commented 7 years ago

Hmm I don't think I updated the code anytime recently, but that would explain the incorrect weight dimension.

Thanks for to heads up. I'll look into it when I have a bit more time.

Jim61C commented 7 years ago

Sure, no problem!