Dracomoth commited on
Commit
5464139
·
1 Parent(s): f835075

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -4
app.py CHANGED
@@ -1,8 +1,60 @@
1
  import os
2
 
3
- os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
4
- os.chdir(f"/home/user/app/stable-diffusion-webui")
 
 
 
 
 
 
 
 
 
 
5
 
6
- os.system(f"%pip install torch==1.13.1+cu117 torchvision=0.14.1+cu117 torchtext=0.14.1 torchaudio=0.13.1 torchdata=0.5.1 --extra-index-url https ://download.pytorch.org/whl/cu117`")
 
 
 
 
 
7
 
8
- os.system(f"python launch.py --skip-torch-cuda-test --precision full --no-half")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
 
3
+ #Gitclone function
4
+ def Gitclone(URI:str,ClonePath:pathlib.Path ) -> int :
5
+ if pathlib.Path.exists(ClonePath):
6
+ return 0
7
+ for z in range(10):
8
+ i=subprocess.run([r"git",r"clone",str(URI),str(ClonePath)])
9
+ if(i.returncode == 0 ):
10
+ del i
11
+ return 0
12
+ else :
13
+ del i
14
+ raise Exception(str.format("clone \'{0}\' failed",URI))
15
 
16
+ #run_echo_command procedure
17
+ def run_echo_command():
18
+ try:
19
+ start_huggingface
20
+ except NameError:
21
+ start_huggingface = int(time.time()) - 5
22
 
23
+ cmd = f"echo -n {start_huggingface} > /home/user/app/stable-diffusion-webui/static/colabTimer.txt"
24
+ subprocess.run(cmd, shell=True)
25
+
26
+ user_home =pathlib.Path.home().resolve()
27
+ os.chdir(str(user_home))
28
+
29
+ #clone stable-diffusion-webui repo
30
+ print("cloning stable-diffusion-webui repo")
31
+ Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",user_home / r"stable-diffusion-webui")
32
+
33
+ run_echo_command()
34
+ os.chdir(user_home / r"stable-diffusion-webui")
35
+
36
+ #strt Stable Diffusion Webui
37
+ print("Done\nStarting Webui...")
38
+ os.chdir(user_home / r"stable-diffusion-webui")
39
+ import subprocess
40
+ import pathlib
41
+
42
+ user_home = pathlib.Path("/home/user") # Gantilah dengan path yang sesuai
43
+
44
+ args = [
45
+ executable,
46
+ user_home / "stable-diffusion-webui" / "launch.py",
47
+ "--precision", "full",
48
+ "--no-half",
49
+ "--no-half-vae",
50
+ "--skip-torch-cuda-test",
51
+ "--ui-settings-file=" + str(pathlib.Path(__file__).parent / "config.json")
52
+ ]
53
+
54
+ args = [arg.as_posix() if isinstance(arg, pathlib.PosixPath) else arg for arg in args]
55
+
56
+ try:
57
+ ret = subprocess.run(args)
58
+ except Exception as e:
59
+ print("Error:", e)
60
+ del os ,user_home ,pyexecutable ,subprocess