File size: 24,508 Bytes
a549d26
6cf06c6
 
a549d26
 
6cf06c6
a549d26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5c3d3e1
 
57a9529
a549d26
 
5c3d3e1
 
99640b8
811bbbe
 
a549d26
99640b8
0fe5787
 
 
 
b4ab94c
0fe5787
 
a549d26
 
 
e0593bf
a549d26
99640b8
1186f3b
c1aa91e
e0593bf
 
5c3d3e1
99640b8
 
 
 
 
 
 
 
 
 
 
 
a549d26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186f3b
aa365f5
f70f672
aa365f5
f70f672
ac01c1b
742b5c6
b3e5518
 
 
 
 
742b5c6
f70f672
811bbbe
 
1186f3b
b3e5518
f70f672
b3e5518
 
76c6600
 
 
f70f672
567fbf5
 
76c6600
 
 
 
 
 
 
 
99640b8
d84c2cf
f70f672
76c6600
 
f70f672
 
 
66303f3
 
 
 
 
 
742b5c6
 
5c3d3e1
742b5c6
66303f3
 
 
 
 
 
 
 
 
 
 
f70f672
 
 
 
 
 
 
 
66303f3
a549d26
 
811bbbe
99640b8
0fe5787
811bbbe
99640b8
5c3d3e1
811bbbe
99640b8
a549d26
811bbbe
99640b8
811bbbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a549d26
 
e0593bf
a549d26
e0593bf
a549d26
e0593bf
a549d26
 
 
e0593bf
ac01c1b
 
 
 
 
 
 
 
 
 
a549d26
 
 
 
 
 
 
ac01c1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7a6c54
ac01c1b
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
"""
Stable Diffusion Webui Version 1.7.0
https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.7.0

"""
commit_id=r"cf2772fab0af5573da775e7437e6acdca424f26e" #Version 1.7.0
import os
from sys import executable 
import subprocess
import pathlib
import gc

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))
    

def DownLoad(URI:str,DownloadPath:pathlib.Path,DownLoadFileName:str ) -> int:
  if (DownloadPath / DownLoadFileName).is_file(): return 0
  for z in range(10):
    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",str(DownloadPath),r"-o",DownLoadFileName,URI]);
    if(i.returncode == 0 ): 
      del i
      gc.collect()
      return 0
    else :
      del i
  raise Exception(str.format("download \'{0}\' failed",URI))

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")
os.chdir(str(user_home / r"stable-diffusion-webui"))
os.system("git reset --hard "+commit_id)
#install extensions
print("installing extensions")
Gitclone(r"https://huggingface.co/embed/negative",user_home / r"stable-diffusion-webui" / r"embeddings"  / r"negative")
Gitclone(r"https://huggingface.co/embed/lora",user_home / r"stable-diffusion-webui" / r"models" / r"Lora" / r"positive")
DownLoad(r"https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth",user_home / r"stable-diffusion-webui" / r"models" / r"ESRGAN" ,r"4x-UltraSharp.pth")
while (True):
   i=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")])
   if(i.returncode == 0 ): 
    del i
    gc.collect()
    break
   else :
    del i
