Spaces:
Runtime error
Runtime error
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| import gradio as gr | |
| # 加载 SDXL 模型 | |
| pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16) | |
| pipe.to("cuda") # 使用 GPU 加速 | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # 创建 Gradio 界面 | |
| iface = gr.Interface(fn=generate_image, inputs="text", outputs="image", title="SDXL Image Generator") | |
| iface.launch() | |