Spaces:
Runtime error
Runtime error
| import os | |
| from sys import executable | |
| import subprocess | |
| import pathlib | |
| import gc | |
| import time | |
| import subprocess | |
| #Gitclone function | |
| def Gitclone(URI:str,ClonePath:pathlib.Path ) -> int : | |
| if pathlib.Path.exists(ClonePath): | |
| return 0 | |
| for z in range(10): | |
| i=subprocess.run([r"git",r"clone",str(URI),str(ClonePath)]) | |
| if(i.returncode == 0 ): | |
| del i | |
| return 0 | |
| else : | |
| del i | |
| raise Exception(str.format("clone \'{0}\' failed",URI)) | |
| #run_echo_command procedure | |
| def run_echo_command(): | |
| try: | |
| start_huggingface | |
| except NameError: | |
| start_huggingface = int(time.time()) - 5 | |
| cmd = f"echo -n {start_huggingface} > /home/user/app/stable-diffusion-webui/static/colabTimer.txt" | |
| subprocess.run(cmd, shell=True) | |
| user_home =pathlib.Path.home().resolve() | |
| os.chdir(str(user_home)) | |
| #clone stable-diffusion-webui repo | |
| print("cloning stable-diffusion-webui repo") | |
| Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",user_home / r"stable-diffusion-webui") | |
| run_echo_command() | |
| os.chdir(user_home / r"stable-diffusion-webui") | |
| #strt Stable Diffusion Webui | |
| print("Done\nStarting Webui...") | |
| os.chdir(user_home / r"stable-diffusion-webui") | |
| import subprocess | |
| import pathlib | |
| user_home = pathlib.Path("/home/user") # Gantilah dengan path yang sesuai | |
| args = [ | |
| executable, | |
| user_home / "stable-diffusion-webui" / "launch.py", | |
| "--precision", "full", | |
| "--no-half", | |
| "--no-half-vae", | |
| "--skip-torch-cuda-test", | |
| "--ui-settings-file=" + str(pathlib.Path(__file__).parent / "config.json") | |
| ] | |
| args = [arg.as_posix() if isinstance(arg, pathlib.PosixPath) else arg for arg in args] | |
| try: | |
| ret = subprocess.run(args) | |
| except Exception as e: | |
| print("Error:", e) | |
| del os ,user_home ,pyexecutable ,subprocess | |