huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.
https://huggingface.co/docs/diffusers
Apache License 2.0
25.68k stars 5.31k forks source link

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

Open BasimBashir opened 1 day ago

BasimBashir commented 1 day ago

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

Additional context

asomoza commented 1 day ago

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 commented 21 hours ago

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