如何快速上手AnyFlow-FAR-Wan2.1-1.3B-Diffusers:5分钟搭建文本到视频生成环境

📅 2026/7/13 15:33:39
如何快速上手AnyFlow-FAR-Wan2.1-1.3B-Diffusers:5分钟搭建文本到视频生成环境
如何快速上手AnyFlow-FAR-Wan2.1-1.3B-Diffusers5分钟搭建文本到视频生成环境【免费下载链接】AnyFlow-FAR-Wan2.1-1.3B-Diffusers项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-1.3B-DiffusersAnyFlow-FAR-Wan2.1-1.3B-Diffusers是一款基于Wan2.1-T2V-1.3B-Diffusers文本到视频骨干模型开发的1.3B因果视频扩散模型支持文本到视频T2V、图像到视频I2V和视频到视频V2V多种生成任务让用户能够轻松将创意转化为生动视频内容。 为什么选择AnyFlow-FAR-Wan2.1-1.3B-Diffusers这款模型具有以下核心优势⚡ 任意步数生成不同于传统蒸馏模型固定步数预算单个模型可适应任意推理预算实现高质量少步生成且随着采样步数增加提供稳定改进 多架构支持支持因果和双向视频扩散模型的任意步蒸馏 多任务兼容一个因果视频扩散模型即可支持文本到视频、图像到视频和视频到视频生成 可扩展性能已在1.3B至14B参数范围内验证了性能表现⚙️ 环境准备步骤1️⃣ 创建Conda环境首先需要创建并激活专用的Conda环境conda create -n far python3.10 conda activate far2️⃣ 安装PyTorch和依赖项安装PyTorch及相关依赖pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 pip install -r requirements.txt --no-build-isolation 模型下载方法克隆仓库通过以下命令克隆项目仓库git clone https://gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers使用Hugging Face Hub下载安装Hugging Face Hub工具并下载模型pip install huggingface_hub[cli] hf download nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers --repo-type model --local-dir experiments/pretrained_models/AnyFlow-FAR-Wan2.1-1.3B-Diffusers 项目核心文件结构项目主要包含以下关键目录和文件scheduler/包含调度器配置文件scheduler_config.jsontext_encoder/文本编码器配置和模型文件如config.json和模型权重文件tokenizer/分词器相关文件包括special_tokens_map.json、spiece.model等transformer/转换器配置和模型文件config.json、diffusion_pytorch_model.safetensorsvae/VAE配置和模型文件config.json、diffusion_pytorch_model.safetensorsLICENSE.md模型许可协议文件README.md项目说明文档model_index.json模型索引配置文件 快速开始生成视频文本到视频生成使用以下Python代码实现文本到视频生成import torch from diffusers.utils import export_to_video from far.pipelines.pipeline_far_wan_anyflow import FARWanAnyFlowPipeline model_id nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers pipeline FARWanAnyFlowPipeline.from_pretrained(model_path).to(cuda, dtypetorch.bfloat16) prompt CG game concept digital art, a majestic elephant with a vibrant tusk and sleek fur running swiftly towards a herd of its kind. video pipeline( promptprompt, height480, width832, num_frames81, num_inference_steps4, generatortorch.Generator(cuda).manual_seed(0) ).frames[0] export_to_video(output, output.mp4, fps16)图像到视频生成基于现有图像生成视频import torch from diffusers.utils import export_to_video from PIL import Image from torchvision import transforms from far.pipelines.pipeline_far_wan_anyflow import FARWanAnyFlowPipeline model_id nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers pipeline FARWanAnyFlowPipeline.from_pretrained(model_path).to(cuda, dtypetorch.bfloat16) # 加载图像 image_path assets/example_image.jpg prompt A towering, battle-scarred humanoid robot walking through the skeletal remains of a city ruin. image Image.open(image_path).convert(RGB) image transforms.ToTensor()(transforms.Resize([480, 832])(image)).unsqueeze(0).unsqueeze(0) video pipeline( promptprompt, context_sequence{raw: image}, height480, width832, num_frames81, num_inference_steps4, generatortorch.Generator(cuda).manual_seed(0) ).frames[0] export_to_video(output, output.mp4, fps16)视频到视频生成基于现有视频生成新视频import torch from diffusers.utils import export_to_video import decord from torchvision import transforms from far.pipelines.pipeline_far_wan_anyflow import FARWanAnyFlowPipeline decord.bridge.set_bridge(torch) model_id nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers pipeline FARWanAnyFlowPipeline.from_pretrained(model_path).to(cuda, dtypetorch.bfloat16) # 加载视频 video_path assets/example_video.mp4 prompt A focused trail runners powerful strides through a dense, sun-dappled forest. video_reader decord.VideoReader(video_path) frame_idxs select_frame_indices(len(video_reader), video_reader.get_avg_fps(), target_fps16)[:num_cond_frames] frames video_reader.get_batch(frame_idxs) frames (frames / 255.0).float().permute(0, 3, 1, 2).contiguous() frames transforms.Resize([480, 832])(frames).unsqueeze(0) video pipeline( promptprompt, context_sequence{raw: frames}, height480, width832, num_frames81, num_inference_steps4, generatortorch.Generator(cuda).manual_seed(0) ).frames[0] export_to_video(output, output.mp4, fps16) 许可协议说明该模型根据NVIDIA单向非商业许可NSCLv1发布主要限制包括模型仅供非商业使用NVIDIA不对使用模型或衍生模型生成的任何输出主张所有权完整许可条款请参见LICENSE.md文件。 致谢本代码库基于Diffusers构建同时参考了FAR、Self-Forcing和TiM的实现感谢这些项目的作者开源其工作。【免费下载链接】AnyFlow-FAR-Wan2.1-1.3B-Diffusers项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考