超越sora,最新文生视频CogVideoX-5b模型分享

devtools/2024/10/19 5:31:13/

CogVideoX-5B是由智谱 AI 开源的一款先进的文本到视频生成模型,它是 CogVideoX 系列中的更大尺寸版本,旨在提供更高质量的视频生成效果。

CogVideoX-5B 采用了 3D 因果变分自编码器(3D causal VAE)技术,通过在空间和时间维度上对视频进行压缩,大幅度降低了计算复杂度,同时提高了视频生成的连续性和质量。

此外,模型还使用了专家 Transformer 技术,通过 3D-RoPE 作为位置编码,并采用 3D 全注意力机制来进行时空联合建模,改善视频与文本的对齐。

CogVideoX-5B模型能够生成高达 720×480 分辨率、每秒 8 帧、最长 6 秒的视频,使得生成的视频在动态表现上更为连贯流畅。

在硬件适配性上,CogVideoX-5B表现出色,可以在 RTX 3060 等桌面端显卡上运行,推理门槛大幅降低,使得更多的用户能够体验到顶尖的 AI 视频生成技术。

CogVideoX-5B模型支持多种精度的推理方式,如 FP16、BF16、FP32、INT8 等,用户可以根据自身硬件情况灵活选择,以在性能和效率之间找到最佳平衡点。

github项目地址:https://github.com/THUDM/CogVideo。

一、环境安装

1、python环境

建议安装python版本在3.10以上。

2、pip库安装

pip install torch==2.4.0+cu118 torchvision==0.19.0+cu118 torchaudio==2.4.0 --extra-index-url https://download.pytorch.org/whl/cu118

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

3、CogVideoX-5b模型下载

git lfs install

git clone https://www.modelscope.cn/AI-ModelScope/CogVideoX-5b.git

、功能测试

1、运行测试

(1)python代码调用测试

import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video
import loggingdef generate_video(model_path, prompt, output_path, num_videos=1, inference_steps=50, num_frames=49, guidance_scale=6, seed=42, fps=8):try:# Initialize loggerlogging.basicConfig(level=logging.INFO)logger = logging.getLogger("VideoGeneration")# Load modellogger.info("Loading model from path: %s", model_path)pipe = CogVideoXPipeline.from_pretrained(model_path,torch_dtype=torch.bfloat16)pipe.enable_model_cpu_offload()pipe.vae.enable_tiling()# Log device informationlogger.info("Using device: %s", torch.cuda.get_device_name(0))# Generate videologger.info("Generating video with prompt: %s", prompt)video = pipe(prompt=prompt,num_videos_per_prompt=num_videos,num_inference_steps=inference_steps,num_frames=num_frames,guidance_scale=guidance_scale,generator=torch.Generator(device="cuda").manual_seed(seed),).frames[0]# Export videologger.info("Exporting video to file: %s", output_path)export_to_video(video, output_path, fps=fps)logger.info("Video generation completed successfully.")except Exception as e:logger.error("An error occurred during video generation: %s", str(e))if __name__ == "__main__":model_path = "CogVideoX-5b"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.")output_path = "output.mp4"generate_video(model_path, prompt, output_path)

未完......

更多详细的欢迎关注:杰哥新技术


http://www.ppmy.cn/devtools/117788.html

相关文章

EasyCVR智慧公园视频智能管理方案:赋能公园安全管理新高度

随着城市化进程的加速,智慧城市建设已成为提升城市管理效率、增强居民生活质量的重要途径。智慧公园作为智慧城市的重要组成部分,其安全与管理水平直接影响着市民的休闲娱乐体验。EasyCVR智慧公园视频智能管理方案,正是基于这一背景应运而生&…

gitlab集成CI/CD,shell方式部署

目录 1.首先安装好gitlab和gitlab-runner,这两个,看我以往的教程 2.注册新的 Runner 3. 步骤 3.1 Enter the GitLab instance URL (for example, https://gitlab.com/): 3.2 Enter the registration token: 3.3 Enter a description for the runner: 3…

多模态大模型学习(一)

参考:https://www.bilibili.com/video/BV1kT411o7a6?p2&spm_id_frompageDriver&vd_source156234c72054035c149dcb072202e6be 余弦相似度,让正样本内积趋近于1,负样本趋近于-1。度量学习。N特别大时,负样本远大于正样本&…

如何基于Flink CDC与OceanBase构建实时数仓,实现简化链路,高效排查

本文作者:阿里云Flink SQL负责人,伍翀,Apache Flink PMC Member & Committer 众多数据领域的专业人士都很熟悉Apache Flink,它作为流式计算引擎,流批一体,其核心在于其强大的分布式流数据处理能力&…

【机器学习导引】ch3-线性模型

线性回归 梯度 在数学中,对于函数 f ( x 1 , … , x m ) f(x_1, \ldots, x_m) f(x1​,…,xm​) 在点 a ( a 1 , … , a m ) a (a_1, \ldots, a_m) a(a1​,…,am​) 处的梯度被定义为: ∇ f ( a ) ( ∂ f ∂ x 1 ( a ) , … , ∂ f ∂ x m ( a ) )…

华为NAT ALG技术的实现

双向NAT技术:经过防火墙的2报文源IP地址和目的IP地址都同时被转换,外网发送报文给内网服务器,先转换目的IP地址,然后符合安全策略后,在替换源IP地址,然后将记录写入防火墙会话表,并发送出报文&a…

11. Map和Set

一、二叉搜索树 1. 概念 二叉搜索树又称二叉排序树,它或者是一棵空树,或者是具有以下性质的二叉树: 若它的左子树不为空,则左子树上所有节点的值都小于根节点的值若它的右子树不为空,则右子树上所有节点的值都大于根…

set和map

目录 一、概述 1.set常用成员函数 insert插入 erase删除 ​编辑 lower_bound和upper_bound equal_range 2.map常用的成员函数 operator[ ]重载 3.set以及map的返回值 二、map和set的模拟实现 第一个难点 第二个难点 三、迭代器设计 operator !和operat…