Yntec commited on
Commit
72975c5
·
verified ·
1 Parent(s): 28362f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +82 -35
app.py CHANGED
@@ -1,13 +1,61 @@
1
  import os
 
 
 
 
 
 
 
 
 
2
  from sys import executable as pyexecutable
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()
@@ -17,6 +65,13 @@ def Gitclone(URI:str,ClonePath:str = "") -> int :
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,20 +80,24 @@ def Gitclone(URI:str,ClonePath:str = "") -> int :
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
@@ -50,13 +109,15 @@ 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/AlUlkesh/stable-diffusion-webui-images-browser",str(user_home / r"stable-diffusion-webui" / r"extensions"/ r"stable-diffusion-webui-images-browser"))
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
-
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
 
61
  #Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet"))
62
  #Gitclone(r"https://github.com/fkunn1326/openpose-editor",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"openpose-editor"))
@@ -126,30 +187,16 @@ del dList
126
  print("ControlNet models download done.\ndownloading model")
127
 
128
  DownLoad(r"https://huggingface.co/Yntec/AnythingV7/resolve/main/AnythingV7.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"AnythingV7.safetensors")
129
- #DownLoad(r"https://huggingface.co/Yntec/epiCPhotoGasm/resolve/main/epiCPhotoGasmVAE.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"epiCPhotoGasmVAE.safetensors")
130
- #DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0/resolve/main/dreamlike-photoreal-2.0.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-photoreal-2.0.safetensors")
131
- #DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-anime-1.0/resolve/main/dreamlike-anime-1.0.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-anime-1.0.safetensors")
132
- #DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0/resolve/main/dreamlike-diffusion-1.0.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-diffusion-1.0.safetensors")
133
- #DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-photoreal-1.0/resolve/main/dreamlike-photoreal-1.0.ckpt",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-photoreal-1.0.ckpt")
134
- #DownLoad(r"https://huggingface.co/Yntec/Photosphere/resolve/main/photosphere.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"photosphere.safetensors")
135
- #DownLoad(r"https://huggingface.co/Yntec/Dreamlike/resolve/main/Dreamlike.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"!Dreamlike.safetensors")
136
- #DownLoad(r"https://huggingface.co/Yntec/DreamLikeRemix/resolve/main/dreamLikeRemix.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamLikeRemix.safetensors")
137
- #DownLoad(r"https://huggingface.co/Yntec/dreamlike-photoreal-remix/resolve/main/dreamlike-photoreal-remix.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-photoreal-remix.safetensors")
138
- #DownLoad(r"https://huggingface.co/Yntec/Dreamsphere/resolve/main/dreamsphere.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamsphere.safetensors")
139
 
140
- #DownLoad(r"https://huggingface.co/ckpt/anything-v4.0/resolve/main/anything-v4.5-pruned.ckpt",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"anything-v4.5-pruned.ckpt")
141
- #DownLoad(r"https://huggingface.co/ckpt/anything-v4.0/resolve/main/anything-v4.0.vae.pt",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"anything-v4.0.vae.pt")
142
- #DownLoad(r"https://huggingface.co/gsdf/Counterfeit-V3.0/resolve/main/Counterfeit-V3.0_fp16.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"Counterfeit-V3.0_fp16.safetensors")
143
- #DownLoad(r"https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1B_orangemixs.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"AOM3A1B_orangemixs.safetensors")
144
- #DownLoad(r"https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"orangemix.vae.pt")
145
- #DownLoad(r"https://huggingface.co/Meina/MeinaPastel/resolve/main/MeinaPastelV5%20-%20Baked%20VAE.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"MeinaPastelV5_BakedVAE.safetensors")
146
- #DownLoad(r"https://huggingface.co/Meina/MeinaPastel/resolve/main/MeinaPastelV5%20-%20Without%20VAE.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"MeinaPastelV5_WithoutVAE.safetensors")
147
- #DownLoad(r"https://civitai.com/api/download/models/9474",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"chilloutmix_NiPrunedFp16.safetensors")
148
 
149
- DownLoad(r"https://civitai.com/api/download/models/39885",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"Better_light.safetensors")
150
- DownLoad(r"https://civitai.com/api/download/models/21065",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"LAS.safetensors")
151
- DownLoad(r"https://civitai.com/api/download/models/39164",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"backlighting.safetensors")
152
- #strt webui
153
 
154
  print("Done\nStarting Webui...")
155
  os.chdir(user_home / r"stable-diffusion-webui")
 
1
  import os
2
+ if os.environ.get("SPACES_ZERO_GPU") is not None:
3
+ import spaces
4
+ else:
5
+ class spaces:
6
+ @staticmethod
7
+ def GPU(func):
8
+ def wrapper(*args, **kwargs):
9
+ return func(*args, **kwargs)
10
+ return wrapper
11
  from sys import executable as pyexecutable
12
  import subprocess
13
  import pathlib
14
  import gc
15
+ from huggingface_hub import hf_hub_download
16
+ import re
17
+ import urllib.parse
18
 
19
+ @spaces.GPU
20
+ def fake_gpu():
21
+ pass
22
+
23
+ def split_hf_url(url: str):
24
+ try:
25
+ s = list(re.findall(r'^(?:https?://huggingface.co/)(?:(datasets)/)?(.+?/.+?)/\w+?/.+?/(?:(.+)/)?(.+?.\w+)(?:\?download=true)?$', url)[0])
26
+ if len(s) < 4: return "", "", "", ""
27
+ repo_id = s[1]
28
+ repo_type = "dataset" if s[0] == "datasets" else "model"
29
+ subfolder = urllib.parse.unquote(s[2]) if s[2] else None
30
+ filename = urllib.parse.unquote(s[3])
31
+ return repo_id, filename, subfolder, repo_type
32
+ except Exception as e:
33
+ print(e)
34
+
35
+ def download_hf_file(directory, url):
36
+ repo_id, filename, subfolder, repo_type = split_hf_url(url)
37
+ try:
38
+ if subfolder is not None: hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, repo_type=repo_type, local_dir=directory)
39
+ else: hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory)
40
+ print(f"Downloading: {url}")
41
+ return True
42
+ except Exception as e:
43
+ print(f"Failed to download: {e}")
44
+ return False
45
+
46
+ def Gitclone(URI:str,ClonePath:str = "",HASH:str = "") -> int :
47
  if(ClonePath == "") :
