Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,48 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
from fastapi import FastAPI
|
| 4 |
|
| 5 |
-
# Intentar importar
|
| 6 |
try:
|
| 7 |
from generation import generate_image_from_prompt
|
| 8 |
except Exception as e:
|
| 9 |
def generate_image_from_prompt(*args, **kwargs):
|
| 10 |
-
return None, f"Error
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Si el
|
| 16 |
-
# Usamos los estilos que ya definimos antes
|
| 17 |
img, status = generate_image_from_prompt(
|
| 18 |
-
prompt=
|
| 19 |
-
negative_prompt="low quality, blurry",
|
| 20 |
model_name="black-forest-labs/FLUX.1-dev",
|
| 21 |
seed=None
|
| 22 |
)
|
| 23 |
return img, status
|
| 24 |
|
| 25 |
-
# INTERFAZ
|
| 26 |
-
with gr.Blocks() as demo:
|
| 27 |
gr.Markdown("# 馃摳 SOFIA AI STUDIO")
|
|
|
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
-
with gr.Column():
|
| 31 |
-
|
| 32 |
-
label="Selecciona Estilo",
|
| 33 |
choices=["lifestyle", "fitness", "fashion", "beach", "Personalizado"],
|
|
|
|
| 34 |
value="lifestyle"
|
| 35 |
)
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
with gr.Column():
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
generate_btn.click(
|
| 44 |
-
fn=predict,
|
| 45 |
-
inputs=[style_input, prompt_input],
|
| 46 |
-
outputs=[output_image, output_text]
|
| 47 |
-
)
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
|
|
|
| 3 |
|
| 4 |
+
# Intentar importar tu l贸gica de generaci贸n
|
| 5 |
try:
|
| 6 |
from generation import generate_image_from_prompt
|
| 7 |
except Exception as e:
|
| 8 |
def generate_image_from_prompt(*args, **kwargs):
|
| 9 |
+
return None, f"Error en generation.py: {str(e)}"
|
| 10 |
|
| 11 |
+
# Funci贸n que conecta los botones con el motor
|
| 12 |
+
def crear_foto(style, custom_text):
|
| 13 |
+
# Aqu铆 llamamos a tu archivo generation.py
|
| 14 |
+
# Si el estilo es 'lifestyle', 'fitness', etc., puedes mapearlo aqu铆
|
|
|
|
| 15 |
img, status = generate_image_from_prompt(
|
| 16 |
+
prompt=custom_text if style == "Personalizado" else style,
|
| 17 |
+
negative_prompt="low quality, blurry, distorted",
|
| 18 |
model_name="black-forest-labs/FLUX.1-dev",
|
| 19 |
seed=None
|
| 20 |
)
|
| 21 |
return img, status
|
| 22 |
|
| 23 |
+
# INTERFAZ LIMPIA (Gradio Puro)
|
| 24 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 25 |
gr.Markdown("# 馃摳 SOFIA AI STUDIO")
|
| 26 |
+
gr.Markdown("Generador oficial de contenido para la influencer Sof铆a Rivera.")
|
| 27 |
|
| 28 |
with gr.Row():
|
| 29 |
+
with gr.Column(scale=1):
|
| 30 |
+
estilo = gr.Dropdown(
|
|
|
|
| 31 |
choices=["lifestyle", "fitness", "fashion", "beach", "Personalizado"],
|
| 32 |
+
label="Selecciona el estilo de Sof铆a",
|
| 33 |
value="lifestyle"
|
| 34 |
)
|
| 35 |
+
prompt_extra = gr.Textbox(
|
| 36 |
+
label="Detalles extra (Opcional)",
|
| 37 |
+
placeholder="Ej: vistiendo un vestido rojo, en la Gran V铆a..."
|
| 38 |
+
)
|
| 39 |
+
boton = gr.Button("馃殌 GENERAR IMAGEN", variant="primary")
|
| 40 |
|
| 41 |
+
with gr.Column(scale=2):
|
| 42 |
+
resultado = gr.Image(label="Imagen de Sof铆a")
|
| 43 |
+
info = gr.Textbox(label="Estado del Servidor", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
boton.click(fn=crear_foto, inputs=[estilo, prompt_extra], outputs=[resultado, info])
|
| 46 |
|
| 47 |
+
# Lanzar la app de forma nativa para Hugging Face
|
| 48 |
+
demo.launch()
|