Update Forge.py
Browse files
Forge.py
CHANGED
|
@@ -5,258 +5,257 @@ from pathlib import Path
|
|
| 5 |
import subprocess, time, os, shlex, json, shutil
|
| 6 |
from nenen88 import pull, say, download, clone, tempe
|
| 7 |
|
| 8 |
-
repo = f"git clone -q https://github.com/
|
| 9 |
|
| 10 |
home = Path.home()
|
| 11 |
src = home / '.gutris1'
|
| 12 |
-
|
| 13 |
img = src / 'loading.png'
|
| 14 |
mark = src / 'marking.py'
|
| 15 |
-
|
| 16 |
|
| 17 |
tmp = Path('/tmp')
|
| 18 |
vnv = tmp / 'venv'
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
os.chdir(home)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
os.chdir(webui)
|
| 28 |
-
commit_hash = os.popen('git rev-parse HEAD').read().strip()
|
| 29 |
-
|
| 30 |
-
get_ipython().system("git pull origin main")
|
| 31 |
-
get_ipython().system("git fetch --tags")
|
| 32 |
-
|
| 33 |
-
x = [
|
| 34 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/controlnet/controlnet.py {webui}/asd",
|
| 35 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {webui}",
|
| 36 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {webui}",
|
| 37 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/ngrokk.py {webui}",
|
| 38 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/venv.py {webui}",
|
| 39 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/multi/segsmaker.py {webui}"]
|
| 40 |
-
|
| 41 |
-
for y in x:
|
| 42 |
-
download(y)
|
| 43 |
-
|
| 44 |
-
else:
|
| 45 |
-
devnull = {"stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
|
| 46 |
-
|
| 47 |
-
loading = widgets.Output()
|
| 48 |
-
sd_setup = widgets.Output()
|
| 49 |
-
|
| 50 |
-
button1 = widgets.Button(description='SD 1.5')
|
| 51 |
-
button2 = widgets.Button(description='SD XL')
|
| 52 |
-
back_button = widgets.Button(description='⬅️')
|
| 53 |
-
|
| 54 |
-
panel = widgets.HBox([button1, back_button, button2], layout=widgets.Layout(
|
| 55 |
-
width='500px',
|
| 56 |
-
height='100%',
|
| 57 |
-
display='flex',
|
| 58 |
-
flex_flow='row',
|
| 59 |
-
align_items='center',
|
| 60 |
-
justify_content='space-between',
|
| 61 |
-
padding='20px'))
|
| 62 |
-
|
| 63 |
-
button1.add_class("buttons")
|
| 64 |
-
button2.add_class("buttons")
|
| 65 |
-
back_button.add_class("back-b")
|
| 66 |
-
panel.add_class("main-panel")
|
| 67 |
-
|
| 68 |
-
def load_css(css):
|
| 69 |
-
with css.open("r") as file:
|
| 70 |
-
data = file.read()
|
| 71 |
-
|
| 72 |
-
display(HTML(f"<style>{data}</style>"))
|
| 73 |
-
|
| 74 |
-
def tmp_cleaning():
|
| 75 |
-
for item in tmp.iterdir():
|
| 76 |
-
if item.is_dir() and item != vnv:
|
| 77 |
-
shutil.rmtree(item)
|
| 78 |
-
elif item.is_file() and item != vnv:
|
| 79 |
-
item.unlink()
|
| 80 |
-
|
| 81 |
-
def venv_install():
|
| 82 |
-
url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv.tar.lz4'
|
| 83 |
-
fn = Path(url).name
|
| 84 |
-
|
| 85 |
-
def check(folder):
|
| 86 |
-
du = get_ipython().getoutput(f'du -s -b {folder}')
|
| 87 |
-
if du:
|
| 88 |
-
size = int(du[0].split()[0])
|
| 89 |
-
return size
|
| 90 |
-
else:
|
| 91 |
-
return 0
|
| 92 |
-
|
| 93 |
-
def venv():
|
| 94 |
-
if vnv.exists() and check(vnv) > 7 * 1024**3:
|
| 95 |
-
return
|
| 96 |
-
else:
|
| 97 |
-
os.chdir(tmp)
|
| 98 |
-
get_ipython().system(f'rm -rf {vnv}')
|
| 99 |
-
|
| 100 |
-
say("<br><b>【{red} Installing VENV{d} 】{red}</b>")
|
| 101 |
-
download(url)
|
| 102 |
|
| 103 |
-
|
| 104 |
-
Path(fn).unlink()
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
|
|
|
| 113 |
|
| 114 |
-
def
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
f"rm -rf {webui}/models/Stable-diffusion/tmp_ckpt {webui}/models/Lora/tmp_lora {webui}/models/ControlNet",
|
| 118 |
-
f"rm -rf {webui}/models/svd {webui}/models/z123",
|
| 119 |
-
f"mkdir -p {webui}/models/Lora",
|
| 120 |
-
f"mkdir -p {webui}/models/ESRGAN",
|
| 121 |
-
f"ln -vs /tmp {home}/tmp",
|
| 122 |
-
f"ln -vs /tmp/ckpt {webui}/models/Stable-diffusion/tmp_ckpt",
|
| 123 |
-
f"ln -vs /tmp/lora {webui}/models/Lora/tmp_lora",
|
| 124 |
-
f"ln -vs /tmp/controlnet {webui}/models/ControlNet",
|
| 125 |
-
f"ln -vs /tmp/z123 {webui}/models/z123",
|
| 126 |
-
f"ln -vs /tmp/svd {webui}/models/svd"]
|
| 127 |
-
|
| 128 |
-
def sd_clone(home, webui, devnull):
|
| 129 |
-
time.sleep(1)
|
| 130 |
-
pull(f"https://github.com/gutris1/segsmaker forge {webui}")
|
| 131 |
-
|
| 132 |
-
tmp_cleaning()
|
| 133 |
-
|
| 134 |
-
os.chdir(webui)
|
| 135 |
-
req = req_list(home, webui)
|
| 136 |
-
|
| 137 |
-
for lines in req:
|
| 138 |
-
subprocess.run(shlex.split(lines), **devnull)
|
| 139 |
-
|
| 140 |
-
scripts = [
|
| 141 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/controlnet/controlnet.py {webui}/asd",
|
| 142 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {webui}",
|
| 143 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {webui}",
|
| 144 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/ngrokk.py {webui}",
|
| 145 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/venv.py {webui}",
|
| 146 |
-
f"https://github.com/gutris1/segsmaker/raw/main/script/multi/segsmaker.py {webui}"]
|
| 147 |
-
|
| 148 |
-
upscalers = [
|
| 149 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {webui}/models/ESRGAN",
|
| 150 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {webui}/models/ESRGAN",
|
| 151 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {webui}/models/ESRGAN",
|
| 152 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {webui}/models/ESRGAN",
|
| 153 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {webui}/models/ESRGAN",
|
| 154 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {webui}/models/ESRGAN"]
|
| 155 |
-
|
| 156 |
-
line = scripts + upscalers
|
| 157 |
-
for item in line:
|
| 158 |
-
download(item)
|
| 159 |
-
|
| 160 |
-
tempe()
|
| 161 |
-
|
| 162 |
-
def extensions(webui):
|
| 163 |
-
say("<br><b>【{red} Installing Extensions{d} 】{red}</b>")
|
| 164 |
-
os.chdir(webui / "extensions")
|
| 165 |
-
clone(str(webui / "asd/extension.txt"))
|
| 166 |
-
|
| 167 |
-
def sd_1_5(home, webui, devnull):
|
| 168 |
-
sd_clone(home, webui, devnull)
|
| 169 |
-
|
| 170 |
-
extras = [
|
| 171 |
-
f"https://huggingface.co/pantat88/ui/resolve/main/embeddings.zip {webui}",
|
| 172 |
-
f"https://civitai.com/api/download/models/150491 {webui}/embeddings edgQuality.pt",
|
| 173 |
-
f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {webui}/models/VAE"]
|
| 174 |
-
|
| 175 |
-
for items in extras:
|
| 176 |
-
download(items)
|
| 177 |
-
|
| 178 |
-
get_ipython().system(f"unzip -qo {webui}/embeddings.zip -d {webui}/embeddings && rm {webui}/embeddings.zip")
|
| 179 |
-
|
| 180 |
-
extensions(webui)
|
| 181 |
-
|
| 182 |
-
def sd_xl(home, webui, devnull):
|
| 183 |
-
sd_clone(home, webui, devnull)
|
| 184 |
-
|
| 185 |
-
extras = [
|
| 186 |
-
f"https://civitai.com/api/download/models/182974 {webui}/embeddings",
|
| 187 |
-
f"https://civitai.com/api/download/models/159385 {webui}/embeddings",
|
| 188 |
-
f"https://civitai.com/api/download/models/159184 {webui}/embeddings",
|
| 189 |
-
f"https://civitai.com/api/download/models/264491 {webui}/models/VAE XL_VAE_F1.safetensors"]
|
| 190 |
-
|
| 191 |
-
for items in extras:
|
| 192 |
-
download(items)
|
| 193 |
-
|
| 194 |
-
extensions(webui)
|
| 195 |
-
|
| 196 |
-
def marking(path, fn, ui):
|
| 197 |
-
txt = path / fn
|
| 198 |
-
values = {
|
| 199 |
-
'ui': ui,
|
| 200 |
-
'launch_args1': '',
|
| 201 |
-
'launch_args2': '',
|
| 202 |
-
'zrok_token': '',
|
| 203 |
-
'ngrok_token': '',
|
| 204 |
-
'tunnel': ''
|
| 205 |
-
}
|
| 206 |
-
|
| 207 |
-
if not txt.exists():
|
| 208 |
-
with open(txt, 'w') as file:
|
| 209 |
-
json.dump(values, file, indent=4)
|
| 210 |
-
|
| 211 |
-
with open(txt, 'r') as file:
|
| 212 |
-
data = json.load(file)
|
| 213 |
-
|
| 214 |
-
data.update({
|
| 215 |
-
'ui': ui,
|
| 216 |
-
'launch_args1': '',
|
| 217 |
-
'launch_args2': '',
|
| 218 |
-
'tunnel': ''
|
| 219 |
-
})
|
| 220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
with open(txt, 'w') as file:
|
| 222 |
-
json.dump(
|
| 223 |
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
clear_output()
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
get_ipython().system(f"{repo}")
|
| 235 |
-
|
| 236 |
-
if b.description == 'SD 1.5':
|
| 237 |
-
sd_1_5(home, webui, devnull)
|
| 238 |
-
elif b.description == 'SD XL':
|
| 239 |
-
sd_xl(home, webui, devnull)
|
| 240 |
|
| 241 |
-
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
|
|
|
| 245 |
|
| 246 |
-
|
| 247 |
-
loading.clear_output(wait=True)
|
| 248 |
-
say("<b>【{red} Done{d} 】{red}</b>")
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
| 253 |
|
| 254 |
-
|
| 255 |
-
get_ipython().magic(f"run {multi}")
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
| 259 |
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import subprocess, time, os, shlex, json, shutil
|
| 6 |
from nenen88 import pull, say, download, clone, tempe
|
| 7 |
|
| 8 |
+
repo = f"git clone -q https://github.com/lllyasviel/stable-diffusion-webui-forge forge"
|
| 9 |
|
| 10 |
home = Path.home()
|
| 11 |
src = home / '.gutris1'
|
| 12 |
+
css_setup = src / 'setup.css'
|
| 13 |
img = src / 'loading.png'
|
| 14 |
mark = src / 'marking.py'
|
| 15 |
+
setup = home / '.conda/setup.py'
|
| 16 |
|
| 17 |
tmp = Path('/tmp')
|
| 18 |
vnv = tmp / 'venv'
|
| 19 |
|
| 20 |
+
sd = home / 'forge'
|
| 21 |
|
| 22 |
os.chdir(home)
|
| 23 |
|
| 24 |
+
def load_css():
|
| 25 |
+
with open(css_setup, "r") as file:
|
| 26 |
+
data = file.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
display(HTML(f"<style>{data}</style>"))
|
|
|
|
| 29 |
|
| 30 |
+
def tmp_cleaning():
|
| 31 |
+
for item in tmp.iterdir():
|
| 32 |
+
if item.is_dir() and item != vnv:
|
| 33 |
+
shutil.rmtree(item)
|
| 34 |
+
elif item.is_file() and item != vnv:
|
| 35 |
+
item.unlink()
|
| 36 |
|
| 37 |
+
def venv_install():
|
| 38 |
+
url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv.tar.lz4'
|
| 39 |
+
fn = Path(url).name
|
| 40 |
|
| 41 |
+
def check_venv(folder):
|
| 42 |
+
du = get_ipython().getoutput(f'du -s -b {folder}')
|
| 43 |
+
return int(du[0].split()[0]) if du else 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
while True:
|
| 46 |
+
if vnv.exists():
|
| 47 |
+
size = check_venv(vnv)
|
| 48 |
+
if size > 7 * 1024**3:
|
| 49 |
+
return
|
| 50 |
+
get_ipython().system(f'rm -rf {vnv}')
|
| 51 |
+
|
| 52 |
+
os.chdir(tmp)
|
| 53 |
+
|
| 54 |
+
say("<br><b>【{red} Installing VENV{d} 】{red}</b>")
|
| 55 |
+
download(url)
|
| 56 |
+
|
| 57 |
+
get_ipython().system(f'pv {fn} | lz4 -d | tar xf -')
|
| 58 |
+
Path(fn).unlink()
|
| 59 |
+
|
| 60 |
+
get_ipython().system(f'rm -rf {vnv / "bin" / "pip*"}')
|
| 61 |
+
get_ipython().system(f'rm -rf {vnv / "bin" / "python*"}')
|
| 62 |
+
get_ipython().system(f'python -m venv {vnv}')
|
| 63 |
+
get_ipython().system(f'{vnv / "bin" / "python"} -m pip install -q --upgrade pip')
|
| 64 |
+
|
| 65 |
+
def req_list():
|
| 66 |
+
return [
|
| 67 |
+
f"rm -rf {home}/tmp {home}/.cache/*",
|
| 68 |
+
f"rm -rf {sd}/models/Stable-diffusion/tmp_ckpt {sd}/models/Lora/tmp_lora {sd}/models/ControlNet",
|
| 69 |
+
f"rm -rf {sd}/models/svd {sd}/models/z123",
|
| 70 |
+
f"mkdir -p {sd}/models/Lora",
|
| 71 |
+
f"mkdir -p {sd}/models/ESRGAN",
|
| 72 |
+
f"ln -vs /tmp {home}/tmp",
|
| 73 |
+
f"ln -vs /tmp/ckpt {sd}/models/Stable-diffusion/tmp_ckpt",
|
| 74 |
+
f"ln -vs /tmp/lora {sd}/models/Lora/tmp_lora",
|
| 75 |
+
f"ln -vs /tmp/controlnet {sd}/models/ControlNet",
|
| 76 |
+
f"ln -vs /tmp/z123 {sd}/models/z123",
|
| 77 |
+
f"ln -vs /tmp/svd {sd}/models/svd"]
|
| 78 |
+
|
| 79 |
+
def sd_clone():
|
| 80 |
+
time.sleep(1)
|
| 81 |
+
pull(f"https://github.com/gutris1/segsmaker forge {sd}")
|
| 82 |
+
|
| 83 |
+
tmp_cleaning()
|
| 84 |
+
|
| 85 |
+
os.chdir(sd)
|
| 86 |
+
req = req_list()
|
| 87 |
+
|
| 88 |
+
for lines in req:
|
| 89 |
+
subprocess.run(shlex.split(lines), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 90 |
+
|
| 91 |
+
scripts = [
|
| 92 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/controlnet/controlnet.py {sd}/asd",
|
| 93 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {sd}",
|
| 94 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {sd}",
|
| 95 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/ngrokk.py {sd}",
|
| 96 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/venv.py {sd}",
|
| 97 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/multi/segsmaker.py {sd}"]
|
| 98 |
+
|
| 99 |
+
upscalers = [
|
| 100 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {sd}/models/ESRGAN",
|
| 101 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {sd}/models/ESRGAN",
|
| 102 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth {sd}/models/ESRGAN",
|
| 103 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {sd}/models/ESRGAN",
|
| 104 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {sd}/models/ESRGAN",
|
| 105 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {sd}/models/ESRGAN"]
|
| 106 |
+
|
| 107 |
+
line = scripts + upscalers
|
| 108 |
+
for item in line:
|
| 109 |
+
download(item)
|
| 110 |
+
|
| 111 |
+
tempe()
|
| 112 |
+
|
| 113 |
+
def exts():
|
| 114 |
+
say("<br><b>【{red} Installing Extensions{d} 】{red}</b>")
|
| 115 |
+
os.chdir(sd / "extensions")
|
| 116 |
+
clone(str(sd / "asd/extension.txt"))
|
| 117 |
+
|
| 118 |
+
def sd_15():
|
| 119 |
+
sd_clone()
|
| 120 |
+
|
| 121 |
+
extras = [
|
| 122 |
+
f"https://huggingface.co/pantat88/ui/resolve/main/embeddings.zip {sd}",
|
| 123 |
+
f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {sd}/models/VAE"]
|
| 124 |
+
|
| 125 |
+
for items in extras:
|
| 126 |
+
download(items)
|
| 127 |
+
|
| 128 |
+
get_ipython().system(f"unzip -qo {sd}/embeddings.zip -d {sd}/embeddings && rm {sd}/embeddings.zip")
|
| 129 |
+
|
| 130 |
+
exts()
|
| 131 |
+
|
| 132 |
+
def sd_xl():
|
| 133 |
+
sd_clone()
|
| 134 |
+
|
| 135 |
+
extras = [
|
| 136 |
+
f"https://civitai.com/api/download/models/182974 {sd}/embeddings",
|
| 137 |
+
f"https://civitai.com/api/download/models/159385 {sd}/embeddings",
|
| 138 |
+
f"https://civitai.com/api/download/models/159184 {sd}/embeddings",
|
| 139 |
+
f"https://civitai.com/api/download/models/264491 {sd}/models/VAE XL_VAE_F1.safetensors"]
|
| 140 |
+
|
| 141 |
+
for items in extras:
|
| 142 |
+
download(items)
|
| 143 |
+
|
| 144 |
+
exts()
|
| 145 |
+
|
| 146 |
+
def marking(path, fn, ui):
|
| 147 |
+
txt = path / fn
|
| 148 |
+
values = {
|
| 149 |
+
'ui': ui,
|
| 150 |
+
'launch_args1': '',
|
| 151 |
+
'launch_args2': '',
|
| 152 |
+
'zrok_token': '',
|
| 153 |
+
'ngrok_token': '',
|
| 154 |
+
'tunnel': ''
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
if not txt.exists():
|
| 158 |
with open(txt, 'w') as file:
|
| 159 |
+
json.dump(values, file, indent=4)
|
| 160 |
|
| 161 |
+
with open(txt, 'r') as file:
|
| 162 |
+
data = json.load(file)
|
|
|
|
| 163 |
|
| 164 |
+
data.update({
|
| 165 |
+
'ui': ui,
|
| 166 |
+
'launch_args1': '',
|
| 167 |
+
'launch_args2': '',
|
| 168 |
+
'tunnel': ''
|
| 169 |
+
})
|
| 170 |
+
|
| 171 |
+
with open(txt, 'w') as file:
|
| 172 |
+
json.dump(data, file, indent=4)
|
| 173 |
|
| 174 |
+
def sd_install(b):
|
| 175 |
+
panel.close()
|
| 176 |
+
clear_output()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
+
with loading:
|
| 179 |
+
display(Image(filename=str(img)))
|
| 180 |
|
| 181 |
+
with sd_setup:
|
| 182 |
+
say("<b>【{red} Installing Stable Diffusion Forge{d} 】{red}</b>")
|
| 183 |
+
get_ipython().system(f"{repo}")
|
| 184 |
|
| 185 |
+
marking(src, 'marking.json', 'Forge')
|
|
|
|
|
|
|
| 186 |
|
| 187 |
+
if b == 'button-15':
|
| 188 |
+
sd_15()
|
| 189 |
+
elif b == 'button-xl':
|
| 190 |
+
sd_xl()
|
| 191 |
|
| 192 |
+
get_ipython().run_line_magic('run', f'{mark}')
|
|
|
|
| 193 |
|
| 194 |
+
venv_install()
|
| 195 |
+
os.chdir(home)
|
| 196 |
|
| 197 |
+
with loading:
|
| 198 |
+
loading.clear_output(wait=True)
|
| 199 |
+
say("<b>【{red} Done{d} 】{red}</b>")
|
| 200 |
+
|
| 201 |
+
def go_back(b):
|
| 202 |
+
panel.close()
|
| 203 |
+
clear_output()
|
| 204 |
+
|
| 205 |
+
with sd_setup:
|
| 206 |
+
get_ipython().run_line_magic('run', f'{setup}')
|
| 207 |
+
|
| 208 |
+
loading = widgets.Output()
|
| 209 |
+
sd_setup = widgets.Output()
|
| 210 |
+
|
| 211 |
+
options = ['button-15', 'button-back', 'button-xl']
|
| 212 |
+
buttons = []
|
| 213 |
+
|
| 214 |
+
for btn in options:
|
| 215 |
+
button = widgets.Button(description='')
|
| 216 |
+
button.add_class(btn.lower())
|
| 217 |
+
if btn == 'button-back':
|
| 218 |
+
button.on_click(lambda x: go_back(btn))
|
| 219 |
+
else:
|
| 220 |
+
button.on_click(lambda x, btn=btn: sd_install(btn))
|
| 221 |
+
buttons.append(button)
|
| 222 |
+
|
| 223 |
+
panel = widgets.HBox(
|
| 224 |
+
buttons, layout=widgets.Layout(
|
| 225 |
+
width='600px',
|
| 226 |
+
height='405px'))
|
| 227 |
+
|
| 228 |
+
panel.add_class("multi-panel")
|
| 229 |
+
|
| 230 |
+
def webui_widgets():
|
| 231 |
+
if sd.exists():
|
| 232 |
+
git_dir = sd / '.git'
|
| 233 |
+
if git_dir.exists():
|
| 234 |
+
os.chdir(sd)
|
| 235 |
+
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8')
|
| 236 |
+
|
| 237 |
+
get_ipython().system("git pull origin main")
|
| 238 |
+
get_ipython().system("git fetch --tags")
|
| 239 |
+
|
| 240 |
+
x = [
|
| 241 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/controlnet/controlnet.py {sd}/asd",
|
| 242 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {sd}",
|
| 243 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {sd}",
|
| 244 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/ngrokk.py {sd}",
|
| 245 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/venv.py {sd}",
|
| 246 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/multi/segsmaker.py {sd}"
|
| 247 |
+
]
|
| 248 |
+
|
| 249 |
+
for y in x:
|
| 250 |
+
download(y)
|
| 251 |
+
|
| 252 |
+
else:
|
| 253 |
+
if any([(home / 'asd').exists(), (home / 'ComfyUI').exists()]):
|
| 254 |
+
print('A1111 is installed, Uninstall first.' if (home / 'asd').exists() else 'ComfyUI is installed, Uninstall first.')
|
| 255 |
+
get_ipython().run_line_magic('run', f'{mark}')
|
| 256 |
+
return
|
| 257 |
+
|
| 258 |
+
load_css()
|
| 259 |
+
display(panel, sd_setup, loading)
|
| 260 |
+
|
| 261 |
+
webui_widgets()
|