Stablediffusion LCM模型教程

图片[1]-Stablediffusion LCM模型教程-CG迷(cgmi.com)
LCM相关资源链接

LCM模型+Lora下载链接:https://pan.quark.cn/s/53bd31c8fa47

LCM项目官方主页:https://latent-consistency-models.github.io/

sd-webui-lcm插件安装链接:https://github.com/0xbitches/sd-webui-lcm

在线体验LCM_Dreamshaper_v7:https://huggingface.co/spaces/SimianLuo/Latent_Consistency_Model

Stable diffusion添加LCM采样器

1、用记事本之类的软件打开Stablediffusion webui/modules/sd_samplers_kdiffusion.py ,在LMS下面一行添加下面代码

('LCM', sd_samplers_extra.sample_lcm, ['k_lcm'], {}),

2、用记事本之类的软件打开Stablediffusion webui/modules/sd_samplers_extra.py ,在import k_diffusion.sampling下面添加下面代码

@torch.no_grad()
def sample_lcm(model, x, sigmas, extra_args=None, callback=None, disable=None, noise_sampler=None):
    extra_args = {} if extra_args is None else extra_args
    noise_sampler = k_diffusion.sampling.default_noise_sampler(x) if noise_sampler is None else noise_sampler
    s_in = x.new_ones([x.shape[0]])
    for i in tqdm.auto.trange(len(sigmas) - 1, disable=disable):
        denoised = model(x, sigmas[i] * s_in, **extra_args)
        if callback is not None:
            callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised})

        x = denoised
        if sigmas[i + 1] > 0:
            x += sigmas[i + 1] * noise_sampler(sigmas[i], sigmas[i + 1])
    return x
© 版权声明
THE END
喜欢就支持一下吧
点赞17 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容