paths_internal.py 1.5 KB
Newer Older
1 2 3 4
"""this module defines internal paths used by program and is safe to import before dependencies are installed in launch.py"""

import argparse
import os
W
w-e-w 已提交
5 6
import sys
import shlex
C
catboxanon 已提交
7 8 9 10
from pathlib import Path


normalized_filepath = lambda filepath: str(Path(filepath).resolve())
W
w-e-w 已提交
11 12 13

commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
sys.argv += shlex.split(commandline_args)
14

15
cwd = os.getcwd()
16 17
modules_path = os.path.dirname(os.path.realpath(__file__))
script_path = os.path.dirname(modules_path)
18 19 20 21 22 23 24 25

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)
26
parser_pre.add_argument("--data-dir", type=str, default=os.path.dirname(modules_path), help="base path where all user data is stored", )
27 28 29 30 31 32 33
cmd_opts_pre = parser_pre.parse_known_args()[0]

data_path = cmd_opts_pre.data_dir

models_path = os.path.join(data_path, "models")
extensions_dir = os.path.join(data_path, "extensions")
extensions_builtin_dir = os.path.join(script_path, "extensions-builtin")
34
config_states_dir = os.path.join(script_path, "config_states")
W
w-e-w 已提交
35
default_output_dir = os.path.join(data_path, "output")
36 37

roboto_ttf_file = os.path.join(modules_path, 'Roboto-Regular.ttf')