Mightys/Notebook_Scripts
02.8k
1#!/usr/bin/env python32"""3forge_classic_install.py4Instala WhiteRF (sd-webui-forge-classic) con extensiones y enlaces simbólicos para Kaggle.5"""6 7import os8import subprocess9from pathlib import Path10 11WORK_DIR = Path("/kaggle/working").resolve()12FORGE_DIR = WORK_DIR / "sd-webui-forge-classic"13EXT_DIR = FORGE_DIR / "extensions"14 15# ---------- helpers ----------16def run(cmd: str, cwd: Path | None = None, check: bool = False) -> None:17 """Ejecuta un comando shell."""18 print(f"+ {cmd}")19 subprocess.run(cmd, shell=True, check=check, cwd=cwd)20 21def clone(repo: str, depth: int | None = None) -> None:22 """Clona un repo en EXT_DIR."""23 cmd = "git clone"24 if depth:25 cmd += f" --depth {depth}"26 cmd += f" {repo}"27 run(cmd, cwd=EXT_DIR)28 29def wget(url: str, output: str | None = None, quiet: bool = False, show_progress: bool = False) -> None:30 """Descarga con wget."""31 cmd = "wget"32 if quiet:33 cmd += " -q"34 if show_progress:35 cmd += " --show-progress"36 if output:37 cmd += f" -O {output}"38 cmd += f" {url}"39 run(cmd)40 41# ---------- main ----------42def main() -> None:43 os.chdir(WORK_DIR)44 45 # 1. Clonar forge-classic46 if not FORGE_DIR.exists():47 run("git clone https://github.com/MightyCrimsonX/sd-webui-forge-classic.git")48 49 # 2. Descargar ui-config.json y styles.csv50 wget(51 "https://huggingface.co/datasets/WhiteAiZ/sd-webui-forge-classic/resolve/main/ui-config.json",52 output=str(FORGE_DIR / "ui-config.json"),53 quiet=True,54 show_progress=True55 )56 wget(57 "https://huggingface.co/datasets/WhiteAiZ/sd-webui-forge-classic/resolve/main/styles.csv",58 output=str(FORGE_DIR / "styles.csv"),59 quiet=True,60 show_progress=True61 )62 63 # 3. Extensiones64 EXT_DIR.mkdir(parents=True, exist_ok=True)65 66 repos = [67 ("https://github.com/pamparamm/sd-perturbed-attention", None),68 ("https://github.com/gutris1/sd-image-encryption", None),69 ("https://github.com/yankooliveira/sd-webui-photopea-embed.git", None),70 ("https://github.com/gutris1/sd-hub", 1),71 ("https://github.com/uorufu/stable-diffusion-webui-wildcards-adetailer.git", 1),72 ("https://github.com/Haoming02/sd-forge-couple", 1),73 ("https://github.com/etherealxx/batchlinks-webui", None),74 ("https://github.com/gutris1/sd-civitai-browser-plus-plus", None),75 ("https://github.com/AlUlkesh/stable-diffusion-webui-images-browser", 1),76 ("https://github.com/DominikDoom/a1111-sd-webui-tagcomplete", 1),77 ("https://github.com/Anzhc/aadetailer-reforge.git", 1),78 ("https://github.com/NoCrypt/sd-fast-pnginfo", 1),79 ("https://github.com/viyiviyi/stable-diffusion-webui-zoomimage", 1),80 ("https://github.com/gutris1/sd-simple-dimension-preset", 1),81 ]82 83 for repo, depth in repos:84 clone(repo, depth=depth)85 86 # 4. Sistema + aria287 run("sudo apt update -qq")88 run("sudo apt install aria2 -q")89 90 # 5. gdown91 run("pip install gdown -q")92 93 # 6. Limpiar output y mostrar mensaje94 os.system("clear" if os.name != "nt" else "cls")95 print("\n" + "=" * 50)96 print("🎉 Instalación completada")97 print("=" * 50 + "\n")98 99 # 7. Enlaces simbólicos100 # tmp101 run("rm -rf /kaggle/working/tmp ~/tmp")102 run("ln -vs /tmp ~/tmp")103 104 # models105 run("rm -rf /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models")106 run("mkdir -p /tmp/models")107 run("ln -vs /tmp/models /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models")108 109 # lora110 run("rm -rf /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora")111 run("mkdir -p /tmp/lora")112 run("ln -vs /tmp/lora /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora")113 114 print("\n✅ Enlaces simbólicos creados.")115 116if __name__ == "__main__":117 main()