Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
| 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()
|