Skip to content

Commit 22e23db

Browse files
committed
add hypertile infotext
1 parent 883d6a2 commit 22e23db

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

extensions-builtin/hypertile/scripts/hypertile_script.py

+42-11
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,42 @@ def process(self, p, *args):
1717

1818
configure_hypertile(p.width, p.height, enable_unet=shared.opts.hypertile_enable_unet)
1919

20+
self.add_infotext(p)
21+
2022
def before_hr(self, p, *args):
23+
24+
enable = shared.opts.hypertile_enable_unet_secondpass or shared.opts.hypertile_enable_unet
25+
2126
# exclusive hypertile seed for the second pass
22-
if not shared.opts.hypertile_enable_unet:
27+
if enable:
2328
hypertile.set_hypertile_seed(p.all_seeds[0])
24-
configure_hypertile(p.hr_upscale_to_x, p.hr_upscale_to_y, enable_unet=shared.opts.hypertile_enable_unet_secondpass)
29+
30+
configure_hypertile(p.hr_upscale_to_x, p.hr_upscale_to_y, enable_unet=enable)
31+
32+
if enable and not shared.opts.hypertile_enable_unet:
33+
p.extra_generation_params["Hypertile U-Net second pass"] = True
34+
35+
self.add_infotext(p, add_unet_params=True)
36+
37+
def add_infotext(self, p, add_unet_params=False):
38+
def option(name):
39+
value = getattr(shared.opts, name)
40+
default_value = shared.opts.get_default(name)
41+
return None if value == default_value else value
42+
43+
if shared.opts.hypertile_enable_unet:
44+
p.extra_generation_params["Hypertile U-Net"] = True
45+
46+
if shared.opts.hypertile_enable_unet or add_unet_params:
47+
p.extra_generation_params["Hypertile U-Net max depth"] = option('hypertile_max_depth_unet')
48+
p.extra_generation_params["Hypertile U-Net max tile size"] = option('hypertile_max_tile_unet')
49+
p.extra_generation_params["Hypertile U-Net swap size"] = option('hypertile_swap_size_unet')
50+
51+
if shared.opts.hypertile_enable_vae:
52+
p.extra_generation_params["Hypertile VAE"] = True
53+
p.extra_generation_params["Hypertile VAE max depth"] = option('hypertile_max_depth_vae')
54+
p.extra_generation_params["Hypertile VAE max tile size"] = option('hypertile_max_tile_vae')
55+
p.extra_generation_params["Hypertile VAE swap size"] = option('hypertile_swap_size_vae')
2556

2657

2758
def configure_hypertile(width, height, enable_unet=True):
@@ -57,16 +88,16 @@ def on_ui_settings():
5788
benefit.
5889
"""),
5990

60-
"hypertile_enable_unet": shared.OptionInfo(False, "Enable Hypertile U-Net").info("noticeable change in details of the generated picture; if enabled, overrides the setting below"),
61-
"hypertile_enable_unet_secondpass": shared.OptionInfo(False, "Enable Hypertile U-Net for hires fix second pass"),
62-
"hypertile_max_depth_unet": shared.OptionInfo(3, "Hypertile U-Net max depth", gr.Slider, {"minimum": 0, "maximum": 3, "step": 1}),
63-
"hypertile_max_tile_unet": shared.OptionInfo(256, "Hypertile U-net max tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}),
64-
"hypertile_swap_size_unet": shared.OptionInfo(3, "Hypertile U-net swap size", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}),
91+
"hypertile_enable_unet": shared.OptionInfo(False, "Enable Hypertile U-Net", infotext="Hypertile U-Net").info("enables hypertile for all modes, including hires fix second pass; noticeable change in details of the generated picture"),
92+
"hypertile_enable_unet_secondpass": shared.OptionInfo(False, "Enable Hypertile U-Net for hires fix second pass", infotext="Hypertile U-Net second pass").info("enables hypertile just for hires fix second pass - regardless of whether the above setting is enabled"),
93+
"hypertile_max_depth_unet": shared.OptionInfo(3, "Hypertile U-Net max depth", gr.Slider, {"minimum": 0, "maximum": 3, "step": 1}, infotext="Hypertile U-Net max depth").info("larger = more neural network layers affected; minor effect on performance"),
94+
"hypertile_max_tile_unet": shared.OptionInfo(256, "Hypertile U-Net max tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}, infotext="Hypertile U-Net max tile size").info("larger = worse performance"),
95+
"hypertile_swap_size_unet": shared.OptionInfo(3, "Hypertile U-Net swap size", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}, infotext="Hypertile U-Net swap size"),
6596

66-
"hypertile_enable_vae": shared.OptionInfo(False, "Enable Hypertile VAE").info("minimal change in the generated picture"),
67-
"hypertile_max_depth_vae": shared.OptionInfo(3, "Hypertile VAE max depth", gr.Slider, {"minimum": 0, "maximum": 3, "step": 1}),
68-
"hypertile_max_tile_vae": shared.OptionInfo(128, "Hypertile VAE max tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}),
69-
"hypertile_swap_size_vae": shared.OptionInfo(3, "Hypertile VAE swap size ", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}),
97+
"hypertile_enable_vae": shared.OptionInfo(False, "Enable Hypertile VAE", infotext="Hypertile VAE").info("minimal change in the generated picture"),
98+
"hypertile_max_depth_vae": shared.OptionInfo(3, "Hypertile VAE max depth", gr.Slider, {"minimum": 0, "maximum": 3, "step": 1}, infotext="Hypertile VAE max depth"),
99+
"hypertile_max_tile_vae": shared.OptionInfo(128, "Hypertile VAE max tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}, infotext="Hypertile VAE max tile size"),
100+
"hypertile_swap_size_vae": shared.OptionInfo(3, "Hypertile VAE swap size ", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}, infotext="Hypertile VAE swap size"),
70101
}
71102

72103
for name, opt in options.items():

0 commit comments

Comments
 (0)