赞
踩
StableDiffusionXLPipeline 加载仓库:
import torch
from diffusers import StableDiffusionXLPipeline, EulerDiscreteScheduler
base = "Vargol/sdxl-lightning-4-steps"
pipe = StableDiffusionXLPipeline.from_pretrained(base, torch_dtype=torch.float16).to("cuda")
# Ensure sampler uses "trailing" timesteps.
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
# Ensure using the same inference steps as the loaded model and CFG set to 0.
pipe("A girl smiling", num_inference_steps=4, guidance_scale=0).images[0].save("output.png")
diffusers 从单个safetensors文件加载pipe:
import torch
from diffusers import StableDiffusionXLPipeline
pretrained_ckpt_path = "/data/xiedong/fooocus_tensorRT/Fooocus/models/checkpoints/juggernautXL_version6Rundiffusion.safetensors"
pipe = StableDiffusionXLPipeline.from_single_file(pretrained_ckpt_path, torch_dtype=torch.float16).to("cuda")
将pipe保存单个safetensors文件:
https://github.com/huggingface/diffusers/discussions/7336#discussioncomment-8796829
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。