一个比SDXL更快的模型——Stable Cascade【必坑指北】

2024年的春节假期,AIGC界又发生了重大革命性事件。

  • OpenAI 发布了首款文生视频模型------Sora。简单来说就是,AI视频要变天了!之前的SVD,还是Google的Lumiere最多就几十帧,大约十秒左右,但是Sora却是SOTA级别且达到60s长度的文生视频模型。
  • Stability AI 开源 Stable Cascade,重新修改了diffusion架构,并且速度比原来的sdxl更快。不过目前huggingface下的模型,我仍建议使用 20GB以上的VRAM,而X 平台用户 @GozukaraFurkan 发文表示它只需要大约 9GB 的 GPU 内存,且速度依旧能保持得较好,具体优化需等GitHub发布了。
  • Apple 开售 Vision Pro,继 Meta Quest 3 之后又一位元宇宙的重量级选手。虽然Pico和黑鲨暂时退热了, 但是硅谷依旧热情高涨,值得向往学习。

部署

javascript 复制代码
#install `diffusers` from this branch while the PR is WIP
pip install git+https://github.com/kashif/diffusers.git@wuerstchen-v3

官方最新的有问题,会提示 If you want to instead overwrite randomly initialized weights, please make sure to pass both low_cpu_mem_usage=False and ignore_mismatched_sizes=True.

perl 复制代码
# 参考 https://github.com/kijai/ComfyUI-DiffusersStableCascade/issues/13
pip install --force-reinstall --no-deps git+https://github.com/huggingface/diffusers.git@a3dc21385b7386beb3dab3a9845962ede6765887

代码

ini 复制代码
import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline

device = "cuda"
dtype = torch.bfloat16
num_images_per_prompt = 2

prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=dtype).to(device)
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=dtype).to(device)

prompt = "Anthropomorphic cat dressed as a pilot"
negative_prompt = ""

with torch.cuda.amp.autocast(dtype=dtype):
    prior_output = prior(
        prompt=prompt,
        height=1024,
        width=1024,
        negative_prompt=negative_prompt,
        guidance_scale=4.0,
        num_images_per_prompt=num_images_per_prompt,
    )
    decoder_output = decoder(
        image_embeddings=prior_output.image_embeddings,
        prompt=prompt,
        negative_prompt=negative_prompt,
        guidance_scale=0.0,
        output_type="pil",
    ).images

代码

ini 复制代码
import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline

device = "cuda"
num_images_per_prompt = 2

prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade",  torch_dtype=torch.float16).to(device)

prompt = "Anthropomorphic cat dressed as a pilot"
negative_prompt = ""

prior_output = prior(
    prompt=prompt,
    height=1024,
    width=1024,
    negative_prompt=negative_prompt,
    guidance_scale=4.0,
    num_images_per_prompt=num_images_per_prompt,
    num_inference_steps=20
)
decoder_output = decoder(
    image_embeddings=prior_output.image_embeddings.half(),
    prompt=prompt,
    negative_prompt=negative_prompt,
    guidance_scale=0.0,
    output_type="pil",
    num_inference_steps=10
).images

#Now decoder_output is a list with your PIL images
相关推荐
乙真仙人2 小时前
AIGC时代!AI的“iPhone时刻”与投资机遇
人工智能·aigc·iphone
EdisonZhou3 小时前
大模型应用开发初探 : 通用函数调用Planner
aigc·.net·.net core
人工智能培训咨询叶梓4 小时前
生成式人工智能在无人机群中的应用、挑战和机遇
人工智能·语言模型·自然语言处理·aigc·无人机·多模态·生成式人工智能
AI极客菌19 小时前
Stable Diffusion绘画 | 生成高清多细节图片的各个要素
人工智能·ai·ai作画·stable diffusion·aigc·midjourney·人工智能作画
SHI-HANG1 天前
13 Midjourney从零到商用·实战篇:漫画设计一条龙
ai作画·aigc·midjourney
NLP工程化1 天前
Dify 中的讯飞星火平台工具源码分析
aigc·dify
Seal软件1 天前
GPUStack 0.2:开箱即用的分布式推理、CPU推理和调度策略
大模型·llm·aigc·gpu·genai·gpu集群
GPUStack1 天前
GPUStack 0.2:开箱即用的分布式推理、CPU推理和调度策略
ai·大模型·aigc·gpu·genai·gpu集群
Hoper.J1 天前
使用 HFD 加快 Hugging Face 模型和数据集的下载
llm·aigc·hugging face·hfd
雅菲奥朗2 天前
FinOps三人行:共话FinOps云成本管理与AI的未来在线分享(文字+视频)
人工智能·aigc·finops·云财务管理·云成本管理