Carlos2312 commited on
Commit
1a9370c
Β·
verified Β·
1 Parent(s): 32a74d5

Update setup.py

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