from diffusers import DiffusionPipeline
import torch
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("mps")
pipe.enable_attention_slicing()
prompt = "便利店开业"
_ = pipe(prompt, num_inference_steps=1)
images = pipe(prompt=prompt).images[0]
images.save("output1.png")
diffusers
Hugging Face 平台提供了基础模型权重以及通用的模型训练框架 diffusers
参考
How to use Stable Diffusion in Apple Silicon (M1/M2)