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

[BUG] Runtime error if an image not matching the specified width & height is used with the crop #398

Closed
anon-hlhl opened this issue Aug 31, 2022 · 10 comments

Comments

@anon-hlhl
Copy link
Contributor

anon-hlhl commented Aug 31, 2022

https://github.com/hlky/stable-diffusion-webui/blob/8212d8e5de4f5cc92e0c1cda31dcb288f822a12c/webui.py#L1138

image is accidently overwritten after resize with the original uploaded image

Steps to reproduce:

  • Select img2img tab
  • Select either the Mask, crop or uncrop mode
  • Set the width & height to 512
  • Select/Upload an image that is greater than 512x512 (i.e 620x620)

This will produce an error when pressing "Generate":

    output_images, seed, info, stats = process_images(
  File ".\scripts\webui.py", line 819, in process_images
    samples_ddim = func_sample(init_data=init_data, x=x, conditioning=c, unconditional_conditioning=uc, sampler_name=sampler_name)
  File ".\scripts\webui.py", line 1204, in sample
    xi = x0 + noise
RuntimeError: The size of tensor a (120) must match the size of tensor b (64) at non-singleton dimension 3```
(Line numbers will differ)
@Cainor
Copy link

Cainor commented Aug 31, 2022

Based on my tries. It only worked if the input image is exactly 512x512.

Used to work before I did a pull.

@codedealer
Copy link
Collaborator

Looks like a typo to me

@paciox
Copy link

paciox commented Sep 1, 2022

Same here.
How to fix?

@ivdos
Copy link

ivdos commented Sep 1, 2022

@paciox
image = init_img.convert("RGB")
replace by
image = image.convert("RGB")

@Guizmus
Copy link

Guizmus commented Sep 1, 2022

I can confirm this fix seems to work correctly in the use case I detailed in #200

@hlky
Copy link
Contributor

hlky commented Sep 1, 2022

Pushed major txt2img ui overhaul that has img2img working in my tests
Please update and open a new issue if the problem recurs

@altryne
Copy link
Contributor

altryne commented Sep 1, 2022

@hlky I think this is due to the cropped/uncropped images not being divisible by 64, I'll test more and have a fix (same happened to me just now

@Cainor
Copy link

Cainor commented Sep 1, 2022

Can't understand the "Width" and "Hight" sliders in img2img.
Is it possible to just copy the Hight and Width of the input image? and just use it.

@paciox
Copy link

paciox commented Sep 1, 2022

Pushed major txt2img ui overhaul that has img2img working in my tests Please update and open a new issue if the problem recurs

Please, I have everything installed here on a machine. How can I upgrade everything without redoing the whole install procedure?

@Cainor
Copy link

Cainor commented Sep 1, 2022

Pushed major txt2img ui overhaul that has img2img working in my tests Please update and open a new issue if the problem recurs

Please, I have everything installed here on a machine. How can I upgrade everything without redoing the whole install procedure?

If you have done
“git clone https:// ……”

then just go to the root of webui folder and type the command
“git pull”

done

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

8 participants