|
""" |
|
Stable Diffusion Webui Version 1.6 |
|
https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.6.0 |
|
""" |
|
|
|
import os |
|
from sys import executable |
|
import subprocess |
|
import pathlib |
|
import gc |
|
import time |
|
import subprocess |
|
def Gitclone(URI:str,ClonePath:pathlib.Path ) -> int : |
|
if pathlib.Path.exists(ClonePath): |
|
return 0 |
|
for z in range(10): |
|
i=subprocess.run([r"git",r"clone",str(URI),str(ClonePath)]) |
|
if(i.returncode == 0 ): |
|
del i |
|
return 0 |
|
else : |
|
del i |
|
raise Exception(str.format("clone \'{0}\' failed",URI)) |
|
|
|
|
|
def DownLoad(URI:str,DownloadPath:pathlib.Path,DownLoadFileName:str ) -> int: |
|
if (DownloadPath / DownLoadFileName).is_file(): return 0 |
|
for z in range(10): |
|
i=subprocess.run([r"aria2c",r"-c",r"-x" ,r"16", r"-s",r"16", r"-k" ,r"1M" ,r"-m",r"0",r"--enable-mmap=false",r"--console-log-level=error",r"-d",str(DownloadPath),r"-o",DownLoadFileName,URI]); |
|
if(i.returncode == 0 ): |
|
del i |
|
gc.collect() |
|
return 0 |
|
else : |
|
del i |
|
raise Exception(str.format("download \'{0}\' failed",URI)) |
|
|
|
user_home =pathlib.Path.home().resolve() |
|
os.chdir(str(user_home)) |
|
|
|
print("cloning stable-diffusion-webui repo") |
|
Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",user_home / r"stable-diffusion-webui") |
|
|
|
|
|
os.chdir(user_home / r"stable-diffusion-webui") |
|
Gitclone(r"https://github.com/vorstcavry/ncpt_colab_timer",user_home / r"stable-diffusion-webui" / r"extensions" / r"ncpt_colab_timer") |
|
Gitclone(r"https://github.com/vorstcavry/static",user_home / r"stable-diffusion-webui" / r"static") |
|
|
|
def run_echo_command(): |
|
try: |
|
start_huggingface |
|
except NameError: |
|
start_huggingface = int(time.time()) - 5 |
|
|
|
cmd = f"echo -n {start_huggingface} > /home/user/app/stable-diffusion-webui/static/colabTimer.txt" |
|
subprocess.run(cmd, shell=True) |
|
|
|
|
|
run_echo_command() |
|
os.chdir(user_home / r"stable-diffusion-webui") |
|
|
|
print("installing extensions") |
|
Gitclone(r"https://github.com/vorstcavry/embeddings",user_home / r"stable-diffusion-webui" / r"embeddings" / r"negative") |
|
Gitclone(r"https://github.com/vorstcavry/lora",user_home / r"stable-diffusion-webui" / r"models" / r"Lora" / r"positive") |
|
Gitclone(r"https://github.com/vorstcavry/Checkpoint-Model",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion" / r"Checkpoint") |
|
|
|
DownLoad(r"https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth",user_home / r"stable-diffusion-webui" / r"models" / r"ESRGAN" ,r"4x-UltraSharp.pth") |
|
while (True): |
|
i=subprocess.run([r"wget",r"https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py",r"-O",str(user_home / r"stable-diffusion-webui" / r"scripts" / r"run_n_times.py")]) |
|
if(i.returncode == 0 ): |
|
del i |
|
gc.collect() |
|
break |
|
else : |
|
del i |
|
|
|
|
|
Gitclone(r"https://github.com/camenduru/stable-diffusion-webui-huggingface",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-huggingface") |
|
Gitclone(r"https://github.com/BlafKing/sd-civitai-browser-plus",user_home / r"stable-diffusion-webui" / r"extensions" / r"civitai-browser") |
|
Gitclone(r"https://github.com/kohya-ss/sd-webui-additional-networks",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks") |
|
Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet") |
|
Gitclone(r"https://github.com/fkunn1326/openpose-editor",user_home / r"stable-diffusion-webui" / r"extensions" / r"openpose-editor") |
|
|
|
|
|
|
|
|
|
Gitclone(r"https://github.com/EdithForsaken/sd-webui-cloud-inference.git",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-cloud-inference") |
|
Gitclone(r"https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git" , user_home / r"stable-diffusion-webui" / r"extensions" / r"a1111-sd-webui-tagcomplete") |
|
Gitclone(r"https://github.com/camenduru/sd-webui-tunnels",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-tunnels") |
|
Gitclone(r"https://github.com/etherealxx/batchlinks-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"batchlinks-webui") |
|
Gitclone(r"https://github.com/zanllp/sd-webui-infinite-image-browsing",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-infinite-image-browsing") |
|
|
|
|
|
Gitclone(r"https://tinyurl.com/aspect-ratio-v",user_home / r"stable-diffusion-webui" / r"extensions" / r"aspect-ratio") |
|
|
|
Gitclone(r"https://github.com/hnmr293/sd-webui-llul",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-llul") |
|
Gitclone(r"https://github.com/IDEA-Research/DWPose",user_home / r"stable-diffusion-webui" / r"extensions" / r"DWPose") |
|
Gitclone(r"https://github.com/Bing-su/adetailer",user_home / r"stable-diffusion-webui" / r"extensions" / r"adetailer") |
|
Gitclone(r"https://github.com/NoCrypt/sd_hf_out",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd_hf_out") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.chdir(user_home / r"stable-diffusion-webui") |
|
|
|
print("extensions dolwnload done .\ndownloading ControlNet models") |
|
dList =[ r"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", |
|
r"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", |
|
r"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", |
|
r"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors", |
|
r"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors"] |
|
for i in range(0,len(dList)): DownLoad(dList[i],user_home / r"stable-diffusion-webui" / r"models" / r"ControlNet",pathlib.Path(dList[i]).name) |
|
del dList |
|
|
|
print("ControlNet models download done.\ndownloading model") |
|
|
|
|
|
DownLoad(r"https://huggingface.co/vorstcavry/mymodel/resolve/main/Cavry_V2.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion" / r"Checkpoint",r"Cavry_V2.safetensors") |
|
|
|
DownLoad(r"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"VAE",r"vae-ft-mse-840000-ema-pruned.safetensors") |
|
DownLoad(r"https://huggingface.co/vorstcavry/loraasia1/resolve/main/japaneseDollLikeness_v15.safetensors",user_home / r"stable-diffusion-webui" / r"models"/ r"lora",r"japaneseDollLikeness_v15.safetensors") |
|
DownLoad(r"https://huggingface.co/vorstcavry/loraasia1/resolve/main/koreanDollLikeness_v20.safetensors",user_home / r"stable-diffusion-webui" / r"models"/ r"lora",r"koreanDollLikeness_v20.safetensors") |
|
DownLoad(r"https://huggingface.co/vorstcavry/loraasia1/resolve/main/taiwanDollLikeness_v15.safetensors",user_home / r"stable-diffusion-webui" / r"models"/ r"lora",r"taiwanDollLikeness_v15.safetensors") |
|
|
|
|
|
|
|
|
|
|
|
|
|
DownLoad(r"https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"detection_Resnet50_Final.pth") |
|
|
|
DownLoad(r"https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"parsing_parsenet.pth") |
|
|
|
DownLoad(r"https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth",user_home / r"stable-diffusion-webui"/r"models"/r"GFPGAN",r"GFPGANv1.4.pth") |
|
|
|
print("Done\nStarting Webui...") |
|
os.chdir(user_home / r"stable-diffusion-webui") |
|
import subprocess |
|
import pathlib |
|
|
|
user_home = pathlib.Path("/home/user") |
|
|
|
args = [ |
|
executable, |
|
user_home / "stable-diffusion-webui" / "launch.py", |
|
"--precision", "full", |
|
"--no-half", |
|
"--no-half-vae", |
|
"--enable-insecure-extension-access", |
|
"--medvram", |
|
"--skip-torch-cuda-test", |
|
"--enable-console-prompts", |
|
"--ui-settings-file=" + str(pathlib.Path(__file__).parent / "config.json"), |
|
"--hf-token-out", |
|
"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" |
|
] |
|
|
|
args = [arg.as_posix() if isinstance(arg, pathlib.PosixPath) else arg for arg in args] |
|
|
|
try: |
|
ret = subprocess.run(args) |
|
except Exception as e: |
|
print("Error:", e) |
|
del os ,user_home ,pyexecutable ,subprocess |