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

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

getting benchmarks to run #2

Closed dribnet closed 8 years ago

dribnet commented 8 years ago

Hi - thanks for publishing this work in progress. I'd like to try to get some of your examples working, but can't get the code in the README or benchmark tests to run. Are you using a special version of keras, or just 1.1.0? Here's what I get when running the benchmark:

$ KERAS_BACKEND=tensorflow PYTHONPATH=.. python benchmark_test.py
Using TensorFlow backend.
Traceback (most recent call last):
...
ValueError: Incompatible shapes for broadcasting: (1, 64, 192, 192) and (1, 1, 1, 64)

$ KERAS_BACKEND=theano PYTHONPATH=.. python benchmark_test.py Using Theano backend.
SR ResNet model weights loaded.
Testing model on Set 5 Validation images
Found 5 images belonging to 1 classes.
...
ValueError: GpuDnnConv images and kernel must have the same stack size
Inputs shapes: [(1, 96, 3, 96), (3, 3, 64, 3), (1, 3, 4, 96), 'No shapes', (), ()]
Inputs strides: [(0, 288, 96, 1), (576, 192, 3, 1), (0, 384, 96, 1), 'No strides', (), ()]

And similarly for the code in the README

srgan_network = SRGANNetwork(img_width=32, img_height=32, batch_size=1)
srgan_model = srgan_network.build_srgan_pretrain_model()
...
ValueError: Incompatible shapes for broadcasting: (1, 64, 128, 128) and (1, 1, 1, 64)

Would be interested in getting this working and potentially contributing to this project.

titu1994 commented 8 years ago

This project format doesn't support Tensorflow backend properly.

To get it to work on Tensorflow, change the image_dim_orderingto to "th" in the Keras.json file.

Or simply use Theano with the th dim ordering.

Edit: I am using Keras 1.1.0 only, but bypassing some internal keras code. It shouldnt be affected by keras versions.

dribnet commented 8 years ago

Aha, th dim ordering on theano fixed it (I haven't used keras in awhile and was unaware of that option). Seems fine now, thanks!