juanelot commited on
Commit
3e1061a
verified
1 Parent(s): a65b3e1
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,6 +1,10 @@
1
  import gradio as gr
2
  from diffusers import DiffusionPipeline
3
  import torch
 
 
 
 
4
 
5
  # Cargar el modelo base y los pesos LoRA
6
  model_name = "stabilityai/stable-diffusion-xl-base-1.0"
@@ -18,17 +22,27 @@ def generate_image(prompt):
18
  image = pipeline(prompt).images[0]
19
  return image
20
 
21
- # Crear la interfaz de Gradio
22
  iface = gr.Interface(
23
  fn=generate_image,
24
- inputs=gr.inputs.Textbox(lines=5, label="Descripci贸n de la imagen", placeholder="Introduce el texto aqu铆..."),
25
- outputs=gr.outputs.Image(type="pil", label="Imagen generada"),
26
  title="Generador de Im谩genes a partir de Texto",
27
  description="Ingrese un texto y obtenga una imagen generada por IA.",
28
  examples=[
29
  ["A picturesque view of a local market. The first light of day illuminates the stone facades and worn tiles of the houses and buildings, some of which date back centuries. At the center of the scene, a cobblestone square leads to an open-air market that begins to come to life, with vendors setting up their stalls selling fruits, vegetables, flowers, and local crafts. The narrow, winding streets are lined with old lanterns, now unlit, while lazy cats lounge on the stone steps. In one corner, an ancient fountain, adorned with weathered carvings, murmurs softly, adding to the tranquil atmosphere. In the background, the towers of an ancient cathedral rise, capturing the first rays of sunlight that paint the sky in soft pinks and oranges. This image should convey a sense of tranquility, beauty, and a deep connection to the past, celebrating the rich history and timeless charm of the ancient village or town."]
30
  ],
31
- live=True
 
 
 
 
 
 
 
 
 
 
32
  )
33
 
34
  # Ejecutar la interfaz
 
1
  import gradio as gr
2
  from diffusers import DiffusionPipeline
3
  import torch
4
+ from transformers.utils import move_cache
5
+
6
+ # Mover la cach茅 si es necesario
7
+ move_cache()
8
 
9
  # Cargar el modelo base y los pesos LoRA
10
  model_name = "stabilityai/stable-diffusion-xl-base-1.0"
 
22
  image = pipeline(prompt).images[0]
23
  return image
24
 
25
+ # Crear la interfaz de Gradio con CSS personalizado
26
  iface = gr.Interface(
27
  fn=generate_image,
28
+ inputs=gr.Textbox(lines=5, label="Descripci贸n de la imagen", placeholder="Introduce el texto aqu铆..."),
29
+ outputs=gr.Image(type="pil", label="Imagen generada"),
30
  title="Generador de Im谩genes a partir de Texto",
31
  description="Ingrese un texto y obtenga una imagen generada por IA.",
32
  examples=[
33
  ["A picturesque view of a local market. The first light of day illuminates the stone facades and worn tiles of the houses and buildings, some of which date back centuries. At the center of the scene, a cobblestone square leads to an open-air market that begins to come to life, with vendors setting up their stalls selling fruits, vegetables, flowers, and local crafts. The narrow, winding streets are lined with old lanterns, now unlit, while lazy cats lounge on the stone steps. In one corner, an ancient fountain, adorned with weathered carvings, murmurs softly, adding to the tranquil atmosphere. In the background, the towers of an ancient cathedral rise, capturing the first rays of sunlight that paint the sky in soft pinks and oranges. This image should convey a sense of tranquility, beauty, and a deep connection to the past, celebrating the rich history and timeless charm of the ancient village or town."]
34
  ],
35
+ live=True,
36
+ css="""
37
+ .gradio-container {
38
+ background-color: #f9f9f9;
39
+ color: #333;
40
+ font-family: Arial, sans-serif;
41
+ }
42
+ .gradio-container h1 {
43
+ color: #4CAF50;
44
+ }
45
+ """
46
  )
47
 
48
  # Ejecutar la interfaz