protoxx91/stable-diffusion-webui-controlnet-docker
1
1import os2import subprocess3import sys4 5 6def on_start():7 print("---------------")8 print("Running script './on_start.sh' to download models ...")9 print("---------------")10 result = subprocess.run("./on_start.sh", shell=True, env=os.environ)11 if result.returncode != 0:12 raise RuntimeError(f"Error executing ./on_start.sh [exit code: {result.returncode}]")13 14 15def start():16 on_start()17 18 print("---------------")19 print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with arguments: {' '.join(sys.argv[1:])}")20 print("---------------")21 import webui # type: ignore # noqa22 if '--nowebui' in sys.argv:23 webui.api_only()24 else:25 webui.webui()26 27 28if __name__ == "__main__":29 import torch30 if not torch.cuda.is_available():31 sys.argv.extend(["--precision", "full", "--no-half", "--use-cpu", "SD", "BSRGAN", "ESRGAN", "SCUNet", "CodeFormer", "--all"])32 else:33 sys.argv.extend(["--force-enable-xformers", "--xformers"])34 35 start()36 