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

Mismatched tensors when using stable diffusion implementation #9

Closed
JianingF opened this issue Jun 29, 2023 · 2 comments
Closed

Mismatched tensors when using stable diffusion implementation #9

JianingF opened this issue Jun 29, 2023 · 2 comments

Comments

@JianingF
Copy link

When running the code with text_editing_stable_diffusion.py, I am getting the following error when using the sample image and mask:
FutureWarning: Accessing config attribute in_channels directly via 'UNet2DConditionModel' object attribute is deprecated. Please access 'in_channels' over 'UNet2DConditionModel's config object instead, e.g. 'unet.config.in_channels'.
(batch_size, self.unet.in_channels, height // 8, width // 8),
Traceback (most recent call last):
File "/nfshomes/jianing/project_files/blended-latent-diffusion/scripts/text_editing_stable_diffusion.py", line 167, in
results = bld.edit_image(
^^^^^^^^^^^^^^^
File "/nfshomes/jianing/CAAR/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/nfshomes/jianing/project_files/blended-latent-diffusion/scripts/text_editing_stable_diffusion.py", line 127, in edit_image
noise_source_latents = self.scheduler.add_noise(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nfshomes/jianing/CAAR/lib/python3.11/site-packages/diffusers/schedulers/scheduling_ddim.py", line 468, in add_noise
noisy_samples = sqrt_alpha_prod * original_samples + sqrt_one_minus_alpha_prod * noise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RuntimeError: The size of tensor a (84) must match the size of tensor b (64) at non-singleton dimension 3

@omriav
Copy link
Owner

omriav commented Jul 4, 2023

Hi,

Thanks for sharing.
I think that the problem is that you used image resolution that is not compatible with Stable Diffusion (512x512 in case of the base model).
I added an explicit resize in the code for the future, so you can pull the new changes.

Thanks.

@JianingF
Copy link
Author

I changed the image dimensions and there is no problem now. Thanks!

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

No branches or pull requests

2 participants