48
  while True:
49
+ try:
50
+ user_home =pathlib.Path.home().resolve()
51
+ os.chdir(str(user_home))
52
+ except Exception:
53
+ pass
54
  i=subprocess.run([r"git",r"clone",URI])
55
+ try:
56
+ if HASH: os.system(f"git reset --hard {HASH}")
57
+ except Exception:
58
+ pass
59
  if(i.returncode == 0 ):
60
  del i
61
  gc.collect()
 
65
  else:
66
  while True:
67
  i=subprocess.run([r"git",r"clone",URI,ClonePath])
68
+ try:
69
+ os.chdir(ClonePath)
70
+ if HASH: os.system(f"git reset --hard {HASH}")
71
+ user_home =pathlib.Path.home().resolve()
72
+ os.chdir(str(user_home))
73
+ except Exception:
74
+ pass
75
  if(i.returncode == 0 ):
76
  del i
77
  gc.collect()
 
80
  del i
81
  def DownLoad(URI:str,DownloadPath:str,DownLoadFileName:str ) -> int:
82
  while (True):
83
+ if "huggingface.co" in URI:
84
+ success=download_hf_file(DownloadPath, URI)
85
+ if success: return 0
86
+ else:
87
+ 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]);
88
+ if(i.returncode == 0 ):
89
+ del i
90
+ gc.collect()
91
+ return 0
92
+ else :
93
+ del i
94
  user_home =pathlib.Path.home().resolve()
95
  os.chdir(str(user_home))
96
  #clone stable-diffusion-webui repo
97
  print("cloning stable-diffusion-webui repo")
98
  Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",str(user_home / r"stable-diffusion-webui"))
99
+ #os.chdir(str(user_home / r"stable-diffusion-webui"))
100
+ #os.system("git reset --hard 89f9faa63388756314e8a1d96cf86bf5e0663045")
101
  #
102
 
103
  #install extensions
 
109
  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):
110
  break
111
  #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" ))
112
+ #Gitclone(r"https://github.com/BlafKing/sd-civitai-browser-plus",str(user_home / r"stable-diffusion-webui" / r"extensions"/ r"sd-civitai-browser-plus"))
113
  Gitclone(r"https://github.com/camenduru/stable-diffusion-webui-huggingface",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-huggingface"))
114
  #Gitclone(r"https://github.com/bbc-mc/sdweb-merge-board",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sdweb-merge-board"))
115
+ Gitclone(r"https://github.com/etherealxx/batchlinks-webui",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui"))
116
  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"))
117
  Gitclone(r"https://github.com/Akegarasu/sd-webui-model-converter",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-model-converter"))
118
+ #Gitclone(r"https://github.com/hako-mikan/sd-webui-supermerger",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-supermerger"))
119
+ Gitclone(r"https://github.com/tmzint/sd-webui-supermerger",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-supermerger"))
120
+ 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"))
121
 
122
  #Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet"))
123
  #Gitclone(r"https://github.com/fkunn1326/openpose-editor",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"openpose-editor"))
 
187
  print("ControlNet models download done.\ndownloading model")
188
 
189
  DownLoad(r"https://huggingface.co/Yntec/AnythingV7/resolve/main/AnythingV7.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"AnythingV7.safetensors")
 
 
 
 
 
 
 
 
 
 
190
 
191
+ #DownLoad(r"https://huggingface.co/Yntec/DucHaitenClassicAnime768/resolve/main/duchaitenclassicanimv10VAE.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"duchaitenclassicanimv10VAE.safetensors")
192
+ #DownLoad(r"https://huggingface.co/DucHaiten/DucHaitenAIart/resolve/main/DucHaitenAIart-v4.5.3.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaitenAIart-v4.5.3.safetensors")
193
+ #DownLoad(r"https://huggingface.co/DucHaiten/DucHaitenDreamWorld/resolve/main/DucHaitenDreamWorld_v3.0.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaitenDreamWorld_v3.0.safetensors")
194
+ #DownLoad(r"https://huggingface.co/DucHaiten/DucHaitenJourney/resolve/main/DucHaiten-Journey_v5.6.7.2.3.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaiten-Journey_v5.6.7.2.3.safetensors")
195
+ #DownLoad(r"https://huggingface.co/DucHaiten/DucHaiten-StyleLikeMe/resolve/main/DucHaiten-StyleLikeMe_v1.5-fp16-no-ema.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaiten-StyleLikeMe_v1.5-fp16-no-ema.safetensors")
196
+ #DownLoad(r"https://huggingface.co/DucHaiten/DucHaitenSuperCute/resolve/main/DucHaitenSuperCute_v2.0.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaitenSuperCute_v2.0.safetensors")
197
+ #DownLoad(r"https://huggingface.co/Yntec/DucHaitenAnime768/resolve/main/DucHaitenAnimefp16noema.safetensors",str(user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"DucHaitenAnimefp16noema.safetensors")
 
198
 
199
+ #start webui
 
 
 
200
 
201
  print("Done\nStarting Webui...")
202
  os.chdir(user_home / r"stable-diffusion-webui")