#Gitclone(r"https://github.com/deforum-art/deforum-for-automatic1111-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"deforum-for-automatic1111-webui" )
Gitclone(r"https://github.com/wcde/custom-hires-fix-for-automatic1111",user_home / r"stable-diffusion-webui" / r"extensions" / r"custom-hires-fix-for-automatic1111" )
Gitclone(r"https://github.com/Coyote-A/ultimate-upscale-for-automatic1111",user_home / r"stable-diffusion-webui" / r"extensions" / r"ultimate-upscale-for-automatic1111" )
Gitclone(r"https://github.com/AlUlkesh/stable-diffusion-webui-images-browser",user_home / r"stable-diffusion-webui" / r"extensions"/ r"stable-diffusion-webui-images-browser")
Gitclone(r"https://github.com/camenduru/stable-diffusion-webui-huggingface",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-huggingface")
# keeping this in case if someone wants to revert to this extension, I guess?
#Gitclone(r"https://github.com/camenduru/sd-civitai-browser",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-civitai-browser")
Gitclone(r"https://github.com/SignalFlagZ/sd-webui-civbrowser",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-civbrowser")
# keeping this in case if someone wants to actually use this extension, I guess?
#Gitclone(r"https://github.com/kohya-ss/sd-webui-additional-networks",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks")
Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet")
Gitclone(r"https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-dynamic-thresholding")
# the following four are disabled because of issues breaking the whole thing, and since
# these extensions are beyond my control anyway, these will be all disabled for the time being
# until their respective authors fixes these issues. deal with it, folks.
#Gitclone(r"https://github.com/fkunn1326/openpose-editor",user_home / r"stable-diffusion-webui" / r"extensions" / r"openpose-editor")
#Gitclone(r"https://github.com/wywywywy/sd-webui-depth-lib",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-depth-lib")
#Gitclone(r"https://github.com/hnmr293/posex",user_home / r"stable-diffusion-webui" / r"extensions" / r"posex")
#Gitclone(r"https://github.com/nonnonstop/sd-webui-3d-open-pose-editor",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-3d-open-pose-editor")
#中文本地化的请解除下一行的注释
#Gitclone(r"https://github.com/dtlnor/stable-diffusion-webui-localization-zh_CN.git",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-localization-zh_CN")
Gitclone(r"https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git" , user_home / r"stable-diffusion-webui" / r"extensions" / r"a1111-sd-webui-tagcomplete")
#Gitclone(r"https://github.com/camenduru/sd-webui-tunnels",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-tunnels")
Gitclone(r"https://github.com/etherealxx/batchlinks-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui")
Gitclone(r"https://github.com/Iyashinouta/sd-model-downloader",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-model-downloader")
#Gitclone(r"https://github.com/catppuccin/stable-diffusion-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-catppuccin")
#Gitclone(r"https://github.com/Bing-su/adetailer",user_home / r"stable-diffusion-webui" / r"extensions" / r"adetailer")
#Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-rembg")
#Gitclone(r"https://github.com/ashen-sensored/stable-diffusion-webui-two-shot",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-two-shot")
#Gitclone(r"https://github.com/camenduru/sd_webui_stealth_pnginfo",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd_webui_stealth_pnginfo")

# ==cursed extensions one should not install at all==
# this list is here just so anybody who's messing around with
# the code should not install one of the following, because it
# might cause issues on a space that'll be impossible to recover 
# without reduplicating the space to comment out a problematic
# extension in question.
# failure to read the following above would be quite devastated
# to someone who has no idea what is even causing issues at all.

#Gitclone(r"https://github.com/BlafKing/sd-civitai-browser-plus",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-civitai-browser-plus")

os.chdir(user_home / r"stable-diffusion-webui")
#download ControlNet models
print("extensions dolwnload done .\ndownloading ControlNet models")
dList =[r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_style_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_sketch_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_seg_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_openpose_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_keypose_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_depth_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_canny_sd14v1.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_canny_sd15v2.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_depth_sd15v2.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_sketch_sd15v2.pth",
               r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_zoedepth_sd15v1.pth"]
for i in range(0,len(dList)): DownLoad(dList[i],user_home / r"stable-diffusion-webui" / r"extensions" / "sd-webui-controlnet" / r"models",pathlib.Path(dList[i]).name)
del dList
#download model    
#you can change model download address here
print("ControlNet models download done.\ndownloading model")
#Stable Diffusion Checkpoint Model
#anything version4.5
DownLoad(r"https://huggingface.co/ckpt/anything-v4.0/resolve/main/anything-v4.5-pruned.ckpt",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"anything-v4.5-pruned.ckpt")
DownLoad(r"https://huggingface.co/ckpt/anything-v4.0/resolve/main/anything-v4.0.vae.pt",user_home / r"stable-diffusion-webui" / r"models" / r"VAE",r"anything-v4.0.vae.pt")
#anythingV5-Ink
DownLoad(r"https://civitai.com/api/download/models/90854",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"AnythingV5Ink_ink.safetensors")
#MeinaMixV11
DownLoad(r"https://civitai.com/api/download/models/119057",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"meinamix_meinaV11.safetensors")

# ==optional checkpoint models (and misc stuff)==
# by default, none of them are installed (mainly because of storage space reasons),
# unless you uncomment one of them just to actually use them.
# some of them generate 3d-like images, and may or may not actually generate
# 2d images than the least you'd most expect.

#CounterfeitV3
#DownLoad(r"https://huggingface.co/gsdf/Counterfeit-V3.0/resolve/main/Counterfeit-V3.0_fp16.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"Counterfeit-V3.0_fp16.safetensors")
#AbyssOrangeMix2 sfw
#DownLoad(r"https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_sfw.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"AbyssOrangeMix2_sfw.safetensors")
#DownLoad(r"https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt",user_home / r"stable-diffusion-webui" / r"models" / r"VAE",r"orangemix.vae.pt")
#DreamShaper version 8
DownLoad(r"https://civitai.com/api/download/models/128713",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"dreamshaper_8.safetensors")
#XXMix_9realistic (v4.0)
#DownLoad(r"https://civitai.com/api/download/models/102222",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"xxmix9realistic_v40.safetensors")
#MeinaPastel versions 5 and 6
#DownLoad(r"https://civitai.com/api/download/models/108289",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"meinapastel_v6Pastel.safetensors")
#DownLoad(r"https://huggingface.co/Meina/MeinaPastel/resolve/main/MeinaPastelV5%20-%20Baked%20VAE.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"MeinaPastelV5_BakedVAE.safetensors")
#DownLoad(r"https://huggingface.co/Meina/MeinaPastel/resolve/main/MeinaPastelV5%20-%20Without%20VAE.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"MeinaPastelV5_WithoutVAE.safetensors")
#tb_zANIME+mix
#DownLoad(r"https://civitai.com/api/download/models/197115",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"tbZanimeMix_v10.safetensors")
#MMT5
#DownLoad(r"https://civitai.com/api/download/models/160277",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"mmt5_v3.safetensors")
#AingDiffusion
#DownLoad(r"https://civitai.com/api/download/models/249329",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"aingdiffusion_v13.safetensors")
#Sweet-mix version2.2(flat) (with blessed2 VAE included)
#DownLoad(r"https://civitai.com/api/download/models/158294",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"sweetMix_v22Flat.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/121302",user_home / r"stable-diffusion-webui" / r"models" / r"VAE",r"blessed2_v1.pt")
#AnyLoRA
#DownLoad(r"https://civitai.com/api/download/models/95489",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"anyloraCheckpoint_bakedvaeBlessedFp16.safetensors")
#Anime Dreamer Mixed
DownLoad(r"https://civitai.com/api/download/models/221305",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"animeDreamerMixed_v10.safetensors")
#Sevan Mix
#DownLoad(r"https://civitai.com/api/download/models/226816",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"sevanMix_v10.safetensors")
#Laridae and Paridae
DownLoad(r"https://civitai.com/api/download/models/244516",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"laridaeV1_chlidonias.safetensors")
DownLoad(r"https://civitai.com/api/download/models/239663",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"paridaeV1_baeolophus.safetensors")
#Yntec's checkpoint models that has the word dream on it (yeah, not a good title for this, but whatever)
#DownLoad(r"https://huggingface.co/Yntec/Dreamsphere/resolve/main/dreamsphere.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"dreamsphere.safetensors")
#DownLoad(r"https://huggingface.co/Yntec/dreamlike-photoreal-remix/resolve/main/dreamlike-photoreal-remix.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"dreamlike-photoreal-remix.safetensors")
#DownLoad(r"https://huggingface.co/Yntec/DreamLikeRemix/resolve/main/dreamLikeRemix.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"dreamLikeRemix.safetensors")
#DownLoad(r"https://huggingface.co/Yntec/Dreamlike/resolve/main/Dreamlike.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"Dreamlike.safetensors")
#DownLoad(r"https://huggingface.co/Yntec/Photosphere/resolve/main/photosphere.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"photosphere.safetensors")

#MasterVae
#DownLoad(r"https://civitai.com/api/download/models/141727",user_home / r"stable-diffusion-webui" / r"models" / r"VAE",r"mastervae_v1Pt.pt")

# ==Stable Diffusion XL-based checkpoint models==
# by default, these are commented out, since they don't work
# at all if one were to use them on a CPU-powered space... this
# is why all of them in this section are not uncommented out
# because of hardware related issues. Works if they are
# run on a GPU, but not if it's CPU-powered.

#Counterfeit-xl
#DownLoad(r"https://huggingface.co/ckpt/counterfeit-xl/resolve/main/counterfeitxl_v10.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"counterfeitxl_v10.safetensors")
#Animagine-xl
#DownLoad(r"https://huggingface.co/ckpt/animagine-xl/resolve/main/animagineXL_v10.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"animagineXL_v10.safetensors")
#Animagine XL V3
#DownLoad(r"https://civitai.com/api/download/models/293564",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"animagineXLV3_v30.safetensors")
#DreamShaper XL
#DownLoad(r"https://civitai.com/api/download/models/126688",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"dreamshaperXL_alpha2Xl10.safetensors")
#XXMix_9realisticSDXL
#DownLoad(r"https://civitai.com/api/download/models/163192",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"xxmix9realisticsdxl_v10.safetensors")
#AAM XL (Anime Mix)
#DownLoad(r"https://civitai.com/api/download/models/303526",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"aamXLAnimeMix_v10.safetensors")

#Lora Model
#Better Light
#DownLoad(r"https://civitai.com/api/download/models/39885",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"Better_light.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/39885",user_home / r"stable-diffusion-webui" / r"models" / r"Lora",r"Better_light.safetensors")
#Detail Tweaker LoRA
#DownLoad(r"https://civitai.com/api/download/models/62833",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"add_detail.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/62833",user_home / r"stable-diffusion-webui" / r"models" / r"Lora",r"add_detail.safetensors")
#Add More Details - Detail Enhancer / Tweaker
#DownLoad(r"https://civitai.com/api/download/models/87153",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"more_details.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/87153",user_home / r"stable-diffusion-webui" / r"models" / r"Lora",r"more_details.safetensors")
#Backlighting
#DownLoad(r"https://civitai.com/api/download/models/39164",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"backlighting.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/39164",user_home / r"stable-diffusion-webui" / r"models" / r"Lora",r"backlighting.safetensors")

# ==optional lora models (and misc stuff)==
# by default, none of them are installed (mainly because of storage space reasons),
# unless you uncomment one of them just to actually use them.

# ==weird fact==
# Turns out that A1111 seem to be case sensitive about the first letter being an uppercase,
# which may explain the reason why it's not showing up in the Lora tab.
# I'm wondering why the additional networks extension had to be installed because of
# some issue the original author had to deal with, something they never bothered
# to fix, for whatever reason.

#LAS
#DownLoad(r"https://civitai.com/api/download/models/21065",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"LAS.safetensors")
#DownLoad(r"https://civitai.com/api/download/models/21065",user_home / r"stable-diffusion-webui" / r"models" / r"Lora",r"LAS.safetensors")

#GFPGAN Model
#detection Resnet50
#DownLoad(r"https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"detection_Resnet50_Final.pth")
#parsing_parsenet
#DownLoad(r"https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"parsing_parsenet.pth")
#GFPGANv1.4
#DownLoad(r"https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"GFPGANv1.4.pth")
#strt Stable Diffusion Webui
print("Done\nStarting Webui...")
os.chdir(user_home / r"stable-diffusion-webui")
gc.collect()

# ==CPU Option==
# this is the default startup setting if you're not planning to
# run your duplicated space on a GPU.
# if you are planning to run your duplicated space on
# CPU upgrade, this default startup setting is pretty much
# enough as it gets, since it's more or less the same as the
# the other option, albeit a faster processor and more system RAM...
# yeah, that's supported, so it's fine I guess.

while True:
  ret=subprocess.run([executable ,user_home / r"stable-diffusion-webui" / r"launch.py",r"--precision",r"full",r"--no-half",r"--no-half-vae",r"--enable-insecure-extension-access",r"--medvram",r"--skip-torch-cuda-test",r"--enable-console-prompts",r"--ui-settings-file="+str(pathlib.Path(__file__).parent /r"config.json")])
  if(ret.returncode == 0 ): 
    del ret
    gc.collect()
  else :
    del ret
del os ,user_home ,pyexecutable ,subprocess

# ==GPU Option (UNTESTED)==
# if you are planning to run your duplicated space on a GPU, you must
# first comment out the default startup setting above this message
# to do so, and then after that, uncomment this below that is commented
# out by default in order to make the most out of it, if this is
# going to run on a GPU.
#
# do not use this option if the space is running on
# CPU upgrade, instead, use the default option above if you are
# planning to run your duplicated space on CPU upgrade.
#
# do not leave the former uncommented if you are going to
# uncomment the other startup option in case if you're running
# it on a GPU. You must pick one option, but not both at the
# same time, because it might cause issues and/or runtime
# errors in that case.
#
# if there's any issues and/or errors for this option below,
# be sure to report any issues about this option or maybe 
# at least give feedback on this anyway, because it's not
# really tested that much at the moment.

#while True:
#  ret=subprocess.run([executable ,user_home / r"stable-diffusion-webui" / r"launch.py",r"--xformers",r"--enable-insecure-extension-access",r"--skip-torch-cuda-test",r"--enable-console-prompts",r"--ui-settings-file="+str(pathlib.Path(__file__).parent /r"config.json")])
#  if(ret.returncode == 0 ): 
#    del ret
#    gc.collect()
#  else :
#    del ret
#del os ,user_home ,pyexecutable ,subprocess