ritpop commited on
Commit
b724fde
1 Parent(s): c7caf92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -70
app.py CHANGED
@@ -3,50 +3,11 @@ from sys import executable as pyexecutable
3
  import subprocess
4
  import pathlib
5
  import gc
6
- from huggingface_hub import hf_hub_download
7
- import re
8
- import urllib.parse
9
 
10
- @spaces.GPU
11
- def fake_gpu():
12
- pass
13
-
14
- def split_hf_url(url: str):
15
- try:
16
- s = list(re.findall(r'^(?:https?://huggingface.co/)(?:(datasets)/)?(.+?/.+?)/\w+?/.+?/(?:(.+)/)?(.+?.\w+)(?:\?download=true)?$', url)[0])
17
- if len(s) < 4: return "", "", "", ""
18
- repo_id = s[1]
19
- repo_type = "dataset" if s[0] == "datasets" else "model"
20
- subfolder = urllib.parse.unquote(s[2]) if s[2] else None
21
- filename = urllib.parse.unquote(s[3])
22
- return repo_id, filename, subfolder, repo_type
23
- except Exception as e:
24
- print(e)
25
-
26
- def download_hf_file(directory, url):
27
- repo_id, filename, subfolder, repo_type = split_hf_url(url)
28
- try:
29
- if subfolder is not None: hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, repo_type=repo_type, local_dir=directory)
30
- else: hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory)
31
- print(f"Downloading: {url}")
32
- return True
33
- except Exception as e:
34
- print(f"Failed to download: {e}")
35
- return False
36
-
37
- def Gitclone(URI:str,ClonePath:str = "",HASH:str = "") -> int :
38
  if(ClonePath == "") :
39
  while True:
40
- try:
41
- user_home =pathlib.Path.home().resolve()
42
- os.chdir(str(user_home))
43
- except Exception:
44
- pass
45
  i=subprocess.run([r"git",r"clone",URI])
46
- try:
47
- if HASH: os.system(f"git reset --hard {HASH}")
48
- except Exception:
49
- pass
50
  if(i.returncode == 0 ):
51
  del i
52
  gc.collect()
@@ -55,14 +16,7 @@ def Gitclone(URI:str,ClonePath:str = "",HASH:str = "") -> int :
55
  del i
56
  else:
57
  while True:
58
- i=subprocess.run([r"git",r"clone",URI,ClonePath], timeout=60)
59
- try:
60
- os.chdir(ClonePath)
61
- if HASH: os.system(f"git reset --hard {HASH}")
62
- user_home =pathlib.Path.home().resolve()
63
- os.chdir(str(user_home))
64
- except Exception:
65
- pass
66
  if(i.returncode == 0 ):
67
  del i
68
  gc.collect()
@@ -71,24 +25,20 @@ def Gitclone(URI:str,ClonePath:str = "",HASH:str = "") -> int :
71
  del i
72
  def DownLoad(URI:str,DownloadPath:str,DownLoadFileName:str ) -> int:
73
  while (True):
74
- if "huggingface.co" in URI:
75
- success=download_hf_file(DownloadPath, URI)
76
- if success: return 0
77
- else:
78
- i=subprocess.run([r"aria2c",r"-c",r"-x" ,r"16", r"-s",r"16", r"-k" ,r"1M" ,r"-m",r"0",r"--enable-mmap=false",r"--console-log-level=error",r"-d",DownloadPath,r"-o",DownLoadFileName,URI], timeout=60);
79
- if(i.returncode == 0 ):
80
- del i
81
- gc.collect()
82
- return 0
83
- else :
84
- del i
85
  user_home =pathlib.Path.home().resolve()
86
  os.chdir(str(user_home))
87
  #clone stable-diffusion-webui repo
88
  print("cloning stable-diffusion-webui repo")
89
  Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",str(user_home / r"stable-diffusion-webui"))
90
- #os.chdir(str(user_home / r"stable-diffusion-webui"))
91
- #os.system("git reset --hard 89f9faa63388756314e8a1d96cf86bf5e0663045")
92
  #
93
 
94
  #install extensions
