如何快速上手AnyFlow-FAR-Wan2.1-14B-Diffusers?超详细环境搭建与模型下载指南 如何快速上手AnyFlow-FAR-Wan2.1-14B-Diffusers超详细环境搭建与模型下载指南【免费下载链接】AnyFlow-FAR-Wan2.1-14B-Diffusers项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-14B-DiffusersAnyFlow-FAR-Wan2.1-14B-Diffusers是一款强大的视频生成模型支持文本到视频Text-to-Video、图像到视频Image-to-Video和视频到视频Video-to-Video的生成任务。本指南将帮助你快速搭建环境并下载模型轻松开启视频创作之旅。 关于AnyFlow-FAR-Wan2.1-14B-DiffusersAnyFlow-FAR-Wan2.1-14B-Diffusers是基于Wan2.1-T2V-14B-Diffusers文本到视频骨干模型开发的14B因果视频扩散模型。它具有以下核心特性任意步数生成无需固定推理步数可根据需求灵活调整实现高质量少步生成并随步数增加稳定提升效果。多架构支持支持因果和双向视频扩散模型的任意步蒸馏。多任务能力一站式支持文本到视频、图像到视频和视频到视频生成。可扩展性能已在1.3B到14B参数规模上验证了其性能。 环境搭建步骤1️⃣ 创建并激活Conda环境首先我们需要创建一个专用的Conda环境来隔离项目依赖。打开终端执行以下命令conda create -n far python3.10 conda activate far2️⃣ 安装PyTorch和相关依赖AnyFlow-FAR-Wan2.1-14B-Diffusers需要PyTorch及其他依赖库的支持。使用以下命令安装pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 pip install -r requirements.txt --no-build-isolation 模型下载指南可用模型列表AnyFlow系列提供了多个版本的模型满足不同需求模型名称支持任务分辨率AnyFlow-FAR-Wan2.1-1.3B-DiffusersT2V, I2V, V2V480PAnyFlow-FAR-Wan2.1-14B-DiffusersT2V, I2V, V2V480PAnyFlow-Wan2.1-T2V-14B-DiffusersT2V480PAnyFlow-Wan2.1-T2V-1.3B-DiffusersT2V480P克隆仓库使用以下命令克隆项目仓库git clone https://gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-14B-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 快速开始使用文本到视频生成以下是使用Diffusers进行文本到视频生成的示例代码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-14B-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-14B-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-14B-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) 许可证信息AnyFlow-FAR-Wan2.1-14B-Diffusers模型根据NVIDIA单向非商业许可证NSCLv1发布。根据该许可证模型仅供非商业使用。NVIDIA不对使用模型或衍生模型生成的任何输出主张所有权。完整的许可证信息请参见LICENSE.md。 致谢本代码库基于Diffusers构建。同时参考了FAR、Self-Forcing和TiM的实现。感谢这些项目的作者开源他们的工作。希望本指南能帮助你顺利上手AnyFlow-FAR-Wan2.1-14B-Diffusers开启你的视频创作之旅如有任何问题欢迎查阅项目文档或提交issue。【免费下载链接】AnyFlow-FAR-Wan2.1-14B-Diffusers项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/AnyFlow-FAR-Wan2.1-14B-Diffusers创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考