首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >CogVideoX-5B:最新开源!!你可以在本地使用AI文本生成视频了!(12G显存 & 本地部署)

CogVideoX-5B:最新开源!!你可以在本地使用AI文本生成视频了!(12G显存 & 本地部署)

作者头像
AI进修生
发布2024-12-02 19:17:26
发布2024-12-02 19:17:26
82500
代码可运行
举报
文章被收录于专栏:AI进修生AI进修生
运行总次数:0
代码可运行
Aitrainee | 公众号:AI进修生

Hi,这里是Aitrainee,欢迎阅读本期新文章。

智谱CogVideoX系列新开源CogVideoX-5b,视频生成质量更高,视觉效果更好,此前开源的版本为CogVideoX-2B。

GIF有点卡 ...

实测案例一(AI-杨百万):

代码语言:javascript
代码运行次数:0
运行
复制
提示词:
Picture this: a sleek, confident cat lounging casually in a sun-drenched room, its fur glistening under the warm rays. But what sets this feline apart is not just its glossy coat or the graceful poise it exudes; it's the pair of stylish sunglasses perched on its nose, adding an air of mystery and coolness to its demeanor. The sunglasses, with their reflective lenses, hide the cat's enigmatic eyes, making it seem as if it's pondering life's mysteries or perhaps just planning its next mischievous adventure. As sunlight filters through the window, casting patterns on the floor, the cat, utterly unfazed by its unusual accessory, gives off a vibe of effortless chic. It sits there, a picture of serenity and detachment, occasionally flicking its tail or letting out a soft purr, completely embodying the essence of cool. This cat doesn't just wear sunglasses; it owns the look, making anyone who glances its way do a double-take, charmed by the sight of such an unexpected yet striking fashion statement.

实测案例二(AI-杨百万):

代码语言:javascript
代码运行次数:0
运行
复制
提示词:In a heartwarming scene, a delightful panda bear finds itself in the gentle embrace of a human, engaging in what can only be described as a whimsical dance. The panda, with its striking black and white fur, looks up with trusting, curious eyes, its round face framed by fuzzy ears. The human, filled with joy and awe, carefully supports the panda's soft, plump body, guiding it in a series of gentle, swaying movements. As they move together, the panda's clumsy yet endearing attempts to mimic the rhythm create a moment of pure magic. Its tiny paws occasionally reach out, touching the human's hands, as if trying to understand this novel form of interaction. Around them, the air is filled with laughter and soft music, enhancing the enchantment of their dance. This unique encounter, a blend of nature's innocence and human affection, unfolds like a tender dance of friendship, leaving an indelible mark of joy and connection on all who witness it.

推理的硬件需求如下:

CogVideoX-2B 模型:

  • FP16 精度
    • • 使用 diffusers:需要 12.5GB 显存
  • INT8 精度
    • • 使用 diffusers with torchaudio:需要 7.8GB 显存

CogVideoX-5B 模型:

  • BF16 精度
    • • 使用 diffusers:需要 20.7GB 显存
  • INT8 精度
    • • 使用 diffusers with torchaudio:需要 11.4GB 显存

体验界面如下:

快速上手 🤗

本模型已经支持使用 Huggingface 的 diffusers 库进行部署,你可以按照以下步骤进行部署。

安装对应的依赖

代码语言:javascript
代码运行次数:0
运行
复制
# diffusers>=0.30.1
# transformers>=0.44.0
# accelerate>=0.33.0 (建议从源代码安装)
# imageio-ffmpeg>=0.5.1

pip install --upgrade transformers accelerate diffusers imageio-ffmpeg

运行代码 (BF16 / FP16)

代码语言:javascript
代码运行次数:0
运行
复制
import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video

prompt = (
    "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool "
    "in a serene bamboo forest. The panda's fluffy paws strum a miniature acoustic "
    "guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, "
    "watching curiously and some clapping in rhythm. Sunlight filters through the tall "
    "bamboo, casting a gentle glow on the scene. The panda's face is expressive, showing "
    "concentration and joy as it plays. The background includes a small, flowing stream "
    "and vibrant green foliage, enhancing the peaceful and magical atmosphere of this "
    "unique musical performance."
)

pipe = CogVideoXPipeline.from_pretrained(
    "THUDM/CogVideoX-5b",
    torch_dtype=torch.bfloat16
)

pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()

video = pipe(
    prompt=prompt,
    num_videos_per_prompt=1,
    num_inference_steps=50,
    num_frames=49,
    guidance_scale=6,
    generator=torch.Generator(device="cuda").manual_seed(42),
).frames[0]

export_to_video(video, "output.mp4", fps=8)

🌟希望这篇文章对你有帮助,感谢阅读!如果你喜欢这系列文章请以 点赞 / 分享 / 在看 的方式告诉我,以便我用来评估创作方向。

视频教程

https://www.youtube.com/watch?v=Hs1Cxc2FeAg

参考链接: [2] huggingface:https://huggingface.co/THUDM/CogVideoX-5b/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-08-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 AI进修生 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • CogVideoX-2B 模型:
  • CogVideoX-5B 模型:
  • 快速上手 🤗
    • 安装对应的依赖
    • 运行代码 (BF16 / FP16)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档