Spaces:
Sleeping
Sleeping
File size: 772 Bytes
a93a71f 28fa2f6 a93a71f 45c0e3d a93a71f 28fa2f6 a93a71f 28fa2f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained(
"stabilityai/sd-turbo",
torch_dtype=torch.float32
)
pipe = pipe.to("cpu")
def generar_imagen(prompt):
imagen = pipe(
prompt,
num_inference_steps=3, # antes era 1
guidance_scale=7.5 # mejora calidad
).images[0]
return imagen
with gr.Blocks() as demo:
gr.Markdown("# 🎨 ImaginaAI")
gr.Markdown("Genera imágenes con inteligencia artificial")
prompt = gr.Textbox(label="Escribe tu idea")
boton_generar = gr.Button("Generar imagen")
resultado = gr.Image(label="Imagen generada")
boton_generar.click(fn=generar_imagen, inputs=prompt, outputs=resultado)
demo.launch() |