@@ -99,18 +49,31 @@ DownLoad(r"https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth",
99
  while True:
100
  if(subprocess.run([r"wget",r"https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py",r"-O",str(user_home / r"stable-diffusion-webui" / r"scripts" / r"run_n_times.py")]).returncode == 0):
101
  break
102
- #Gitclone(r"https://github.com/camenduru/stable-diffusion-webui-huggingface",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-huggingface"))
103
- #Gitclone(r"https://github.com/etherealxx/batchlinks-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui"))
104
- #Gitclone(r"https://github.com/kohya-ss/sd-webui-additional-networks",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks"))
105
- #Gitclone(r"https://github.com/Akegarasu/sd-webui-model-converter",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-model-converter"))
106
- ##Gitclone(r"https://github.com/hako-mikan/sd-webui-supermerger",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-supermerger"))
107
- #Gitclone(r"https://github.com/tmzint/sd-webui-supermerger",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-supermerger"))
108
- #Gitclone(r"https://github.com/bbc-mc/sdweb-merge-block-weighted-gui",str(user_home / r"stable-diffusion-webui" / r"extensions"/ r"sdweb-merge-block-weighted-gui"))
 
 
109
 
110
- #Gitclone(r"https://github.com/camenduru/sd-webui-tunnels",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-tunnels"))
 
 
 
 
 
 
 
 
111
  #Gitclone(r"https://github.com/etherealxx/batchlinks-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui"))
112
- #Gitclone(r"https://github.com/catppuccin/stable-diffusion-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-catppuccin"))
 
113
  #Gitclone(r"https://github.com/KohakuBueleaf/a1111-sd-webui-locon",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"a1111-sd-webui-locon" ))
 
 
114
  #Gitclone(r"https://github.com/camenduru/sd_webui_stealth_pnginfo",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd_webui_stealth_pnginfo"))
115
 
116
  os.chdir(user_home / r"stable-diffusion-webui")
 
3
  import subprocess
4
  import pathlib
5
  import gc
 
 
 
6
 
7
+ def Gitclone(URI:str,ClonePath:str = "") -> int :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  if(ClonePath == "") :
9
  while True:
 
 
 
 
 
10
  i=subprocess.run([r"git",r"clone",URI])
 
 
 
 
11
  if(i.returncode == 0 ):
12
  del i
13
  gc.collect()
 
16
  del i
17
  else:
18
  while True:
19
+ i=subprocess.run([r"git",r"clone",URI,ClonePath])
 
 
 
 
 
 
 
20
  if(i.returncode == 0 ):
21
  del i
22
  gc.collect()
 
25
  del i
26
  def DownLoad(URI:str,DownloadPath:str,DownLoadFileName:str ) -> int:
27
  while (True):
28
+ i=subprocess.run([r"aria2c",r"-c",r"-x" ,r"16", r"-s",r"16", r"-k" ,r"1M" ,r"-m",r"0",r"--enable-mmap=false",r"--console-log-level=error",r"-d",DownloadPath,r"-o",DownLoadFileName,URI]);
29
+ if(i.returncode == 0 ):
30
+ del i
31
+ gc.collect()
32
+ return 0
33
+ else :
34
+ del i
 
 
 
 
35
  user_home =pathlib.Path.home().resolve()
36
  os.chdir(str(user_home))
37
  #clone stable-diffusion-webui repo
38
  print("cloning stable-diffusion-webui repo")
39
  Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",str(user_home / r"stable-diffusion-webui"))
40
+ os.chdir(str(user_home / r"stable-diffusion-webui"))
41
+ os.system("git reset --hard 89f9faa63388756314e8a1d96cf86bf5e0663045")
42
  #
43
 
44
  #install extensions
 
49
  while True:
50
  if(subprocess.run([r"wget",r"https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py",r"-O",str(user_home / r"stable-diffusion-webui" / r"scripts" / r"run_n_times.py")]).returncode == 0):
51
  break
52
+ #Gitclone(r"https://github.com/deforum-art/deforum-for-automatic1111-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"deforum-for-automatic1111-webui" ))
53
+ #Gitclone(r"https://github.com/BlafKing/sd-civitai-browser-plus",str(user_home / r"stable-diffusion-webui" / r"extensions"/ r"sd-civitai-browser-plus"))
54
+ Gitclone(r"https://github.com/camenduru/stable-diffusion-webui-huggingface",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-huggingface"))
55
+ #Gitclone(r"https://github.com/bbc-mc/sdweb-merge-board",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sdweb-merge-board"))
56
+ Gitclone(r"https://github.com/etherealxx/batchlinks-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui"))
57
+ Gitclone(r"https://github.com/kohya-ss/sd-webui-additional-networks",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks"))
58
+ Gitclone(r"https://github.com/Akegarasu/sd-webui-model-converter",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-model-converter"))
59
+ Gitclone(r"https://github.com/hako-mikan/sd-webui-supermerger",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-supermerger"))
60
+ Gitclone(r"https://github.com/bbc-mc/sdweb-merge-block-weighted-gui",str(user_home / r"stable-diffusion-webui" / r"extensions"/ r"sdweb-merge-block-weighted-gui"))
61
 
62
+ #Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet"))
63
+ #Gitclone(r"https://github.com/fkunn1326/openpose-editor",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"openpose-editor"))
64
+ Gitclone(r"https://github.com/jexom/sd-webui-depth-lib",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-depth-lib"))
65
+ Gitclone(r"https://github.com/hnmr293/posex",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"posex"))
66
+ #Gitclone(r"https://github.com/nonnonstop/sd-webui-3d-open-pose-editor",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-3d-open-pose-editor"))
67
+ #中文本地化的请解除下一行的注释
68
+ #Gitclone(r"https://github.com/dtlnor/stable-diffusion-webui-localization-zh_CN.git",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-localization-zh_CN"))
69
+ #Gitclone(r"https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git" , str(user_home / r"stable-diffusion-webui" / r"extensions" / r"a1111-sd-webui-tagcomplete"))
70
+ Gitclone(r"https://github.com/camenduru/sd-webui-tunnels",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-tunnels"))
71
  #Gitclone(r"https://github.com/etherealxx/batchlinks-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui"))
72
+ Gitclone(r"https://github.com/catppuccin/stable-diffusion-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-catppuccin"))
73
+
74
  #Gitclone(r"https://github.com/KohakuBueleaf/a1111-sd-webui-locon",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"a1111-sd-webui-locon" ))
75
+ #Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-rembg"))
76
+ #Gitclone(r"https://github.com/ashen-sensored/stable-diffusion-webui-two-shot",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-two-shot"))
77
  #Gitclone(r"https://github.com/camenduru/sd_webui_stealth_pnginfo",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd_webui_stealth_pnginfo"))
78
 
79
  os.chdir(user_home / r"stable-diffusion-webui")