Skip to content

顶级的视频高清放大工具 FlashVSR

功能介绍

对指定视频进行超分放大,效果很不错。具体效果见官网。

img.png

安装

由于安装相对麻烦(尤其是 Block-Sparse-Attention),故制作了一键整合包,关注本公众号,回复 flashvsr 获取。

shell
git clone https://github.com/OpenImagingLab/FlashVSR
cd .\FlashVSR\
 
conda create -n flashvsr_env python=3.11.13
conda activate  flashvsr_env
pip install -e .
pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128
 
# 轮子在此处下载 https://github.com/lihaoyun6/Block-Sparse-Attention/releases/tag/v0.0.1
pip install .\block_sparse_attn-0.0.1+cu128torch2.7cxx11abiFALSE-cp311-cp311-win_amd64.whl

模型下载

text
cd examples/WanVSR

在此处创建文件夹 FlashVSR,之后下载 此处 的所有模型,放置到该文件夹下。

使用方式

目前没有 UI 界面,如果需要 UI 界面,可以考虑是使用 ComfyUI-FlashVSR 插件,对于 windows 来说,为了使用现成的 Block-Sparse-Attention 轮子(自己构建轮子,很容易 OOM,具体见官方描述),需要考虑适配的 python 版本/torch版本/cuda版本。

以下以官方的命令行方式来运行。

首先在 FlashVSR\examples\WanVSR\inputs 目录下放置文件。

之后在 infer_flashvsr_full.py 或者 infer_flashvsr_tiny.py 中指定文件路径,配置放大倍数(官方强烈推荐使用 4 倍放大,我测试下来,2s 的视频放大到 1k,使用 Full 模型的话,24G 显存不足),之后运行如下命令即可。

python
def main():
    RESULT_ROOT = "./results"
    os.makedirs(RESULT_ROOT, exist_ok=True)
    // 这里配置文件路径
    inputs = [
        "./inputs/example0.mp4",
    ]
    // scale 配置放大倍数
    seed, scale, dtype, device = 0, 1, torch.bfloat16, 'cuda'
    sparse_ratio = 2.0      # Recommended: 1.5 or 2.0. 1.5 → faster; 2.0 → more stable.
    pipe = init_pipeline()

Full 模型方式

对显存要求较高。

shell
python infer_flashvsr_full.py

Tiny 模型方式

对显存要求相对较低。

shell
python infer_flashvsr_tiny.py