import gradio as gr import torch # from diffusers import DiffusionPipeline from diffusers import StableDiffusionPipeline SAFETENSORS_PATH = "./dreamshaper_5BakedVae.safetensors" def generate(prompt): pipeline = StableDiffusionPipeline.from_pretrained(SAFETENSORS_PATH , torch_dtype = torch.float16 , use_safetensors = True) pipeline.to("cuda") return pipeline(prompt).images[0] iface = gr.Interface(fn=generate, inputs="text", outputs="image") iface.launch()