Giter VIP home page Giter VIP logo

--sd-webui-ar-plusplus's Introduction

Stable Diffusion WebUI Aspect Ratio and Resolution Buttons

Extension for stable-diffusion-webui and stable-diffusion-webui-forge adding image aspect ratio selector buttons.


Main Fork feature

Screenshot 2024-03-13 111328

Uses an enhanced method to calculate the width/height values when clicking Aspect Ratio buttons.

  • Gets the mean value (average) of the current width and height values in the UI.

  • For the selected aspect ratio, the dimensions are offset equally (positively and negatively) from the average, ensuring nearest total pixel count to user's initial resolution.

  • Uses the same precision rounding method as Stability-AI/StableSwarmUI when updating image dimensions.

  • "Mode" button allows switching to use calculation method from LEv145/--sd-webui-ar-plus (Only update Width OR Height)


1

For best results switching between aspect ratios, pick a static res value (such as 1024, etc), then press the "Lock" button to lock in an average res.

  • The calculation method works correctly in all cases

  • However, since the output values are rounded to the nearest division of 64, the mean value (average) of the input values will change when "Unlocked".


2

The original "Calculator panel" has been replaced with an information panel:

  • Current average is displayed for reference.

  • Rounding precision can be adjusted with default value of 64px.


Installation

  1. Navigate to the Extensions tab in stable-diffusion-webui or stable-diffusion-webui-forge

  2. Click "Install from URL"

  3. Copy/Paste this repository into the "URL for extension's git repository" field and click "Install"

    https://github.com/altoiddealer/--sd-webui-ar-plusplus
    
    install
  4. Return to the "Installed" tab and click "Apply and restart UI"

Restart
Details from [the source project (LEv145/--sd-webui-ar-plus)

Details from the source project (LEv145/--sd-webui-ar-plus)

(For reference - much of this is obsolete)

Fork features

  • New button ๐Ÿ”ƒ for calculation of height and width inverse
    • Normal mode: 1024x1024 and 16:9 = 1820x1024
    • Reverse mode: 1024x1024 and 16:9 = 1024x576
  • New button ๐Ÿ” for rounding dimensions to the nearest multiples of 4 (1023x101 => 1024x100)
  • New styles (Some styles have been moved to the original extension)
  • Better resolution presets (By formula: f(x) = 512 + (1024-512)/4*x, 0 <= x <= 4)
  • Better ratios presets (From wikipedia)
  • Rename Calc button to ๐Ÿ“
  • Can work together with the original extension

Updates

  • 20/02/2023 โš ๏ธ this update will remove your local config files (aspect_ratios.txt and resolutions.txt) and it will create new default ones. These can be then modified freely and preserved in the future. For more info read here.

Install

Browse to the Extensions tab -> go to Install from URL -> paste in https://github.com/alemelis/sd-webui-ar -> click Install

Here's how the UI looks like after installing this extension

Screenshot 2023-03-30 at 20 37 56

Usage

  • Click on the aspect ratio button you want to set. In the case of an aspect ratio greater than 1, the script fixes the width and changes the height. Whereas if the aspect ratio is smaller than 1, the width changes while the height is fixed.
  • Reset image resolution by clicking on one of the buttons on the second row.

Configuration

Aspect ratios can be defined in the /sd-webui-ar/aspect_ratios.txt file. For example,

1:1, 1.0
3:2, 3/2
4:3, 4/3
16:9, 16/9
# 6:13, 6/13
# 9:16, 9/16
# 3:5, 3/5
# 2:3, 2/3
# 19:16, 19/16 # fox movietone
# 5:4, 5/4 # medium format photo
# 11:8, 11/8 # academy standard
# IMAX, 1.43
# 14:9, 14/9
# 16:10, 16/10
# ๐œ‘, 1.6180 # golden ratio
# 5:3, 5/3 # super 16mm
# 1.85, 1.85 # US widescreen cinema
# DCI, 1.9 # digital imax
# 2:1, 2.0 # univisium
# 70mm, 2.2
# 21:9, 21/9 # cinematic wide screen
# ฮด, 2.414 # silver ratio
# UPV70, 2.76 # ultra panavision 70
# 32:9, 32/9 # ultra wide screen
# PV, 4.0 # polyvision

Note the # marking the line as a comment, i.e. the extension is not reading that line. To use a custom value, un-comment the relative line by removing the starting #. A custom aspect ratio is defined as button-label, aspect-ratio-value # comment. It is recommended to set the aspect-ratio-value to a fraction, but a float or int will work as well. The # comment is optional. The button-label will be displayed inside the button. It can be anything you like.

Resolutions presets are defined inside resolutions.txt file,

1, 512, 512 # 1:1 square
2, 768, 512 # 3:2 landscape
3, 403, 716 # 9:16 portrait

The format to be used is button-label, width, height, # optional comment. As before, lines starting with # will be ignored.

Calculator Panel

Use the calculator to determine new width or height values based on the aspect ratio of source dimensions.

  • Click Calc to show or hide the aspect ratio calculator
  • Set the source dimensions:
    • Enter manually, or
    • Click โฌ‡๏ธ to get source dimentions from txt2img/img2img sliders, or
    • Click ๐Ÿ–ผ๏ธ to get source dimensions from input image component on the current tab
  • Click โ‡… to swap the width and height, if desired
  • Set the desired width or height, then click either Calculate Height or Calculate Width to calculate the missing value
  • Click Apply to send the values to the txt2txt/img2img sliders

Basic usage of aspect ratio calculator

--sd-webui-ar-plusplus's People

Contributors

alemelis avatar altoiddealer avatar lev145 avatar roamindev avatar yownas avatar thelounger avatar minemo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar Antonio Vaca Cozar avatar  avatar Fischer2000 avatar Drac avatar  avatar  avatar  avatar  avatar reaper557 avatar  avatar  avatar Leonid DZHabiev avatar Sphelx Komodo avatar I.N.K.Y avatar Archon avatar David Terracino avatar Andray avatar Artificiangel avatar  avatar  avatar  avatar  avatar  avatar

--sd-webui-ar-plusplus's Issues

Notification: about listing on webui extension index

  • AUTOMATIC1111/stable-diffusion-webui-extensions#330
    @altoiddealer
    we recived a request to add this extentons to the index
    when possible we like to confirm with the author before listing it
  • are you okay with listing your extension on the index, if not then it won't be listed
  • do have any changes you wish to make to the how it's listed (ie description)

if we didn't receive a confirmation with you after a week you will add it to index in this state
should you see this message at a later date and wish to make changes or have it removed please make contact.

{
    "name": "Aspect Ratio and Resolution Buttons (ar-plusplus)",
    "url": "https://github.com/altoiddealer/--sd-webui-ar-plusplus.git",
    "description": "Fork of Aspect Ratio selector plus with advance resolution rounding",
    "tags": [
        "UI related"
    ]
}

What is this doing?

Somehow I do not understand the logic behind this extention.

So for instance I click on 1280, then I click on 8:5 and it sets the resolution to 1600x1024 instead of 1280x800. What's the sense in this?

Occasional TypeError upon pressing the 1:1 button

It sometimes happens that w and/or h are of type str, not int. Then trying to compute (w + h) / 2 raises a TypeError, and the image dimensions are not updated.

Unfortunately this only happens sometimes, and I haven't yet figured out exactly when. The last time this hit me, I was in the img2img tab.

What I do know, however, is that this can be fixed by introducing an explicit typecast, like this:

def avg_from_dims(w, h):
    w = int(w)
    h = int(h)
    avg = (w + h) // 2
    if (w + h) % 2 != 0:
        avg += 1
    return avg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.