lllyasviel / lllyasviel/stable-diffusion-webui-forge

Hires. Fix button from gallery not working

Open
#2,729 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Whenever I'm trying to use the Hires. Fix/upscale button from the gallery in txt2img after generating a batch, I'm getting a RuntimeError and the gallery is cleared. Hires. Fix as part of generating works though.
I'm using Animagine XL 4.0 Opt, an SDXL model.

Logs:
Traceback (most recent call last):
File "C:\SD\Forge\webui\modules_forge\main_thread.py", line 30, in work
self.result = self.func(*self.args, **self.kwargs)
File "C:\SD\Forge\webui\modules\txt2img.py", line 101, in txt2img_upscale_function
processed = processing.process_images(p)
File "C:\SD\Forge\webui\modules\processing.py", line 842, in process_images
res = process_images_inner(p)
File "C:\SD\Forge\webui\modules\processing.py", line 990, in process_images_inner
samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
File "C:\SD\Forge\webui\modules\processing.py", line 1364, in sample
samples = images_tensor_to_samples(image, approximation_indexes.get(opts.sd_vae_encode_method), self.sd_model)
File "C:\SD\Forge\webui\modules\sd_samplers_common.py", line 115, in images_tensor_to_samples
x_latent = model.get_first_stage_encoding(model.encode_first_stage(image))
File "C:\SD\Forge\system\python\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\SD\Forge\webui\backend\diffusion_engine\sdxl.py", line 130, in encode_first_stage
sample = self.forge_objects.vae.encode(x.movedim(1, -1) * 0.5 + 0.5)
File "C:\SD\Forge\webui\backend\patcher\vae.py", line 189, in encode
return self.encode_inner(pixel_samples)
File "C:\SD\Forge\webui\backend\patcher\vae.py", line 178, in encode_inner
samples[x:x + batch_number] = self.first_stage_model.encode(pixels_in, regulation).to(self.output_device).float()
File "C:\SD\Forge\webui\backend\nn\vae.py", line 294, in encode
z = self.encoder(x)
File "C:\SD\Forge\system\python\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\SD\Forge\system\python\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "C:\SD\Forge\webui\backend\nn\vae.py", line 184, in forward
h = self.conv_in(x)
File "C:\SD\Forge\system\python\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\SD\Forge\system\python\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "C:\SD\Forge\webui\backend\operations.py", line 170, in forward
return super()._conv_forward(x, weight, bias)
File "C:\SD\Forge\system\python\lib\site-packages\torch\nn\modules\conv.py", line 456, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [128, 3, 3, 3], expected input[1, 4, 768, 1344] to have 3 channels, but got 4 channels instead
Given groups=1, weight of size [128, 3, 3, 3], expected input[1, 4, 768, 1344] to have 3 channels, but got 4 channels instead

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by using Hires. Fix from the txt2img gallery after generating a batch, then start at modules/txt2img.py and follow processing.py into sd_samplers_common.py, backend/diffusion_engine/sdxl.py, backend/patcher/vae.py, and backend/nn/vae.py. Check where the four-channel input reaches the three-channel VAE encoder. Done means gallery Hires. Fix works without the RuntimeError or clearing the gallery.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.