Spaces:
No application file
No application file
File size: 781 Bytes
19fa8b2 1a2afdb 5504e73 19fa8b2 5504e73 21b9e96 1a2afdb 21b9e96 5504e73 19fa8b2 1a2afdb 19fa8b2 1a2afdb 21b9e96 5504e73 19fa8b2 1a2afdb 21b9e96 1a2afdb 19fa8b2 5504e73 19fa8b2 |
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 |
import gradio as gr
from diffusers import StableDiffusionPipeline
from PIL import Image
import torch
#Modelo que genera imágenes, está poco probado ya que tarda muchísimo en generarlas
model_id = "OFA-Sys/small-stable-diffusion-v0"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
pipe = pipe.to("cpu")
# Función que Gradio llamará
def generar_imagen(prompt):
if not prompt:
return None
image = pipe(prompt).images[0]
return image
# Interfaz Gradio
demo = gr.Interface(
fn=generar_imagen,
inputs=gr.Textbox(label="Prompt"),
outputs=gr.Image(type="pil"),
title="Generador de imágenes ligero",
description="Introduce un prompt y el modelo generará la imagen. Podrás descargarla con el botón de Gradio."
)
demo.launch()
|