neka-nat / image_completion_tf2

"Globally and Locally Consistent Image Completion" with Tensorflow2 Keras
31 stars 11 forks source link

error on Keras 2.2.2 merge #12

Closed ldenoue closed 5 years ago

ldenoue commented 5 years ago

I get this error on Keras 2.2.2. Any idea how to replace the merge?


  File "train.py", line 160, in <module>
    main()
  File "train.py", line 156, in main
    example_gan()
  File "train.py", line 84, in example_gan
    in_img = merge([org_img, mask],mode=lambda x: x[0] * (1 - x[1]),output_shape=input_shape)
TypeError: 'module' object is not callable```
ldenoue commented 5 years ago

Perhaps this: from keras.engine.topology import Network instead of Container

in_img = Lambda(lambda x: x[0] * (1 - x[1]), output_shape=input_shape)([org_img, mask])

completion = Lambda(lambda x: x[0] * x[2] + x[1] * (1 - x[2]), output_shape=input_shape)([imitation, org_img, mask])

and replace Container with Network throughout.

neka-nat commented 5 years ago

It may be the same as this problem. https://github.com/keras-team/keras/issues/3921#issuecomment-306031159

ldenoue commented 5 years ago

I think Merge was used to compute the in_img and completion variables, using a Lambda function. But add or concatenate from Keras 2.2 are not useful for that, which is why I used a Lambda directly.

neka-nat commented 5 years ago

I made it work with keras = 2.2.2 and tensorflow = 1.4.0. Please try it. neka-nat/image_completion_keras@ba3dc5b