{"id":13491483,"url":"https://github.com/THUDM/CogVideo","last_synced_at":"2025-03-28T08:33:19.342Z","repository":{"id":37277215,"uuid":"497512032","full_name":"THUDM/CogVideo","owner":"THUDM","description":"text and image to video generation: CogVideoX (2024) and CogVideo (ICLR 2023)","archived":false,"fork":false,"pushed_at":"2025-03-25T10:59:49.000Z","size":182539,"stargazers_count":11034,"open_issues_count":61,"forks_count":1058,"subscribers_count":135,"default_branch":"main","last_synced_at":"2025-03-25T19:03:56.677Z","etag":null,"topics":["cogvideox","image-to-video","llm","sora","text-to-video","video-generation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/THUDM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-29T06:46:18.000Z","updated_at":"2025-03-25T17:02:15.000Z","dependencies_parsed_at":"2024-10-15T09:41:10.408Z","dependency_job_id":"0ab90904-3920-4537-b269-1a494a46d4bf","html_url":"https://github.com/THUDM/CogVideo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FCogVideo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FCogVideo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FCogVideo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FCogVideo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/THUDM","download_url":"https://codeload.github.com/THUDM/CogVideo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245996794,"owners_count":20707323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cogvideox","image-to-video","llm","sora","text-to-video","video-generation"],"created_at":"2024-07-31T19:00:57.400Z","updated_at":"2025-03-28T08:33:19.334Z","avatar_url":"https://github.com/THUDM.png","language":"Python","readme":"# CogVideo \u0026 CogVideoX\n\n[中文阅读](./README_zh.md)\n\n[日本語で読む](./README_ja.md)\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=resources/logo.svg width=\"50%\"/\u003e\n\u003c/div\u003e\n\u003cp align=\"center\"\u003e\nExperience the CogVideoX-5B model online at \u003ca href=\"https://huggingface.co/spaces/THUDM/CogVideoX-5B\" target=\"_blank\"\u003e 🤗 Huggingface Space\u003c/a\u003e or \u003ca href=\"https://modelscope.cn/studios/ZhipuAI/CogVideoX-5b-demo\" target=\"_blank\"\u003e 🤖 ModelScope Space\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n📚 View the \u003ca href=\"https://arxiv.org/abs/2408.06072\" target=\"_blank\"\u003epaper\u003c/a\u003e and \u003ca href=\"https://zhipu-ai.feishu.cn/wiki/DHCjw1TrJiTyeukfc9RceoSRnCh\" target=\"_blank\"\u003euser guide\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    👋 Join our \u003ca href=\"resources/WECHAT.md\" target=\"_blank\"\u003eWeChat\u003c/a\u003e and \u003ca href=\"https://discord.gg/dCGfUsagrD\" target=\"_blank\"\u003eDiscord\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n📍 Visit \u003ca href=\"https://chatglm.cn/video?lang=en?fr=osm_cogvideo\"\u003eQingYing\u003c/a\u003e and \u003ca href=\"https://open.bigmodel.cn/?utm_campaign=open\u0026_channel_track_key=OWTVNma9\"\u003eAPI Platform\u003c/a\u003e to experience larger-scale commercial video generation models.\n\u003c/p\u003e\n\n## Project Updates\n\n- 🔥🔥 **News**: ```2025/03/24```: We have launched [CogKit](https://github.com/THUDM/CogKit), a fine-tuning and inference framework for the **CogView4** and **CogVideoX** series. This toolkit allows you to fully explore and utilize our multimodal generation models.\n- 🔥 **News**: ```2025/02/28```: DDIM Inverse is now supported in `CogVideoX-5B` and `CogVideoX1.5-5B`. Check [here](inference/ddim_inversion.py).\n- 🔥 **News**: ```2025/01/08```: We have updated the code for `Lora` fine-tuning based on the `diffusers` version model, which uses less GPU memory. For more details, please see [here](finetune/README.md).\n- 🔥 **News**: ```2024/11/15```: We released the `CogVideoX1.5` model in the diffusers version. Only minor parameter adjustments are needed to continue using previous code.\n- 🔥 **News**: ```2024/11/08```: We have released the CogVideoX1.5 model. CogVideoX1.5 is an upgraded version of the open-source model CogVideoX.\nThe CogVideoX1.5-5B series supports 10-second videos with higher resolution, and CogVideoX1.5-5B-I2V supports video generation at any resolution.\nThe SAT code has already been updated, while the diffusers version is still under adaptation. Download the SAT version code [here](https://huggingface.co/THUDM/CogVideoX1.5-5B-SAT).\n- 🔥 **News**: ```2024/10/13```: A more cost-effective fine-tuning framework for `CogVideoX-5B` that works with a single\n  4090 GPU, [cogvideox-factory](https://github.com/a-r-r-o-w/cogvideox-factory), has been released. It supports\n  fine-tuning with multiple resolutions. Feel free to use it!\n- 🔥 **News**: ```2024/10/10```: We have updated our technical report. Please\n  click [here](https://arxiv.org/pdf/2408.06072) to view it. More training details and a demo have been added. To see\n  the demo, click [here](https://yzy-thu.github.io/CogVideoX-demo/).- 🔥 **News**: ```2024/10/09```: We have publicly\n  released the [technical documentation](https://zhipu-ai.feishu.cn/wiki/DHCjw1TrJiTyeukfc9RceoSRnCh) for CogVideoX\n  fine-tuning on Feishu, further increasing distribution flexibility. All examples in the public documentation can be\n  fully reproduced.\n- 🔥 **News**: ```2024/9/19```: We have open-sourced the CogVideoX series image-to-video model **CogVideoX-5B-I2V**.\n  This model can take an image as a background input and generate a video combined with prompt words, offering greater\n  controllability. With this, the CogVideoX series models now support three tasks: text-to-video generation, video\n  continuation, and image-to-video generation. Welcome to try it online\n  at [Experience](https://huggingface.co/spaces/THUDM/CogVideoX-5B-Space).\n- 🔥 ```2024/9/19```: The Caption\n  model [CogVLM2-Caption](https://huggingface.co/THUDM/cogvlm2-llama3-caption), used in the training process of\n  CogVideoX to convert video data into text descriptions, has been open-sourced. Welcome to download and use it.\n- 🔥 ```2024/8/27```: We have open-sourced a larger model in the CogVideoX series, **CogVideoX-5B**. We have\n  significantly optimized the model's inference performance, greatly lowering the inference threshold.\n  You can run **CogVideoX-2B** on older GPUs like `GTX 1080TI`, and **CogVideoX-5B** on desktop GPUs like `RTX 3060`. Please strictly\n  follow the [requirements](requirements.txt) to update and install dependencies, and refer\n  to [cli_demo](inference/cli_demo.py) for inference code. Additionally, the open-source license for\n  the **CogVideoX-2B** model has been changed to the **Apache 2.0 License**.\n- 🔥 ```2024/8/6```: We have open-sourced **3D Causal VAE**, used for **CogVideoX-2B**, which can reconstruct videos with\n  almost no loss.\n- 🔥 ```2024/8/6```: We have open-sourced the first model of the CogVideoX series video generation models, **CogVideoX-2B\n  **.\n- 🌱 **Source**: ```2022/5/19```: We have open-sourced the CogVideo video generation model (now you can see it in\n  the `CogVideo` branch). This is the first open-source large Transformer-based text-to-video generation model. You can\n  access the [ICLR'23 paper](https://arxiv.org/abs/2205.15868) for technical details.\n\n## Table of Contents\n\nJump to a specific section:\n\n- [Quick Start](#quick-start)\n  - [Prompt Optimization](#prompt-optimization)\n  - [SAT](#sat)\n  - [Diffusers](#diffusers)\n- [Gallery](#gallery)\n  - [CogVideoX-5B](#cogvideox-5b)\n  - [CogVideoX-2B](#cogvideox-2b)\n- [Model Introduction](#model-introduction)\n- [Friendly Links](#friendly-links)\n- [Project Structure](#project-structure)\n  - [Quick Start with Colab](#quick-start-with-colab)\n  - [Inference](#inference)\n  - [finetune](#finetune)\n  - [sat](#sat-1)\n  - [Tools](#tools)\n- [CogVideo(ICLR'23)](#cogvideoiclr23)\n- [Citation](#citation)\n- [Model-License](#model-license)\n\n## Quick Start\n\n### Prompt Optimization\n\nBefore running the model, please refer to [this guide](inference/convert_demo.py) to see how we use large models like\nGLM-4 (or other comparable products, such as GPT-4) to optimize the model. This is crucial because the model is trained\nwith long prompts, and a good prompt directly impacts the quality of the video generation.\n\n### SAT\n\n**Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.**\n\nFollow instructions in [sat_demo](sat/README.md): Contains the inference code and fine-tuning code of SAT weights. It is\nrecommended to improve based on the CogVideoX model structure. Innovative researchers use this code to better perform\nrapid stacking and development.\n\n### Diffusers\n\n**Please make sure your Python version is between 3.10 and 3.12, inclusive of both 3.10 and 3.12.**\n\n```\npip install -r requirements.txt\n```\n\nThen follow [diffusers_demo](inference/cli_demo.py): A more detailed explanation of the inference code, mentioning the\nsignificance of common parameters.\n\nFor more details on quantized inference, please refer\nto [diffusers-torchao](https://github.com/sayakpaul/diffusers-torchao/). With Diffusers and TorchAO, quantized inference\nis also possible leading to memory-efficient inference as well as speedup in some cases when compiled. A full list of\nmemory and time benchmarks with various settings on A100 and H100 has been published\nat [diffusers-torchao](https://github.com/sayakpaul/diffusers-torchao).\n\n## Gallery\n\n### CogVideoX-5B\n\n\u003ctable border=\"0\" style=\"width: 100%; text-align: left; margin-top: 20px;\"\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/cf5953ea-96d3-48fd-9907-c4708752c714\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/fe0a78e6-b669-4800-8cf0-b5f9b5145b52\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n       \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/c182f606-8f8c-421d-b414-8487070fcfcb\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/7db2bbce-194d-434d-a605-350254b6c298\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/62b01046-8cab-44cc-bd45-4d965bb615ec\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/d78e552a-4b3f-4b81-ac3f-3898079554f6\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n       \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/30894f12-c741-44a2-9e6e-ddcacc231e5b\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/926575ca-7150-435b-a0ff-4900a963297b\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### CogVideoX-2B\n\n\u003ctable border=\"0\" style=\"width: 100%; text-align: left; margin-top: 20px;\"\u003e\n  \u003ctr\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/ea3af39a-3160-4999-90ec-2f7863c5b0e9\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/9de41efd-d4d1-4095-aeda-246dd834e91d\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n      \u003c/td\u003e\n       \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/941d6661-6a8d-4a1b-b912-59606f0b2841\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n      \u003ctd\u003e\n          \u003cvideo src=\"https://github.com/user-attachments/assets/938529c4-91ae-4f60-b96b-3c3947fa63cb\" width=\"100%\" controls autoplay loop\u003e\u003c/video\u003e\n     \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nTo view the corresponding prompt words for the gallery, please click [here](resources/galary_prompt.md)\n\n## Model Introduction\n\nCogVideoX is an open-source version of the video generation model originating\nfrom [QingYing](https://chatglm.cn/video?lang=en?fr=osm_cogvideo). The table below displays the list of video generation\nmodels we currently offer, along with their foundational information.\n\n\u003ctable style=\"border-collapse: collapse; width: 100%;\"\u003e\n  \u003ctr\u003e\n    \u003cth style=\"text-align: center;\"\u003eModel Name\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eCogVideoX1.5-5B (Latest)\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eCogVideoX1.5-5B-I2V (Latest)\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eCogVideoX-2B\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eCogVideoX-5B\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eCogVideoX-5B-I2V\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eRelease Date\u003c/td\u003e\n    \u003cth style=\"text-align: center;\"\u003eNovember 8, 2024\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eNovember 8, 2024\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eAugust 6, 2024\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eAugust 27, 2024\u003c/th\u003e\n    \u003cth style=\"text-align: center;\"\u003eSeptember 19, 2024\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eVideo Resolution\u003c/td\u003e\n    \u003ctd colspan=\"1\" style=\"text-align: center;\"\u003e1360 * 768\u003c/td\u003e\n    \u003ctd colspan=\"1\" style=\"text-align: center;\"\u003e Min(W, H) = 768 \u003cbr\u003e 768 ≤ Max(W, H) ≤ 1360 \u003cbr\u003e Max(W, H) % 16 = 0 \u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003e720 * 480\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eNumber of Frames\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003eShould be \u003cb\u003e16N + 1\u003c/b\u003e where N \u003c= 10 (default 81)\u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003eShould be \u003cb\u003e8N + 1\u003c/b\u003e where N \u003c= 6 (default 49)\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eInference Precision\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003cb\u003eBF16 (Recommended)\u003c/b\u003e, FP16, FP32, FP8*, INT8, Not supported: INT4\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003cb\u003eFP16*(Recommended)\u003c/b\u003e, BF16, FP32, FP8*, INT8, Not supported: INT4\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003cb\u003eBF16 (Recommended)\u003c/b\u003e, FP16, FP32, FP8*, INT8, Not supported: INT4\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eSingle GPU Memory Usage\u003cbr\u003e\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003ca href=\"https://github.com/THUDM/SwissArmyTransformer\"\u003eSAT\u003c/a\u003e BF16: 76GB \u003cbr\u003e\u003cb\u003ediffusers BF16: from 10GB*\u003c/b\u003e\u003cbr\u003e\u003cb\u003ediffusers INT8(torchao): from 7GB*\u003c/b\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://github.com/THUDM/SwissArmyTransformer\"\u003eSAT\u003c/a\u003e FP16: 18GB \u003cbr\u003e\u003cb\u003ediffusers FP16: 4GB minimum* \u003c/b\u003e\u003cbr\u003e\u003cb\u003ediffusers INT8 (torchao): 3.6GB minimum*\u003c/b\u003e\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003ca href=\"https://github.com/THUDM/SwissArmyTransformer\"\u003eSAT\u003c/a\u003e BF16: 26GB \u003cbr\u003e\u003cb\u003ediffusers BF16 : 5GB minimum* \u003c/b\u003e\u003cbr\u003e\u003cb\u003ediffusers INT8 (torchao): 4.4GB minimum* \u003c/b\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eMulti-GPU Memory Usage\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003cb\u003eBF16: 24GB* using diffusers\u003c/b\u003e\u003cbr\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003cb\u003eFP16: 10GB* using diffusers\u003c/b\u003e\u003cbr\u003e\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003cb\u003eBF16: 15GB* using diffusers\u003c/b\u003e\u003cbr\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eInference Speed\u003cbr\u003e(Step = 50, FP/BF16)\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003eSingle A100: ~1000 seconds (5-second video)\u003cbr\u003eSingle H100: ~550 seconds (5-second video)\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003eSingle A100: ~90 seconds\u003cbr\u003eSingle H100: ~45 seconds\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003eSingle A100: ~180 seconds\u003cbr\u003eSingle H100: ~90 seconds\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003ePrompt Language\u003c/td\u003e\n    \u003ctd colspan=\"5\" style=\"text-align: center;\"\u003eEnglish*\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003ePrompt Token Limit\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e224 Tokens\u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003e226 Tokens\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eVideo Length\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e5 seconds or 10 seconds\u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003e6 seconds\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eFrame Rate\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e16 frames / second \u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003e8 frames / second \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003ePosition Encoding\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e3d_rope_pos_embed\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e3d_sincos_pos_embed\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e3d_rope_pos_embed\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e3d_rope_pos_embed + learnable_pos_embed\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eDownload Link (Diffusers)\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX1.5-5B\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX1.5-5B\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX1.5-5B\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX1.5-5B-I2V\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX1.5-5B-I2V\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX1.5-5B-I2V\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX-2b\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX-2b\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX-2b\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX-5b\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX-5b\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX-5b\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n    \u003ctd style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX-5b-I2V\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX-5b-I2V\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX-5b-I2V\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd style=\"text-align: center;\"\u003eDownload Link (SAT)\u003c/td\u003e\n    \u003ctd colspan=\"2\" style=\"text-align: center;\"\u003e\u003ca href=\"https://huggingface.co/THUDM/CogVideoX1.5-5b-SAT\"\u003e🤗 HuggingFace\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://modelscope.cn/models/ZhipuAI/CogVideoX1.5-5b-SAT\"\u003e🤖 ModelScope\u003c/a\u003e\u003cbr\u003e\u003ca href=\"https://wisemodel.cn/models/ZhipuAI/CogVideoX1.5-5b-SAT\"\u003e🟣 WiseModel\u003c/a\u003e\u003c/td\u003e\n    \u003ctd colspan=\"3\" style=\"text-align: center;\"\u003e\u003ca href=\"./sat/README_zh.md\"\u003eSAT\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n**Data Explanation**\n\n+ While testing using the diffusers library, all optimizations included in the diffusers library were enabled. This\n  scheme has not been tested for actual memory usage on devices outside of **NVIDIA A100 / H100** architectures.\n  Generally, this scheme can be adapted to all **NVIDIA Ampere architecture** and above devices. If optimizations are\n  disabled, memory consumption will multiply, with peak memory usage being about 3 times the value in the table.\n  However, speed will increase by about 3-4 times. You can selectively disable some optimizations, including:\n\n```\npipe.enable_sequential_cpu_offload()\npipe.vae.enable_slicing()\npipe.vae.enable_tiling()\n```\n\n+ For multi-GPU inference, the `enable_sequential_cpu_offload()` optimization needs to be disabled.\n+ Using INT8 models will slow down inference, which is done to accommodate lower-memory GPUs while maintaining minimal\n  video quality loss, though inference speed will significantly decrease.\n+ The CogVideoX-2B model was trained in `FP16` precision, and all CogVideoX-5B models were trained in `BF16` precision.\n  We recommend using the precision in which the model was trained for inference.\n+ [PytorchAO](https://github.com/pytorch/ao) and [Optimum-quanto](https://github.com/huggingface/optimum-quanto/) can be\n  used to quantize the text encoder, transformer, and VAE modules to reduce the memory requirements of CogVideoX. This\n  allows the model to run on free T4 Colabs or GPUs with smaller memory! Also, note that TorchAO quantization is fully\n  compatible with `torch.compile`, which can significantly improve inference speed. FP8 precision must be used on\n  devices with NVIDIA H100 and above, requiring source installation of `torch`, `torchao` Python packages. CUDA 12.4 is recommended.\n+ The inference speed tests also used the above memory optimization scheme. Without memory optimization, inference speed\n  increases by about 10%. Only the `diffusers` version of the model supports quantization.\n+ The model only supports English input; other languages can be translated into English for use via large model\n  refinement.\n\n\n## Friendly Links\n\nWe highly welcome contributions from the community and actively contribute to the open-source community. The following\nworks have already been adapted for CogVideoX, and we invite everyone to use them:\n\n+ [RIFLEx-CogVideoX](https://github.com/thu-ml/RIFLEx)：\n  RIFLEx extends the video with just one line of code: `freq[k-1]=(2np.pi)/(Ls)`. The framework not only supports training-free inference, but also offers models fine-tuned based on CogVideoX. By fine-tuning the model for just 1,000 steps on original-length videos, RIFLEx significantly enhances its length extrapolation capability.\n+ [CogVideoX-Fun](https://github.com/aigc-apps/CogVideoX-Fun): CogVideoX-Fun is a modified pipeline based on the\n  CogVideoX architecture, supporting flexible resolutions and multiple launch methods.\n+ [CogStudio](https://github.com/pinokiofactory/cogstudio): A separate repository for CogVideo's Gradio Web UI, which\n  supports more functional Web UIs.\n+ [Xorbits Inference](https://github.com/xorbitsai/inference): A powerful and comprehensive distributed inference\n  framework, allowing you to easily deploy your own models or the latest cutting-edge open-source models with just one\n  click.\n+ [ComfyUI-CogVideoXWrapper](https://github.com/kijai/ComfyUI-CogVideoXWrapper) Use the ComfyUI framework to integrate\n  CogVideoX into your workflow.\n+ [VideoSys](https://github.com/NUS-HPC-AI-Lab/VideoSys): VideoSys provides a user-friendly, high-performance\n  infrastructure for video generation, with full pipeline support and continuous integration of the latest models and\n  techniques.\n+ [AutoDL Space](https://www.codewithgpu.com/i/THUDM/CogVideo/CogVideoX-5b-demo): A one-click deployment Huggingface\n  Space image provided by community members.\n+ [Interior Design Fine-Tuning Model](https://huggingface.co/collections/bertjiazheng/koolcogvideox-66e4762f53287b7f39f8f3ba):\n  is a fine-tuned model based on CogVideoX, specifically designed for interior design.\n+ [xDiT](https://github.com/xdit-project/xDiT): xDiT is a scalable inference engine for Diffusion Transformers (DiTs)\n  on multiple GPU Clusters. xDiT supports real-time image and video generations services.\n  [cogvideox-factory](https://github.com/a-r-r-o-w/cogvideox-factory): A cost-effective\n  fine-tuning framework for CogVideoX, compatible with the `diffusers` version model. Supports more resolutions, and\n  fine-tuning CogVideoX-5B can be done with a single 4090 GPU.\n+ [CogVideoX-Interpolation](https://github.com/feizc/CogvideX-Interpolation): A pipeline based on the modified CogVideoX\n  structure, aimed at providing greater flexibility for keyframe interpolation generation.\n+ [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio): DiffSynth Studio is a diffusion engine. It has\n  restructured the architecture, including text encoders, UNet, VAE, etc., enhancing computational performance while\n  maintaining compatibility with open-source community models. The framework has been adapted for CogVideoX.\n+ [CogVideoX-Controlnet](https://github.com/TheDenk/cogvideox-controlnet): A simple ControlNet module code that includes the CogVideoX model.\n+ [VideoTuna](https://github.com/VideoVerses/VideoTuna): VideoTuna is the first repo that integrates multiple AI video generation models for text-to-video, image-to-video, text-to-image generation.\n+ [ConsisID](https://github.com/PKU-YuanGroup/ConsisID): An identity-preserving text-to-video generation model, bases on CogVideoX-5B, which keep the face consistent in the generated video by frequency decomposition.\n+ [A Step by Step Tutorial](https://www.youtube.com/watch?v=5UCkMzP2VLE\u0026ab_channel=SECourses): A step-by-step guide on installing and optimizing the CogVideoX1.5-5B-I2V model in Windows and cloud environments. Special thanks to the [FurkanGozukara](https://github.com/FurkanGozukara) for his effort and support!\n\n## Project Structure\n\nThis open-source repository will guide developers to quickly get started with the basic usage and fine-tuning examples\nof the **CogVideoX** open-source model.\n\n### Quick Start with Colab\n\nHere provide three projects that can be run directly on free Colab T4 instances:\n\n+ [CogVideoX-5B-T2V-Colab.ipynb](https://colab.research.google.com/drive/1pCe5s0bC_xuXbBlpvIH1z0kfdTLQPzCS?usp=sharing):\n  CogVideoX-5B Text-to-Video Colab code.\n+ [CogVideoX-5B-T2V-Int8-Colab.ipynb](https://colab.research.google.com/drive/1DUffhcjrU-uz7_cpuJO3E_D4BaJT7OPa?usp=sharing):\n  CogVideoX-5B Quantized Text-to-Video Inference Colab code, which takes about 30 minutes per run.\n+ [CogVideoX-5B-I2V-Colab.ipynb](https://colab.research.google.com/drive/17CqYCqSwz39nZAX2YyonDxosVKUZGzcX?usp=sharing):\n  CogVideoX-5B Image-to-Video Colab code.\n+ [CogVideoX-5B-V2V-Colab.ipynb](https://colab.research.google.com/drive/1comfGAUJnChl5NwPuO8Ox5_6WCy4kbNN?usp=sharing):\n  CogVideoX-5B Video-to-Video Colab code.\n\n### Inference\n\n+ [dcli_demo](inference/cli_demo.py): A more detailed inference code explanation, including the significance of\n  common parameters. All of this is covered here.\n+ [cli_demo_quantization](inference/cli_demo_quantization.py):\n  Quantized model inference code that can run on devices with lower memory. You can also modify this code to support\n  running CogVideoX models in FP8 precision.\n+ [diffusers_vae_demo](inference/cli_vae_demo.py): Code for running VAE inference separately.\n+ [space demo](inference/gradio_composite_demo): The same GUI code as used in the Huggingface Space, with frame\n  interpolation and super-resolution tools integrated.\n\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003cimg src=\"resources/web_demo.png\" style=\"width: 100%; height: auto;\" /\u003e\n\u003c/div\u003e\n\n+ [convert_demo](inference/convert_demo.py): How to convert user input into long-form input suitable for CogVideoX.\n  Since CogVideoX is trained on long texts, we need to transform the input text distribution to match the training data\n  using an LLM. The script defaults to using GLM-4, but it can be replaced with GPT, Gemini, or any other large language\n  model.\n+ [gradio_web_demo](inference/gradio_composite_demo): A simple Gradio web application demonstrating how to use the\n  CogVideoX-2B / 5B model to generate videos. Similar to our Huggingface Space, you can use this script to run a simple\n  web application for video generation.\n\n### finetune\n\n+ [finetune_demo](finetune/README.md): Fine-tuning scheme and details of the diffusers version of the CogVideoX model.\n\n### sat\n\n+ [sat_demo](sat/README.md): Contains the inference code and fine-tuning code of SAT weights. It is recommended to\n  improve based on the CogVideoX model structure. Innovative researchers use this code to better perform rapid stacking\n  and development.\n\n### Tools\n\nThis folder contains some tools for model conversion / caption generation, etc.\n\n+ [convert_weight_sat2hf](tools/convert_weight_sat2hf.py): Converts SAT model weights to Huggingface model weights.\n+ [caption_demo](tools/caption/README.md): Caption tool, a model that understands videos and outputs descriptions in\n  text.\n+ [export_sat_lora_weight](tools/export_sat_lora_weight.py): SAT fine-tuning model export tool, exports the SAT Lora\n  Adapter in diffusers format.\n+ [load_cogvideox_lora](tools/load_cogvideox_lora.py): Tool code for loading the diffusers version of fine-tuned Lora\n  Adapter.\n+ [llm_flux_cogvideox](tools/llm_flux_cogvideox/llm_flux_cogvideox.py): Automatically generate videos using an\n  open-source local large language model + Flux + CogVideoX.\n+ [parallel_inference_xdit](tools/parallel_inference/parallel_inference_xdit.py):\n  Supported by [xDiT](https://github.com/xdit-project/xDiT), parallelize the\n  video generation process on multiple GPUs.\n\n## CogVideo(ICLR'23)\n\nThe official repo for the\npaper: [CogVideo: Large-scale Pretraining for Text-to-Video Generation via Transformers](https://arxiv.org/abs/2205.15868)\nis on the [CogVideo branch](https://github.com/THUDM/CogVideo/tree/CogVideo)\n\n**CogVideo is able to generate relatively high-frame-rate videos.**\nA 4-second clip of 32 frames is shown below.\n\n![High-frame-rate sample](https://raw.githubusercontent.com/THUDM/CogVideo/CogVideo/assets/appendix-sample-highframerate.png)\n\n![Intro images](https://raw.githubusercontent.com/THUDM/CogVideo/CogVideo/assets/intro-image.png)\n\u003cdiv align=\"center\"\u003e\n  \u003cvideo src=\"https://github.com/user-attachments/assets/2fa19651-e925-4a2a-b8d6-b3f216d490ba\" width=\"80%\" controls autoplay\u003e\u003c/video\u003e\n\u003c/div\u003e\n\n\nThe demo for CogVideo is at [https://models.aminer.cn/cogvideo](https://models.aminer.cn/cogvideo/), where you can get\nhands-on practice on text-to-video generation. *The original input is in Chinese.*\n\n## Citation\n\n🌟 If you find our work helpful, please leave us a star and cite our paper.\n\n```\n@article{yang2024cogvideox,\n  title={CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer},\n  author={Yang, Zhuoyi and Teng, Jiayan and Zheng, Wendi and Ding, Ming and Huang, Shiyu and Xu, Jiazheng and Yang, Yuanming and Hong, Wenyi and Zhang, Xiaohan and Feng, Guanyu and others},\n  journal={arXiv preprint arXiv:2408.06072},\n  year={2024}\n}\n@article{hong2022cogvideo,\n  title={CogVideo: Large-scale Pretraining for Text-to-Video Generation via Transformers},\n  author={Hong, Wenyi and Ding, Ming and Zheng, Wendi and Liu, Xinghan and Tang, Jie},\n  journal={arXiv preprint arXiv:2205.15868},\n  year={2022}\n}\n```\n\n## Model-License\n\nThe code in this repository is released under the [Apache 2.0 License](LICENSE).\n\nThe CogVideoX-2B model (including its corresponding Transformers module and VAE module) is released under\nthe [Apache 2.0 License](LICENSE).\n\nThe CogVideoX-5B model (Transformers module, include I2V and T2V) is released under\nthe [CogVideoX LICENSE](https://huggingface.co/THUDM/CogVideoX-5b/blob/main/LICENSE).\n","funding_links":[],"categories":["Content Creation","Python","Image Segmentation","\u003cspan id=\"video\"\u003eVideo\u003c/span\u003e","其他_机器视觉","llm","Video Generation","Open-source Toolboxes and Foundation Models","视频 Video","Repos","4. 机器学习项目 | ML","Outstanding Community Custom Nodes","📋 Contents","Classic Papers"],"sub_categories":["Lead Generation","Creative Uses of Generative AI Image Synthesis Tools","\u003cspan id=\"tool\"\u003eLLM (LLM \u0026 Tool)\u003c/span\u003e","网络服务_其他","🧠 2. Open Foundation Models","World Models \u0026 Simulation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUDM%2FCogVideo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTHUDM%2FCogVideo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUDM%2FCogVideo/lists"}