Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CycleGan save error #691

Closed
antoine-l opened this issue Nov 3, 2021 · 4 comments
Closed

CycleGan save error #691

antoine-l opened this issue Nov 3, 2021 · 4 comments

Comments

@antoine-l
Copy link

Hi,

I'm running the Colab of CycleGan as is (https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/generative/ipynb/cyclegan.ipynb) and have the following error:

ValueError Traceback (most recent call last)
in ()
42 tf.data.Dataset.zip((train_horses, train_zebras)),
43 epochs=1,
---> 44 callbacks=[plotter, model_checkpoint_callback],
45 )

7 frames
/usr/local/lib/python3.7/dist-packages/keras/saving/saving_utils.py in raise_model_input_error(model)
86 'set. Usually, input shapes are automatically determined from calling'
87 ' .fit() or .predict(). To manually set the shapes, call '
---> 88 'model.build(input_shape).'.format(model))
89
90

ValueError: Model <main.CycleGan object at 0x7f1515ca2b50> cannot be saved because the input shapes have not been set. Usually, input shapes are automatically determined from calling .fit() or .predict(). To manually set the shapes, call model.build(input_shape).

I tried different fixes but they just gave me different errors:

  cycle_gan_model.compute_output_shape(input_shape=(None, 256, 256, 3))
  cycle_gan_model.build((None, 256, 256, 3))

What can I do to fix it?

Thank you!

@k2ok3i
Copy link
Contributor

k2ok3i commented Jun 14, 2022

I solved the problem by adding a call method to the CycleGan class.

    def call(self, inputs, training=None, mask=None):
        return self.disc_X(inputs), self.disc_Y(inputs), self.gen_G(inputs), self.gen_F(inputs)

Then specify the input size like this.

  cycle_gan_model.compute_output_shape(input_shape=(None, 256, 256, 3))

Copy link

github-actions bot commented May 8, 2024

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label May 8, 2024
Copy link

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants