File size: 16,712 Bytes
dd73c39 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
{
"cells": [
{
"cell_type": "markdown",
"id": "ab7d1636-c632-4fc6-9969-86bf146c7b89",
"metadata": {
"tags": []
},
"source": [
"### General HunterDesigner Notebook Actualizado V.1.0\n",
"[](https://www.facebook.com/jhilmitar/)\n",
"[](https://www.facebook.com/hunterdesignerbol)\n",
"[](https://www.facebook.com/hunterdesignerbol)\n",
"<img src=\"https://emoji.discadia.com/emojis/00b5ebd1-84cf-41dd-a3bd-91c59f31bd70.PNG\" width=\"20\" height=\"20\"/>\n",
"<img src=\"https://emoji.discadia.com/emojis/00b5ebd1-84cf-41dd-a3bd-91c59f31bd70.PNG\" width=\"20\" height=\"20\"/>\n",
"<img src=\"https://i.pinimg.com/originals/7d/07/a2/7d07a255678962d30d8717dcf5dbd266.gif\" width=60% height=50%> \n",
"> ¡Hola! Si tienes algún problema al ejecutar este Notebook, no dudes en contactarme. Estoy abierto a sugerencias y modificaciones para crear una comunidad más libre. ¡Será un placer ayudarte! <img src=\"https://emoji.discadia.com/emojis/bdf70476-e7fb-41dd-9341-b28608e7f00d.GIF\" width=\"20\" height=\"20\"/>\n",
"<font color=\"#1AC851\"><br>\n",
"<small><font color=gray> v27-09-23A </small></font></font>\n"
]
},
{
"cell_type": "markdown",
"id": "2a86fcac-7907-4ab9-8287-d21b241e1b89",
"metadata": {},
"source": [
"### <img src=\"https://cdn3.emoji.gg/emojis/2868-announcement.gif\" width=\"25\" height=\"25\"> SESION VIVA EN ANDROID\n",
"#### Ejecute esta celda para mantener viva la pestaña en el dispositivo móvil (antes de ejecutar la celda de inicio)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8dc184cd-25e2-48b1-bdfb-d7b2ef6c0056",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%html\n",
"<b>Presione reproducir en el reproductor de música para mantener viva la pestaña antes de ejecutar la celda de inicio (usa solo 13 MB de datos)</b><br/>\n",
"<audio src=\"https://raw.githubusercontent.com/KoboldAI/KoboldAI-Client/main/colab/silence.m4a\" controls>"
]
},
{
"cell_type": "markdown",
"id": "dfd4fb94-9951-40ab-be3a-f9641e782b62",
"metadata": {},
"source": [
"### <img src=\"https://emoji.discadia.com/emojis/788f3a39-7ecf-4aee-bac0-d7c0dbbf02a3.gif\" width=\"25\" height=\"25\"> EMPEZAR AQUÍ \n",
"#### Si ya usaste este Notebook antes en la sesión actual, verifica que la carpeta `sdf_web` no se encuentre para poder ejecutar el código de abajo. Si ya está en tu sesión, puedes saltar a la celda de **Inicio Rápido**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c1d32b2-c01c-4e10-82a4-591cd87d9c05",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"import time\n",
"import zipfile\n",
"import datetime\n",
"from IPython.display import HTML, clear_output, display\n",
"from IPython.utils import capture\n",
"\n",
"commandline_arguments = \" --ngrok 2VOvWtXsocjLqHIBaECsKoW3rgE_2qyjkyz66CJYLNHmZbAGt --skip-torch-cuda-test --enable-insecure-extension-access --opt-sdp-attention --listen --no-half-vae --disable-safe-unpickle --disable-nan-check --theme dark --no-hashing --gradio-queue\"\n",
"try:\n",
" start_colab\n",
"except:\n",
" start_colab = int(time.time())-5\n",
"clear_output()\n",
"inicio = time.time()\n",
"!pwd \n",
"\n",
"# Obtener la ruta actual\n",
"ruta_actual = os.getcwd()\n",
"\n",
"# CONFIG DIR (not recommended to change unless you know what you're doing)\n",
"models_dir = f\"/home/studio-lab-user/sdf_web/models/Stable-diffusion\"\n",
"source_dir = f\"/home/studio-lab-user/sdf_web\"\n",
"# ---------------------------------------------------------------------\n",
"\n",
"print(\"🚀 Descargando SD modificado por HunterDesigner... Por favor, no detengas este proceso bajo ninguna circunstancia...\\n\", end='')\n",
"if not os.path.exists(source_dir):\n",
" with capture.capture_output() as cap:\n",
" !conda install -c conda-forge libglib -y & conda update -n base conda -y\n",
" !pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio===2.0.2+cu118 -f https://download.pytorch.org/whl/cu118/torch_stable.html\n",
" !wget https://huggingface.co/datasets/HUNTERDEBASTADOR/models2/resolve/main/sdf_web.zip\n",
" with zipfile.ZipFile('sdf_web.zip', 'r') as zip_ref:\n",
" zip_ref.extractall('')\n",
" !pip install pytorch_lightning gradio omegaconf safetensors kornia tqdm mutagen ngrok ultralytics\n",
" !rm -r sdf_web.zip\n",
" del cap\n",
"\n",
" # Colab 🤝 Gradio (Colab timer integration for gradio) by NoCrypt\n",
" !echo -n {start_colab} > /home/studio-lab-user/sdf_web/static/colabTimer.txt\n",
"\n",
" \n",
"clear_output()"
]
},
{
"cell_type": "markdown",
"id": "656cb7e3",
"metadata": {},
"source": [
"### <img src=\"https://cdn3.emoji.gg/emojis/7555-cowroll.gif\" width=\"25\" height=\"25\"> **MODELOS REALISTAS**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0fe8c3a4",
"metadata": {},
"outputs": [],
"source": [
"#Model CARGAR MODELOS Y LORAS\n",
" print(\"📦 Descargando Modelos de HunterDesigner\\n\", end='')\n",
"!conda install -y -c conda-forge libglib ffmpeg aria2\n",
"!pip install mediapipe\n",
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/145885 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o epiCPhotoGasm.safetensors\n",
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/126344 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o OMEGACENTAURI.safetensors\n",
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/51913 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o EdgeOfRealism.safetensors\n",
"#!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/130072 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o RealisticVisionV5.safetensors\n",
"#!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/160495 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o AnalogMadnessv6.safetensors\n",
"#!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/143906 -d /home/studio-lab-user/sdf_web/models/Stable-diffusion/ -o EpicRealism_v5.safetensors\n",
"\n",
"\n",
"##epiCPhotoGasm\n",
"#https://civitai.com/api/download/models/145885\n",
"##OMEGA CENTAURI\n",
"#https://civitai.com/api/download/models/126344\n",
"##Edge Of Realism fp16 baked VAE\n",
"#https://civitai.com/api/download/models/51913\n",
"##Realistic Vision V5.1\n",
"#https://civitai.com/api/download/models/130072\n",
"##Analog Madness v6\n",
"#https://civitai.com/api/download/models/160495\n",
"##EPICREALISM 5\n",
"#https://civitai.com/api/download/models/143906\n",
"##CyberRealistic V3\n",
"#https://civitai.com/api/download/models/138176\n",
"\n",
"#Lora\n",
"%cd /home/studio-lab-user/sdf_web/models/Lora\n",
"!curl -Lo /home/studio-lab-user/sdf_web/models/Lora/add_detail.safetensors https://huggingface.co/Kizi-Art/Lora-Clone/resolve/main/add_detail.safetensors\n",
"!wget --content-disposition https://civitai.com/api/download/models/128212\n",
"!wget --content-disposition https://civitai.com/api/download/models/128752\n",
"!wget --content-disposition https://civitai.com/api/download/models/179730\n",
"!wget --content-disposition https://civitai.com/api/download/models/87153\n",
"!wget --content-disposition https://civitai.com/api/download/models/171989\n",
"!wget --content-disposition https://civitai.com/api/download/models/46885\n",
"!wget --content-disposition https://civitai.com/api/download/models/129643\n",
"!wget --content-disposition https://civitai.com/api/download/models/109808\n",
"!wget --content-disposition https://civitai.com/api/download/models/62833\n",
"!wget --content-disposition https://civitai.com/api/download/models/95006\n",
"!curl -Lo /home/studio-lab-user/sdf_web/models/Lora/ https://huggingface.co/gemasai/FilmG2/resolve/main/FilmG2.safetensors\n",
"!wget --content-disposition https://civitai.com/api/download/models/16576\n",
"\n",
"#VAE\n",
"!curl -Lo /home/studio-lab-user/sdf_web/models/VAE/kl-f8-anime2.ckpt https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt\n",
"!curl -Lo /home/studio-lab-user/sdf_web/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.ckpt\n",
"clear_output()\n",
"print(\"📦 Se Descargo exitosamente todos los modelos\\n\", end='')"
]
},
{
"cell_type": "markdown",
"id": "ad2befe3-2b7f-45c4-a1b6-24696fc56d47",
"metadata": {},
"source": [
"### <img src=\"https://cdn3.emoji.gg/emojis/7555-cowroll.gif\" width=\"25\" height=\"25\"> **Inicio Rápido**\n",
"#### Usa esta celda para iniciar Stable Diffusion si ya está descargado. Puedes iniciar aquí cuando se detiene la celda anterior."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4fe92b97-071d-4da5-8fc2-b6e289625b33",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"import time\n",
"import datetime\n",
"from IPython.display import clear_output\n",
"\n",
"try:\n",
" start_colab\n",
"except:\n",
" start_colab = int(time.time()) - 5\n",
"!pip install pytorch_lightning gradio omegaconf safetensors kornia tqdm mutagen ngrok ultralytics\n",
"clear_output()\n",
"\n",
"ruta_actual = os.getcwd()\n",
"\n",
"# CONFIG DIR (not recommended to change unless you know what you're doing)\n",
"models_dir = f\"/home/studio-lab-user/sdf_web/models/Stable-diffusion\"\n",
"source_dir = f\"/home/studio-lab-user/sdf_web/\"\n",
"\n",
"inicio = time.time()\n",
"!echo -n {start_colab} > /home/studio-lab-user/sdf_web/static/colabTimer.txt\n",
"\n",
"print(\"✅ Iniciando Stable Diffusion by HunterDesigner\\n\", end='')\n",
"%cd /home/studio-lab-user/sdf_web/\n",
"!python webui.py --ngrok 2VOvWtXsocjLqHIBaECsKoW3rgE_2qyjkyz66CJYLNHmZbAGt --skip-torch-cuda-test --enable-insecure-extension-access --opt-sdp-attention --listen --no-half-vae --disable-safe-unpickle --disable-nan-check --theme dark --no-hashing --gradio-queue"
]
},
{
"cell_type": "markdown",
"id": "9c02e956-5769-4be9-96e9-fea479706e91",
"metadata": {},
"source": [
"### Descarga todas las imagenes generadas"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fdeece9b-7e0a-4c93-aec2-6d96b95cdc84",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Descargar y comprimir todas las salidas\n",
"import zipfile\n",
"import os\n",
"\n",
"def create_zip_archive(source_dir, output_path):\n",
" with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:\n",
" for root, dirs, files in os.walk(source_dir):\n",
" for file in files:\n",
" file_path = os.path.join(root, file)\n",
" zipf.write(file_path, os.path.relpath(file_path, source_dir))\n",
"\n",
"# Especificar el directorio de origen y la ruta de salida\n",
"source_dir = '/home/studio-lab-user/sdf_web/outputs'\n",
"output_path = '/home/studio-lab-user/outputs.zip'\n",
"\n",
"# Crear el archivo ZIP\n",
"create_zip_archive(source_dir, output_path)"
]
},
{
"cell_type": "markdown",
"id": "364e78a6-1b16-4336-8439-c0eb0b94c4ed",
"metadata": {},
"source": [
"# <font color=\"red\"> Estas celdas solo son para el mantenimiento del Notebook </font> - \n",
"# NO sirven para ejecutar ninguna función relacionada con Stable Diffusion"
]
},
{
"cell_type": "markdown",
"id": "c12aa52e-fc8c-4480-826b-e9a9573bcee5",
"metadata": {},
"source": [
"### Compruebe el almacenamiento disponible (si el almacenamiento está lleno, puede causar problemas)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "439692fe-f99d-4703-aa6d-27a8bcc8a775",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!df -h | grep -E 'Avail|home'"
]
},
{
"cell_type": "markdown",
"id": "e2379128-f432-4226-a011-3a61005ddd08",
"metadata": {},
"source": [
"## Eliminar y vaciar la carpeta `OUTPUT`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8a56c3a-f0af-4c87-bf83-c99942a3a3b0",
"metadata": {},
"outputs": [],
"source": [
"!rm -rf /home/studio-lab-user/sdf_web/outputs/*"
]
},
{
"cell_type": "markdown",
"id": "510f601a-173e-4806-b05f-15902c65e717",
"metadata": {},
"source": [
"## Eliminar y vaciar la carpeta `MODELS`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8ac13a1e-906a-4da8-b98b-0e300ab5b8b4",
"metadata": {},
"outputs": [],
"source": [
"!rm -rf /home/studio-lab-user/sdf_web/models/Stable-diffusion/*"
]
},
{
"cell_type": "markdown",
"id": "1d0a3313-0c65-44ef-b89e-459fa779e84b",
"metadata": {},
"source": [
"### COMIENCE A LIMPIAR TODO SOLO SI TIENE UN <font color=\"red\"> ERROR </font>"
]
},
{
"cell_type": "markdown",
"id": "a3996dac",
"metadata": {},
"source": [
"#### Compruebe el almacenamiento disponible (si el almacenamiento está lleno, puede causar problemas)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ad6a08b-34a4-4a73-b618-38715a895bd2",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!df -h | grep -E 'Avail|home'"
]
},
{
"cell_type": "markdown",
"id": "381279ee",
"metadata": {},
"source": [
"#### Lista todas las carpetas y tamaños"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aaea3473-1ac6-40d8-98c2-a29386ca147e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!du -h --max-depth=1 /home/studio-lab-user/"
]
},
{
"cell_type": "markdown",
"id": "26239982",
"metadata": {},
"source": [
"#### Limpiar eliminar todo, caché y Stable Diffusion"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab02c781-46ea-4f07-8c4b-f329069d903b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!rm -r /home/studio-lab-user/sdf_web\n",
"!rm -r /home/studio-lab-user/.cache\n",
"!rm -r /home/studio-lab-user/.conda"
]
},
{
"cell_type": "markdown",
"id": "7b0f500d-0af2-457b-bc13-fb222f675832",
"metadata": {},
"source": [
"### Crear el `env` si fue eliminado"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98a14c37-58e5-4ca6-9fe9-02f14ff707c3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!conda create --name default -y\n",
"!conda install -c conda-forge libglib -y"
]
},
{
"cell_type": "markdown",
"id": "49cb0194-771e-46ef-a274-bcd34fd55b74",
"metadata": {},
"source": [
"### Muestra la version actual de `Torch` y `Torchvision` con su version de `Cuda`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47d905dd-a987-459a-8d28-3d2294203541",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import torch\n",
"import torchvision\n",
"print(torch.__version__)\n",
"print(torchvision.__version__)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "default:Python",
"language": "python",
"name": "conda-env-default-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|