当前位置:   article > 正文

【深度学习】SDXL,diffusers加载单个safetensors文件,保存单个safetensors文件_diffusers from single file

diffusers from single file

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")

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

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")
  • 1
  • 2
  • 3
  • 4

将pipe保存单个safetensors文件:

https://github.com/huggingface/diffusers/discussions/7336#discussioncomment-8796829

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/761142
推荐阅读
相关标签
  

闽ICP备14008679号