bubbliiiing commited on
Commit
bfd08f4
1 Parent(s): 9720d1e

update Readme

Browse files
Files changed (4) hide show
  1. LICENSE +71 -0
  2. README.md +324 -3
  3. README_en.md +308 -0
  4. configuration.json +1 -0
LICENSE ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The CogVideoX License
2
+
3
+ 1. Definitions
4
+
5
+ “Licensor” means the CogVideoX Model Team that distributes its Software.
6
+
7
+ “Software” means the CogVideoX model parameters made available under this license.
8
+
9
+ 2. License Grant
10
+
11
+ Under the terms and conditions of this license, the licensor hereby grants you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty-free copyright license. The intellectual property rights of the generated content belong to the user to the extent permitted by applicable local laws.
12
+ This license allows you to freely use all open-source models in this repository for academic research. Users who wish to use the models for commercial purposes must register and obtain a basic commercial license in https://open.bigmodel.cn/mla/form .
13
+ Users who have registered and obtained the basic commercial license can use the models for commercial activities for free, but must comply with all terms and conditions of this license. Additionally, the number of service users (visits) for your commercial activities must not exceed 1 million visits per month.
14
+ If the number of service users (visits) for your commercial activities exceeds 1 million visits per month, you need to contact our business team to obtain more commercial licenses.
15
+ The above copyright statement and this license statement should be included in all copies or significant portions of this software.
16
+
17
+ 3. Restriction
18
+
19
+ You will not use, copy, modify, merge, publish, distribute, reproduce, or create derivative works of the Software, in whole or in part, for any military, or illegal purposes.
20
+
21
+ You will not use the Software for any act that may undermine China's national security and national unity, harm the public interest of society, or infringe upon the rights and interests of human beings.
22
+
23
+ 4. Disclaimer
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ 5. Limitation of Liability
28
+
29
+ EXCEPT TO THE EXTENT PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER BASED IN TORT, NEGLIGENCE, CONTRACT, LIABILITY, OR OTHERWISE WILL ANY LICENSOR BE LIABLE TO YOU FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, OR ANY OTHER COMMERCIAL LOSSES, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
30
+
31
+ 6. Dispute Resolution
32
+
33
+ This license shall be governed and construed in accordance with the laws of People’s Republic of China. Any dispute arising from or in connection with this License shall be submitted to Haidian District People's Court in Beijing.
34
+
35
+ Note that the license is subject to update to a more comprehensive version. For any questions related to the license and copyright, please contact us at license@zhipuai.cn.
36
+
37
+ 1. 定义
38
+
39
+ “许可方”是指分发其软件的 CogVideoX 模型团队。
40
+
41
+ “软件”是指根据本许可提供的 CogVideoX 模型参数。
42
+
43
+ 2. 许可授予
44
+
45
+ 根据本许可的条款和条件,许可方特此授予您非排他性、全球性、不可转让、不可再许可、可撤销、免版税的版权许可。生成内容的知识产权所属,可根据适用当地法律的规定,在法律允许的范围内由用户享有生成内容的知识产权或其他权利。
46
+ 本许可允许您免费使用本仓库中的所有开源模型进行学术研究。对于希望将模型用于商业目的的用户,需在 https://open.bigmodel.cn/mla/form 完成登记并获得基础商用授权。
47
+
48
+ 经过登记并获得基础商用授权的用户可以免费使用本模型进行商业活动,但必须遵守本许可的所有条款和条件。
49
+ 在本许可证下,您的商业活动的服务用户数量(访问量)不得超过100万人次访问 / 每月。如果超过,您需要与我们的商业团队联系以获得更多的商业许可。
50
+ 上述版权声明和本许可声明应包含在本软件的所有副本或重要部分中。
51
+
52
+ 3.限制
53
+
54
+ 您不得出于任何军事或非法目的使用、复制、修改、合并、发布、分发、复制或创建本软件的全部或部分衍生作品。
55
+
56
+ 您不得利用本软件从事任何危害国家安全和国家统一、危害社会公共利益、侵犯人身权益的行为。
57
+
58
+ 4.免责声明
59
+
60
+ 本软件“按原样”提供,不提供任何明示或暗示的保证,包括但不限于对适销性、特定用途的适用性和非侵权性的保证。
61
+ 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是在合同诉讼、侵权行为还是其他方面,由软件或软件的使用或其他交易引起、由软件引起或与之相关 软件。
62
+
63
+ 5. 责任限制
64
+
65
+ 除适用��律禁止的范围外,在任何情况下且根据任何法律理论,无论是基于侵权行为、疏忽、合同、责任或其他原因,任何许可方均不对您承担任何直接、间接、特殊、偶然、示范性、 或间接损害,或任何其他商业损失,即使许可人已被告知此类损害的可能性。
66
+
67
+ 6.争议解决
68
+
69
+ 本许可受中华人民共和国法律管辖并按其解释。 因本许可引起的或与本许可有关的任何争议应提交北京市海淀区人民法院。
70
+
71
+ 请注意,许可证可能会更新到更全面的版本。 有关许可和版权的任何问题,请通过 license@zhipuai.cn 与我们联系。
README.md CHANGED
@@ -1,3 +1,324 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_link: https://modelscope.cn/models/ZhipuAI/CogVideoX-5B/file/view/master?fileName=LICENSE&status=0
4
+ language:
5
+ - en
6
+ tags:
7
+ - cogvideox
8
+ - video-generation
9
+ - thudm
10
+ - text-to-video
11
+ studios:
12
+ - alibaba-pai/CogVideoX-Fun-5b
13
+ inference: false
14
+ ---
15
+
16
+ # CogVideoX-Fun
17
+
18
+ 😊 Welcome!
19
+
20
+ [English](./README_en.md) | 简体中文
21
+
22
+ # 目录
23
+ - [目录](#目录)
24
+ - [简介](#简介)
25
+ - [快速启动](#快速启动)
26
+ - [视频作品](#视频作品)
27
+ - [如何使用](#如何使用)
28
+ - [模型地址](#模型地址)
29
+ - [未来计划](#未来计划)
30
+ - [参考文献](#参考文献)
31
+ - [许可证](#许可证)
32
+
33
+ # 简介
34
+ CogVideoX-Fun是一个基于CogVideoX结构修改后的的pipeline,是一个生成条件更自由的CogVideoX,可用于生成AI图片与视频、训练Diffusion Transformer的基线模型与Lora模型,我们支持从已经训练好的CogVideoX-Fun模型直接进行预测,生成不同分辨率,6秒左右、fps8的视频(1 ~ 49帧),也支持用户训练自己的基线模型与Lora模型,进行一定的风格变换。
35
+
36
+ 我们会逐渐支持从不同平台快速启动,请参阅 [快速启动](#快速启动)。
37
+
38
+ 新特性:
39
+ - 创建代码!现在支持 Windows 和 Linux。支持2b与5b最大256x256x49到1024x1024x49的任意分辨率的视频生成。[ 2024.09.18 ]
40
+
41
+ 功能概览:
42
+ - [数据预处理](#data-preprocess)
43
+ - [训练DiT](#dit-train)
44
+ - [模型生成](#video-gen)
45
+
46
+ 我们的ui界面如下:
47
+ ![ui](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/asset/v1/ui.jpg)
48
+
49
+ # 快速启动
50
+ ### 1. 云使用: AliyunDSW/Docker
51
+ #### a. 通过阿里云 DSW
52
+ DSW 有免费 GPU 时间,用户可申请一次,申请后3个月内有效。
53
+
54
+ 阿里云在[Freetier](https://free.aliyun.com/?product=9602825&crowd=enterprise&spm=5176.28055625.J_5831864660.1.e939154aRgha4e&scm=20140722.M_9974135.P_110.MO_1806-ID_9974135-MID_9974135-CID_30683-ST_8512-V_1)提供免费GPU时间,获取并在阿里云PAI-DSW中使用,5分钟内即可启动CogVideoX-Fun。
55
+
56
+ [![DSW Notebook](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/easyanimate/asset/dsw.png)](https://gallery.pai-ml.com/#/preview/deepLearning/cv/cogvideox_fun)
57
+
58
+ #### b. 通过ComfyUI
59
+ 我们的ComfyUI界面如下,具体查看[ComfyUI README](comfyui/README.md)。
60
+ ![workflow graph](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/asset/v1/cogvideoxfunv1_workflow_i2v.jpg)
61
+
62
+ #### c. 通过docker
63
+ 使用docker的情况下,请保证机器中已经正确安装显卡驱动与CUDA环境,然后以此执行以下命令:
64
+
65
+ ```
66
+ # pull image
67
+ docker pull mybigpai-public-registry.cn-beijing.cr.aliyuncs.com/easycv/torch_cuda:cogvideox_fun
68
+
69
+ # enter image
70
+ docker run -it -p 7860:7860 --network host --gpus all --security-opt seccomp:unconfined --shm-size 200g mybigpai-public-registry.cn-beijing.cr.aliyuncs.com/easycv/torch_cuda:cogvideox_fun
71
+
72
+ # clone code
73
+ git clone https://github.com/aigc-apps/CogVideoX-Fun.git
74
+
75
+ # enter CogVideoX-Fun's dir
76
+ cd CogVideoX-Fun
77
+
78
+ # download weights
79
+ mkdir models/Diffusion_Transformer
80
+ mkdir models/Personalized_Model
81
+
82
+ wget https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz -O models/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz
83
+ wget https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz -O models/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz
84
+
85
+ cd models/Diffusion_Transformer/
86
+ tar -xvf CogVideoX-Fun-2b-InP.tar.gz
87
+ tar -xvf CogVideoX-Fun-5b-InP.tar.gz
88
+ cd ../../
89
+ ```
90
+
91
+ ### 2. 本地安装: 环境检查/下载/安装
92
+ #### a. 环境检查
93
+ 我们已验证CogVideoX-Fun可在以下环境中执行:
94
+
95
+ Windows 的详细信息:
96
+ - 操作系统 Windows 10
97
+ - python: python3.10 & python3.11
98
+ - pytorch: torch2.2.0
99
+ - CUDA: 11.8 & 12.1
100
+ - CUDNN: 8+
101
+ - GPU: Nvidia-3060 12G & Nvidia-3090 24G
102
+
103
+ Linux 的详细信息:
104
+ - 操作系统 Ubuntu 20.04, CentOS
105
+ - python: python3.10 & python3.11
106
+ - pytorch: torch2.2.0
107
+ - CUDA: 11.8 & 12.1
108
+ - CUDNN: 8+
109
+ - GPU:Nvidia-V100 16G & Nvidia-A10 24G & Nvidia-A100 40G & Nvidia-A100 80G
110
+
111
+ 我们需要大约 60GB 的可用磁盘空间,请检查!
112
+
113
+ #### b. 权重放置
114
+ 我们最好将[权重](#model-zoo)按照指定路径进行放置:
115
+
116
+ ```
117
+ 📦 models/
118
+ ├── 📂 Diffusion_Transformer/
119
+ │ ├── 📂 CogVideoX-Fun-2b-InP/
120
+ │ └── 📂 CogVideoX-Fun-5b-InP/
121
+ ├── 📂 Personalized_Model/
122
+ │ └── your trained trainformer model / your trained lora model (for UI load)
123
+ ```
124
+
125
+ # 视频作品
126
+ 所展示的结果都是图生视频获得。
127
+
128
+ ### CogVideoX-Fun-5B
129
+
130
+ Resolution-1024
131
+
132
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
133
+ <tr>
134
+ <td>
135
+ <video src="https://github.com/user-attachments/assets/ec749326-b529-453f-a4b4-f587875dff64" width="100%" controls autoplay loop></video>
136
+ </td>
137
+ <td>
138
+ <video src="https://github.com/user-attachments/assets/84df4178-f493-4aa8-a888-d2020338da82" width="100%" controls autoplay loop></video>
139
+ </td>
140
+ <td>
141
+ <video src="https://github.com/user-attachments/assets/c66c139d-94d3-4930-985b-60e3e0600d8f" width="100%" controls autoplay loop></video>
142
+ </td>
143
+ <td>
144
+ <video src="https://github.com/user-attachments/assets/647c0e0c-28d6-473e-b4eb-a30197dddefc" width="100%" controls autoplay loop></video>
145
+ </td>
146
+ </tr>
147
+ </table>
148
+
149
+ Resolution-768
150
+
151
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
152
+ <tr>
153
+ <td>
154
+ <video src="https://github.com/user-attachments/assets/647d45b0-4253-4438-baf3-f692789bde78" width="100%" controls autoplay loop></video>
155
+ </td>
156
+ <td>
157
+ <video src="https://github.com/user-attachments/assets/e5a5a948-5c34-445d-9446-324a666a6a33" width="100%" controls autoplay loop></video>
158
+ </td>
159
+ <td>
160
+ <video src="https://github.com/user-attachments/assets/0e605797-4a86-4e0c-8589-40ed686d97a4" width="100%" controls autoplay loop></video>
161
+ </td>
162
+ <td>
163
+ <video src="https://github.com/user-attachments/assets/5356bf79-0a3b-4caf-ac31-2d796e20e429" width="100%" controls autoplay loop></video>
164
+ </td>
165
+ </tr>
166
+ </table>
167
+
168
+ Resolution-512
169
+
170
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
171
+ <tr>
172
+ <td>
173
+ <video src="https://github.com/user-attachments/assets/5a9f3457-fe82-4082-8494-d8f4f8db75e9" width="100%" controls autoplay loop></video>
174
+ </td>
175
+ <td>
176
+ <video src="https://github.com/user-attachments/assets/ca6874b8-41d1-4f02-bee3-4fc886f309ad" width="100%" controls autoplay loop></video>
177
+ </td>
178
+ <td>
179
+ <video src="https://github.com/user-attachments/assets/9216b348-2c80-4eab-9c1c-dd3a54b7ea1e" width="100%" controls autoplay loop></video>
180
+ </td>
181
+ <td>
182
+ <video src="https://github.com/user-attachments/assets/e99ec495-655f-44d8-afa7-3ad0a14f9975" width="100%" controls autoplay loop></video>
183
+ </td>
184
+ </tr>
185
+ </table>
186
+
187
+ ### CogVideoX-Fun-2B
188
+
189
+ Resolution-768
190
+
191
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
192
+ <tr>
193
+ <td>
194
+ <video src="https://github.com/user-attachments/assets/d329b4d4-f08f-4e77-887e-049cfc93a908" width="100%" controls autoplay loop></video>
195
+ </td>
196
+ <td>
197
+ <video src="https://github.com/user-attachments/assets/dd7fa2d5-9871-436c-ae5a-44f1494c9c9f" width="100%" controls autoplay loop></video>
198
+ </td>
199
+ <td>
200
+ <video src="https://github.com/user-attachments/assets/c24a2fa2-2fe3-4277-aa9f-e812a2cf0a4e" width="100%" controls autoplay loop></video>
201
+ </td>
202
+ <td>
203
+ <video src="https://github.com/user-attachments/assets/573edac3-8bd0-4e95-82df-bcfdcba9a73f" width="100%" controls autoplay loop></video>
204
+ </td>
205
+ </tr>
206
+ </table>
207
+
208
+
209
+ # 如何使用
210
+
211
+ <h3 id="video-gen">1. 生成 </h3>
212
+
213
+ #### a. 视频生成
214
+ ##### i、运行python文件
215
+ - 步骤1:下载对应[权重](#model-zoo)放入models文件夹。
216
+ - 步骤2:在predict_t2v.py文件中修改prompt、neg_prompt、guidance_scale和seed。
217
+ - 步骤3:运行predict_t2v.py文件,等待生成结果,结果保存在samples/cogvideox-fun-videos-t2v文件夹中。
218
+ - 步骤4:如果想结合自己训练的其他backbone与Lora,则看情况修改predict_t2v.py中的predict_t2v.py和lora_path。
219
+
220
+ ##### ii、通过ui界面
221
+ - 步骤1:下载对应[权重](#model-zoo)放入models文件夹。
222
+ - 步骤2:运行app.py文件,进入gradio页面。
223
+ - 步骤3:根据页面选择生成模型,填入prompt、neg_prompt、guidance_scale和seed等,点击生成,等待生成结果,结果保存在sample文件夹中。
224
+
225
+ ##### iii、通过comfyui
226
+ 具体查看[ComfyUI README](comfyui/README.md)。
227
+
228
+ ### 2. 模型训练
229
+ 一个完整的CogVideoX-Fun训练链路应该包括数据预处理和Video DiT训练。
230
+
231
+ <h4 id="data-preprocess">a.数据预处理</h4>
232
+ 我们给出了一个简单的demo通过图片数据训练lora模型,详情可以查看[wiki](https://github.com/aigc-apps/CogVideoX-Fun/wiki/Training-Lora)。
233
+
234
+ 一个完整的长视频切分、清洗、描述的数据预处理链路可以参考video caption部分的[README](cogvideox/video_caption/README.md)进行。
235
+
236
+ 如果期望训练一个文生图视频的生成模型,您需要以这种格式排列数据集。
237
+ ```
238
+ 📦 project/
239
+ ├── 📂 datasets/
240
+ │ ├── 📂 internal_datasets/
241
+ │ ├── 📂 train/
242
+ │ │ ├── 📄 00000001.mp4
243
+ │ │ ├── 📄 00000002.jpg
244
+ │ │ └── 📄 .....
245
+ │ └── 📄 json_of_internal_datasets.json
246
+ ```
247
+
248
+ json_of_internal_datasets.json是一个标准的json文件。json中的file_path可以被设置为相对路径,如下所示:
249
+ ```json
250
+ [
251
+ {
252
+ "file_path": "train/00000001.mp4",
253
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
254
+ "type": "video"
255
+ },
256
+ {
257
+ "file_path": "train/00000002.jpg",
258
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
259
+ "type": "image"
260
+ },
261
+ .....
262
+ ]
263
+ ```
264
+
265
+ 你也可以将路径设置为绝对路径:
266
+ ```json
267
+ [
268
+ {
269
+ "file_path": "/mnt/data/videos/00000001.mp4",
270
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
271
+ "type": "video"
272
+ },
273
+ {
274
+ "file_path": "/mnt/data/train/00000001.jpg",
275
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
276
+ "type": "image"
277
+ },
278
+ .....
279
+ ]
280
+ ```
281
+ <h4 id="dit-train">b. Video DiT训练 </h4>
282
+
283
+ 如果数据预处理时,数据的格式为相对路径,则进入scripts/train.sh进行如下设置。
284
+ ```
285
+ export DATASET_NAME="datasets/internal_datasets/"
286
+ export DATASET_META_NAME="datasets/internal_datasets/json_of_internal_datasets.json"
287
+
288
+ ...
289
+
290
+ train_data_format="normal"
291
+ ```
292
+
293
+ 如果数据的格式为绝对路径,则进入scripts/train.sh进行如下设置。
294
+ ```
295
+ export DATASET_NAME=""
296
+ export DATASET_META_NAME="/mnt/data/json_of_internal_datasets.json"
297
+ ```
298
+
299
+ 最后运行scripts/train.sh。
300
+ ```sh
301
+ sh scripts/train.sh
302
+ ```
303
+
304
+ 关于一些参数的设置细节,可以查看[Readme Train](scripts/README_TRAIN.md)与[Readme Lora](scripts/README_TRAIN_LORA.md)
305
+
306
+ # 模型地址
307
+ | 名称 | 存储空间 | 下载地址 | Hugging Face | 描述 |
308
+ |--|--|--|--|--|
309
+ | CogVideoX-Fun-2b-InP.tar.gz | 解压前 9.7 GB / 解压后 13.0 GB | [Download](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz) | [🤗Link](https://huggingface.co/alibaba-pai/CogVideoX-Fun-2b-InP)| 官方的图生视频权重。支持多分辨率(512,768,1024,1280)的视频预测,以49帧、每秒8帧进行训练 |
310
+ | CogVideoX-Fun-5b-InP.tar.gz | 解压前 16.0GB / 解压后 20.0 GB | [Download](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz) | [🤗Link](https://huggingface.co/alibaba-pai/CogVideoX-Fun-5b-InP)| 官方的图生视频权重。支持多分辨率(512,768,1024,1280)的视频预测,以49帧、每秒8帧进行训练 |
311
+
312
+ # 未来计划
313
+ - 支持中文。
314
+
315
+ # 参考文献
316
+ - CogVideo: https://github.com/THUDM/CogVideo/
317
+ - EasyAnimate: https://github.com/aigc-apps/EasyAnimate
318
+
319
+ # 许可证
320
+ 本项目采用 [Apache License (Version 2.0)](https://github.com/modelscope/modelscope/blob/master/LICENSE).
321
+
322
+ CogVideoX-2B 模型 (包括其对应的Transformers模块,VAE模块) 根据 [Apache 2.0 协议](LICENSE) 许可证发布。
323
+
324
+ CogVideoX-5B 模型(Transformer 模块)在[CogVideoX许可证](https://huggingface.co/THUDM/CogVideoX-5b/blob/main/LICENSE)下发布.
README_en.md ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CogVideoX-Fun
2
+
3
+ 😊 Welcome!
4
+
5
+ English | [简体中文](./README.md)
6
+
7
+ # Table of Contents
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Introduction](#introduction)
10
+ - [Quick Start](#quick-start)
11
+ - [Video Result](#video-result)
12
+ - [How to use](#how-to-use)
13
+ - [Model zoo](#model-zoo)
14
+ - [TODO List](#todo-list)
15
+ - [Reference](#reference)
16
+ - [License](#license)
17
+
18
+ # Introduction
19
+ CogVideoX-Fun is a modified pipeline based on the CogVideoX structure, designed to provide more flexibility in generation. It can be used to create AI images and videos, as well as to train baseline models and Lora models for Diffusion Transformer. We support predictions directly from the already trained CogVideoX-Fun model, allowing the generation of videos at different resolutions, approximately 6 seconds long with 8 fps (1 to 49 frames). Users can also train their own baseline models and Lora models to achieve certain style transformations.
20
+
21
+ We will support quick pull-ups from different platforms, refer to [Quick Start](#quick-start).
22
+
23
+ What's New:
24
+ - Create code! Now supporting Windows and Linux. Supports 2b and 5b models. Supports video generation at any resolution from 256x256x49 to 1024x1024x49. [ 2024.09.18 ]
25
+
26
+ Function:
27
+ - [Data Preprocessing](#data-preprocess)
28
+ - [Train DiT](#dit-train)
29
+ - [Video Generation](#video-gen)
30
+
31
+ Our UI interface is as follows:
32
+ ![ui](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/asset/v1/ui.jpg)
33
+
34
+ # Quick Start
35
+ ### 1. Cloud usage: AliyunDSW/Docker
36
+ #### a. From AliyunDSW
37
+ DSW has free GPU time, which can be applied once by a user and is valid for 3 months after applying.
38
+
39
+ Aliyun provide free GPU time in [Freetier](https://free.aliyun.com/?product=9602825&crowd=enterprise&spm=5176.28055625.J_5831864660.1.e939154aRgha4e&scm=20140722.M_9974135.P_110.MO_1806-ID_9974135-MID_9974135-CID_30683-ST_8512-V_1), get it and use in Aliyun PAI-DSW to start CogVideoX-Fun within 5min!
40
+
41
+ [![DSW Notebook](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/easyanimate/asset/dsw.png)](https://gallery.pai-ml.com/#/preview/deepLearning/cv/cogvideox_fun)
42
+
43
+ #### b. From ComfyUI
44
+ Our ComfyUI is as follows, please refer to [ComfyUI README](comfyui/README.md) for details.
45
+ ![workflow graph](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/asset/v1/cogvideoxfunv1_workflow_i2v.jpg)
46
+
47
+ #### c. From docker
48
+ If you are using docker, please make sure that the graphics card driver and CUDA environment have been installed correctly in your machine.
49
+
50
+ Then execute the following commands in this way:
51
+
52
+ ```
53
+ # pull image
54
+ docker pull mybigpai-public-registry.cn-beijing.cr.aliyuncs.com/easycv/torch_cuda:cogvideox_fun
55
+
56
+ # enter image
57
+ docker run -it -p 7860:7860 --network host --gpus all --security-opt seccomp:unconfined --shm-size 200g mybigpai-public-registry.cn-beijing.cr.aliyuncs.com/easycv/torch_cuda:cogvideox_fun
58
+
59
+ # clone code
60
+ git clone https://github.com/aigc-apps/CogVideoX-Fun.git
61
+
62
+ # enter CogVideoX-Fun's dir
63
+ cd CogVideoX-Fun
64
+
65
+ # download weights
66
+ mkdir models/Diffusion_Transformer
67
+ mkdir models/Personalized_Model
68
+
69
+ wget https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz -O models/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz
70
+ wget https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz -O models/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz
71
+
72
+ cd models/Diffusion_Transformer/
73
+ tar -xvf CogVideoX-Fun-2b-InP.tar.gz
74
+ tar -xvf CogVideoX-Fun-5b-InP.tar.gz
75
+ cd ../../
76
+ ```
77
+
78
+ ### 2. Local install: Environment Check/Downloading/Installation
79
+ #### a. Environment Check
80
+ We have verified CogVideoX-Fun execution on the following environment:
81
+
82
+ The detailed of Windows:
83
+ - OS: Windows 10
84
+ - python: python3.10 & python3.11
85
+ - pytorch: torch2.2.0
86
+ - CUDA: 11.8 & 12.1
87
+ - CUDNN: 8+
88
+ - GPU: Nvidia-3060 12G & Nvidia-3090 24G
89
+
90
+ The detailed of Linux:
91
+ - OS: Ubuntu 20.04, CentOS
92
+ - python: python3.10 & python3.11
93
+ - pytorch: torch2.2.0
94
+ - CUDA: 11.8 & 12.1
95
+ - CUDNN: 8+
96
+ - GPU:Nvidia-V100 16G & Nvidia-A10 24G & Nvidia-A100 40G & Nvidia-A100 80G
97
+
98
+ We need about 60GB available on disk (for saving weights), please check!
99
+
100
+ #### b. Weights
101
+ We'd better place the [weights](#model-zoo) along the specified path:
102
+
103
+ ```
104
+ 📦 models/
105
+ ├── 📂 Diffusion_Transformer/
106
+ │ ├── 📂 CogVideoX-Fun-2b-InP/
107
+ │ └── 📂 CogVideoX-Fun-5b-InP/
108
+ ├── 📂 Personalized_Model/
109
+ │ └── your trained trainformer model / your trained lora model (for UI load)
110
+ ```
111
+
112
+ # Video Result
113
+ The results displayed are all based on image.
114
+
115
+ ### CogVideoX-Fun-5B
116
+
117
+ Resolution-1024
118
+
119
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
120
+ <tr>
121
+ <td>
122
+ <video src="https://github.com/user-attachments/assets/ec749326-b529-453f-a4b4-f587875dff64" width="100%" controls autoplay loop></video>
123
+ </td>
124
+ <td>
125
+ <video src="https://github.com/user-attachments/assets/84df4178-f493-4aa8-a888-d2020338da82" width="100%" controls autoplay loop></video>
126
+ </td>
127
+ <td>
128
+ <video src="https://github.com/user-attachments/assets/c66c139d-94d3-4930-985b-60e3e0600d8f" width="100%" controls autoplay loop></video>
129
+ </td>
130
+ <td>
131
+ <video src="https://github.com/user-attachments/assets/647c0e0c-28d6-473e-b4eb-a30197dddefc" width="100%" controls autoplay loop></video>
132
+ </td>
133
+ </tr>
134
+ </table>
135
+
136
+ Resolution-768
137
+
138
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
139
+ <tr>
140
+ <td>
141
+ <video src="https://github.com/user-attachments/assets/647d45b0-4253-4438-baf3-f692789bde78" width="100%" controls autoplay loop></video>
142
+ </td>
143
+ <td>
144
+ <video src="https://github.com/user-attachments/assets/e5a5a948-5c34-445d-9446-324a666a6a33" width="100%" controls autoplay loop></video>
145
+ </td>
146
+ <td>
147
+ <video src="https://github.com/user-attachments/assets/0e605797-4a86-4e0c-8589-40ed686d97a4" width="100%" controls autoplay loop></video>
148
+ </td>
149
+ <td>
150
+ <video src="https://github.com/user-attachments/assets/5356bf79-0a3b-4caf-ac31-2d796e20e429" width="100%" controls autoplay loop></video>
151
+ </td>
152
+ </tr>
153
+ </table>
154
+
155
+ Resolution-512
156
+
157
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
158
+ <tr>
159
+ <td>
160
+ <video src="https://github.com/user-attachments/assets/5a9f3457-fe82-4082-8494-d8f4f8db75e9" width="100%" controls autoplay loop></video>
161
+ </td>
162
+ <td>
163
+ <video src="https://github.com/user-attachments/assets/ca6874b8-41d1-4f02-bee3-4fc886f309ad" width="100%" controls autoplay loop></video>
164
+ </td>
165
+ <td>
166
+ <video src="https://github.com/user-attachments/assets/9216b348-2c80-4eab-9c1c-dd3a54b7ea1e" width="100%" controls autoplay loop></video>
167
+ </td>
168
+ <td>
169
+ <video src="https://github.com/user-attachments/assets/e99ec495-655f-44d8-afa7-3ad0a14f9975" width="100%" controls autoplay loop></video>
170
+ </td>
171
+ </tr>
172
+ </table>
173
+
174
+ ### CogVideoX-Fun-2B
175
+
176
+ <table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
177
+ <tr>
178
+ <td>
179
+ <video src="https://github.com/user-attachments/assets/d329b4d4-f08f-4e77-887e-049cfc93a908" width="100%" controls autoplay loop></video>
180
+ </td>
181
+ <td>
182
+ <video src="https://github.com/user-attachments/assets/dd7fa2d5-9871-436c-ae5a-44f1494c9c9f" width="100%" controls autoplay loop></video>
183
+ </td>
184
+ <td>
185
+ <video src="https://github.com/user-attachments/assets/c24a2fa2-2fe3-4277-aa9f-e812a2cf0a4e" width="100%" controls autoplay loop></video>
186
+ </td>
187
+ <td>
188
+ <video src="https://github.com/user-attachments/assets/573edac3-8bd0-4e95-82df-bcfdcba9a73f" width="100%" controls autoplay loop></video>
189
+ </td>
190
+ </tr>
191
+ </table>
192
+
193
+ # How to use
194
+
195
+ <h3 id="video-gen">1. Inference </h3>
196
+
197
+ #### a. Using Python Code
198
+ - Step 1: Download the corresponding [weights](#model-zoo) and place them in the models folder.
199
+ - Step 2: Modify prompt, neg_prompt, guidance_scale, and seed in the predict_t2v.py file.
200
+ - Step 3: Run the predict_t2v.py file, wait for the generated results, and save the results in the samples/cogvideox-fun-videos-t2v folder.
201
+ - Step 4: If you want to combine other backbones you have trained with Lora, modify the predict_t2v.py and Lora_path in predict_t2v.py depending on the situation.
202
+
203
+ #### b. Using webui
204
+ - Step 1: Download the corresponding [weights](#model-zoo) and place them in the models folder.
205
+ - Step 2: Run the app.py file to enter the graph page.
206
+ - Step 3: Select the generated model based on the page, fill in prompt, neg_prompt, guidance_scale, and seed, click on generate, wait for the generated result, and save the result in the samples folder.
207
+
208
+ #### c. From ComfyUI
209
+ Please refer to [ComfyUI README](comfyui/README.md) for details.
210
+
211
+ ### 2. Model Training
212
+ A complete CogVideoX-Fun training pipeline should include data preprocessing, and Video DiT training.
213
+
214
+ <h4 id="data-preprocess">a. data preprocessing</h4>
215
+
216
+ We have provided a simple demo of training the Lora model through image data, which can be found in the [wiki](https://github.com/aigc-apps/CogVideoX-Fun/wiki/Training-Lora) for details.
217
+
218
+ A complete data preprocessing link for long video segmentation, cleaning, and description can refer to [README](cogvideox/video_caption/README.md) in the video captions section.
219
+
220
+ If you want to train a text to image and video generation model. You need to arrange the dataset in this format.
221
+
222
+ ```
223
+ 📦 project/
224
+ ├── 📂 datasets/
225
+ │ ├── 📂 internal_datasets/
226
+ │ ├── 📂 train/
227
+ │ │ ├── 📄 00000001.mp4
228
+ │ │ ├── 📄 00000002.jpg
229
+ │ │ └── 📄 .....
230
+ │ └── 📄 json_of_internal_datasets.json
231
+ ```
232
+
233
+ The json_of_internal_datasets.json is a standard JSON file. The file_path in the json can to be set as relative path, as shown in below:
234
+ ```json
235
+ [
236
+ {
237
+ "file_path": "train/00000001.mp4",
238
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
239
+ "type": "video"
240
+ },
241
+ {
242
+ "file_path": "train/00000002.jpg",
243
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
244
+ "type": "image"
245
+ },
246
+ .....
247
+ ]
248
+ ```
249
+
250
+ You can also set the path as absolute path as follow:
251
+ ```json
252
+ [
253
+ {
254
+ "file_path": "/mnt/data/videos/00000001.mp4",
255
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
256
+ "type": "video"
257
+ },
258
+ {
259
+ "file_path": "/mnt/data/train/00000001.jpg",
260
+ "text": "A group of young men in suits and sunglasses are walking down a city street.",
261
+ "type": "image"
262
+ },
263
+ .....
264
+ ]
265
+ ```
266
+
267
+ <h4 id="dit-train">b. Video DiT training </h4>
268
+
269
+ If the data format is relative path during data preprocessing, please set ```scripts/train.sh``` as follow.
270
+ ```
271
+ export DATASET_NAME="datasets/internal_datasets/"
272
+ export DATASET_META_NAME="datasets/internal_datasets/json_of_internal_datasets.json"
273
+ ```
274
+
275
+ If the data format is absolute path during data preprocessing, please set ```scripts/train.sh``` as follow.
276
+ ```
277
+ export DATASET_NAME=""
278
+ export DATASET_META_NAME="/mnt/data/json_of_internal_datasets.json"
279
+ ```
280
+
281
+ Then, we run scripts/train.sh.
282
+ ```sh
283
+ sh scripts/train.sh
284
+ ```
285
+
286
+ For details on setting some parameters, please refer to [Readme Train](scripts/README_TRAIN.md) and [Readme Lora](scripts/README_TRAIN_LORA.md).
287
+
288
+
289
+ # Model zoo
290
+
291
+ | Name | Storage Space | Url | Hugging Face | Description |
292
+ |--|--|--|--|--|
293
+ | CogVideoX-Fun-2b-InP.tar.gz | Before extraction:9.7 GB \/ After extraction: 13.0 GB | [Download](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-2b-InP.tar.gz) | [🤗Link](https://huggingface.co/alibaba-pai/CogVideoX-Fun-2b-InP)| Our official graph-generated video model is capable of predicting videos at multiple resolutions (512, 768, 1024, 1280) and has been trained on 49 frames at a rate of 8 frames per second. |
294
+ | CogVideoX-Fun-5b-InP.tar.gz | Before extraction:16.0 GB \/ After extraction: 20.0 GB | [Download](https://pai-aigc-photog.oss-cn-hangzhou.aliyuncs.com/cogvideox_fun/Diffusion_Transformer/CogVideoX-Fun-5b-InP.tar.gz) | [🤗Link](https://huggingface.co/alibaba-pai/CogVideoX-Fun-5b-InP)| Our official graph-generated video model is capable of predicting videos at multiple resolutions (512, 768, 1024, 1280) and has been trained on 49 frames at a rate of 8 frames per second. |
295
+
296
+ # TODO List
297
+ - Support Chinese.
298
+
299
+ # Reference
300
+ - CogVideo: https://github.com/THUDM/CogVideo/
301
+ - EasyAnimate: https://github.com/aigc-apps/EasyAnimate
302
+
303
+ # License
304
+ This project is licensed under the [Apache License (Version 2.0)](https://github.com/modelscope/modelscope/blob/master/LICENSE).
305
+
306
+ The CogVideoX-2B model (including its corresponding Transformers module and VAE module) is released under the [Apache 2.0 License](LICENSE).
307
+
308
+ The CogVideoX-5B model (Transformers module) is released under the [CogVideoX LICENSE](https://huggingface.co/THUDM/CogVideoX-5b/blob/main/LICENSE).
configuration.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"framework":"Pytorch","task":"text-to-video-synthesis"}