2023-03-25 21:05:12 +08:00
|
|
|
"""this module defines internal paths used by program and is safe to import before dependencies are installed in launch.py"""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
2023-05-12 21:33:21 +08:00
|
|
|
import sys
|
|
|
|
import shlex
|
2024-02-16 03:22:13 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
2024-02-27 01:44:57 +08:00
|
|
|
normalized_filepath = lambda filepath: str(Path(filepath).absolute())
|
2023-05-12 21:33:21 +08:00
|
|
|
|
|
|
|
commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
|
|
|
|
sys.argv += shlex.split(commandline_args)
|
2023-03-25 21:05:12 +08:00
|
|
|
|
2023-09-13 15:05:55 +08:00
|
|
|
cwd = os.getcwd()
|
2023-05-11 15:05:39 +08:00
|
|
|
modules_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
script_path = os.path.dirname(modules_path)
|
2023-03-25 21:05:12 +08:00
|
|
|
|
|
|
|
sd_configs_path = os.path.join(script_path, "configs")
|
|
|
|
sd_default_config = os.path.join(sd_configs_path, "v1-inference.yaml")
|
|
|
|
sd_model_file = os.path.join(script_path, 'model.ckpt')
|
|
|
|
default_sd_model_file = sd_model_file
|
|
|
|
|
|
|
|
# Parse the --data-dir flag first so we can use it as a base for our other argument default values
|
|
|
|
parser_pre = argparse.ArgumentParser(add_help=False)
|
2023-05-11 15:05:39 +08:00
|
|
|
parser_pre.add_argument("--data-dir", type=str, default=os.path.dirname(modules_path), help="base path where all user data is stored", )
|
2024-05-09 04:48:10 +08:00
|
|
|
parser_pre.add_argument("--models-dir", type=str, default=None, help="base path where models are stored; overrides --data-dir", )
|
2023-03-25 21:05:12 +08:00
|
|
|
cmd_opts_pre = parser_pre.parse_known_args()[0]
|
|
|
|
|
|
|
|
data_path = cmd_opts_pre.data_dir
|
|
|
|
|
2024-06-08 16:35:45 +08:00
|
|
|
models_path = cmd_opts_pre.models_dir if cmd_opts_pre.models_dir else os.path.join(data_path, "models")
|
2023-03-25 21:05:12 +08:00
|
|
|
extensions_dir = os.path.join(data_path, "extensions")
|
|
|
|
extensions_builtin_dir = os.path.join(script_path, "extensions-builtin")
|
2023-03-30 05:46:03 +08:00
|
|
|
config_states_dir = os.path.join(script_path, "config_states")
|
2024-03-18 23:54:56 +08:00
|
|
|
default_output_dir = os.path.join(data_path, "outputs")
|
2023-05-11 15:07:01 +08:00
|
|
|
|
|
|
|
roboto_ttf_file = os.path.join(modules_path, 'Roboto-Regular.ttf')
|