AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.3k stars 26.55k forks source link

[Bug]: Error with non-square images #3957

Closed Enderion closed 1 year ago

Enderion commented 1 year ago

Is there an existing issue for this?

What happened?

The software doesn't appear able to generate images of an aspect ratio that isn't square.

Steps to reproduce the problem

  1. Set width and height to seperate values, EX: Width 338, Height 563
  2. Attempt to generate (present with text2img and inpainting)
  3. Generation will error

What should have happened?

Should have generated properly

Commit where the problem happens

ccf95b0

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

No response

Additional information, context and logs

Error completing request Arguments: (1, '{By artist Vitaly S Alexius, Alexiuss}, Male, brown hair, relaxed pose in a tron legacy sci-fi jacket and jeans, high contrast, sharp, commission, amazing detail, detailed scaled, white background, masterpiece, best quality, high quality, perfect', '', 'None', 'None', None, {'image': <PIL.Image.Image image mode=RGBA size=338x563 at 0x217E1EAC490>, 'mask': <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=338x563 at 0x217E1EAC820>}, None, None, 0, 20, 0, 4, 1, False, False, 1, 1, 7, 0.27, -1.0, -1.0, 0, 0, 0, False, 563, 338, 1, False, 32, 0, '', '', 0, '

\n', True, True, '', '', True, 50, True, 1, 0, False, 4, 1, '

Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8

', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, None, '', '

Will upscale the image to twice the dimensions; use width and height sliders to set tile size

', 64, 0, 1, '', 0, '', True, False, False) {} Traceback (most recent call last): File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\ui.py", line 185, in f res = list(func(*args, kwargs)) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\webui.py", line 63, in f res = func(*args, *kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\img2img.py", line 137, in img2img processed = process_images(p) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\processing.py", line 426, in process_images res = process_images_inner(p) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\processing.py", line 519, in process_images_inner samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\processing.py", line 836, in sample samples = self.sampler.sample_img2img(self, self.init_latent, x, conditioning, unconditional_conditioning, image_conditioning=self.image_conditioning) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\sd_samplers.py", line 432, in sample_img2img samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args={ File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\sd_samplers.py", line 365, in launch_sampling return func() File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\sd_samplers.py", line 432, in samples = self.launch_sampling(t_enc + 1, lambda: self.func(self.model_wrap_cfg, xi, extra_args={ File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\venv\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(args, kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\sampling.py", line 80, in sample_euler_ancestral denoised = model(x, sigmas[i] * s_in, extra_args) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, *kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\modules\sd_samplers.py", line 285, in forward x_out = self.inner_model(x_in, sigma_in, cond={"c_crossattn": [cond_in], "c_concat": [image_cond_in]}) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 112, in forward eps = self.get_eps(input * c_in, self.sigma_to_t(sigma), kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\external.py", line 138, in get_eps return self.inner_model.apply_model(args, kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\stable-diffusion\ldm\models\diffusion\ddpm.py", line 987, in apply_model x_recon = self.model(x_noisy, t, cond) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\stable-diffusion\ldm\models\diffusion\ddpm.py", line 1410, in forward out = self.diffusion_model(x, t, context=cc) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "E:\AI\SSD 2.0 (Annet)\stable-diffusion-webui\repositories\stable-diffusion\ldm\modules\diffusionmodules\openaimodel.py", line 736, in forward h = th.cat([h, hs.pop()], dim=1) RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 12 but got size 11 for tensor number 1 in the list.

Enderion commented 1 year ago

On further investigation it still errors when given 563 x 563 as a target resolution

EyeDeck commented 1 year ago

SD doesn't like it when any dimension is not a multiple of 64.

ColonelWulf commented 1 year ago

From my understanding, most SD-related things work off of multiples of 64, from my testing.

ClashSAN commented 1 year ago

@Enderion This is a limit of stable diffusion, not webui.