mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
fix clean install
This commit is contained in:
@@ -22,13 +22,18 @@ python = sys.executable # used by some extensions to run python
|
||||
skip_install = False # parsed by some extensions
|
||||
|
||||
|
||||
def init_modules():
|
||||
global parser, args, script_path, extensions_dir # pylint: disable=global-statement
|
||||
def init_args():
|
||||
global parser, args # pylint: disable=global-statement
|
||||
import modules.cmd_args
|
||||
parser = modules.cmd_args.parser
|
||||
installer.add_args(parser)
|
||||
args, _ = parser.parse_known_args()
|
||||
|
||||
|
||||
def init_paths():
|
||||
global script_path, extensions_dir # pylint: disable=global-statement
|
||||
import modules.paths
|
||||
modules.paths.register_paths()
|
||||
script_path = modules.paths.script_path
|
||||
extensions_dir = modules.paths.extensions_dir
|
||||
|
||||
@@ -161,7 +166,7 @@ def start_server(immediate=True, server=None):
|
||||
|
||||
if __name__ == "__main__":
|
||||
installer.ensure_base_requirements()
|
||||
init_modules() # setup argparser and default folders
|
||||
init_args() # setup argparser and default folders
|
||||
installer.args = args
|
||||
installer.setup_logging()
|
||||
installer.log.info('Starting SD.Next')
|
||||
@@ -188,16 +193,19 @@ if __name__ == "__main__":
|
||||
if args.skip_all:
|
||||
installer.log.info('Skipping all checks')
|
||||
installer.quick_allowed = True
|
||||
init_paths()
|
||||
elif installer.check_timestamp():
|
||||
installer.log.info('No changes detected: quick launch active')
|
||||
installer.install_requirements()
|
||||
installer.install_packages()
|
||||
init_paths()
|
||||
installer.check_extensions()
|
||||
else:
|
||||
installer.install_requirements()
|
||||
installer.install_packages()
|
||||
installer.install_repositories()
|
||||
installer.install_submodules()
|
||||
init_paths()
|
||||
installer.install_extensions()
|
||||
installer.install_requirements() # redo requirements since extensions may change them
|
||||
installer.update_wiki()
|
||||
|
||||
+20
-35
@@ -5,6 +5,7 @@ import json
|
||||
import argparse
|
||||
from modules.errors import log
|
||||
|
||||
|
||||
# parse args, parse again after we have the data-dir and early-read the config file
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser.add_argument("--ckpt", type=str, default=os.environ.get("SD_MODEL", None), help="Path to model checkpoint to load immediately, default: %(default)s")
|
||||
@@ -18,7 +19,6 @@ try:
|
||||
with open(config_path, 'r', encoding='utf8') as f:
|
||||
config = json.load(f)
|
||||
except Exception as err:
|
||||
print(f'Error loading config file: ${config_path} {err}')
|
||||
config = {}
|
||||
|
||||
modules_path = os.path.dirname(os.path.realpath(__file__))
|
||||
@@ -33,45 +33,30 @@ sd_default_config = os.path.join(sd_configs_path, "v1-inference.yaml")
|
||||
sd_model_file = cli.ckpt or os.path.join(script_path, 'model.ckpt') # not used
|
||||
default_sd_model_file = sd_model_file # not used
|
||||
debug = log.info if os.environ.get('SD_PATH_DEBUG', None) is not None else lambda *args, **kwargs: None
|
||||
paths = {}
|
||||
|
||||
if os.environ.get('SD_PATH_DEBUG', None) is not None:
|
||||
print(f'Paths: script-path="{script_path}" data-dir="{data_path}" models-dir="{models_path}" config="{config_path}"')
|
||||
|
||||
"""
|
||||
data_path = paths_internal.data_path
|
||||
script_path = paths_internal.script_path
|
||||
models_path = paths_internal.models_path
|
||||
sd_configs_path = paths_internal.sd_configs_path
|
||||
sd_default_config = paths_internal.sd_default_config
|
||||
sd_model_file = paths_internal.sd_model_file
|
||||
default_sd_model_file = paths_internal.default_sd_model_file
|
||||
extensions_dir = paths_internal.extensions_dir
|
||||
extensions_builtin_dir = paths_internal.extensions_builtin_dir
|
||||
"""
|
||||
|
||||
sys.path.insert(0, script_path)
|
||||
|
||||
sd_path = os.path.join(script_path, 'repositories')
|
||||
modules_path = os.path.join(script_path, 'modules')
|
||||
|
||||
path_dirs = [
|
||||
(sd_path, 'ldm', 'ldm', []),
|
||||
(sd_path, 'taming', 'Taming Transformers', []),
|
||||
(os.path.join(sd_path, 'blip'), 'models/blip.py', 'BLIP', []),
|
||||
(os.path.join(sd_path, 'codeformer'), 'inference_codeformer.py', 'CodeFormer', []),
|
||||
(os.path.join(modules_path, 'k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
|
||||
]
|
||||
|
||||
paths = {}
|
||||
|
||||
for d, must_exist, what, _options in path_dirs:
|
||||
must_exist_path = os.path.abspath(os.path.join(script_path, d, must_exist))
|
||||
if not os.path.exists(must_exist_path):
|
||||
log.error(f'Required path not found: path={must_exist_path} item={what}')
|
||||
else:
|
||||
d = os.path.abspath(d)
|
||||
sys.path.append(d)
|
||||
paths[what] = d
|
||||
def register_paths():
|
||||
sys.path.insert(0, script_path)
|
||||
sd_path = os.path.join(script_path, 'repositories')
|
||||
path_dirs = [
|
||||
(sd_path, 'ldm', 'ldm', []),
|
||||
(sd_path, 'taming', 'Taming Transformers', []),
|
||||
(os.path.join(sd_path, 'blip'), 'models/blip.py', 'BLIP', []),
|
||||
(os.path.join(sd_path, 'codeformer'), 'inference_codeformer.py', 'CodeFormer', []),
|
||||
(os.path.join(modules_path, 'k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
|
||||
]
|
||||
for d, must_exist, what, _options in path_dirs:
|
||||
must_exist_path = os.path.abspath(os.path.join(script_path, d, must_exist))
|
||||
if not os.path.exists(must_exist_path):
|
||||
log.error(f'Required path not found: path={must_exist_path} item={what}')
|
||||
else:
|
||||
d = os.path.abspath(d)
|
||||
sys.path.append(d)
|
||||
paths[what] = d
|
||||
|
||||
|
||||
def create_path(folder):
|
||||
|
||||
Reference in New Issue
Block a user