2023-08-09 10:25:35 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from modules.shared_cmd_options import cmd_opts
|
2023-01-26 23:29:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
def realesrgan_models_names():
|
|
|
|
import modules.realesrgan_model
|
|
|
|
return [x.name for x in modules.realesrgan_model.get_realesrgan_models(None)]
|
|
|
|
|
2023-01-27 11:28:12 +03:00
|
|
|
|
2023-01-26 23:29:27 +03:00
|
|
|
def postprocessing_scripts():
|
|
|
|
import modules.scripts
|
|
|
|
|
2023-01-27 11:28:12 +03:00
|
|
|
return modules.scripts.scripts_postproc.scripts
|
|
|
|
|
|
|
|
|
|
|
|
def sd_vae_items():
|
|
|
|
import modules.sd_vae
|
|
|
|
|
|
|
|
return ["Automatic", "None"] + list(modules.sd_vae.vae_dict)
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_vae_list():
|
|
|
|
import modules.sd_vae
|
|
|
|
|
2023-02-19 12:23:40 +03:00
|
|
|
modules.sd_vae.refresh_vae_list()
|
2023-05-18 22:48:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
def cross_attention_optimizations():
|
|
|
|
import modules.sd_hijack
|
|
|
|
|
|
|
|
return ["Automatic"] + [x.title() for x in modules.sd_hijack.optimizers] + ["None"]
|
|
|
|
|
|
|
|
|
2023-05-27 15:47:33 +03:00
|
|
|
def sd_unet_items():
|
|
|
|
import modules.sd_unet
|
|
|
|
|
|
|
|
return ["Automatic"] + [x.label for x in modules.sd_unet.unet_options] + ["None"]
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_unet_list():
|
|
|
|
import modules.sd_unet
|
|
|
|
|
|
|
|
modules.sd_unet.list_unets()
|
|
|
|
|
2023-05-31 20:31:17 +03:00
|
|
|
|
2023-08-09 10:25:35 +03:00
|
|
|
def list_checkpoint_tiles():
|
|
|
|
import modules.sd_models
|
|
|
|
return modules.sd_models.checkpoint_tiles()
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_checkpoints():
|
|
|
|
import modules.sd_models
|
|
|
|
return modules.sd_models.list_models()
|
|
|
|
|
|
|
|
|
|
|
|
def list_samplers():
|
|
|
|
import modules.sd_samplers
|
|
|
|
return modules.sd_samplers.all_samplers
|
|
|
|
|
|
|
|
|
|
|
|
def reload_hypernetworks():
|
|
|
|
from modules.hypernetworks import hypernetwork
|
|
|
|
from modules import shared
|
|
|
|
|
|
|
|
shared.hypernetworks = hypernetwork.list_hypernetworks(cmd_opts.hypernetwork_dir)
|
|
|
|
|
|
|
|
|
2023-05-31 20:31:17 +03:00
|
|
|
ui_reorder_categories_builtin_items = [
|
|
|
|
"inpaint",
|
|
|
|
"sampler",
|
|
|
|
"checkboxes",
|
|
|
|
"hires_fix",
|
|
|
|
"dimensions",
|
|
|
|
"cfg",
|
|
|
|
"seed",
|
|
|
|
"batch",
|
|
|
|
"override_settings",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def ui_reorder_categories():
|
2023-05-31 22:40:09 +03:00
|
|
|
from modules import scripts
|
|
|
|
|
2023-05-31 20:31:17 +03:00
|
|
|
yield from ui_reorder_categories_builtin_items
|
2023-05-31 22:40:09 +03:00
|
|
|
|
|
|
|
sections = {}
|
|
|
|
for script in scripts.scripts_txt2img.scripts + scripts.scripts_img2img.scripts:
|
|
|
|
if isinstance(script.section, str):
|
|
|
|
sections[script.section] = 1
|
|
|
|
|
|
|
|
yield from sections
|
|
|
|
|
2023-05-31 20:31:17 +03:00
|
|
|
yield "scripts"
|
2023-08-09 10:25:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Shared(sys.modules[__name__].__class__):
|
|
|
|
"""
|
|
|
|
this class is here to provide sd_model field as a property, so that it can be created and loaded on demand rather than
|
|
|
|
at program startup.
|
|
|
|
"""
|
|
|
|
|
|
|
|
sd_model_val = None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def sd_model(self):
|
|
|
|
import modules.sd_models
|
|
|
|
|
|
|
|
return modules.sd_models.model_data.get_sd_model()
|
|
|
|
|
|
|
|
@sd_model.setter
|
|
|
|
def sd_model(self, value):
|
|
|
|
import modules.sd_models
|
|
|
|
|
|
|
|
modules.sd_models.model_data.set_sd_model(value)
|
|
|
|
|
|
|
|
|
|
|
|
sys.modules['modules.shared'].__class__ = Shared
|