模型部署arrowPic SkyReels-V2 模型部署教程
SkyReels-V2 模型部署教程
发布时间:2025-07-02 11:36:38

一、简介

SkyReels-V2 模型集成了多模态大语言模型(MLLM)、多阶段预训练、强化学习以及创新的扩散强迫(Diffusion-forcing)框架,实现了在提示词遵循、视觉质量、运动动态以及视频时长等方面的全面突破。通过扩散强迫框架和 多阶段优化技术 ,首次实现了单镜头 30 秒、40 秒的流畅输出,并通过“ Extend ”无限延伸,彻底打破了时长枷锁。

具体详情可看算家云平台镜像社区

本文件主要讲的是SkyReels-V2的部署.

二、环境部署

基础环境要求:

环境名称 版本信息 1
Ubuntu 22.04.5 LTS
Cuda V12.4.131
Python 3.12.7
NVIDIA Corporation RTX 4090

从算家云基础镜像开始创建:
image.png

三、SkyReels-V2安装

首先查看环境信息:

image.png

从github 克隆代码,然后 pip 安装依赖包。

# clone the repository.
git clone https://github.com/SkyworkAI/SkyReels-V2
cd SkyReels-V2
pip install -r requirements.txt

若遇到 flash_attn 一起在安装的问题:可以真的到Releases · Dao-AILab/flash-attention 下载它的编译好的 whl 包,一定要选择对应的版本,

wget https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp312-cp312-linux_x86_64.whl
pip install flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp312-cp312-linux_x86_64.whl

然后在执行 pip install -r requirements.txt

四、下载模型文件

目前开源的模型如下:

Type Model Variant Recommended Height/Width/Frame Link
Diffusion Forcing 1.3B-540P 544 * 960 * 97f 🤗Huggingface 🤖 ModelScope
  5B-540P 544 * 960 * 97f Coming Soon
  5B-720P 720 * 1280 * 121f Coming Soon
  14B-540P 544 * 960 * 97f 🤗Huggingface 🤖 ModelScope
  14B-720P 720 * 1280 * 121f Coming Soon
Text-to-Video 1.3B-540P 544 * 960 * 97f Coming Soon
  5B-540P 544 * 960 * 97f Coming Soon
  5B-720P 720 * 1280 * 121f Coming Soon
  14B-540P 544 * 960 * 97f 🤗Huggingface 🤖 ModelScope
  14B-720P 720 * 1280 * 121f 🤗Huggingface 🤖 ModelScope
Image-to-Video 1.3B-540P 544 * 960 * 97f 🤗Huggingface 🤖 ModelScope
  5B-540P 544 * 960 * 97f Coming Soon
  5B-720P 720 * 1280 * 121f Coming Soon
  14B-540P 544 * 960 * 97f 🤗Huggingface 🤖 ModelScope
  14B-720P 720 * 1280 * 121f Coming Soon
Camera Director 5B-540P 544 * 960 * 97f Coming Soon
  5B-720P 720 * 1280 * 121f Coming Soon
  14B-720P 720 * 1280 * 121f Coming Soon

从ModelScope 下载 Diffusion Forcing1.3B-540P 的模型:

git lfs install
git clone https://www.modelscope.cn/Skywork/SkyReels-V2-DF-1.3B-540P.git

五、运行测试

下载完模型后,将下列代码写入:test.sh

model_id=Skywork/SkyReels-V2-DF-1.3B-540P
# synchronous inference
python generate_video_df.py \
  --model_id ${model_id} \
  --resolution 540P \
  --ar_step 0 \
  --base_num_frames 97 \
  --num_frames 257 \
  --overlap_history 17 \
  --prompt "A graceful white swan with a curved neck and delicate feathers swimming in a serene lake at dawn, its reflection perfectly mirrored in the still water as mist rises from the surface, with the swan occasionally dipping its head into the water to feed." \
  --addnoise_condition 20 \
  --offload

运行 sh test.sh 完成后结果保存在:root/SkyReels-V2/result/diffusion_forcing

image.png

  • 若出现在问题:Error opening output file: File name too long 是由于导出视频的文件名太长所导致的,可以修改 generate_video_df.py 的代码 :找到下列代码,将 [:100] 修改为 [:10]
    if local_rank == 0:
        current_time = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
        video_out_file = f"{args.prompt[:10].replace('/','')}_{args.seed}_{current_time}.mp4"
        output_path = os.path.join(save_dir, video_out_file)
        imageio.mimwrite(output_path, video_frames, fps=fps, quality=8, output_params=["-loglevel", "error"])
  • 无法使用14B模型,若要使用需要至少一张大于60G显存的显卡

六、使用webui界面

通过 python app.py 运行webui

模型可以放在 SkyReels-V2/Skywork 文件夹下,这个镜像中的模型是使用 ln 创建的链接

# app.py
import os
import gradio as gr
import subprocess
import time
import glob
import torch.distributed as dist

def get_model_list(base_dir="./Skywork/"):
    """扫描Skywork目录获取可用的模型列表"""
    try:
        # 确保目录存在
        if not os.path.exists(base_dir):
            os.makedirs(base_dir)
            return ["请选择模型"]  # 返回默认列表
  
        # 扫描目录下的所有子目录
        model_dirs = glob.glob(os.path.join(base_dir, "*"))
        model_ids = []
  
        for dir_path in model_dirs:
            if os.path.isdir(dir_path):
                # 将目录路径转换为model_id格式
                model_name = os.path.basename(dir_path)
                model_id = f"{base_dir}/{model_name}"
                model_ids.append(model_id)
  
        # 如果没有找到模型,返回默认列表
        return model_ids if model_ids else ["请选择模型"]
    except Exception as e:
        print(f"扫描模型目录出错: {str(e)}")
        return ["扫描模型目录出错"]  # 发生错误时返回默认列表

def enhance_prompt(prompt):
    """使用提示词增强器处理提示词"""
    try:
        cmd = [
            "python",
            "skyreels_v2_infer/pipelines/prompt_enhancer.py",
            "--prompt", str(prompt)
        ]
  
        # 执行提示词增强
        process = subprocess.Popen(
            cmd,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            text=True,
            bufsize=1,
            universal_newlines=True

点击此处,立即体验SkyReels-V2!
bg-circle
算力加速·赋能科研
2026闲时计算资源公益助研活动进行中
2026年1月1日-2026年12月31
立即申请
关注好礼
客服中心