Spaces:
Runtime error
Runtime error
File size: 1,779 Bytes
200b6e9 4d8b0f0 7bb7eb0 5c7bd7f 4d8b0f0 200b6e9 5464139 200b6e9 5464139 f835075 5464139 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 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
|