import os from sys import executable as pyexecutable import subprocess import pathlib import gc def Gitclone(URI:str,ClonePath:str = "") -> int : if(ClonePath == "") : while True: i=subprocess.run([r"git",r"clone",URI]) if(i.returncode == 0 ): del i gc.collect() return 0 else : del i else: while True: i=subprocess.run([r"git",r"clone",URI,ClonePath]) if(i.returncode == 0 ): del i gc.collect() return 0 else : del i def DownLoad(URI:str,DownloadPath:str,DownLoadFileName:str ) -> int: while (True): 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",DownloadPath,r"-o",DownLoadFileName,URI]); if(i.returncode == 0 ): del i gc.collect() return 0 else : del i user_home =pathlib.Path.home().resolve() os.chdir(str(user_home)) def clone_repository(repo_url, target_dir): if not os.path.exists(target_dir): subprocess.run(["git", "clone", repo_url, target_dir]) else: print(f"El directorio {target_dir} ya existe. Omitiendo la clonaciĆ³n.") Gitclone(r"https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",str(user_home / r"webui" / r"stable-diffusion-webui")) os.chdir(str(user_home / r"webui" / r"stable-diffusion-webui")) os.system("git reset --hard 89f9faa63388756314e8a1d96cf86bf5e0663045") print("installing extensions") Gitclone(r"https://huggingface.co/embed/negative",str(user_home / r"webui" / r"stable-diffusion-webui" / r"embeddings" / r"negative")) Gitclone(r"https://huggingface.co/embed/lora",str(user_home / r"webui" / r"stable-diffusion-webui" / r"models" / r"Lora" / r"positive")) Gitclone(r"https://github.com/deforum-art/deforum-for-automatic1111-webui",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"deforum-for-automatic1111-webui" )) Gitclone(r"https://github.com/Mikubill/sd-webui-controlnet",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-controlnet")) Gitclone(r"https://github.com/camenduru/sd-webui-tunnels",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-tunnels")) os.chdir(user_home / r"webui" / r"stable-diffusion-webui") print("extensions dolwnload done .\ndownloading ControlNet models") dList =[r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors", r"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_zoedepth_sd15v1.pth"] for i in range(0,len(dList)): DownLoad(dList[i],str(user_home / r"webui" / "stable-diffusion-webui" / "extensions" / "sd-webui-controlnet" / "models"),pathlib.Path(dList[i]).name) del dList print("ControlNet models download done.\ndownloading model") DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0/resolve/main/dreamlike-photoreal-2.0.safetensors",str(user_home / r"webui" / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-photoreal-2.0.safetensors") DownLoad(r"https://huggingface.co/dreamlike-art/dreamlike-anime-1.0/resolve/main/dreamlike-anime-1.0.safetensors",str(user_home / r"webui" / r"stable-diffusion-webui" / r"models" / r"Stable-diffusion"),r"dreamlike-anime-1.0.safetensors") DownLoad(r"https://civitai.com/api/download/models/39885",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"Better_light.safetensors") DownLoad(r"https://civitai.com/api/download/models/21065",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"LAS.safetensors") DownLoad(r"https://civitai.com/api/download/models/39164",str(user_home / r"webui" / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"backlighting.safetensors") print("Done\nStarting Webui...") os.chdir(user_home / r"webui" / r"stable-diffusion-webui") while True: ret=subprocess.run([r"python3" ,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