RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 64 but got size 32 for tensor number 2 in the list.
4 pipe = pipe.to('cuda')
5 pipe.enable_attention_slicing()
----> 6 image = pipe(prompt=prompt, image=pil_image, mask_image=mask).images[0]
7 image.save("./yellow_cat_on_park_bench.png")
/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
28 return cast(F, decorate_context)
29
/opt/conda/lib/python3.7/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py in call(self, prompt, image, mask_image, height, width, num_inference_steps, guidance_scale, negative_prompt, num_images_per_prompt, eta, generator, latents, prompt_embeds, negative_prompt_embeds, output_type, return_dict, callback, callback_steps)
852 # concat latents, mask, masked_image_latents in the channel dimension
853 latent_model_input = self.scheduler.scale_model_input(latent_model_input, t)
--> 854 latent_model_input = torch.cat([latent_model_input, mask, masked_image_latents], dim=1)
855
856 # predict the noise residual
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 64 but got size 32 for tensor number 2 in the list.
how to solve this??
Try:
image = pipe(
prompt=prompt,
image=pil_image,
mask_image=mask,
height=pil_image.height,
width=pil_image.width,
).images[0]
Hello,
I have added the parameters of height and width. However, there is still an error. Any other methods?
Traceback (most recent call last):
File "test.py", line 30, in <module>
image = pipe(
File "/root/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/root/anaconda3/envs/ldm/lib/python3.8/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py", line 1381, in __call__
latent_model_input = torch.cat([latent_model_input, mask, masked_image_latents], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 64 but got size 512 for tensor number 2 in the list.