Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

x4 super resolution image upscaler using stable diffusion

License

Notifications You must be signed in to change notification settings

1jz/stable-diffusion-scaler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable Diffusion Upscaler

Python script to scale images beyond 512x512 by x4 using the Stable Diffusion x4 upscaler model card with image segmentation.

Key Features

  • cuts images into segments of 64, 128, 256 or 512 pixels
  • merges scaled segments into final image
  • can specify noise level, seed and inference steps per segment
  • "crop" and "overlay" segmentation/merging strategies

Installation

pip install -r requirements.txt

Tested with Python 3.10.8

Usage

To scale an image with a noise_level of 5 with 20 steps for scaling:

python .\scale.py -i image.png -v -s 20 -n 5 -o scaled.png

NOTE: Scaling tends to work best segments sized 128 or 256, 64 tends to give poor results and often deforms the scaled image, 512 tends to give diminishing returns from scaling.

Comparisons

Paprika Frogs

frogs frogs_upscaled

Forest

forest forest_upscaled

Thinkpad

thinkpad thinkpad_upscaled


Segmentation Type

"crop" will fill any overflow with black pixels, scale them and finally crop them from the final image: crop NOTE: this can affect scaling deforming

"overlay" will overlay segments that would otherwise extend over the images original resolution: overlay

Tips and other Information

it's common for some segments to deform and lose their colour when being scaled up, if you encounter any "garbage" segments try again with another seed, lower inference step count or change the segment size.

Additionally, since segments are scaled properly it possible for some pixels to be misaligned creating a "tearing" like effect. This is mostly noticeable when zoomed in.

About

x4 super resolution image upscaler using stable diffusion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages