字节开源SDXL-Lightning,毫秒级生成1024p高清高质量图片

“ 体验很棒,demo基本就是实时输入实时生成图片,而且图片质量都挺不错,没看论文,抄抄readme


        
          
https://fastsdxl.ai/  
https://huggingface.co/ByteDance/SDXL-Lightning  
https://arxiv.org/pdf/2402.13929.pdf  

      

picture.image

SDXL-Lightning 是一个闪电般快速的文本到图像生成模型。它可以在几个步骤内生成高质量的1024像素图像。

模型是从 stabilityai/stable-diffusion-xl-base-1.0 中蒸馏出来的。开源了包含了1步、2步、4步和8步蒸馏模型的ckpt。2步、4步和8步模型的生成质量非常出色。1步模型更具实验性。

提供了完整的UNet和LoRA检查点。完整的UNet模型具有最佳质量,而LoRA模型可以应用于其他基础模型。

用diffusers很简单:

2-Step, 4-Step, 8-Step UNet


        
          
import torch  
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, EulerDiscreteScheduler  
from huggingface_hub import hf_hub_download  
from safetensors.torch import load_file  
  
base = "stabilityai/stable-diffusion-xl-base-1.0"  
repo = "ByteDance/SDXL-Lightning"  
ckpt = "sdxl\_lightning\_4step\_unet.safetensors" # Use the correct ckpt for your step setting!  
  
# Load model.  
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)  
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))  
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").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")  
  

      
0
0
0
0
评论
未登录
暂无评论