-
Notifications
You must be signed in to change notification settings - Fork 330
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
StableDiffusion.text_to_image() casuses an excaption in Colab #2467
Comments
I have the same error when trying to replicate any Stable-Diffusion-related tutorial from official Keras repo (eg. https://keras.io/examples/generative/random_walks_with_stable_diffusion/), no matter if run locally or using original repo in colab. Possibly something is broken with Keras3 and latest TF? It seems like encoder (77 tokens, 768 values) does not communicate with diffusor UNET (basic 64x64x3 shape). Any clues would be most welcome. Or even confirmation on which exact versions of tf, keras, keras_cv does the official repo works on, because the Keras api is so inconsistent between versions that it is really hard to follow on. Further details of Error: ValueError: Exception encountered when calling DiffusionModel.call(). Invalid input shape for input Tensor("data_2:0", shape=(3, 77, 768), dtype=float32). Expected shape (None, 64, 64, 4), but input has incompatible shape (3, 77, 768) Arguments received by DiffusionModel.call(): |
i have the same as i tried different backends , issue wont be gone |
I got the same problem by following this tensorflow tutorial with the same error as @pjogi-testy Long story short got it working on: keras 2.13.1, keras-core 0.1.7, keras-cv 0.9.0, tensorflow 2.13.1
Didn't tried out tensorflow 2.16.* In the keras repo readme there is a note "Keras 3 will not function with TensorFlow 2.14 or earlier." Not sure how are you suppose to use Keras 3 because whenever I installed tensorflow a specific version of keras was added, I install --upgrade the keras version but gave me a version error incompatibility. |
I had the same error when i use docker image tensorflow/tensorflow:2.17.0-gpu |
This issue is caused by a bug in the In the However, this is a temporary solution, and the error when inserting a dict into a method in Keras will eventually be completely resolved. If you use it in colab,
...
# context = self.text_encoder.predict_on_batch(
# {"tokens": phrase, "positions": self._get_pos_ids()}
# )
context = self.text_encoder.predict_on_batch([phrase, self._get_pos_ids()])
...
# unconditional_latent = self.diffusion_model.predict_on_batch(
# {
# "latent": latent,
# "timestep_embedding": t_emb,
# "context": unconditional_context,
# }
# )
unconditional_latent = self.diffusion_model.predict_on_batch([latent, t_emb, unconditional_context])
# latent = self.diffusion_model.predict_on_batch(
# {
# "latent": latent,
# "timestep_embedding": t_emb,
# "context": context,
# }
# )
latent = self.diffusion_model.predict_on_batch([latent, t_emb, context])
...
# model = keras_cv.models.StableDiffusion(
model = StableDiffusion(
img_width=512, img_height=512, jit_compile=False
) Although it is in Korean, check out my colab documentation. https://colab.research.google.com/drive/1JzF8rP8y8XN2jUsmJiH0NMS-Ti1Nd6Ql#scrollTo=y100OUIHDkOH
|
Thanks for reporting the issue.
We will not be making any changes to the models in |
Thanks, I got the ERROR, but it works well!
Do you have a fine tuning guide for this model using original images such as |
Hi Keras Team,
Current Behavior:
The code based on https://keras.io/api/keras_cv/models/tasks/stable_diffusion/ causes an exception: ValueError: Exception encountered when calling DiffusionModelV2.call().
https://colab.research.google.com/drive/1OYet7JBOwgt7L5itxOOzVg-jclgPpdnT?usp=sharing
StableDiffusion class, too.
Am I missing something?
Steps To Reproduce:
https://colab.research.google.com/drive/1OYet7JBOwgt7L5itxOOzVg-jclgPpdnT?usp=sharing
Version:
Keras 3.4.1
TF 2.16.2
KerasCV 0.9.0
The text was updated successfully, but these errors were encountered: