Carlos2312 commited on
Commit
3a56676
·
verified ·
1 Parent(s): c935894

Upload setup.py

Browse files
Files changed (1) hide show
  1. setup.py +211 -0
setup.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from IPython.display import display, HTML, clear_output
2
+ from ipywidgets import widgets, Layout
3
+ from IPython import get_ipython
4
+ import subprocess
5
+ import time
6
+ import os
7
+ from nenen88 import pull, say, download, clone, tempe
8
+
9
+ xxx = "/home/studio-lab-user"
10
+ zzz = f"{xxx}/forge"
11
+
12
+ if os.path.exists(zzz):
13
+ say("/home/studio-lab-user/forge{cyan} already exists. Delete it first.")
14
+ say("/home/studio-lab-user/forge{cyan} のおっぱいはすでに存在します。先に消してね。")
15
+
16
+ else:
17
+ mama = f"{xxx}/.conda/setup.css"
18
+ fff = {"shell": True, "stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
19
+ gariz = """
20
+ <div class="gradient-text">asd</div>
21
+ """
22
+ subprocess.run(f"rm -rf {xxx}/.zrok", **fff)
23
+ subprocess.run(f"curl -sLo {mama} https://github.com/gutris1/segsmaker/raw/main/ui/sd/asd/setup.css", **fff)
24
+
25
+ garis = widgets.Output()
26
+ selected = [None]
27
+ b1 = widgets.Button(description='SD 1.5')
28
+ b2 = widgets.Button(description='SDXL')
29
+ ikuuuhhh = widgets.Button(description='Install')
30
+
31
+ b1b2 = widgets.HBox([b1, b2], layout=Layout(justify_content='space-between'))
32
+ sd_setup = widgets.Output()
33
+ boxxx = widgets.VBox([b1b2, ikuuuhhh], layout=Layout(
34
+ width='400px',
35
+ height='150px',
36
+ display='flex',
37
+ flex_flow='column',
38
+ align_items='center',
39
+ justify_content='space-between',
40
+ padding='20px'))
41
+
42
+ b1.add_class("b1")
43
+ b2.add_class("b2")
44
+ ikuuuhhh.add_class("out")
45
+ boxxx.add_class("boxxx")
46
+
47
+ def ccss(mama):
48
+ with open(mama, "r") as gantung:
49
+ susu = gantung.read()
50
+
51
+ display(HTML(f"<style>{susu}</style>"))
52
+
53
+ def gorengan(xxx, zzz):
54
+ return [
55
+ f"pip install -q -r requirements.txt basicsr insightface onnxruntime-gpu",
56
+ f"rm -rf {xxx}/tmp/* {xxx}/tmp {zzz}/models/Stable-diffusion/tmp_models {zzz}/models/Lora/tmp_Lora {zzz}/models/ControlNet {zzz}/models/svd {zzz}/models/z123",
57
+ f"mkdir -p {zzz}/models/Lora",
58
+ f"mkdir -p {zzz}/models/ESRGAN",
59
+ f"ln -vs /tmp {xxx}/tmp",
60
+ f"ln -vs /tmp/models {zzz}/models/Stable-diffusion/tmp_models",
61
+ f"ln -vs /tmp/Lora {zzz}/models/Lora/tmp_Lora",
62
+ f"ln -vs /tmp/z123 {zzz}/models/z123",
63
+ f"ln -vs /tmp/svd {zzz}/models/svd",
64
+ f"ln -vs /tmp/ControlNet {zzz}/models/ControlNet",]
65
+
66
+ def sd_1_5(xxx, zzz, fff):
67
+ asu = f"git clone -q https://github.com/lllyasviel/stable-diffusion-webui-forge forge"
68
+ subprocess.run(asu, **fff)
69
+
70
+ time.sleep(2)
71
+ pull(f"https://github.com/gutris1/segsmaker forge {zzz}")
72
+
73
+ # requirements , tmp symlink
74
+ os.chdir(zzz)
75
+ minyak = gorengan(xxx, zzz)
76
+ for tepung in minyak:
77
+ subprocess.run(tepung, **fff)
78
+
79
+ # embedding upscaler vae
80
+ jalanan = [
81
+ f"https://huggingface.co/Carlos2312/wild/resolve/main/embeddings.zip {zzz}",
82
+ f"https://huggingface.co/Carlos2312/wild/resolve/main/wildc.zip {zzz}",
83
+ f"https://civitai.com/api/download/models/150491 {zzz}/embeddings edgQuality.pt",
84
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
85
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
86
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {zzz}/models/ESRGAN",
87
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
88
+ f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
89
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
90
+ f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {zzz}/models/VAE"]
91
+
92
+ for janda in jalanan:
93
+ download(janda)
94
+
95
+ subprocess.run(f"rm -rf {zzz}/asd/extension.txt",
96
+ **fff)
97
+ subprocess.run(f"curl -sLo {zzz}/asd/extension.txt https://huggingface.co/Carlos2312/asd/resolve/main/extension.txt",
98
+ **fff)
99
+
100
+ # extension
101
+ os.chdir(f"{zzz}/extensions")
102
+ clone(f"{zzz}/asd/extension.txt")
103
+
104
+ weww = f"{zzz}/asd/cn-1_5.py"
105
+ woww = f"{zzz}/asd/controlnet.py"
106
+ os.rename(weww, woww)
107
+
108
+
109
+ subprocess.run(f"rm -rf {zzz}/models/adetailer",
110
+ **fff)
111
+ download(f"https://huggingface.co/Carlos2312/md {zzz}/models/adetailer")
112
+
113
+ subprocess.run(f"rm -rf {zzz}/models/Lora",
114
+ **fff)
115
+ download(f"https://huggingface.co/Carlos2312/lrs {zzz}/models/Lora")
116
+
117
+ unzip = f"unzip -qo {zzz}/embeddings.zip -d {zzz}/embeddings && rm {zzz}/embeddings.zip"
118
+ unzip = f"unzip -qo {zzz}/wildc.zip -d {zzz}/extensions/sd-dynamic-prompts/wildcards && rm {zzz}/wildc.zip"
119
+ subprocess.run(unzip, **fff)
120
+
121
+ def sd_xl(xxx, zzz, fff):
122
+ asu = f"git clone -q https://github.com/lllyasviel/stable-diffusion-webui-forge forge"
123
+ subprocess.run(asu, **fff)
124
+
125
+ time.sleep(2)
126
+ pull(f"https://github.com/gutris1/segsmaker forge {zzz}")
127
+
128
+ # requirements , tmp symlink
129
+ os.chdir(zzz)
130
+ minyak = gorengan(xxx, zzz)
131
+ for tepung in minyak:
132
+ subprocess.run(tepung, **fff)
133
+
134
+ # embedding upscaler vae
135
+ jalanan = [
136
+ f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
137
+ f"https://civitai.com/api/download/models/356370 {zzz}/embeddings",
138
+ f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
139
+ f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
140
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
141
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
142
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {zzz}/models/ESRGAN",
143
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
144
+ f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
145
+ f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
146
+ f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors"]
147
+
148
+ for janda in jalanan:
149
+ download(janda)
150
+
151
+ # extension
152
+ os.chdir(f"{zzz}/extensions")
153
+ clone(f"{zzz}/asd/extension.txt")
154
+
155
+ weww = f"{zzz}/asd/cn-xl.py"
156
+ woww = f"{zzz}/asd/controlnet.py"
157
+ os.rename(weww, woww)
158
+
159
+ def zrok_in():
160
+ zorok = f"{xxx}/.zrok/bin"
161
+ os.makedirs(zorok, exist_ok=True)
162
+ tarok = f"{zorok}/zrok_0.4.25_linux_amd64.tar.gz"
163
+ subprocess.run(f"curl -sLo {tarok} https://github.com/openziti/zrok/releases/download/v0.4.25/zrok_0.4.25_linux_amd64.tar.gz", **fff)
164
+ subprocess.run(f"tar -xzf {tarok} -C {zorok} --wildcards *zrok", **fff)
165
+ subprocess.run(f"rm -rf {xxx}/.cache/*", **fff)
166
+ os.remove(tarok)
167
+
168
+ def install(selection):
169
+ with garis:
170
+ display(HTML(gariz))
171
+
172
+ with sd_setup:
173
+ sd_setup.clear_output()
174
+ say("【{red} Installing Stable Diffusion Forge{d} 】{red}")
175
+ os.chdir(xxx)
176
+
177
+ if selection == 'SD 1.5':
178
+ sd_1_5(xxx, zzz, fff)
179
+ else:
180
+ sd_xl(xxx, zzz, fff)
181
+
182
+ with garis:
183
+ garis.clear_output()
184
+
185
+ say("【{red} Done{d} 】{red}")
186
+
187
+ def cb(button):
188
+ selected[0] = button.description
189
+
190
+ def uuwaaahhh(button):
191
+ selection = selected[0]
192
+
193
+ if selection:
194
+ widgets.Widget.close(boxxx)
195
+ sd_setup.clear_output()
196
+ install(selection)
197
+
198
+ else:
199
+ with sd_setup:
200
+ print("at least make a choice")
201
+ print("少なくとも選択してよ。")
202
+ return
203
+
204
+ b1.on_click(cb)
205
+ b2.on_click(cb)
206
+ ikuuuhhh.on_click(uuwaaahhh)
207
+
208
+ ccss(mama)
209
+ display(boxxx, sd_setup, garis)
210
+ zrok_in()
211
+ tempe()