diff --git a/backend/invoke_ai_web_server.py b/backend/invoke_ai_web_server.py index 6229f9c45a..efdc932eef 100644 --- a/backend/invoke_ai_web_server.py +++ b/backend/invoke_ai_web_server.py @@ -20,11 +20,12 @@ from ldm.invoke.prompt_parser import split_weighted_subprompts from backend.modules.parameters import parameters_to_command - # Loading Arguments opt = Args() args = opt.parse_args() +# Set the root directory for static files and relative paths +args.root_dir = os.path.expanduser(args.root_dir or '..') if not os.path.isabs(args.outdir): args.outdir=os.path.join(args.root_dir,args.outdir) @@ -64,6 +65,7 @@ class InvokeAIWebServer: if opt.cors: socketio_args["cors_allowed_origins"] = opt.cors + print(f'DEBUG: static_folder should be at {os.path.join(args.root_dir,"frontend/dist")}') self.app = Flask( __name__, static_url_path="", static_folder=os.path.join(args.root_dir,"frontend/dist") ) diff --git a/scripts/load_models.py b/scripts/load_models.py index 25be2dc0d7..51a0d492c4 100755 --- a/scripts/load_models.py +++ b/scripts/load_models.py @@ -590,11 +590,13 @@ def get_root(root:str=None)->str: with open(init_file, 'r') as infile: lines = infile.readlines() for l in lines: + if re.search('\s*#',l): # ignore comments + continue match = re.search('--root\s*=?\s*"?([^"]+)"?',l) if match: root = match.groups()[0] - - return root.strip() or '.' + root = root or '.' + return root.strip() #------------------------------------- def initialize_rootdir(root:str): @@ -675,7 +677,9 @@ def main(): try: introduction() - # We check for this specific file, without which we are toast... + # We check for two files to see if the runtime directory is correctly initialized. + # 1. a key stable diffusion config file + # 2. the web front end static files if not os.path.exists(os.path.join(Globals.root,'configs/stable-diffusion/v1-inference.yaml')) \ or not os.path.exists(os.path.join(Globals.root,'frontend/dist')): initialize_rootdir(Globals.root)