stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

LDSR Upscale producing black bars

Open Chilluminati91 opened this issue 2 years ago • 13 comments

Describe the bug When upscaling an image with LDSR or with a combination of LDSR and another upscaler the final image has "missing tiles". They are completely black when just using LDSR and semi black when using a combination.

00034

To Reproduce Steps to reproduce the behavior:

  1. Go to extras
  2. Load an image
  3. Select LDSR as upscaler 1
  4. Generate and see error

Expected behavior The day before yesterday LDSR was working fine, so it might be a commit from the last two days.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Browser: Firefox
  • Commit revision: cccc5a20fce4bde9a4299f8790366790735f1d05

Chilluminati91 avatar Oct 17 '22 06:10 Chilluminati91

Did you use the "Scale to" option or the "Scale by" option?

JustMaier avatar Oct 17 '22 08:10 JustMaier

Simple scale by 2x. You can still see remnants of the original picture behind the black bar on the picture that I posted. So not related to another aspect ratio.

Chilluminati91 avatar Oct 17 '22 09:10 Chilluminati91

What were the dimensions of the src image. I notice the black bar when the "downscale" resolution/aspect ratio doesn't align with my source, for example, if I give it an image that is 16:9 I'll get a bar along the bottom.

JustMaier avatar Oct 17 '22 09:10 JustMaier

Add --no-half-vae to your command line arguments in webui-user.bat

kybercore avatar Oct 17 '22 09:10 kybercore

Add --no-half-vae to your command line arguments in webui-user.bat

Nope, still getting a black bar.

What were the dimensions of the src image. I notice the black bar when the "downscale" resolution/aspect ratio doesn't align with my source, for example, if I give it an image that is 16:9 I'll get a bar along the bottom.

Original: 704x512 -> Upscaled: 1408x1024

Chilluminati91 avatar Oct 17 '22 10:10 Chilluminati91

Can confirm that this happens with me too. Running with --no-half-vae and "scale by 2" LDSR

Desktop (please complete the following information):

OS: Win11 Browser: Chrome GPU: 2080

AndreRatzenberger avatar Oct 17 '22 10:10 AndreRatzenberger

Add --no-half-vae to your command line arguments in webui-user.bat

Nope, still getting a black bar.

What were the dimensions of the src image. I notice the black bar when the "downscale" resolution/aspect ratio doesn't align with my source, for example, if I give it an image that is 16:9 I'll get a bar along the bottom.

Original: 704x512 -> Upscaled: 1408x1024

Pretty sure LDSR only works correctly with images that, like SD, are a factor of 64. Downloading an image from the internet that's already a non-standard resolution seems to be the issue in every case of this that I've seen, my own included.

SD really does not like resolutions that aren't a factor of 64 on either axis.

Viexi avatar Oct 17 '22 12:10 Viexi

I suppose it could be made to automatically crop the input images. Would be a bit more convenient than doing so in Krita.

Baughn avatar Oct 17 '22 14:10 Baughn

Add --no-half-vae to your command line arguments in webui-user.bat

Nope, still getting a black bar.

What were the dimensions of the src image. I notice the black bar when the "downscale" resolution/aspect ratio doesn't align with my source, for example, if I give it an image that is 16:9 I'll get a bar along the bottom.

Original: 704x512 -> Upscaled: 1408x1024

Pretty sure LDSR only works correctly with images that, like SD, are a factor of 64. Downloading an image from the internet that's already a non-standard resolution seems to be the issue in every case of this that I've seen, my own included.

SD really does not like resolutions that aren't a factor of 64 on either axis.

Image was generated in SD and 704/512 are both divisible by 64. But I tested 768x512 to be sure and weirdly I get a clean output without a black bar. So its definitely input resolution related.

Chilluminati91 avatar Oct 17 '22 17:10 Chilluminati91

reproducible in the current release 695377a8b9f7de28b880d96487a9ddf7230cff14

dfaker avatar Oct 17 '22 18:10 dfaker

I noticed that black bars appear if the input image dimensions are not divisible by 128. I assume this happens because it is first downsampled to half of the original dimensions and than it is working with an image that is not divisible by 64. Tested with 512x832 - get the black bar at the bottom. 512x512 and 512x768 are properly upscaled. Is there a way to turn off the downsampling pass?

49RpK5dY avatar Oct 18 '22 14:10 49RpK5dY

Changing down_sample_rate = target_scale / 4 to down_sample_rate = target_scale / 2 in ldsr_model_arch.py worked as it no longer produces a black bar on 512x832 input image with 2x upscale in extras tab, but it broke SD upscale in img2img tab as I'm getting HIP out of memory when trying to upscale at target resolution. Not unexpected though.

49RpK5dY avatar Oct 18 '22 15:10 49RpK5dY

Changing down_sample_rate = target_scale / 4 to down_sample_rate = target_scale / 2 in ldsr_model_arch.py worked as it no longer produces a black bar on 512x832 input image with 2x upscale in extras tab, but it broke SD upscale in img2img tab as I'm getting HIP out of memory when trying to upscale at target resolution. Not unexpected though.

Confirmed this works for SD upscaling a 768x576 image. It took a very long time (15+ minutes on a 1080ti), so I'll probably leave it how it was and try to avoid images that aren't divisible by 128, but it's good to know that I can use LDSR on any of my old gens. Thanks for the info

RoyHammerlin avatar Oct 20 '22 00:10 RoyHammerlin

it is still occurring. It is happening with different models and different sampler method. Sampling method Euler a, Euler, LMS .., Sampling Steps 100, Denoising strength 0.05, upscaler: None, Lanczos, R-ESRGAN 4x+, LDSR,

00001-292575469 00294-3294287595 00296-3294287597 00320-3588906735

spring-phul avatar Dec 05 '22 19:12 spring-phul

Closing as stale.

catboxanon avatar Aug 03 '23 19:08 catboxanon