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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ipywidgets as widgets
|
| 2 |
+
from IPython.display import display, clear_output, HTML
|
| 3 |
+
from IPython import get_ipython
|
| 4 |
+
import os
|
| 5 |
+
import subprocess
|
| 6 |
+
import requests
|
| 7 |
+
import re
|
| 8 |
+
|
| 9 |
+
# --- Configuración de Rutas para Forge Classic ---
|
| 10 |
+
BASE_MODELS_DIR = "/kaggle/working/sd-webui-forge-classic/models/Stable-diffusion"
|
| 11 |
+
LORA_DIR = "/kaggle/working/sd-webui-forge-classic/models/Lora"
|
| 12 |
+
VAE_DIR = "/kaggle/working/sd-webui-forge-classic/models/VAE"
|
| 13 |
+
UPSCALER_DIR = "/kaggle/working/sd-webui-forge-classic/models/ESRGAN"
|
| 14 |
+
CONTROLNET_DIR = "/kaggle/working/sd-webui-forge-classic/models/ControlNet"
|
| 15 |
+
|
| 16 |
+
os.makedirs(BASE_MODELS_DIR, exist_ok=True)
|
| 17 |
+
os.makedirs(LORA_DIR, exist_ok=True)
|
| 18 |
+
os.makedirs(VAE_DIR, exist_ok=True)
|
| 19 |
+
os.makedirs(UPSCALER_DIR, exist_ok=True)
|
| 20 |
+
os.makedirs(CONTROLNET_DIR, exist_ok=True)
|
| 21 |
+
|
| 22 |
+
# --- Recuperar el Token Guardado ---
|
| 23 |
+
ipython = get_ipython()
|
| 24 |
+
token_guardado = ipython.user_ns.get('token_civitai', '') if ipython else ''
|
| 25 |
+
|
| 26 |
+
# --- Diccionarios de Modelos Predefinidos ---
|
| 27 |
+
PRESET_MODELS = {
|
| 28 |
+
"WaiNSFW V16": "https://huggingface.co/Quiho/best-from-civitai/resolve/main/waiIllustriousSDXL_v160.safetensors",
|
| 29 |
+
"WaiNSFW V15": "https://huggingface.co/WhiteAiZ/WAI-NSFW-illustrious-SDXL-V015/resolve/main/waiNSFWIllustrious_v150.safetensors",
|
| 30 |
+
"waiNSFW V14": "https://huggingface.co/Ine007/waiNSFWIllustrious_v140/resolve/main/waiNSFWIllustrious_v140.safetensors",
|
| 31 |
+
"waiSHUFFLENOOB_v20": "https://huggingface.co/WhiteAiZ/waiSHUFFLENOOB_v20/resolve/main/waiSHUFFLENOOB_v20.safetensors",
|
| 32 |
+
"waiSHUFFLENOOB_vpred20": "https://huggingface.co/WhiteAiZ/waiSHUFFLENOOB_v20/resolve/main/waiSHUFFLENOOB_vPred20.safetensors",
|
| 33 |
+
"ntrMIXIllustriousXL_XIII": "https://huggingface.co/misri/ntrMIXIllustriousXL_xiii/resolve/main/ntrMIXIllustriousXL_xiii.safetensors",
|
| 34 |
+
"NoobaiCyberFix": "https://civitaiarchive.com/api/download/models/1122850",
|
| 35 |
+
"NoobaiCyberFix vpred": "https://civitaiarchive.com/api/download/models/2371102",
|
| 36 |
+
"konanMix Vpred": "https://huggingface.co/wsj1995/Checkpoint/resolve/main/1365468/1542670/konanmixnoobvPredNoob_v10.safetensors",
|
| 37 |
+
"Nova Anime XL": "https://huggingface.co/Chattiori/ChattioriMixesXL/resolve/main/NovaAnimeILV8.safetensors",
|
| 38 |
+
"Illustrious XL personal merge": "https://huggingface.co/nnnn1111/models/resolve/main/illustriousXLPersonalMerge_v30Noob10based.safetensors",
|
| 39 |
+
"Illustrious XL personal merge vpred": "https://huggingface.co/datasets/John6666/model-mirror-14/resolve/main/illustriousXLPersonalMerge_vp05testLowsteps.safetensors",
|
| 40 |
+
"Ikastrious": "https://civitaiarchive.com/api/download/models/2471934",
|
| 41 |
+
"Ikastrious Noobai": "https://huggingface.co/minaiosu/giko/resolve/main/ikastrious_v95.safetensors",
|
| 42 |
+
"RouWei": "https://civitaiarchive.com/api/download/models/1832460",
|
| 43 |
+
"RouWei Vpred": "https://huggingface.co/WhiteAiZ/RouWei/resolve/main/rouwei_v080Vpred.safetensors",
|
| 44 |
+
"PlantMint Walnut": "https://huggingface.co/wsj1995/Checkpoint/resolve/main/1162518/1714002/plantMilkModelSuite_walnut.safetensors"
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
PRESET_VAES = {
|
| 48 |
+
"sdxl_vae": "https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors",
|
| 49 |
+
"sdxl_vae_fix": "https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors",
|
| 50 |
+
"sdxl_anime_vae": "https://huggingface.co/Anzhc/Anzhcs-VAEs/resolve/main/SDXL%20Anime%20VAE%20Dec-only%20B3.safetensors",
|
| 51 |
+
"sdxl_neptunia_vae": "https://huggingface.co/JustAnotherCibrarian/vae/resolve/main/1290283/1455983/neptuniaXLILNAIVAE_contrastColors.safetensors",
|
| 52 |
+
"sdxl_luna_vae": "https://huggingface.co/yuu062/tameshi/resolve/main/lunaXLVAE_luna.safetensors"
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
PRESET_UPSCALERS = {
|
| 56 |
+
"AnimeSharp": "https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth",
|
| 57 |
+
"UltraSharp": "https://huggingface.co/lokCX/4x-Ultrasharp/resolve/main/4x-UltraSharp.pth",
|
| 58 |
+
"Remacri": "https://huggingface.co/LyliaEngine/remacri_original/resolve/main/remacri_original.pt",
|
| 59 |
+
"RealESRGAN_x4plus_anime": "https://huggingface.co/gemasai/RealESRGAN_x4plus_anime_6B/resolve/main/RealESRGAN_x4plus_anime_6B.pth",
|
| 60 |
+
"JaNai": "https://huggingface.co/halllooo/4x_illustrationJaNaiV1/resolve/main/4x_IllustrationJaNai_V1_ESRGAN_135k.pth",
|
| 61 |
+
"YandereNeoXL": "https://huggingface.co/kaeru-shigure/mlx-4x_NMKD-YandereNeoXL_200k/resolve/main/4x_NMKD-YandereNeoXL_200k.safetensors"
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
PRESET_CONTROLNETS = {
|
| 65 |
+
"Controlnet Union Pro Max": "https://huggingface.co/xinsir/controlnet-union-sdxl-1.0/resolve/main/diffusion_pytorch_model_promax.safetensors",
|
| 66 |
+
"Controlnet Lite (Todos)": "https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_sketch.safetensors, https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_softedge.safetensors, https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_dw_openpose.safetensors, https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_canny.safetensors, https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_depth_V2.safetensors, https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/bdsqlsz_controlllite_xl_lineart_anime_denoise.safetensors"
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
# --- Elementos de la Interfaz ---
|
| 70 |
+
out_console = widgets.Output(layout={'border': '1px solid #ccc', 'padding': '10px', 'margin': '10px 0', 'height': '250px', 'overflow': 'auto'})
|
| 71 |
+
|
| 72 |
+
token_input = widgets.Password(
|
| 73 |
+
value=token_guardado,
|
| 74 |
+
placeholder='Ingresa tu API Token (Opcional pero recomendado)',
|
| 75 |
+
description='Civitai Token:',
|
| 76 |
+
style={'description_width': 'initial'},
|
| 77 |
+
layout=widgets.Layout(width='500px')
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# Widgets de Progreso
|
| 81 |
+
progress_bar = widgets.IntProgress(
|
| 82 |
+
value=0, min=0, max=100,
|
| 83 |
+
description='Progreso:',
|
| 84 |
+
bar_style='info',
|
| 85 |
+
orientation='horizontal',
|
| 86 |
+
layout=widgets.Layout(width='80%', display='none')
|
| 87 |
+
)
|
| 88 |
+
status_label = widgets.Label(value="", layout=widgets.Layout(display='none'))
|
| 89 |
+
progress_container = widgets.VBox([progress_bar, status_label])
|
| 90 |
+
|
| 91 |
+
def ejecutar_con_progreso(cmd, is_gdown=False):
|
| 92 |
+
progress_bar.value = 0
|
| 93 |
+
progress_bar.layout.display = 'flex'
|
| 94 |
+
status_label.layout.display = 'flex'
|
| 95 |
+
status_label.value = "Iniciando descarga..."
|
| 96 |
+
|
| 97 |
+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1, universal_newlines=True)
|
| 98 |
+
|
| 99 |
+
for line in process.stdout:
|
| 100 |
+
if not is_gdown:
|
| 101 |
+
match_pct = re.search(r'\((\d+)%\)', line)
|
| 102 |
+
if match_pct:
|
| 103 |
+
progress_bar.value = int(match_pct.group(1))
|
| 104 |
+
|
| 105 |
+
match_speed = re.search(r'DL:([^\s]+)', line)
|
| 106 |
+
if match_speed:
|
| 107 |
+
status_label.value = f"Descargando... Velocidad: {match_speed.group(1)}"
|
| 108 |
+
else:
|
| 109 |
+
match_pct = re.search(r'(\d{1,3})%', line)
|
| 110 |
+
if match_pct:
|
| 111 |
+
progress_bar.value = int(match_pct.group(1))
|
| 112 |
+
status_label.value = "Descargando con gdown..."
|
| 113 |
+
|
| 114 |
+
process.wait()
|
| 115 |
+
progress_bar.value = 100
|
| 116 |
+
progress_bar.bar_style = 'success'
|
| 117 |
+
status_label.value = "¡Descarga de este archivo completada! ✅"
|
| 118 |
+
|
| 119 |
+
def procesar_descarga(b, url_widget, method_widget, dest_path):
|
| 120 |
+
raw_urls = url_widget.value.strip()
|
| 121 |
+
method = method_widget.value
|
| 122 |
+
token = token_input.value.strip()
|
| 123 |
+
|
| 124 |
+
urls = [u.strip() for u in raw_urls.split(",") if u.strip()]
|
| 125 |
+
|
| 126 |
+
if not urls:
|
| 127 |
+
with out_console:
|
| 128 |
+
clear_output()
|
| 129 |
+
display(HTML("<h4 style='color:red;'>⚠️ Por favor, ingresa al menos una URL válida.</h4>"))
|
| 130 |
+
return
|
| 131 |
+
|
| 132 |
+
with out_console:
|
| 133 |
+
clear_output()
|
| 134 |
+
display(HTML(f"<h2>🚀 Iniciando cola de descarga: {len(urls)} archivo(s)</h2>"))
|
| 135 |
+
|
| 136 |
+
for i, url in enumerate(urls, 1):
|
| 137 |
+
progress_bar.bar_style = 'info'
|
| 138 |
+
progress_bar.value = 0
|
| 139 |
+
status_label.value = f"Preparando archivo {i} de {len(urls)}..."
|
| 140 |
+
|
| 141 |
+
download_url = url
|
| 142 |
+
if ("civitai.com" in url or "civitaiarchive.com" in url) and token:
|
| 143 |
+
download_url = f"{url}{'&' if '?' in url else '?'}token={token}"
|
| 144 |
+
|
| 145 |
+
# --- 1. Extraer el nombre del modelo ANTES de descargar ---
|
| 146 |
+
pretty_name = "Desconocido"
|
| 147 |
+
|
| 148 |
+
# Regla especial para Controlnet Union Pro Max
|
| 149 |
+
if url == "https://huggingface.co/xinsir/controlnet-union-sdxl-1.0/resolve/main/diffusion_pytorch_model_promax.safetensors":
|
| 150 |
+
pretty_name = "Controlnet_Union_Pro_Max.safetensors"
|
| 151 |
+
elif method == 'aria2':
|
| 152 |
+
if "civitai.com" in url or "civitaiarchive.com" in url:
|
| 153 |
+
try:
|
| 154 |
+
with requests.get(download_url, stream=True, timeout=5) as r:
|
| 155 |
+
cd = r.headers.get('Content-Disposition', '')
|
| 156 |
+
match = re.findall(r'filename[*]?=(?:UTF-8\'\')?["\']?([^"\';]+)["\']?', cd)
|
| 157 |
+
if match:
|
| 158 |
+
pretty_name = match[0]
|
| 159 |
+
else:
|
| 160 |
+
pretty_name = url.split('/')[-1].split('?')[0]
|
| 161 |
+
except Exception:
|
| 162 |
+
pretty_name = url.split('/')[-1].split('?')[0]
|
| 163 |
+
else:
|
| 164 |
+
pretty_name = url.split('/')[-1].split('?')[0]
|
| 165 |
+
elif method == 'gdown':
|
| 166 |
+
pretty_name = "Archivo de Google Drive (Gdown gestiona el nombre)"
|
| 167 |
+
|
| 168 |
+
# --- 2. Mostrar la información en la consola usando HTML ---
|
| 169 |
+
with out_console:
|
| 170 |
+
display(HTML(f"<hr><h3 style='color:#D4AF37;'>📥 [{i}/{len(urls)}] Descargando: <code>{pretty_name}</code></h3>"))
|
| 171 |
+
display(HTML(f"<h4 style='color:#4682B4;'>📁 Destino: <code>{dest_path}</code></h4>"))
|
| 172 |
+
|
| 173 |
+
if ("civitai.com" in url or "civitaiarchive.com" in url) and token:
|
| 174 |
+
print("🔑 Token detectado y aplicado desde el gestor.")
|
| 175 |
+
elif ("civitai.com" in url or "civitaiarchive.com" in url) and not token:
|
| 176 |
+
print("⚠️ Descargando sin token (algunos modelos pueden requerirlo).")
|
| 177 |
+
|
| 178 |
+
# --- 3. Ejecutar la descarga ---
|
| 179 |
+
if method == 'aria2':
|
| 180 |
+
cmd = [
|
| 181 |
+
"aria2c", "--content-disposition",
|
| 182 |
+
"-c", "-x", "16", "-s", "16", "-k", "1M",
|
| 183 |
+
"--summary-interval=1", "-d", dest_path
|
| 184 |
+
]
|
| 185 |
+
|
| 186 |
+
# Forzamos el nombre si existe y no es de civitai
|
| 187 |
+
if pretty_name and pretty_name != "Desconocido" and "civitai.com" not in url and "civitaiarchive.com" not in url:
|
| 188 |
+
cmd.extend(["-o", pretty_name, url])
|
| 189 |
+
else:
|
| 190 |
+
cmd.append(download_url)
|
| 191 |
+
|
| 192 |
+
ejecutar_con_progreso(cmd, is_gdown=False)
|
| 193 |
+
|
| 194 |
+
if "huggingface.co" in url and pretty_name:
|
| 195 |
+
for f in os.listdir(dest_path):
|
| 196 |
+
if re.fullmatch(r'[0-9a-f]{64}', f):
|
| 197 |
+
os.rename(os.path.join(dest_path, f), os.path.join(dest_path, pretty_name))
|
| 198 |
+
break
|
| 199 |
+
|
| 200 |
+
elif method == 'gdown':
|
| 201 |
+
cmd = ["gdown", "--fuzzy", url, "-O", f"{dest_path}/"]
|
| 202 |
+
ejecutar_con_progreso(cmd, is_gdown=True)
|
| 203 |
+
|
| 204 |
+
with out_console:
|
| 205 |
+
display(HTML("<hr><h2 style='color:lightgreen;'>✅ ¡Todas las descargas han finalizado!</h2>"))
|
| 206 |
+
|
| 207 |
+
# --- Pestaña 1: Modelos Base ---
|
| 208 |
+
opciones_presets_base = ['-- Personalizado / Manual --'] + list(PRESET_MODELS.keys())
|
| 209 |
+
preset_base_dropdown = widgets.Dropdown(options=opciones_presets_base, value='-- Personalizado / Manual --', description='Favoritos:', layout=widgets.Layout(width='80%'))
|
| 210 |
+
base_url = widgets.Text(placeholder='https://url1, https://url2, ...', description='URL:', layout=widgets.Layout(width='80%'))
|
| 211 |
+
|
| 212 |
+
def actualizar_url_base(change):
|
| 213 |
+
seleccion = change['new']
|
| 214 |
+
if seleccion in PRESET_MODELS:
|
| 215 |
+
base_url.value = PRESET_MODELS[seleccion]
|
| 216 |
+
else:
|
| 217 |
+
base_url.value = ""
|
| 218 |
+
|
| 219 |
+
preset_base_dropdown.observe(actualizar_url_base, names='value')
|
| 220 |
+
|
| 221 |
+
base_method = widgets.Dropdown(options=['aria2', 'gdown'], value='aria2', description='Método:')
|
| 222 |
+
base_btn = widgets.Button(description='Descargar Modelos', button_style='primary', icon='download')
|
| 223 |
+
base_btn.on_click(lambda b: procesar_descarga(b, base_url, base_method, BASE_MODELS_DIR))
|
| 224 |
+
|
| 225 |
+
tab_base = widgets.VBox([
|
| 226 |
+
widgets.HTML("<h4>Descargar Modelos (Checkpoints)</h4><p>Elige un modelo favorito o pega enlaces separados por comas (,)</p>"),
|
| 227 |
+
preset_base_dropdown,
|
| 228 |
+
widgets.HBox([base_url, base_method]),
|
| 229 |
+
base_btn
|
| 230 |
+
])
|
| 231 |
+
|
| 232 |
+
# --- Pestaña 2: LoRAs ---
|
| 233 |
+
lora_url = widgets.Text(placeholder='https://url1, https://url2, ...', description='URLs:', layout=widgets.Layout(width='80%'))
|
| 234 |
+
lora_method = widgets.Dropdown(options=['aria2', 'gdown'], value='aria2', description='Método:')
|
| 235 |
+
lora_btn = widgets.Button(description='Descargar LoRAs', button_style='success', icon='download')
|
| 236 |
+
lora_btn.on_click(lambda b: procesar_descarga(b, lora_url, lora_method, LORA_DIR))
|
| 237 |
+
|
| 238 |
+
tab_lora = widgets.VBox([
|
| 239 |
+
widgets.HTML("<h4>Descargar LoRAs</h4><p>Pega múltiples URLs separadas por comas (,)</p>"),
|
| 240 |
+
widgets.HBox([lora_url, lora_method]),
|
| 241 |
+
lora_btn
|
| 242 |
+
])
|
| 243 |
+
|
| 244 |
+
# --- Pestaña 3: VAEs ---
|
| 245 |
+
opciones_presets_vae = ['-- Personalizado / Manual --'] + list(PRESET_VAES.keys())
|
| 246 |
+
preset_vae_dropdown = widgets.Dropdown(options=opciones_presets_vae, value='-- Personalizado / Manual --', description='Favoritos:', layout=widgets.Layout(width='80%'))
|
| 247 |
+
vae_url = widgets.Text(placeholder='https://url1, https://url2, ...', description='URL:', layout=widgets.Layout(width='80%'))
|
| 248 |
+
|
| 249 |
+
def actualizar_url_vae(change):
|
| 250 |
+
seleccion = change['new']
|
| 251 |
+
if seleccion in PRESET_VAES:
|
| 252 |
+
vae_url.value = PRESET_VAES[seleccion]
|
| 253 |
+
else:
|
| 254 |
+
vae_url.value = ""
|
| 255 |
+
|
| 256 |
+
preset_vae_dropdown.observe(actualizar_url_vae, names='value')
|
| 257 |
+
|
| 258 |
+
vae_method = widgets.Dropdown(options=['aria2', 'gdown'], value='aria2', description='Método:')
|
| 259 |
+
vae_btn = widgets.Button(description='Descargar VAEs', button_style='info', icon='download')
|
| 260 |
+
vae_btn.on_click(lambda b: procesar_descarga(b, vae_url, vae_method, VAE_DIR))
|
| 261 |
+
|
| 262 |
+
tab_vae = widgets.VBox([
|
| 263 |
+
widgets.HTML("<h4>Descargar VAEs</h4><p>Elige un VAE favorito o pega enlaces separados por comas (,)</p>"),
|
| 264 |
+
preset_vae_dropdown,
|
| 265 |
+
widgets.HBox([vae_url, vae_method]),
|
| 266 |
+
vae_btn
|
| 267 |
+
])
|
| 268 |
+
|
| 269 |
+
# --- Pestaña 4: Upscalers ---
|
| 270 |
+
opciones_presets_upscalers = ['-- Personalizado / Manual --', '-- Descargar Todos --'] + list(PRESET_UPSCALERS.keys())
|
| 271 |
+
preset_upscaler_dropdown = widgets.Dropdown(options=opciones_presets_upscalers, value='-- Personalizado / Manual --', description='Favoritos:', layout=widgets.Layout(width='80%'))
|
| 272 |
+
upscaler_url = widgets.Text(placeholder='https://url1, https://url2, ...', description='URL:', layout=widgets.Layout(width='80%'))
|
| 273 |
+
|
| 274 |
+
def actualizar_url_upscaler(change):
|
| 275 |
+
seleccion = change['new']
|
| 276 |
+
if seleccion == '-- Descargar Todos --':
|
| 277 |
+
upscaler_url.value = ", ".join(PRESET_UPSCALERS.values())
|
| 278 |
+
elif seleccion in PRESET_UPSCALERS:
|
| 279 |
+
upscaler_url.value = PRESET_UPSCALERS[seleccion]
|
| 280 |
+
else:
|
| 281 |
+
upscaler_url.value = ""
|
| 282 |
+
|
| 283 |
+
preset_upscaler_dropdown.observe(actualizar_url_upscaler, names='value')
|
| 284 |
+
|
| 285 |
+
upscaler_method = widgets.Dropdown(options=['aria2', 'gdown'], value='aria2', description='Método:')
|
| 286 |
+
upscaler_btn = widgets.Button(description='Descargar Upscalers', button_style='warning', icon='download')
|
| 287 |
+
upscaler_btn.on_click(lambda b: procesar_descarga(b, upscaler_url, upscaler_method, UPSCALER_DIR))
|
| 288 |
+
|
| 289 |
+
tab_upscaler = widgets.VBox([
|
| 290 |
+
widgets.HTML("<h4>Descargar Upscalers (ESRGAN)</h4><p>Elige un upscaler, selecciona <b>'-- Descargar Todos --'</b>, o pega enlaces separados por comas (,)</p>"),
|
| 291 |
+
preset_upscaler_dropdown,
|
| 292 |
+
widgets.HBox([upscaler_url, upscaler_method]),
|
| 293 |
+
upscaler_btn
|
| 294 |
+
])
|
| 295 |
+
|
| 296 |
+
# --- Pestaña 5: ControlNet ---
|
| 297 |
+
opciones_presets_controlnet = ['-- Personalizado / Manual --'] + list(PRESET_CONTROLNETS.keys())
|
| 298 |
+
preset_controlnet_dropdown = widgets.Dropdown(options=opciones_presets_controlnet, value='-- Personalizado / Manual --', description='Favoritos:', layout=widgets.Layout(width='80%'))
|
| 299 |
+
controlnet_url = widgets.Text(placeholder='https://url1, https://url2, ...', description='URL:', layout=widgets.Layout(width='80%'))
|
| 300 |
+
|
| 301 |
+
def actualizar_url_controlnet(change):
|
| 302 |
+
seleccion = change['new']
|
| 303 |
+
if seleccion in PRESET_CONTROLNETS:
|
| 304 |
+
controlnet_url.value = PRESET_CONTROLNETS[seleccion]
|
| 305 |
+
else:
|
| 306 |
+
controlnet_url.value = ""
|
| 307 |
+
|
| 308 |
+
preset_controlnet_dropdown.observe(actualizar_url_controlnet, names='value')
|
| 309 |
+
|
| 310 |
+
controlnet_method = widgets.Dropdown(options=['aria2', 'gdown'], value='aria2', description='Método:')
|
| 311 |
+
controlnet_btn = widgets.Button(description='Descargar ControlNet', button_style='danger', icon='download')
|
| 312 |
+
controlnet_btn.on_click(lambda b: procesar_descarga(b, controlnet_url, controlnet_method, CONTROLNET_DIR))
|
| 313 |
+
|
| 314 |
+
tab_controlnet = widgets.VBox([
|
| 315 |
+
widgets.HTML("<h4>Descargar Modelos ControlNet</h4><p>Elige el Pro Max, el paquete Lite, o pega enlaces separados por comas (,)</p>"),
|
| 316 |
+
preset_controlnet_dropdown,
|
| 317 |
+
widgets.HBox([controlnet_url, controlnet_method]),
|
| 318 |
+
controlnet_btn
|
| 319 |
+
])
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
# --- Ensamblar Interfaz ---
|
| 323 |
+
tabs = widgets.Tab(children=[tab_base, tab_lora, tab_vae, tab_upscaler, tab_controlnet])
|
| 324 |
+
tabs.set_title(0, '📦 Modelos Base')
|
| 325 |
+
tabs.set_title(1, '✨ LoRAs')
|
| 326 |
+
tabs.set_title(2, '🎨 VAEs')
|
| 327 |
+
tabs.set_title(3, '🔍 Upscalers')
|
| 328 |
+
tabs.set_title(4, '🕹️ ControlNet')
|
| 329 |
+
|
| 330 |
+
if token_guardado:
|
| 331 |
+
mensaje_token = "<i>(✅ Token cargado automáticamente desde la memoria)</i>"
|
| 332 |
+
else:
|
| 333 |
+
mensaje_token = "<i>(⚠️ No se encontró token guardado, puedes ingresarlo manualmente)</i>"
|
| 334 |
+
|
| 335 |
+
ui = widgets.VBox([
|
| 336 |
+
widgets.HTML("<h2>Gestor de Descargas para SD Forge Classic</h2>"),
|
| 337 |
+
widgets.HBox([token_input, widgets.HTML(mensaje_token)]),
|
| 338 |
+
tabs,
|
| 339 |
+
widgets.HTML("<hr>"),
|
| 340 |
+
progress_container,
|
| 341 |
+
out_console
|
| 342 |
+
])
|
| 343 |
+
|
| 344 |
+
display(ui)
|