williamFalcon / pix2pix-keras

Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras
MIT License
140 stars 50 forks source link

concatenation error #6

Closed jclevesque closed 6 years ago

jclevesque commented 6 years ago

At the moment, when I try to run the main.py script. I get the following error:

py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
./pixve/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
Traceback (most recent call last):
  File "pix2pix/main.py", line 47, in <module>
    generator_nn = UNETGenerator(input_img_dim=input_img_dim, num_output_channels=output_channels)
  File "./pix2pix/networks/generator.py", line 154, in UNETGenerator
    de_2 = merge([de_2, en_6], mode=merge_mode, concat_axis=1)
  File "./pixve/lib/python3.5/site-packages/keras/engine/topology.py", line 1680, in merge
    name=name)
  File "./pixve/lib/python3.5/site-packages/keras/engine/topology.py", line 1299, in __init__
    node_indices, tensor_indices)
  File "./pixve/lib/python3.5/site-packages/keras/engine/topology.py", line 1371, in _arguments_validation
    'Layer shapes: %s' % (input_shapes))
ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 6, 4, 1024), (None, 1, 4, 512)]

I wonder if this could be caused by using a different version of tensorflow, as the version used was not specified anywhere. I tried tensorflow versions 1.9 and 1.7, with the same results. Perhaps you could state what version you used, and that would rule out this one variable.

jclevesque commented 6 years ago

By default, keras expects images to be formated with channel last, and uses this in Convolution layers. Fixed it by adding the following to main.py:

import keras.backend as K
K.set_image_dim_ordering('th')