# Ruyi-Models 欢迎使用 Ruyi-Models! Ruyi 是一款图生视频模型,能够生成 **768 分辨率、每秒 24 帧总计 5 秒 120 帧的影视级视频**,支持**镜头控制**与**运动幅度控制**,使用 **RTX 3090** 或 **RTX 4090** 可**无精度损失**地生成 512 分辨率、120 帧(768分辨率、~72帧)的视频。 ## 安装方法 克隆本仓库并安装所需的依赖。 ```shell git clone https://github.com/IamCreateAI/Ruyi-Models cd Ruyi-Models pip install -r requirements.txt ``` ### ComfyUI 的安装方法 #### 方法(1):通过 ComfyUI Manager 安装 下载并安装 [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager)。 ```shell cd ComfyUI/custom_nodes/ git clone https://github.com/ltdrdata/ComfyUI-Manager.git # install requirements pip install -r ComfyUI-Manager/requirements.txt ``` 启动 ComfyUI 并打开 Manager。选择 Custom Nodes Manager,然后搜索 “Ruyi”。选择搜索结果中的 ComfyUI-Ruyi(如下方截图所示),点击 “Install” 按钮安装。
最后,搜索 “ComfyUI-VideoHelperSuite” 并安装。 #### 方法(2):手动安装 - 下载并保存本仓库到 *ComfyUI/custom_nodes/Ruyi-Models* 路径。 ```shell # download the repo cd ComfyUI/custom_nodes/ git clone https://github.com/IamCreateAI/Ruyi-Models.git # install requirements pip install -r Ruyi-Models/requirements.txt ``` - 安装依赖项 [ComfyUI-VideoHelperSuite](https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite) 以显示视频输出(如已安装,请跳过本步骤)。 ```shell # download ComfyUI-VideoHelperSuite cd ComfyUI/custom_nodes/ git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git # install requirements pip install -r ComfyUI-VideoHelperSuite/requirements.txt ``` ##### Windows 操作系统下的安装方法 在使用Windows操作系统时,[ComfyUI_windows_portable_nvidia](https://github.com/comfyanonymous/ComfyUI/releases) 是一种常见的发行版。当通过 `run_nvidia_gpu.bat` 启动时,会使用其中嵌入的 Python 解释器。因此,需要在这个内置的 Python 环境中安装运行环境。 例如,如果提取后的发行版目录是 _ComfyUI_windows_portable_,通常可使用以下命令下载仓库并安装运行时环境: ```shell # download the repo cd ComfyUI_windows_portable\ComfyUI\custom_nodes git clone https://github.com/IamCreateAI/Ruyi-Models.git # install requirements using embedded Python interpreter ..\..\python_embeded\python.exe -m pip install -r Ruyi-Models\requirements.txt ``` ## 下载模型(可选) 下载模型并将其保存到指定路径。为了直接运行 Ruyi 模型,建议将模型保存到 _Ruyi-Models/models_ 文件夹中。对于 ComfyUI 用户,路径应为 _ComfyUI/models/Ruyi_。 | 名称 | 类型 | 分辨率 | 最大帧数 | 每秒帧数 | 存储空间 | 下载地址 | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | Ruyi-Mini-7B | 图生视频 | 512 & 768 | 120 | 24 | 17 GB | [🤗](https://huggingface.co/IamCreateAI/Ruyi-Mini-7B) | 例如,下载 Ruyi-Mini-7B 后,文件的路径结构应该为: ``` 📦 Ruyi-Models/models/ or ComfyUI/models/Ruyi/ ├── 📂 Ruyi-Mini-7B/ │ ├── 📂 transformers/ │ ├── 📂 vae/ │ └── 📂 ... ``` > 本仓库**支持自动下载模型功能**,但手动下载提供了更多的可控性。例如,可以下载模型到其他位置,再通过软链接等方式链接到 *ComfyUI/models/Ruyi* 路径。 ## 使用方法 我们提供两种运行模型的方法。第一种是直接使用Python代码。 ```shell python3 predict_i2v.py ``` 具体来说,该脚本将模型下载到 _Ruyi-Models/models_ 文件夹,并使用 _[assets](./assets)_ 文件夹中的图像作为视频推理的起始帧和结束帧。您可以修改脚本中的变量来替换输入图像,并设置视频长度和分辨率等参数。 对于显存超过 24GB 的用户,可以使用 predict_i2v_80g.py 来提高生成速度。对于显存较少的用户,提供了优化显存使用的参数,这些参数可以通过延长推理时间来生成更高分辨率和更长时长的视频。这些参数的影响可以在下面的显存优化选项小节找到。 或者,您可以使用我们 GitHub 仓库中的 ComfyUI 封装,ComfyUI 节点的详细信息在 _[comfyui/README_CN.md](comfyui/README_CN.md)_ 中描述。 ## 效果展示 ### 图生视频效果
### 镜头控制
input left right
static up down
### 运动幅度控制
motion 1 motion 2 motion 3 motion 4
## 显存优化选项 提供了 **`GPU_memory_mode` 和 `GPU_offload_steps`** 选项以**降低显存占用**,满足不同用户的需求。 通常来说,**使用更少的显存,需要更多的内存和更长的生成时间**。以下列出预期显存使用和生成时间的参考表格。请注意,下面报告的显存是 `max_memory_allocated()` 的返回值,而 nvidia-smi 的显存数值通常会高于报告的数值。因为 CUDA 会占用一些显存(通常在500 - 800 MiB之间),而 PyTorch 的缓存机制也会请求额外的显存。 此外,在社区的帮助下创建了一张详细的表格 [gpu_memory_appendix.md](assets/gpu_memory_appendix.md),包含了更多分辨率和选项组合。欢迎社区成员帮助完善表格。 ### A100 的显存占用与运行时间 - Resolution of 512 | 帧数 | normal_mode + 0 steps | normal_mode + 10 steps | normal_mode + 7 steps | normal_mode + 5 steps | normal_mode + 1 steps | low_gpu_mode + 0 steps | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | 24 frames | 16119MiB
_01:01s_ | 15535MiB
_01:07s_ | 15340MiB
_01:13s_ | 15210MiB
_01:20s_ | 14950MiB
_01:32s_ | 4216MiB
_05:14s_ | | 48 frames | 18398MiB
_01:53s_ | 17230MiB
_02:15s_ | 16840MiB
_02:29s_ | 16580MiB
_02:32s_ | 16060MiB
_02:54s_ | 4590MiB
_09:59s_ | | 72 frames | 20678MiB
_03:00s_ | 18925MiB
_03:31s_ | 18340MiB
_03:53s_ | 17951MiB
_03:57s_ | 17171MiB
_04:25s_ | 6870MiB
_14:42s_ | | 96 frames | 22958MiB
_04:11s_ | 20620MiB
_04:54s_ | 19841MiB
_05:10s_ | 19321MiB
_05:14s_ | 18281MiB
_05:47s_ | 9150MiB
_19:17s_ | | 120 frames | 25238MiB
_05:42s_ | 22315MiB
_06:34s_ | 21341MiB
_06:59s_ | 20691MiB
_07:07s_ | 19392MiB
_07:41s_ | 11430MiB
_24:08s_ | - Resolution of 768 | 帧数 | normal_mode + 0 steps | normal_mode + 10 steps | normal_mode + 7 steps | normal_mode + 5 steps | normal_mode + 1 steps | low_gpu_mode + 0 steps | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | 24 frames | 18971MiB
_02:06s_ | 17655MiB
_02:40s_ | 17217MiB
_02:39s_ | 16925MiB
_02:41s_ | 16339MiB
_03:13s_ | 5162MiB
_13:42s_ | | 48 frames | 24101MiB
_04:52s_ | 21469MiB
_05:44s_ | 20592MiB
_05:51s_ | 20008MiB
_06:00s_ | 18837MiB
_06:49s_ | 10292MiB
_20:58s_ | | 72 frames | 29230MiB
_08:24s_ | 25283MiB
_09:45s_ | 25283MiB
_09:45s_ | 23091MiB
_10:10s_ | 21335MiB
_11:10s_ | 15421MiB
_39:12s_ | | 96 frames | 34360MiB
_12:49s_ | 29097MiB
_14:41s_ | 27343MiB
_15:33s_ | 26174MiB
_15:44s_ | 23834MiB
_16:33s_ | 20550MiB
_43:47s_ | | 120 frames | 39489MiB
_18:21s_ | 32911MiB
_20:39s_ | 30719MiB
_21:34s_ | 29257MiB
_21:48s_ | 26332MiB
_23:02s_ | 25679MiB
_63:01s_ | ### RTX 4090 的显存占用与运行时间 表格中以 `---` 显示的值表示触发了显存溢出(OOM),无法生成视频。 - Resolution of 512 | 帧数 | normal_mode + 0 steps | normal_mode + 10 steps | normal_mode + 7 steps | normal_mode + 5 steps | normal_mode + 1 steps | low_gpu_mode + 0 steps | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | 24 frames | 16366MiB
_01:18s_ | 15805MiB
_01:26s_ | 15607MiB
_01:37s_ | 15475MiB
_01:36s_ | 15211MiB
_01:39s_ | 4211MiB
_03:57s_ | | 48 frames | 18720MiB
_02:21s_ | 17532MiB
_02:49s_ | 17136MiB
_02:55s_ | 16872MiB
_02:58s_ | 16344MiB
_03:01s_ | 4666MiB
_05:01s_ | | 72 frames | 21036MiB
_03:41s_ | 19254MiB
_04:25s_ | 18660MiB
_04:34s_ | 18264MiB
_04:36s_ | 17472MiB
_04:51s_ | 6981MiB
_06:36s_ | | 96 frames | -----MiB
_--:--s_ | 20972MiB
_06:18s_ | 20180MiB
_06:24s_ | 19652MiB
_06:36s_ | 18596MiB
_06:56s_ | 9298MiB
_10:03s_ | | 120 frames | -----MiB
_--:--s_ | -----MiB
_--:--s_ | 21704MiB
_08:50s_ | 21044MiB
_08:53s_ | 19724MiB
_09:08s_ | 11613MiB
_13:57s_ | - Resolution of 768 | 帧数 | normal_mode + 0 steps | normal_mode + 10 steps | normal_mode + 7 steps | normal_mode + 5 steps | normal_mode + 1 steps | low_gpu_mode + 0 steps | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | 24 frames | 19223MiB
_02:38s_ | 17900MiB
_03:06s_ | 17448MiB
_03:18s_ | 17153MiB
_03:23s_ | 16624MiB
_03:34s_ | 5251MiB
_05:54s_ | | 48 frames | -----MiB
_--:--s_ | -----MiB
_--:--s_ | 20946MiB
_07:28s_ | 20352MiB
_07:35s_ | 19164MiB
_08:04s_ | 10457MiB
_10:55s_ | | 72 frames | -----MiB
_--:--s_ | -----MiB
_--:--s_ | -----MiB
_--:--s_ | -----MiB
_--:--s_ | -----MiB
_--:--s_ | 15671MiB
_18:52s_ | ## 许可证 我们将以宽松的 **Apache 2.0** 许可证发布该模型。 ## 引用 ``` @misc{createai2024ruyi, title={Ruyi-Mini-7B}, author={CreateAI Team}, year={2024}, publisher = {GitHub}, journal = {GitHub repository}, howpublished={\url{https://github.com/IamCreateAI/Ruyi-Models}} } ``` ## 欢迎建议反馈与协同优化 我们真诚欢迎大家积极提供宝贵的反馈和建议,希望能够共同努力优化我们的服务和产品。您的意见将帮助我们更好地理解用户需求,从而不断提升用户体验。感谢您对我们工作的支持和关注!欢迎加入我们的[Discord](https://discord.com/invite/nueQFQwwGw) 或者微信群(扫描下方二维码,添加 Ruyi 小助手,加入官方交流群)!