Carlos2312 commited on
Commit
40945fb
·
verified ·
1 Parent(s): fc12896

Update setup.py

Browse files
Files changed (1) hide show
  1. setup.py +72 -72
setup.py CHANGED
@@ -1,29 +1,33 @@
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}/asd"
 
 
 
 
 
 
 
 
 
 
11
 
12
- if os.path.exists(zzz):
13
- say("/home/studio-lab-user/asd{cyan} already exists. Delete it first.")
14
- say("/home/studio-lab-user/asd{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')
@@ -43,6 +47,7 @@ else:
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:
@@ -50,32 +55,31 @@ else:
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",
56
- f"rm -rf {xxx}/tmp/* {xxx}/tmp {zzz}/models/Stable-diffusion/tmp_models {zzz}/models/Lora/tmp_Lora {zzz}/models/ControlNet",
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/ControlNet {zzz}/models/ControlNet",]
63
-
64
- def sd_1_5(xxx, zzz, fff):
65
- asu = f"git clone -q -b v1.9.0 https://github.com/gutris1/asd"
66
- subprocess.run(asu, **fff)
67
 
68
- time.sleep(2)
 
69
  pull(f"https://github.com/gutris1/segsmaker sd {zzz}")
70
 
71
- # requirements , tmp symlink
72
  os.chdir(zzz)
73
- minyak = gorengan(xxx, zzz)
74
- for tepung in minyak:
75
- subprocess.run(tepung, **fff)
 
 
 
76
 
77
- # embedding upscaler vae
78
- jalanan = [
79
  f"https://civitai.com/api/download/models/150491 {zzz}/embeddings edgQuality.pt",
80
  f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
81
  f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
@@ -83,11 +87,15 @@ else:
83
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
84
  f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
85
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
86
- f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {zzz}/models/VAE"]
87
-
88
- for janda in jalanan:
89
- download(janda)
90
-
 
 
 
 
91
  #add
92
  subprocess.run(f"rm -rf {zzz}/asd/ext-1_5.txt",
93
  **fff)
@@ -126,22 +134,10 @@ else:
126
  **fff)
127
 
128
  def sd_xl(xxx, zzz, fff):
129
- asu = f"git clone -q -b v1.8.0 https://github.com/gutris1/asd"
130
- subprocess.run(asu, **fff)
131
-
132
- time.sleep(2)
133
- pull(f"https://github.com/gutris1/segsmaker sd {zzz}")
134
-
135
- # requirements , tmp symlink
136
- os.chdir(zzz)
137
- minyak = gorengan(xxx, zzz)
138
- for tepung in minyak:
139
- subprocess.run(tepung, **fff)
140
 
141
- # embedding upscaler vae
142
- jalanan = [
143
  f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
144
- f"https://civitai.com/api/download/models/356370 {zzz}/embeddings",
145
  f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
146
  f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
147
  f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
@@ -150,36 +146,40 @@ else:
150
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
151
  f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
152
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
153
- f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors"]
 
 
 
 
154
 
155
- for janda in jalanan:
156
- download(janda)
157
 
158
- # extension
159
  os.chdir(f"{zzz}/extensions")
160
  clone(f"{zzz}/asd/ext-xl.txt")
161
 
162
- weww = f"{zzz}/asd/cn-xl.py"
163
- woww = f"{zzz}/asd/controlnet.py"
164
- os.rename(weww, woww)
 
 
 
 
165
 
166
- def zrok_in():
167
- zorok = f"{xxx}/.zrok/bin"
168
- os.makedirs(zorok, exist_ok=True)
169
- tarok = f"{zorok}/zrok_0.4.25_linux_amd64.tar.gz"
170
- 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)
171
- subprocess.run(f"tar -xzf {tarok} -C {zorok} --wildcards *zrok", **fff)
172
- subprocess.run(f"rm -rf {xxx}/.cache/*", **fff)
173
- os.remove(tarok)
174
 
175
- def install(selection):
176
  with garis:
177
  display(HTML(gariz))
178
 
179
  with sd_setup:
180
  sd_setup.clear_output()
181
- say("【{red} Installing Stable Diffusion{d} 】{red}")
182
  os.chdir(xxx)
 
 
183
 
184
  if selection == 'SD 1.5':
185
  sd_1_5(xxx, zzz, fff)
@@ -189,7 +189,7 @@ else:
189
  with garis:
190
  garis.clear_output()
191
 
192
- say("{red} Done{d} 】{red}")
193
 
194
  def cb(button):
195
  selected[0] = button.description
@@ -200,7 +200,7 @@ else:
200
  if selection:
201
  widgets.Widget.close(boxxx)
202
  sd_setup.clear_output()
203
- install(selection)
204
 
205
  else:
206
  with sd_setup:
@@ -214,5 +214,5 @@ else:
214
 
215
  ccss(mama)
216
  display(boxxx, sd_setup, garis)
217
- zrok_in()
218
  tempe()
 
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
  b1 = widgets.Button(description='SD 1.5')
32
  b2 = widgets.Button(description='SDXL')
33
  ikuuuhhh = widgets.Button(description='Install')
 
47
  b2.add_class("b2")
48
  ikuuuhhh.add_class("out")
49
  boxxx.add_class("boxxx")
50
+ selected = [None]
51
 
52
  def ccss(mama):
53
  with open(mama, "r") as gantung:
 
55
 
56
  display(HTML(f"<style>{susu}</style>"))
57
 
58
+ def req_list(xxx, zzz):
59
  return [
60
+ f"pip install -q -r requirements.txt basicsr insightface onnxruntime-gpu",
61
+ f"rm -rf {xxx}/tmp/* {xxx}/tmp {zzz}/models/Stable-diffusion/tmp_ckpt {zzz}/models/Lora/tmp_lora {zzz}/models/ControlNet",
62
  f"mkdir -p {zzz}/models/Lora",
63
  f"mkdir -p {zzz}/models/ESRGAN",
64
  f"ln -vs /tmp {xxx}/tmp",
65
+ f"ln -vs /tmp/ckpt {zzz}/models/Stable-diffusion/tmp_ckpt",
66
+ f"ln -vs /tmp/lora {zzz}/models/Lora/tmp_lora",
67
+ f"ln -vs /tmp/controlnet {zzz}/models/ControlNet"
68
+ ]
 
 
 
69
 
70
+ def sd_clone(xxx, zzz, fff):
71
+ time.sleep(1)
72
  pull(f"https://github.com/gutris1/segsmaker sd {zzz}")
73
 
 
74
  os.chdir(zzz)
75
+ req = req_list(xxx, zzz)
76
+ for lines in req:
77
+ subprocess.run(shlex.split(lines), **fff)
78
+
79
+ def sd_1_5(xxx, zzz, fff):
80
+ sd_clone(xxx, zzz, fff)
81
 
82
+ extras = [
 
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",
 
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
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
92
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
93
+ f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
94
+ ]
95
+
96
+ for items in extras:
97
+ download(items)
98
+
99
  #add
100
  subprocess.run(f"rm -rf {zzz}/asd/ext-1_5.txt",
101
  **fff)
 
134
  **fff)
