import gradio as gr import os # Intentar importar tu lógica de generación try: from generation import generate_image_from_prompt except Exception as e: error_msg = str(e) def generate_image_from_prompt(*args, **kwargs): return None, f"Error en generation.py: {error_msg}" # Función que conecta los botones con el motor def crear_foto(style, custom_text): # Base física de Sofía para mantener consistencia sofia_base = "Professional portrait of Sofia Rivera, a beautiful 25yo Spanish-Latina woman, hazel eyes, wavy dark chocolate hair, sun-kissed skin, highly detailed, 8k, instagram style, " # Unir la base con el estilo elegido final_prompt = sofia_base + (custom_text if style == "Personalizado" else style) img, status = generate_image_from_prompt( prompt=final_prompt, model_name="SG161222/RealVisXL_V4.0_Lightning" ) return img, status # INTERFAZ LIMPIA (Gradio Puro) with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("# 📸 SOFIA AI STUDIO") gr.Markdown("Generador oficial de contenido para la influencer Sofía Rivera.") with gr.Row(): with gr.Column(scale=1): estilo = gr.Dropdown( choices=["lifestyle", "fitness", "fashion", "beach", "Personalizado"], label="Selecciona el estilo de Sofía", value="lifestyle" ) prompt_extra = gr.Textbox( label="Detalles extra (Opcional)", placeholder="Ej: vistiendo un vestido rojo, en la Gran Vía..." ) boton = gr.Button("🚀 GENERAR IMAGEN", variant="primary") with gr.Column(scale=2): resultado = gr.Image(label="Imagen de Sofía") info = gr.Textbox(label="Estado del Servidor", interactive=False) boton.click(fn=crear_foto, inputs=[estilo, prompt_extra], outputs=[resultado, info]) # Lanzar la app de forma nativa para Hugging Face demo.launch()