hexanovapixel commited on
Commit
28fa2f6
·
verified ·
1 Parent(s): 1239fb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -1,17 +1,27 @@
1
  import gradio as gr
2
  from diffusers import StableDiffusionPipeline
 
 
 
 
 
 
3
 
4
- pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
5
  pipe = pipe.to("cpu")
6
 
7
  def generar_imagen(prompt):
8
- imagen = pipe(prompt).images[0]
9
  return imagen
10
 
11
- interfaz = gr.Interface(
12
- fn=generar_imagen,
13
- inputs=gr.Textbox(label="Escribe tu idea"),
14
- outputs=gr.Image(label="Imagen generada")
15
- )
 
 
 
 
 
16
 
17
- interfaz.launch()
 
1
  import gradio as gr
2
  from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ pipe = StableDiffusionPipeline.from_pretrained(
6
+ "stabilityai/sd-turbo",
7
+ torch_dtype=torch.float32
8
+ )
9
 
 
10
  pipe = pipe.to("cpu")
11
 
12
  def generar_imagen(prompt):
13
+ imagen = pipe(prompt, num_inference_steps=1).images[0]
14
  return imagen
15
 
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("# 🎨 ImaginaAI")
18
+ gr.Markdown("Genera imágenes con inteligencia artificial")
19
+
20
+ prompt = gr.Textbox(label="Escribe tu idea")
21
+
22
+ boton_generar = gr.Button("Generar imagen")
23
+ resultado = gr.Image(label="Imagen generada")
24
+
25
+ boton_generar.click(fn=generar_imagen, inputs=prompt, outputs=resultado)
26
 
27
+ demo.launch()