""" Stable Diffusion Webui Version 1.6 https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.6.0 """ commit_id=r"5ef669de080814067961f28357256e8fe27544f4" #Version 1.3.0 import os from sys import executable import subprocess import pathlib import gc 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)) #clone stable-diffusion-webui repo print("cloning stable-diffusion-webui repo") Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",user_home / r"stable-diffusion-webui") os.chdir(str(user_home / r"stable-diffusion-webui")) os.system("git reset --hard "+commit_id) #install extensions print("installing extensions") Gitclone(r"https://huggingface.co/embed/negative",user_home / r"stable-diffusion-webui" / r"embeddings" / r"negative") Gitclone(r"https://huggingface.co/embed/lora",user_home / r"stable-diffusion-webui" / r"models" / r"Lora" / r"positive") 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/deforum-art/deforum-for-automatic1111-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"deforum-for-automatic1111-webui" ) Gitclone(r"https://github.com/AlUlkesh/stable-diffusion-webui-images-browser",user_home / r"stable-diffusion-webui" / r"extensions"/ r"stable-diffusion-webui-images-browser") 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/Bing-su/adetailer",user_home / r"stable-diffusion-webui" / r"extensions" / r"adetailer") Gitclone(r"https://github.com/nolanaatama/microsoftexcel-controlnet",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet") Gitclone(r"https://github.com/jexom/sd-webui-depth-lib",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-depth-lib") 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/catppuccin/stable-diffusion-webui",user_home / r"stable-diffusion-webui" / r"extensions" / r"stable-diffusion-webui-catppuccin") Gitclone(r"https://tinyurl.com/aspect-ratio-v",user_home / r"stable-diffusion-webui" / r"extensions" / r"aspect-ratio") os.chdir(user_home / r"stable-diffusion-webui") #download ControlNet models print("extensions dolwnload done .\ndownloading ControlNet models") dList =[r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors"] for i in range(0,len(dList)): DownLoad(dList[i],user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet" / r"models",pathlib.Path(dList[i]).name) del dList #download model #you can change model download address here print("ControlNet models download done.\ndownloading model") #Stable Diffusion Checkpoint Model #MeinaPastelV5 DownLoad(r"https://huggingface.co/Meina/MeinaPastel/resolve/main/MeinaPastelV5%20-%20Baked%20VAE.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"MeinaPastelV5_BakedVAE.safetensors") #Photon DownLoad(r"https://huggingface.co/nolanaatama/phtn/resolve/main/phtn.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"phtn.safetensors") #RV DownLoad(r"https://huggingface.co/SG161222/Realistic_Vision_V5.1_noVAE/resolve/main/Realistic_Vision_V5.1_fp16-no-ema.safetensors",user_home / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion",r"Realistic_Vision_latest.safetensors") #Lora Model #Better Light DownLoad(r"https://civitai.com/api/download/models/39885",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"Better_light.safetensors") #Backlighting DownLoad(r"https://civitai.com/api/download/models/39164",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora",r"backlighting.safetensors") #Add details DownLoad(r"https://civitai.com/api/download/models/62833",user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora" / r"add_detail.safetensors") #GFPGAN Model #detection Resnet50 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") #parsing_parsenet 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") #GFPGANv1.4 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") #strt Stable Diffusion Webui print("Done\nStarting Webui...") os.chdir(user_home / r"stable-diffusion-webui") gc.collect() while True: ret=subprocess.run([executable ,user_home / r"stable-diffusion-webui" / r"launch.py",r"--precision",r"full",r"--no-half",r"--no-half-vae",r"--enable-insecure-extension-access",r"--medvram",r"--skip-torch-cuda-test",r"--enable-console-prompts",r"--ui-settings-file="+str(pathlib.Path(__file__).parent /r"config.json")]) if(ret.returncode == 0 ): del ret gc.collect() else : del ret del os ,user_home ,pyexecutable ,subprocess