import transformers import gradio as gr from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler import torch model_id = "stabilityai/stable-diffusion-2" scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler") pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16) pipe = pipe.to("cuda") def imgtext(inp): image = pipe(inp).images[0] return image wp=gr.Interface(fn=imgtext,inputs="text",outputs="image") wp.launch()