Carlos2312 commited on
Commit
46c2869
Β·
verified Β·
1 Parent(s): 0de761c

Create setup_test.py

Browse files
Files changed (1) hide show
  1. setup_test.py +182 -0
setup_test.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from IPython.display import display, HTML, clear_output
2
+ from ipywidgets import widgets, Layout
3
+ from IPython import get_ipython
4
+ from pathlib import Path
5
+ import subprocess, time, os, shlex
6
+ from nenen88 import pull, say, download, clone, tempe
7
+
8
+ version = "v1.9.3"
9
+ xxx = "/home/studio-lab-user"
10
+ zzz = Path(xxx) / "asd"
11
+
12
+ if zzz.exists():
13
+ git_dir = zzz / '.git'
14
+ if git_dir.exists():
15
+ os.chdir(zzz)
16
+ commit_hash = os.popen('git rev-parse HEAD').read().strip()
17
+
18
+ if commit_hash != version:
19
+ get_ipython().system(f"git pull origin {version}")
20
+ get_ipython().system("git fetch --tags")
21
+
22
+ else:
23
+ mama = f"{xxx}/.conda/setup.css"
24
+ fff = {"stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
25
+
26
+ get_ipython().system(f"rm -rf {xxx}/.zrok")
27
+ get_ipython().system(f"curl -sLo {mama} https://github.com/gutris1/segsmaker/raw/main/ui/sd/asd/setup.css")
28
+
29
+ gariz = """<div class="gradient-text">asd</div>"""
30
+ garis = widgets.Output()
31
+ ikuuuhhh = widgets.Button(description='Install')
32
+
33
+ sd_setup = widgets.Output()
34
+
35
+ def ccss(mama):
36
+ with open(mama, "r") as gantung:
37
+ susu = gantung.read()
38
+
39
+ display(HTML(f"<style>{susu}</style>"))
40
+
41
+ def req_list(xxx, zzz):
42
+ return [
43
+ f"pip install -q -r requirements.txt basicsr insightface onnxruntime-gpu",
44
+ f"rm -rf {xxx}/tmp/* {xxx}/tmp {zzz}/models/Stable-diffusion/tmp_ckpt {zzz}/models/Lora/tmp_lora {zzz}/models/ControlNet",
45
+ f"mkdir -p {zzz}/models/Lora",
46
+ f"mkdir -p {zzz}/models/ESRGAN",
47
+ f"ln -vs /tmp {xxx}/tmp",
48
+ f"ln -vs /tmp/ckpt {zzz}/models/Stable-diffusion/tmp_ckpt",
49
+ f"ln -vs /tmp/lora {zzz}/models/Lora/tmp_lora",
50
+ f"ln -vs /tmp/controlnet {zzz}/models/ControlNet"
51
+ ]
52
+
53
+ def sd_clone(xxx, zzz, fff):
54
+ time.sleep(1)
55
+ pull(f"https://github.com/gutris1/segsmaker sd {zzz}")
56
+
57
+ os.chdir(zzz)
58
+ req = req_list(xxx, zzz)
59
+ for lines in req:
60
+ subprocess.run(shlex.split(lines), **fff)
61
+
62
+ def sd_1_5(xxx, zzz, fff):
63
+ sd_clone(xxx, zzz, fff)
64
+
65
+ extras = [
66
+ f"https://civitai.com/api/download/models/150491 {zzz}/embeddings edgQuality.pt",
67
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
68
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
69
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {zzz}/models/ESRGAN",
70
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
71
+ f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
72
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
73
+ f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {zzz}/models/VAE",
74
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
75
+ f"https://huggingface.co/Carlos2312/asd/resolve/main/modelos.py {zzz}/asd",
76
+ f"https://huggingface.co/Carlos2312/asd/resolve/main/ext-1_5.txt {zzz}/asd",
77
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
78
+ f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
79
+ ]
80
+
81
+ for items in extras:
82
+ download(items)
83
+
84
+ #add
85
+
86
+ # extension
87
+ os.chdir(f"{zzz}/extensions")
88
+ clone(f"{zzz}/asd/ext-1_5.txt")
89
+
90
+ weww = f"{zzz}/asd/cn-1_5.py"
91
+ woww = f"{zzz}/asd/controlnet.py"
92
+ os.rename(weww, woww)
93
+
94
+ get_ipython().system(f"rm -rf {zzz}/embeddings")
95
+ get_ipython().system(f"git clone https://huggingface.co/Carlos2312/emb {zzz}/embeddings")
96
+
97
+ get_ipython().system(f"rm -rf {zzz}/models/Lora")
98
+ get_ipython().system(f"git clone https://huggingface.co/Carlos2312/lrs {zzz}/models/Lora")
99
+
100
+ get_ipython().system(f"rm -rf {zzz}/models/adetailer")
101
+ get_ipython().system(f"git clone https://huggingface.co/Carlos2312/md {zzz}/models/adetailer")
102
+
103
+ get_ipython().system(f"rm -rf {zzz}/extensions/sd-dynamic-prompts/wildcards")
104
+ get_ipython().system(f"git clone https://huggingface.co/Carlos2312/Wilcards {zzz}/extensions/sd-dynamic-prompts/wildcards")
105
+
106
+ def sd_xl(xxx, zzz, fff):
107
+ sd_clone(xxx, zzz, fff)
108
+
109
+ extras = [
110
+ f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
111
+ f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
112
+ f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
113
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
114
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
115
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {zzz}/models/ESRGAN",
116
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
117
+ f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
118
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
119
+ f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors",
120
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
121
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
122
+ f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
123
+ ]
124
+
125
+ for items in extras:
126
+ download(items)
127
+
128
+ say("<br><b>【{red} Installing Extensions{d} 】{red}</b>")
129
+ os.chdir(f"{zzz}/extensions")
130
+ clone(f"{zzz}/asd/ext-xl.txt")
131
+
132
+ os.rename(f"{zzz}/asd/cn-xl.py", f"{zzz}/asd/controlnet.py")
133
+
134
+ def zrok_install():
135
+ zrok = Path(f"{xxx}/.zrok/bin")
136
+ zrok.mkdir(parents=True, exist_ok=True)
137
+ url = "https://github.com/openziti/zrok/releases/download/v0.4.25/zrok_0.4.25_linux_amd64.tar.gz"
138
+ z = zrok / Path(url).name
139
+
140
+ get_ipython().system(f"curl -sLo {z} {url}")
141
+ get_ipython().system(f"tar -xzf {z} -C {zrok} --wildcards *zrok")
142
+ get_ipython().system(f"rm -rf {xxx}/.cache/* {z}")
143
+
144
+ def sd_install(selection):
145
+ with garis:
146
+ display(HTML(gariz))
147
+
148
+ with sd_setup:
149
+ sd_setup.clear_output()
150
+ os.chdir(xxx)
151
+ say("<b>【{red} Installing Stable Diffusion{d} 】{red}</b>")
152
+ get_ipython().system(f"git clone -q -b {version} https://github.com/gutris1/asd")
153
+
154
+ if selection == 'SD 1.5':
155
+ sd_1_5(xxx, zzz, fff)
156
+ else:
157
+ sd_xl(xxx, zzz, fff)
158
+
159
+ with garis:
160
+ garis.clear_output()
161
+
162
+ say("<br><b>【{red} Done{d} 】{red}</b>")
163
+
164
+ def uuwaaahhh(button):
165
+ selection = 'SD 1.5'
166
+ if selection:
167
+ widgets.Widget.close(boxxx)
168
+ sd_setup.clear_output()
169
+ sd_install(selection)
170
+ else:
171
+ with sd_setup:
172
+ print("at least make a choice")
173
+ print("ε°‘γͺγγ¨γ‚‚ιΈζŠžγ—γ¦γ‚ˆγ€‚")
174
+ return
175
+
176
+ ccss(mama)
177
+ display(boxxx, sd_setup, garis)
178
+ zrok_install()
179
+ tempe()
180
+
181
+ # Automatically trigger the installation of SD 1.5
182
+ uuwaaahhh(None)