2023-08-09 07:25:35 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import torch
|
|
|
|
|
|
|
|
from modules import shared
|
|
|
|
from modules.shared import cmd_opts
|
|
|
|
|
|
|
|
|
|
|
|
def initialize():
|
|
|
|
"""Initializes fields inside the shared module in a controlled manner.
|
|
|
|
|
|
|
|
Should be called early because some other modules you can import mingt need these fields to be already set.
|
|
|
|
"""
|
|
|
|
|
|
|
|
os.makedirs(cmd_opts.hypernetwork_dir, exist_ok=True)
|
|
|
|
|
|
|
|
from modules import options, shared_options
|
|
|
|
shared.options_templates = shared_options.options_templates
|
|
|
|
shared.opts = options.Options(shared_options.options_templates, shared_options.restricted_opts)
|
2023-08-09 12:06:03 +00:00
|
|
|
shared.restricted_opts = shared_options.restricted_opts
|
2024-01-03 22:16:58 +00:00
|
|
|
try:
|
2023-08-09 07:25:35 +00:00
|
|
|
shared.opts.load(shared.config_filename)
|
2024-01-03 22:16:58 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
2023-08-09 07:25:35 +00:00
|
|
|
|
|
|
|
from modules import shared_state
|
|
|
|
shared.state = shared_state.State()
|
|
|
|
|
|
|
|
from modules import styles
|
|
|
|
shared.prompt_styles = styles.StyleDatabase(shared.styles_filename)
|
|
|
|
|
|
|
|
from modules import interrogate
|
|
|
|
shared.interrogator = interrogate.InterrogateModels("interrogate")
|
|
|
|
|
|
|
|
from modules import shared_total_tqdm
|
|
|
|
shared.total_tqdm = shared_total_tqdm.TotalTQDM()
|
|
|
|
|
|
|
|
from modules import memmon, devices
|
|
|
|
shared.mem_mon = memmon.MemUsageMonitor("MemMon", devices.device, shared.opts)
|
|
|
|
shared.mem_mon.start()
|
|
|
|
|