135
 
136
  def sd_xl(xxx, zzz, fff):
137
+ sd_clone(xxx, zzz, fff)
 
 
 
 
 
 
 
 
 
 
138
 
139
+ extras = [
 
140
  f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
 
141
  f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
142
  f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
143
  f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
 
146
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
147
  f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
148
  f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
149
+ f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors",
150
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
151
+ f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
152
+ f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
153
+ ]
154
 
155
+ for items in extras:
156
+ download(items)
157
 
158
+ say("<br><b>【{red} Installing Extensions{d} 】{red}</b>")
159
  os.chdir(f"{zzz}/extensions")
160
  clone(f"{zzz}/asd/ext-xl.txt")
161
 
162
+ os.rename(f"{zzz}/asd/cn-xl.py", f"{zzz}/asd/controlnet.py")
163
+
164
+ def zrok_install():
165
+ zrok = Path(f"{xxx}/.zrok/bin")
166
+ zrok.mkdir(parents=True, exist_ok=True)
167
+ url = "https://github.com/openziti/zrok/releases/download/v0.4.25/zrok_0.4.25_linux_amd64.tar.gz"
168
+ z = zrok / Path(url).name
169
 
170
+ get_ipython().system(f"curl -sLo {z} {url}")
171
+ get_ipython().system(f"tar -xzf {z} -C {zrok} --wildcards *zrok")
172
+ get_ipython().system(f"rm -rf {xxx}/.cache/* {z}")
 
 
 
 
 
173
 
174
+ def sd_install(selection):
175
  with garis:
176
  display(HTML(gariz))
177
 
178
  with sd_setup:
179
  sd_setup.clear_output()
 
180
  os.chdir(xxx)
181
+ say("<b>【{red} Installing Stable Diffusion{d} 】{red}</b>")
182
+ get_ipython().system(f"git clone -q -b {version} https://github.com/gutris1/asd")
183
 
184
  if selection == 'SD 1.5':
185
  sd_1_5(xxx, zzz, fff)
 
189
  with garis:
190
  garis.clear_output()
191
 
192
+ say("<br><b>【{red} Done{d} 】{red}</b>")
193
 
194
  def cb(button):
195
  selected[0] = button.description
 
200
  if selection:
201
  widgets.Widget.close(boxxx)
202
  sd_setup.clear_output()
203
+ sd_install(selection)
204
 
205
  else:
206
  with sd_setup:
 
214
 
215
  ccss(mama)
216
  display(boxxx, sd_setup, garis)
217
+ zrok_install()
218
  tempe()