Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,6 @@ import os
|
|
| 2 |
import time
|
| 3 |
import random
|
| 4 |
import requests
|
| 5 |
-
import tempfile
|
| 6 |
-
import zipfile
|
| 7 |
-
import uuid
|
| 8 |
-
import base64
|
| 9 |
-
import concurrent.futures
|
| 10 |
-
from io import BytesIO
|
| 11 |
-
from PIL import Image
|
| 12 |
from typing import List, Dict, Any, Optional, Tuple
|
| 13 |
import gradio as gr
|
| 14 |
|
|
@@ -289,36 +282,6 @@ class SambaNovaClient:
|
|
| 289 |
except Exception as e:
|
| 290 |
raise Exception(f"Error en la API: {str(e)}")
|
| 291 |
|
| 292 |
-
# ============================================
|
| 293 |
-
# MANEJO DE ARCHIVOS
|
| 294 |
-
# ============================================
|
| 295 |
-
|
| 296 |
-
def create_zip(images: List[Image.Image]) -> Optional[str]:
|
| 297 |
-
"""Crea un archivo ZIP con las imágenes generadas."""
|
| 298 |
-
if not images:
|
| 299 |
-
return None
|
| 300 |
-
|
| 301 |
-
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
|
| 302 |
-
with zipfile.ZipFile(tmp.name, "w") as zip_file:
|
| 303 |
-
for i, img in enumerate(images):
|
| 304 |
-
buffer = BytesIO()
|
| 305 |
-
img.save(buffer, format="PNG", optimize=True)
|
| 306 |
-
zip_file.writestr(f"genesis_{i+1:03d}.png", buffer.getvalue())
|
| 307 |
-
|
| 308 |
-
return tmp.name
|
| 309 |
-
|
| 310 |
-
def save_images(images: List[Image.Image]) -> List[str]:
|
| 311 |
-
"""Guarda imágenes individuales en archivos temporales."""
|
| 312 |
-
files = []
|
| 313 |
-
for i, img in enumerate(images):
|
| 314 |
-
path = os.path.join(
|
| 315 |
-
tempfile.gettempdir(),
|
| 316 |
-
f"GENESIS_{uuid.uuid4().hex[:8]}_{i+1:03d}.png"
|
| 317 |
-
)
|
| 318 |
-
img.save(path, format="PNG", optimize=True)
|
| 319 |
-
files.append(path)
|
| 320 |
-
return files
|
| 321 |
-
|
| 322 |
# ============================================
|
| 323 |
# GENERADOR DE PROMPTS PREMIUM
|
| 324 |
# ============================================
|
|
@@ -544,8 +507,7 @@ def create_interface():
|
|
| 544 |
output = gr.Textbox(
|
| 545 |
lines=6,
|
| 546 |
label="",
|
| 547 |
-
interactive=False
|
| 548 |
-
show_copy_button=True
|
| 549 |
)
|
| 550 |
prompt_outputs.append(output)
|
| 551 |
|
|
|
|
| 2 |
import time
|
| 3 |
import random
|
| 4 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from typing import List, Dict, Any, Optional, Tuple
|
| 6 |
import gradio as gr
|
| 7 |
|
|
|
|
| 282 |
except Exception as e:
|
| 283 |
raise Exception(f"Error en la API: {str(e)}")
|
| 284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
# ============================================
|
| 286 |
# GENERADOR DE PROMPTS PREMIUM
|
| 287 |
# ============================================
|
|
|
|
| 507 |
output = gr.Textbox(
|
| 508 |
lines=6,
|
| 509 |
label="",
|
| 510 |
+
interactive=False
|
|
|
|
| 511 |
)
|
| 512 |
prompt_outputs.append(output)
|
| 513 |
|