GoGma commited on
Commit
83303ae
verified
1 Parent(s): 8e072f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -30
app.py CHANGED
@@ -1,52 +1,48 @@
1
  import gradio as gr
2
- import uvicorn
3
- from fastapi import FastAPI
4
 
5
- # Intentar importar la funci贸n de generaci贸n
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 de importaci贸n: {str(e)}"
11
 
12
- app = FastAPI()
13
-
14
- def predict(style, custom_p):
15
- # Si el motor generation.py funciona, esto crear谩 la imagen
16
- # Usamos los estilos que ya definimos antes
17
  img, status = generate_image_from_prompt(
18
- prompt=custom_p if style == "Personalizado" else style,
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 SENCILLA Y DIRECTA
26
- with gr.Blocks() as demo:
27
  gr.Markdown("# 馃摳 SOFIA AI STUDIO")
 
28
 
29
  with gr.Row():
30
- with gr.Column():
31
- style_input = gr.Dropdown(
32
- label="Selecciona Estilo",
33
  choices=["lifestyle", "fitness", "fashion", "beach", "Personalizado"],
 
34
  value="lifestyle"
35
  )
36
- prompt_input = gr.Textbox(label="Prompt (Solo si usas Personalizado)", placeholder="Describe la escena...")
37
- generate_btn = gr.Button("馃殌 GENERAR IMAGEN SOF脥A", variant="primary")
 
 
 
38
 
39
- with gr.Column():
40
- output_image = gr.Image(label="Resultado")
41
- output_text = gr.Textbox(label="Estado del Servidor")
42
-
43
- generate_btn.click(
44
- fn=predict,
45
- inputs=[style_input, prompt_input],
46
- outputs=[output_image, output_text]
47
- )
48
 
49
- app = gr.mount_gradio_app(app, demo, path="/")
50
 
51
- if __name__ == "__main__":
52
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
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()