hololens/stable-diffusion-webui-depthmap-script
1
1# This launches DepthMap without the AUTOMATIC1111/stable-diffusion-webui
2
3import argparse
4import os
5import pathlib
6
7import src.misc
8
9
10def maybe_chdir():
11 """Detects if DepthMap was installed as a stable-diffusion-webui script, but run without current directory set to
12 the stable-diffusion-webui root. Changes current directory if needed.
13 This is to avoid re-downloading models and putting results into a wrong folder."""
14 try:
15 file_path = pathlib.Path(__file__)
16 path = file_path.parts
17 while len(path) > 0 and path[-1] != src.misc.REPOSITORY_NAME:
18 path = path[:-1]
19 if len(path) >= 2 and path[-1] == src.misc.REPOSITORY_NAME and path[-2] == "extensions":
20 path = path[:-2]
21 listdir = os.listdir(str(pathlib.Path(*path)))
22 if 'launch.py' in listdir and 'webui.py':
23 os.chdir(str(pathlib.Path(*path)))
24 except:
25 pass
26
27
28if __name__ == '__main__':
29 parser = argparse.ArgumentParser()
30 parser.add_argument("--share", help="Create public link", action='store_true')
31 parser.add_argument("--listen", help="Create public link", action='store_true')
32 parser.add_argument("--no_chdir", help="Do not try to use the root of stable-diffusion-webui", action='store_true')
33 args = parser.parse_args()
34
35 print(f"{src.misc.SCRIPT_FULL_NAME} running in standalone mode!")
36 if not args.no_chdir:
37 maybe_chdir()
38 server_name = "0.0.0.0" if args.listen else None
39 import src.common_ui
40 src.common_ui.on_ui_tabs().launch(share=args.share, server_name=server_name)
41 