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

Add Ultimate SD Upscale pipeline for high-quality tiled image upscaling #9740

Open
BasimBashir opened this issue Oct 22, 2024 · 2 comments
Open

Comments

@BasimBashir
Copy link

Is your feature request related to a problem? Please describe.
Currently, diffusers library lacks advanced tiled upscaling capabilities that are available in other Stable Diffusion implementations. While the library supports basic img2img and upscaling, there's no built-in solution for handling large images through intelligent tiling and seam fixing. This makes it difficult to process high-resolution images while maintaining quality and managing memory efficiently.

Describe the solution you'd like
Implement Ultimate SD Upscale functionality (similar to Automatic1111's WebUI extension) as a pipeline in diffusers. Key features should include:

  1. Progressive upscaling with intelligent scale factor determination
  2. Multiple tiling modes:
    • Linear processing
    • Chess pattern processing
  3. Advanced seam fixing options:
    • Band pass mode
    • Half tile offset
    • Half tile with intersections
  4. Configurable parameters:
    • Tile sizes
    • Padding
    • Mask blur
    • Denoise strength for seam fixing

The implementation should integrate smoothly with existing diffusers pipelines and maintain the library's user-friendly API style.

Describe alternatives you've considered

  • Using basic tiling without seam fixing (leads to visible artifacts)
  • Running multiple separate upscale passes (inefficient and lower quality)
  • Implementing as a separate package (loses benefits of diffusers' optimization and integration)
  • Using other libraries like PIL or cv2 for tiling (lacks SD-specific optimizations)

Additional context

  • Reference implementation: https://github.com/Coyote-A/ultimate-upscale-for-automatic1111
  • This feature would be particularly valuable for:
    • Professional image upscaling
    • Batch processing of large images
    • Creating high-resolution outputs while managing VRAM
    • Maintaining image quality in tiled processing
  • Could potentially be implemented as either a standalone pipeline or an enhancement to existing img2img pipelines
  • Would complement existing super-resolution models in the library
@asomoza
Copy link
Member

asomoza commented Oct 22, 2024

Hi, I've been working on something like this for some time, haven't had the time to finish it and clean the code, but we are going to have an upscaler solution like the Ultimate SD Upscale.

Personally I won't be adding all the options you're mentioning because we always try to make it simple for users to understand it and build on top of it, this doesn't mean people can't add it later.

Also those upscalers are missing some cool new techniques that makes it better and with diffusers we can add them.

Here's some samples but I even haven't updated for it to use controlnet union which is a lot better. I had to convert the upscaled images to jpg because of the size so there's some image loss.

You can open them in other tabs to compare them, they're full size images.

original upscaled
Lotus_Esprit_V8_(low_quality) upscale_20241022112936
andrea-dibitonto-PsJhobbfqkA-unsplash upscale_20241022121256

I don't think they're that good yet but it would help me a lot if you or someone from the community could run the same originals and upscale them 4x so I can compare and see where I'm at.

Original images credits:

Lotus Esprit V8 by Michael Gil

Man wearing blue denim top and black sunglasses by Andrea Dibitonto

@SakshamDhawan
Copy link

I can work on adding the features - maybe pick up from @asomoza ’s progress so far?

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

3 participants