Elldreth / loopback_scaler

Automatic1111 python script to enhance image quality
MIT License
182 stars 9 forks source link

loopback_scaler

Automatic1111 python script to enhance image quality

Overview

The Loopback Scaler is an Automatic1111 Python script that enhances image resolution and quality using an iterative process. The code takes an input image and performs a series of image processing steps, including denoising, resizing, and applying various filters. The algorithm loops through these steps multiple times, with user-defined parameters controlling how the image evolves at each iteration. The result is an improved image, often with more detail, better color balance, and fewer artifacts than the original.

Key features

Recommended settings for img2img processing are provided in the script, including resize mode, sampling method, width/height, CFG scale, denoising strength, and seed.

Please note that the performance of the Loopback Scaler depends on the GPU, input image, and user-defined parameters. Experimenting with different settings can help you achieve the desired results.

Tips, Tricks, and Advice

Manual Installation

  1. Unzip the loopback_scaler.py script.
  2. Move the script to the \stable-diffusion-webui\scripts folder.
  3. Close the Automatic1111 webui console window.
  4. Relaunch the webui by running the webui-user.bat file.
  5. Open your web browser and navigate to the Automatic1111 page or refresh the page if it's already open.

Settings Guide

Loops

The number of times the script will inference your image and increase the resolution in increments. The amount the resolution is increased each loop is determined by this number and the maximum image width/height. The more loops, the more chances of your image picking up more detail, but also artifacts. 4 to 10 is what I find to work best, but you may like more or less.

Denoise change

This setting will increase or decrease the denoising strength every loop. A higher value will increase the denoising strength, while a lower value will decrease it. A setting of 1 keeps the denoising strength as it is set on the img2img settings.

Dimension Increase

This setting changes the amount of resolution increase per loop, keeping the changes from being linear. You will get non-linear increases in image size based on which easing option you choose. To increase the image size earlier in the process, choose one of the 'Ease Out' options, to increase the image size later in the process, choose an 'Ease In' option, to place image increases more toward the center of the process, use an 'Ease InOut' option.

Maximum Image Width/Height

These parameters set the maximum width and height of the final image. Always start with an image smaller than these dimensions. The smaller you start, the more impressive the results. I usually start at either 340x512 or 512x768.

Detail, Blur, Smooth, Contour

These parameters are checkboxes that apply a PIL Image Filter to the final image.

Sharpness, Brightness, Color, Contrast

These parameters are sliders that adjust the sharpness, brightness, color, and contrast of the image. 1 will result in no adjustments, less than one reduces these settings for the final image and greater than 1 increases these settings.

Img2Img Settings

I recommend creating an image with txt2img and then sending the result to img2img with the prompt and settings. For this script, I use these settings: