mirror of
https://github.com/altoiddealer/--sd-webui-ar-plusplus.git
synced 2026-01-26 19:19:55 +00:00
Make recommended review changes
Made recommended review changes except where noted in review comments.
This commit is contained in:
@@ -6,6 +6,8 @@ import gradio as gr
|
||||
import modules.scripts as scripts
|
||||
from modules.ui_components import ToolButton
|
||||
|
||||
from math import gcd
|
||||
|
||||
aspect_ratios_dir = scripts.basedir()
|
||||
|
||||
calculator_symbol = '\U0001F5A9'
|
||||
@@ -127,25 +129,20 @@ def write_resolutions_file(filename):
|
||||
f.writelines(resolutions)
|
||||
|
||||
|
||||
## Functions for calculator panel
|
||||
def gcd(a, b):
|
||||
if b == 0:
|
||||
return a
|
||||
return gcd(b, a % b)
|
||||
|
||||
|
||||
def get_reduced_ratio(n, d):
|
||||
n, d = list(map(int, (n, d)))
|
||||
|
||||
if n == d:
|
||||
return '1:1'
|
||||
|
||||
swapped = False
|
||||
if n < d:
|
||||
temp = n
|
||||
n = d
|
||||
d = temp
|
||||
n, d = d, n
|
||||
swapped = True
|
||||
|
||||
div = gcd(int(n), int(d))
|
||||
div = gcd(n, d)
|
||||
|
||||
if 'temp' not in locals():
|
||||
if swapped:
|
||||
w = int(n) // div
|
||||
h = int(d) // div
|
||||
else:
|
||||
@@ -252,7 +249,7 @@ class AspectRatioScript(scripts.Script):
|
||||
outputs=resolution,
|
||||
)
|
||||
|
||||
# dummy components needed for js function
|
||||
# dummy components needed for JS function
|
||||
dummy_text1 = gr.Text(visible=False)
|
||||
dummy_text2 = gr.Text(visible=False)
|
||||
dummy_text3 = gr.Text(visible=False)
|
||||
|
||||
Reference in New Issue
Block a user