Update setup.py
Browse files
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
|
| 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 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 = {"
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
""
|
| 22 |
-
|
| 23 |
-
|
| 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
|
| 54 |
return [
|
| 55 |
-
f"pip install -q -r requirements.txt basicsr",
|
| 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/
|
| 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 |
-
|
|
|
|
| 69 |
pull(f"https://github.com/gutris1/segsmaker sd {zzz}")
|
| 70 |
|
| 71 |
-
# requirements , tmp symlink
|
| 72 |
os.chdir(zzz)
|
| 73 |
-
|
| 74 |
-
for
|
| 75 |
-
subprocess.run(
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 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 |
-
|
| 89 |
-
|
| 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 |
-
|
| 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 |
-
|
| 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
|
| 156 |
-
download(
|
| 157 |
|
| 158 |
-
|
| 159 |
os.chdir(f"{zzz}/extensions")
|
| 160 |
clone(f"{zzz}/asd/ext-xl.txt")
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 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
|
| 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("
|
| 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 |
-
|
| 204 |
|
| 205 |
else:
|
| 206 |
with sd_setup:
|
|
@@ -214,5 +214,5 @@ else:
|
|
| 214 |
|
| 215 |
ccss(mama)
|
| 216 |
display(boxxx, sd_setup, garis)
|
| 217 |
-
|
| 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()
|