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

Update util.py in stable diffusion to avoid Sizes of tensors error #278

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

CatManJr
Copy link

@CatManJr CatManJr commented Nov 28, 2024

In my experiments, I found that when I directly load an image, both in_paint.py and image_to_image.py encounter an error:

File "/root/autodl-tmp/SD/model/unet.py", line 178, in forward
x = torch.cat([x, x_input_block.pop()], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 34 but got size 33 for tensor number 1 in the list.

This error can be avoided by modifying the load_img function in utils.py, specifically by changing the original multiple of 32 to a multiple of 64. This issue might be caused by the sd-v1-4.ckpt checkpoint.

I apologize if I may have mistakenly made two modifications on the master branch. Please disregard those changes, and this Pull-Request is the real debug version.

In my experiments, I found that when I directly load an image, both in_paint.py and image_to_image.py encounter an error:

File "/root/autodl-tmp/SD/model/unet.py", line 178, in forward
    x = torch.cat([x, x_input_block.pop()], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 34 but got size 33 for tensor number 1 in the list.

This error can be avoided by modifying the load_img function in utils.py, specifically by changing the original multiple of 32 to a multiple of 64. This issue might be caused by the sd-v1-4.ckpt checkpoint.

I apologize if I may have mistakenly made two modifications on the master branch. Please disregard those changes, and this Pull-Request is the real debug version.
@CatManJr CatManJr changed the title Cat man jr patch 1 Update util.py in stable diffusion to avoid Sizes of tensors error Nov 28, 2024
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

Successfully merging this pull request may close these issues.

1 participant