CogVideo README

The project's README from github.com/zai-org/CogVideo. As one markdown file: README.md.

CogVideo & CogVideoX

中文阅读

日本語で読む

Experience the CogVideoX-5B model online at 🤗 Huggingface Space or 🤖 ModelScope Space

📚 View the paper and user guide

👋 Join our WeChat and Discord

📍 Visit QingYing and API Platform to experience larger-scale commercial video generation models.

Project Updates

Table of Contents

Jump to a specific section:

Quick Start

Prompt Optimization

Before running the model, please refer to this guide to see how we use large models like GLM-4 (or other comparable products, such as GPT-4) to optimize the model. This is crucial because the model is trained with long prompts, and a good prompt directly impacts the quality of the video generation.

SAT

Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.

Follow instructions in sat_demo: Contains the inference code and fine-tuning code of SAT weights. It is recommended to improve based on the CogVideoX model structure. Innovative researchers use this code to better perform rapid stacking and development.

Diffusers

Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.

pip install -r requirements.txt

Then follow diffusers_demo: A more detailed explanation of the inference code, mentioning the significance of common parameters.

For more details on quantized inference, please refer to diffusers-torchao. With Diffusers and TorchAO, quantized inference is also possible leading to memory-efficient inference as well as speedup in some cases when compiled. A full list of memory and time benchmarks with various settings on A100 and H100 has been published at diffusers-torchao.

CogVideoX-5B

CogVideoX-2B

To view the corresponding prompt words for the gallery, please click here

Model Introduction

CogVideoX is an open-source version of the video generation model originating from QingYing. The table below displays the list of video generation models we currently offer, along with their foundational information.

Model Name CogVideoX1.5-5B (Latest) CogVideoX1.5-5B-I2V (Latest) CogVideoX-2B CogVideoX-5B CogVideoX-5B-I2V
Release Date November 8, 2024 November 8, 2024 August 6, 2024 August 27, 2024 September 19, 2024
Video Resolution 1360 * 768 Min(W, H) = 768
768 ≤ Max(W, H) ≤ 1360
Max(W, H) % 16 = 0
720 * 480
Number of Frames Should be 16N + 1 where N <= 10 (default 81) Should be 8N + 1 where N <= 6 (default 49)
Inference Precision BF16 (Recommended), FP16, FP32, FP8*, INT8, Not supported: INT4 FP16*(Recommended), BF16, FP32, FP8*, INT8, Not supported: INT4 BF16 (Recommended), FP16, FP32, FP8*, INT8, Not supported: INT4
Single GPU Memory Usage
SAT BF16: 76GB
diffusers BF16: from 10GB*
diffusers INT8(torchao): from 7GB*
SAT FP16: 18GB
diffusers FP16: 4GB minimum*
diffusers INT8 (torchao): 3.6GB minimum*
SAT BF16: 26GB
diffusers BF16 : 5GB minimum*
diffusers INT8 (torchao): 4.4GB minimum*
Multi-GPU Memory Usage BF16: 24GB* using diffusers
FP16: 10GB* using diffusers
BF16: 15GB* using diffusers
Inference Speed
(Step = 50, FP/BF16)
Single A100: ~1000 seconds (5-second video)
Single H100: ~550 seconds (5-second video)
Single A100: ~90 seconds
Single H100: ~45 seconds
Single A100: ~180 seconds
Single H100: ~90 seconds
Prompt Language English*
Prompt Token Limit 224 Tokens 226 Tokens
Video Length 5 seconds or 10 seconds 6 seconds
Frame Rate 16 frames / second 8 frames / second
Position Encoding 3d_rope_pos_embed 3d_sincos_pos_embed 3d_rope_pos_embed 3d_rope_pos_embed + learnable_pos_embed
Download Link (Diffusers) 🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
Download Link (SAT) 🤗 HuggingFace
🤖 ModelScope
🟣 WiseModel
SAT

Data Explanation

pipe.enable_sequential_cpu_offload()
pipe.vae.enable_slicing()
pipe.vae.enable_tiling()

We highly welcome contributions from the community and actively contribute to the open-source community. The following works have already been adapted for CogVideoX, and we invite everyone to use them:

CogVideo (zai-org/CogVideo)

Searching Database…

13.1K ·GitHub
What is this?An open-source family of text-to-video and image-to-video models: CogVideoX (2024) and its CogVideoX1.5 upgrade, following CogVideo (ICLR 2023), the first open-source large Transformer-based text-to-video model.
Do I install something locally, or can I just open a website and try it?Both. You can try CogVideoX-5B in online Hugging Face or ModelScope Spaces, or download the weights and run inference locally on your own GPU. Two code stacks are provided: SAT and the Hugging Face diffusers version.
How do I generate my first video?Install Python 3.10-3.12, then follow the diffusers demo for inference (recommended, since it supports quantization) or the SAT demo, which carries both inference and fine-tuning code. A Colab quick start also exists.
What are the main limits — prompt language, prompt length, video length?Prompts must be in English and are capped at 224-226 tokens; translate other languages with an LLM first. Videos are short: 5 or 10 seconds at 16 fps for CogVideoX1.5, 6 seconds at 8 fps for CogVideoX-2B/5B. INT4 precision is not supported.
Do I need an expensive GPU for this?A modest one can work: CogVideoX-2B runs on GPUs as old as the GTX 1080 TI and CogVideoX-5B on an RTX 3060. With diffusers optimizations the 5B model fits in about 5 GB of VRAM, or ~4.4 GB with INT8 quantization — enough for free T4 Colabs.
What does the newer CogVideoX1.5 add over the original?Released November 8, 2024: CogVideoX1.5-5B generates 10-second videos at higher resolution (1360x768) at 16 fps, and the I2V version accepts an image at any resolution. Old code keeps working with only minor parameter changes.
Which generation tasks does the model family cover?Three: text-to-video generation, video continuation, and image-to-video generation. The I2V model takes an image as a background input and combines it with a prompt for greater controllability.
Why does the README insist on prompt optimization before generating?The models are trained with long prompts, so prompt quality directly impacts the video result. The guide recommends rewriting your prompt with a large model like GLM-4 or GPT-4 first.
Can I fine-tune CogVideoX on my own footage?Yes: SAT fine-tuning code, LoRA fine-tuning on the diffusers version that uses less GPU memory, and cogvideox-factory, which fine-tunes CogVideoX-5B on a single RTX 4090 across multiple resolutions. The team also released CogKit, a fine-tuning and inference framework for the series.
Creator
zai-org
Size
178.4 MB
Stars
13.1K
Age
4y
Commits · 90 Days