add turbo models and kohaku with lightning emoji indicators
Browse files
README.md
CHANGED
|
@@ -76,6 +76,10 @@ Ver `requirements.txt` para la lista completa de dependencias.
|
|
| 76 |
- **FLUX.1 Schnell** ⭐
|
| 77 |
- **FLUX.1 Dev** ⭐
|
| 78 |
- LDM Text2Im 256
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
### Videos
|
| 81 |
- Text-to-Video MS 1.7B
|
|
|
|
| 76 |
- **FLUX.1 Schnell** ⭐
|
| 77 |
- **FLUX.1 Dev** ⭐
|
| 78 |
- LDM Text2Im 256
|
| 79 |
+
- **⚡ SDXL Turbo** (Rápido)
|
| 80 |
+
- **⚡ SD Turbo** (Rápido)
|
| 81 |
+
- **⚡ SDXL Lightning** (Rápido)
|
| 82 |
+
- **🎨 Kohaku V2.1** (Estilo anime)
|
| 83 |
|
| 84 |
### Videos
|
| 85 |
- Text-to-Video MS 1.7B
|
app.py
CHANGED
|
@@ -79,7 +79,13 @@ MODELS = {
|
|
| 79 |
"black-forest-labs/FLUX.1-schnell": "FLUX.1 Schnell (Requiere acceso)",
|
| 80 |
"black-forest-labs/FLUX.1-dev": "FLUX.1 Dev (Requiere acceso)",
|
| 81 |
# ✅ Nuevos modelos de imagen
|
| 82 |
-
"CompVis/ldm-text2im-large-256": "Latent Diffusion Model 256"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
},
|
| 84 |
"video": {
|
| 85 |
"damo-vilab/text-to-video-ms-1.7b": "Text-to-Video MS 1.7B (Libre)",
|
|
@@ -252,6 +258,46 @@ def load_image_model(model_name):
|
|
| 252 |
safety_checker=None
|
| 253 |
)
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
# Configuración para otros modelos
|
| 256 |
else:
|
| 257 |
pipe = StableDiffusionPipeline.from_pretrained(
|
|
@@ -461,6 +507,36 @@ def generate_image(prompt, model_name, num_inference_steps=20):
|
|
| 461 |
max_sequence_length=256, # ✅ Reducido de 512 a 256 para ahorrar memoria
|
| 462 |
generator=torch.Generator("cpu").manual_seed(random_seed) # ✅ Seed aleatorio
|
| 463 |
).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
else:
|
| 465 |
# Configuración básica para otros modelos
|
| 466 |
image = pipeline(
|
|
|
|
| 79 |
"black-forest-labs/FLUX.1-schnell": "FLUX.1 Schnell (Requiere acceso)",
|
| 80 |
"black-forest-labs/FLUX.1-dev": "FLUX.1 Dev (Requiere acceso)",
|
| 81 |
# ✅ Nuevos modelos de imagen
|
| 82 |
+
"CompVis/ldm-text2im-large-256": "Latent Diffusion Model 256",
|
| 83 |
+
# ⚡ Modelos Turbo (rápidos)
|
| 84 |
+
"stabilityai/sdxl-turbo": "⚡ SDXL Turbo",
|
| 85 |
+
"stabilityai/sd-turbo": "⚡ SD Turbo",
|
| 86 |
+
"ByteDance/SDXL-Lightning": "⚡ SDXL Lightning",
|
| 87 |
+
# 🎨 Modelos adicionales
|
| 88 |
+
"KBlueLeaf/kohaku-v2.1": "Kohaku V2.1"
|
| 89 |
},
|
| 90 |
"video": {
|
| 91 |
"damo-vilab/text-to-video-ms-1.7b": "Text-to-Video MS 1.7B (Libre)",
|
|
|
|
| 258 |
safety_checker=None
|
| 259 |
)
|
| 260 |
|
| 261 |
+
# Configuración especial para modelos Turbo (rápidos)
|
| 262 |
+
elif any(turbo_model in model_name.lower() for turbo_model in ["sdxl-turbo", "sd-turbo", "sdxl-lightning"]):
|
| 263 |
+
try:
|
| 264 |
+
print("⚡ Cargando modelo Turbo...")
|
| 265 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 266 |
+
model_name,
|
| 267 |
+
torch_dtype=torch.float32,
|
| 268 |
+
safety_checker=None,
|
| 269 |
+
requires_safety_checker=False
|
| 270 |
+
)
|
| 271 |
+
print("✅ Modelo Turbo cargado exitosamente")
|
| 272 |
+
except Exception as e:
|
| 273 |
+
print(f"❌ Error cargando modelo Turbo: {e}")
|
| 274 |
+
# Fallback a Stable Diffusion
|
| 275 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 276 |
+
"CompVis/stable-diffusion-v1-4",
|
| 277 |
+
torch_dtype=torch.float32,
|
| 278 |
+
safety_checker=None
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
# Configuración especial para Kohaku
|
| 282 |
+
elif "kohaku" in model_name.lower():
|
| 283 |
+
try:
|
| 284 |
+
print("🎨 Cargando modelo Kohaku...")
|
| 285 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 286 |
+
model_name,
|
| 287 |
+
torch_dtype=torch.float32,
|
| 288 |
+
safety_checker=None,
|
| 289 |
+
requires_safety_checker=False
|
| 290 |
+
)
|
| 291 |
+
print("✅ Modelo Kohaku cargado exitosamente")
|
| 292 |
+
except Exception as e:
|
| 293 |
+
print(f"❌ Error cargando Kohaku: {e}")
|
| 294 |
+
# Fallback a Stable Diffusion
|
| 295 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 296 |
+
"CompVis/stable-diffusion-v1-4",
|
| 297 |
+
torch_dtype=torch.float32,
|
| 298 |
+
safety_checker=None
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
# Configuración para otros modelos
|
| 302 |
else:
|
| 303 |
pipe = StableDiffusionPipeline.from_pretrained(
|
|
|
|
| 507 |
max_sequence_length=256, # ✅ Reducido de 512 a 256 para ahorrar memoria
|
| 508 |
generator=torch.Generator("cpu").manual_seed(random_seed) # ✅ Seed aleatorio
|
| 509 |
).images[0]
|
| 510 |
+
|
| 511 |
+
# Configuración específica para modelos Turbo (rápidos)
|
| 512 |
+
elif any(turbo_model in model_name.lower() for turbo_model in ["sdxl-turbo", "sd-turbo", "sdxl-lightning"]):
|
| 513 |
+
print(f"⚡ Generando con modelo Turbo: {model_name}")
|
| 514 |
+
print(f"🔧 Parámetros Turbo: guidance_scale=1.0, steps=1-4, height=512")
|
| 515 |
+
|
| 516 |
+
# Los modelos turbo usan menos pasos y guidance_scale más bajo
|
| 517 |
+
turbo_steps = min(num_inference_steps, 4) # Máximo 4 pasos para turbo
|
| 518 |
+
image = pipeline(
|
| 519 |
+
prompt,
|
| 520 |
+
height=512,
|
| 521 |
+
width=512,
|
| 522 |
+
num_inference_steps=turbo_steps,
|
| 523 |
+
guidance_scale=1.0, # Más bajo para turbo
|
| 524 |
+
eta=1.0 # Parámetro específico para turbo
|
| 525 |
+
).images[0]
|
| 526 |
+
|
| 527 |
+
# Configuración específica para Kohaku
|
| 528 |
+
elif "kohaku" in model_name.lower():
|
| 529 |
+
print(f"🎨 Generando con modelo Kohaku: {model_name}")
|
| 530 |
+
print(f"🔧 Parámetros Kohaku: guidance_scale=7.5, steps={num_inference_steps}")
|
| 531 |
+
|
| 532 |
+
image = pipeline(
|
| 533 |
+
prompt,
|
| 534 |
+
height=512,
|
| 535 |
+
width=512,
|
| 536 |
+
num_inference_steps=num_inference_steps,
|
| 537 |
+
guidance_scale=7.5
|
| 538 |
+
).images[0]
|
| 539 |
+
|
| 540 |
else:
|
| 541 |
# Configuración básica para otros modelos
|
| 542 |
image = pipeline(
|