Update setup_forge.py
Browse files- setup_forge.py +72 -77
setup_forge.py
CHANGED
|
@@ -1,33 +1,34 @@
|
|
| 1 |
from IPython.display import display, HTML, clear_output
|
| 2 |
from ipywidgets import widgets, Layout
|
| 3 |
from IPython import get_ipython
|
| 4 |
-
import
|
| 5 |
-
import time
|
| 6 |
-
import os
|
| 7 |
from nenen88 import pull, say, download, clone, tempe
|
| 8 |
|
| 9 |
xxx = "/home/studio-lab-user"
|
| 10 |
-
zzz =
|
| 11 |
|
| 12 |
-
if
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
else:
|
| 17 |
mama = f"{xxx}/.conda/setup.css"
|
| 18 |
-
fff = {"
|
| 19 |
-
|
| 20 |
-
|
| 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(
|
|
@@ -43,6 +44,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,34 +52,33 @@ else:
|
|
| 50 |
|
| 51 |
display(HTML(f"<style>{susu}</style>"))
|
| 52 |
|
| 53 |
-
def
|
| 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/
|
| 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/
|
| 61 |
-
f"ln -vs /tmp/
|
| 62 |
f"ln -vs /tmp/z123 {zzz}/models/z123",
|
| 63 |
f"ln -vs /tmp/svd {zzz}/models/svd",
|
| 64 |
-
f"ln -vs /tmp/
|
| 65 |
|
| 66 |
-
def
|
| 67 |
-
|
| 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 |
-
|
| 76 |
-
for
|
| 77 |
-
subprocess.run(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
jalanan = [
|
| 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",
|
|
@@ -85,10 +86,14 @@ else:
|
|
| 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 |
|
| 90 |
-
for
|
| 91 |
-
download(
|
| 92 |
|
| 93 |
subprocess.run(f"rm -rf {zzz}/asd/extension.txt",
|
| 94 |
**fff)
|
|
@@ -101,10 +106,8 @@ else:
|
|
| 101 |
# extension
|
| 102 |
os.chdir(f"{zzz}/extensions")
|
| 103 |
clone(f"{zzz}/asd/extension.txt")
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
woww = f"{zzz}/asd/controlnet.py"
|
| 107 |
-
os.rename(weww, woww)
|
| 108 |
|
| 109 |
subprocess.run(f"rm -rf {zzz}/embeddings",
|
| 110 |
**fff)
|
|
@@ -127,22 +130,10 @@ else:
|
|
| 127 |
**fff)
|
| 128 |
|
| 129 |
def sd_xl(xxx, zzz, fff):
|
| 130 |
-
|
| 131 |
-
subprocess.run(asu, **fff)
|
| 132 |
-
|
| 133 |
-
time.sleep(2)
|
| 134 |
-
pull(f"https://github.com/gutris1/segsmaker forge {zzz}")
|
| 135 |
-
|
| 136 |
-
# requirements , tmp symlink
|
| 137 |
-
os.chdir(zzz)
|
| 138 |
-
minyak = gorengan(xxx, zzz)
|
| 139 |
-
for tepung in minyak:
|
| 140 |
-
subprocess.run(tepung, **fff)
|
| 141 |
|
| 142 |
-
|
| 143 |
-
jalanan = [
|
| 144 |
f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
|
| 145 |
-
f"https://civitai.com/api/download/models/356370 {zzz}/embeddings",
|
| 146 |
f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
|
| 147 |
f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
|
| 148 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
|
|
@@ -151,57 +142,61 @@ else:
|
|
| 151 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
|
| 152 |
f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
|
| 153 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
|
| 154 |
-
f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
-
for
|
| 157 |
-
download(
|
| 158 |
|
| 159 |
-
|
| 160 |
-
os.
|
| 161 |
-
clone(f"{zzz}/asd/extension.txt")
|
| 162 |
|
| 163 |
-
weww = f"{zzz}/asd/cn-xl.py"
|
| 164 |
-
woww = f"{zzz}/asd/controlnet.py"
|
| 165 |
-
os.rename(weww, woww)
|
| 166 |
|
| 167 |
-
def
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
subprocess.run(f"tar -xzf {tarok} -C {zorok} --wildcards *zrok", **fff)
|
| 173 |
-
subprocess.run(f"rm -rf {xxx}/.cache/*", **fff)
|
| 174 |
-
os.remove(tarok)
|
| 175 |
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
with garis:
|
| 178 |
display(HTML(gariz))
|
| 179 |
|
| 180 |
with sd_setup:
|
| 181 |
sd_setup.clear_output()
|
| 182 |
-
say("【{red} Installing Stable Diffusion Forge{d} 】{red}")
|
| 183 |
os.chdir(xxx)
|
|
|
|
|
|
|
| 184 |
|
| 185 |
if selection == 'SD 1.5':
|
| 186 |
sd_1_5(xxx, zzz, fff)
|
| 187 |
else:
|
| 188 |
sd_xl(xxx, zzz, fff)
|
| 189 |
-
|
| 190 |
with garis:
|
| 191 |
garis.clear_output()
|
| 192 |
-
|
| 193 |
-
say("
|
| 194 |
|
| 195 |
def cb(button):
|
| 196 |
selected[0] = button.description
|
| 197 |
|
|
|
|
| 198 |
def uuwaaahhh(button):
|
| 199 |
selection = selected[0]
|
| 200 |
|
| 201 |
if selection:
|
| 202 |
widgets.Widget.close(boxxx)
|
| 203 |
sd_setup.clear_output()
|
| 204 |
-
|
| 205 |
|
| 206 |
else:
|
| 207 |
with sd_setup:
|
|
@@ -215,5 +210,5 @@ else:
|
|
| 215 |
|
| 216 |
ccss(mama)
|
| 217 |
display(boxxx, sd_setup, garis)
|
| 218 |
-
|
| 219 |
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 |
xxx = "/home/studio-lab-user"
|
| 9 |
+
zzz = Path(xxx) / "forge"
|
| 10 |
|
| 11 |
+
if zzz.exists():
|
| 12 |
+
git_dir = zzz / '.git'
|
| 13 |
+
if git_dir.exists():
|
| 14 |
+
os.chdir(zzz)
|
| 15 |
+
commit_hash = os.popen('git rev-parse HEAD').read().strip()
|
| 16 |
+
|
| 17 |
+
get_ipython().system("git pull origin master")
|
| 18 |
+
get_ipython().system("git fetch --tags")
|
| 19 |
|
| 20 |
else:
|
| 21 |
mama = f"{xxx}/.conda/setup.css"
|
| 22 |
+
fff = {"stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
|
| 23 |
+
get_ipython().system(f"rm -rf {xxx}/.zrok")
|
| 24 |
+
get_ipython().system(f"curl -sLo {mama} https://github.com/gutris1/segsmaker/raw/main/ui/sd/asd/setup.css")
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
gariz = """<div class="gradient-text">asd</div>"""
|
| 27 |
garis = widgets.Output()
|
|
|
|
| 28 |
b1 = widgets.Button(description='SD 1.5')
|
| 29 |
b2 = widgets.Button(description='SDXL')
|
| 30 |
+
ikuuuhhh = widgets.Button(description='Install')
|
| 31 |
+
|
| 32 |
b1b2 = widgets.HBox([b1, b2], layout=Layout(justify_content='space-between'))
|
| 33 |
sd_setup = widgets.Output()
|
| 34 |
boxxx = widgets.VBox([b1b2, ikuuuhhh], layout=Layout(
|
|
|
|
| 44 |
b2.add_class("b2")
|
| 45 |
ikuuuhhh.add_class("out")
|
| 46 |
boxxx.add_class("boxxx")
|
| 47 |
+
selected = [None]
|
| 48 |
|
| 49 |
def ccss(mama):
|
| 50 |
with open(mama, "r") as gantung:
|
|
|
|
| 52 |
|
| 53 |
display(HTML(f"<style>{susu}</style>"))
|
| 54 |
|
| 55 |
+
def req_list(xxx, zzz):
|
| 56 |
return [
|
| 57 |
f"pip install -q -r requirements.txt basicsr insightface onnxruntime-gpu",
|
| 58 |
+
f"rm -rf {xxx}/tmp/* {xxx}/tmp {zzz}/models/Stable-diffusion/tmp_ckpt {zzz}/models/Lora/tmp_lora {zzz}/models/ControlNet {zzz}/models/svd {zzz}/models/z123",
|
| 59 |
f"mkdir -p {zzz}/models/Lora",
|
| 60 |
f"mkdir -p {zzz}/models/ESRGAN",
|
| 61 |
f"ln -vs /tmp {xxx}/tmp",
|
| 62 |
+
f"ln -vs /tmp/ckpt {zzz}/models/Stable-diffusion/tmp_ckpt",
|
| 63 |
+
f"ln -vs /tmp/lora {zzz}/models/Lora/tmp_lora",
|
| 64 |
f"ln -vs /tmp/z123 {zzz}/models/z123",
|
| 65 |
f"ln -vs /tmp/svd {zzz}/models/svd",
|
| 66 |
+
f"ln -vs /tmp/controlnet {zzz}/models/ControlNet"]
|
| 67 |
|
| 68 |
+
def sd_clone(xxx, zzz, fff):
|
| 69 |
+
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
| 70 |
pull(f"https://github.com/gutris1/segsmaker forge {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 |
+
|
| 78 |
+
def sd_1_5(xxx, zzz, fff):
|
| 79 |
+
sd_clone(xxx, zzz, fff)
|
| 80 |
|
| 81 |
+
extras = [
|
|
|
|
| 82 |
f"https://civitai.com/api/download/models/150491 {zzz}/embeddings edgQuality.pt",
|
| 83 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
|
| 84 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth {zzz}/models/ESRGAN",
|
|
|
|
| 86 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
|
| 87 |
f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
|
| 88 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
|
| 89 |
+
f"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors {zzz}/models/VAE",
|
| 90 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
|
| 91 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
|
| 92 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
|
| 93 |
+
]
|
| 94 |
|
| 95 |
+
for items in extras:
|
| 96 |
+
download(items)
|
| 97 |
|
| 98 |
subprocess.run(f"rm -rf {zzz}/asd/extension.txt",
|
| 99 |
**fff)
|
|
|
|
| 106 |
# extension
|
| 107 |
os.chdir(f"{zzz}/extensions")
|
| 108 |
clone(f"{zzz}/asd/extension.txt")
|
| 109 |
+
ext(zzz)
|
| 110 |
+
os.rename(f"{zzz}/asd/cn-1_5.py", f"{zzz}/asd/controlnet.py")
|
|
|
|
|
|
|
| 111 |
|
| 112 |
subprocess.run(f"rm -rf {zzz}/embeddings",
|
| 113 |
**fff)
|
|
|
|
| 130 |
**fff)
|
| 131 |
|
| 132 |
def sd_xl(xxx, zzz, fff):
|
| 133 |
+
sd_clone(xxx, zzz, fff)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
extras = [
|
|
|
|
| 136 |
f"https://civitai.com/api/download/models/182974 {zzz}/embeddings",
|
|
|
|
| 137 |
f"https://civitai.com/api/download/models/159385 {zzz}/embeddings",
|
| 138 |
f"https://civitai.com/api/download/models/159184 {zzz}/embeddings",
|
| 139 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth {zzz}/models/ESRGAN",
|
|
|
|
| 142 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth {zzz}/models/ESRGAN",
|
| 143 |
f"https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth {zzz}/models/ESRGAN",
|
| 144 |
f"https://huggingface.co/pantat88/ui/resolve/main/4x_foolhardy_Remacri.pth {zzz}/models/ESRGAN",
|
| 145 |
+
f"https://civitai.com/api/download/models/264491 {zzz}/models/VAE XL_VAE_F1.safetensors",
|
| 146 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok_reg.py {zzz}/asd",
|
| 147 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/zrok.py {zzz}",
|
| 148 |
+
f"https://github.com/gutris1/segsmaker/raw/main/script/pinggy.py {zzz}"
|
| 149 |
+
]
|
| 150 |
|
| 151 |
+
for items in extras:
|
| 152 |
+
download(items)
|
| 153 |
|
| 154 |
+
ext(zzz)
|
| 155 |
+
os.rename(f"{zzz}/asd/cn-xl.py", f"{zzz}/asd/controlnet.py")
|
|
|
|
| 156 |
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
+
def zrok_install():
|
| 159 |
+
zrok = Path(f"{xxx}/.zrok/bin")
|
| 160 |
+
zrok.mkdir(parents=True, exist_ok=True)
|
| 161 |
+
url = "https://github.com/openziti/zrok/releases/download/v0.4.25/zrok_0.4.25_linux_amd64.tar.gz"
|
| 162 |
+
z = zrok / Path(url).name
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
+
get_ipython().system(f"curl -sLo {z} {url}")
|
| 165 |
+
get_ipython().system(f"tar -xzf {z} -C {zrok} --wildcards *zrok")
|
| 166 |
+
get_ipython().system(f"rm -rf {xxx}/.cache/* {z}")
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def sd_install(selection):
|
| 170 |
with garis:
|
| 171 |
display(HTML(gariz))
|
| 172 |
|
| 173 |
with sd_setup:
|
| 174 |
sd_setup.clear_output()
|
|
|
|
| 175 |
os.chdir(xxx)
|
| 176 |
+
say("<b>【{red} Installing Stable Diffusion Forge{d} 】{red}</b>")
|
| 177 |
+
get_ipython().system(f"git clone -q https://github.com/lllyasviel/stable-diffusion-webui-forge forge")
|
| 178 |
|
| 179 |
if selection == 'SD 1.5':
|
| 180 |
sd_1_5(xxx, zzz, fff)
|
| 181 |
else:
|
| 182 |
sd_xl(xxx, zzz, fff)
|
| 183 |
+
|
| 184 |
with garis:
|
| 185 |
garis.clear_output()
|
| 186 |
+
|
| 187 |
+
say("<br><b>【{red} Done{d} 】{red}</b>")
|
| 188 |
|
| 189 |
def cb(button):
|
| 190 |
selected[0] = button.description
|
| 191 |
|
| 192 |
+
|
| 193 |
def uuwaaahhh(button):
|
| 194 |
selection = selected[0]
|
| 195 |
|
| 196 |
if selection:
|
| 197 |
widgets.Widget.close(boxxx)
|
| 198 |
sd_setup.clear_output()
|
| 199 |
+
sd_install(selection)
|
| 200 |
|
| 201 |
else:
|
| 202 |
with sd_setup:
|
|
|
|
| 210 |
|
| 211 |
ccss(mama)
|
| 212 |
display(boxxx, sd_setup, garis)
|
| 213 |
+
zrok_install()
|
| 214 |
tempe()
|