aboutsummaryrefslogtreecommitdiff
path: root/extensions-builtin/hypertile/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'extensions-builtin/hypertile/scripts')
-rw-r--r--extensions-builtin/hypertile/scripts/hypertile_script.py2
-rw-r--r--extensions-builtin/hypertile/scripts/hypertile_xyz.py18
2 files changed, 11 insertions, 9 deletions
diff --git a/extensions-builtin/hypertile/scripts/hypertile_script.py b/extensions-builtin/hypertile/scripts/hypertile_script.py
index b2413cc5..d3ab6091 100644
--- a/extensions-builtin/hypertile/scripts/hypertile_script.py
+++ b/extensions-builtin/hypertile/scripts/hypertile_script.py
@@ -75,4 +75,4 @@ def on_ui_settings():
script_callbacks.on_ui_settings(on_ui_settings)
-script_callbacks.on_before_ui(add_axis_options) \ No newline at end of file
+script_callbacks.on_before_ui(add_axis_options)
diff --git a/extensions-builtin/hypertile/scripts/hypertile_xyz.py b/extensions-builtin/hypertile/scripts/hypertile_xyz.py
index eaf7c8d7..3007a083 100644
--- a/extensions-builtin/hypertile/scripts/hypertile_xyz.py
+++ b/extensions-builtin/hypertile/scripts/hypertile_xyz.py
@@ -1,17 +1,17 @@
from modules import scripts
-xyz_grid = [x for x in scripts.scripts_data if x.script_class.__module__ == "xyz_grid.py"][0].module
from modules.shared import opts
+xyz_grid = [x for x in scripts.scripts_data if x.script_class.__module__ == "xyz_grid.py"][0].module
+
def int_applier(value_name:str, min_range:int = -1, max_range:int = -1):
"""
Returns a function that applies the given value to the given value_name in opts.data.
"""
# convert to int
def validate(value_name:str, value:str):
- try:
- value = int(value)
- except:
- raise ValueError(f"Value {value} for {value_name} is not an integer")
+ if not value.isnumeric():
+ raise ValueError(f"Value {value} for {value_name} must be an integer")
+ value = int(value)
# validate value
if not min_range == -1:
assert value >= min_range, f"Value {value} for {value_name} must be greater than or equal to {min_range}"
@@ -46,7 +46,9 @@ def add_axis_options():
xyz_grid.AxisOption("[Hypertile] VAE Max Tile Size", int, int_applier("hypertile_max_tile_vae", 0, 512)),
xyz_grid.AxisOption("[Hypertile] VAE Swap Size", int, int_applier("hypertile_swap_size_vae", 0, 64)),
]
- # check if the axis options have already been added
- if any(set(opt.label for opt in extra_axis_options).intersection(set(opt.label for opt in xyz_grid.axis_options))):
+ set_a = set([opt.label for opt in xyz_grid.axis_options])
+ set_b = set([opt.label for opt in extra_axis_options])
+ if set_a.intersection(set_b):
return
- xyz_grid.axis_options.extend(extra_axis_options) \ No newline at end of file
+
+ xyz_grid.axis_options.extend(extra_axis_options)