Update util.py in stable diffusion to avoid Sizes of tensors error #278
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.