[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-jy0205--Pyramid-Flow":3,"tool-jy0205--Pyramid-Flow":62},[4,18,26,35,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":74,"owner_twitter":74,"owner_website":79,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":10,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":112,"github_topics":113,"view_count":32,"oss_zip_url":74,"oss_zip_packed_at":74,"status":17,"created_at":117,"updated_at":118,"faqs":119,"releases":154},4954,"jy0205\u002FPyramid-Flow","Pyramid-Flow","[ICLR 2025] Pyramidal Flow Matching for Efficient Video Generative Modeling","Pyramid-Flow 是一款基于流匹配（Flow Matching）技术的高效开源视频生成模型，旨在以较低的计算成本创作高质量视频。它解决了传统视频扩散模型因全程在全分辨率下处理高噪声数据而导致的算力浪费问题，通过独特的金字塔式架构，在不同分辨率和噪声层级间进行插值，实现了视觉内容的同步生成与解压。\n\n该工具仅需在开源数据集上训练，即可生成长达 10 秒、768p 分辨率且帧率为 24fps 的流畅视频，并原生支持图生视频功能。其核心技术亮点在于采用端到端优化的单一 DiT 架构，结合多 GPU 推理与 CPU 卸载技术，显著降低了显存需求，使普通显卡也能高效运行。此外，最新推出的 miniFLUX 版本进一步优化了人物结构与运动稳定性。\n\nPyramid-Flow 非常适合 AI 研究人员探索高效的生成式建模方法，也适用于开发者构建视频应用或设计师快速原型创作。对于希望本地部署高性能视频生成模型的进阶用户而言，这是一个兼具学术价值与实用性的优秀选择。","\u003Cdiv align=\"center\">\n\n# ⚡️Pyramid Flow⚡️\n\n[[Paper]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.05954) [[Project Page ✨]](https:\u002F\u002Fpyramid-flow.github.io) [[miniFLUX Model 🚀]](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) [[SD3 Model ⚡️]](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3) [[demo 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow)]\n\n\u003C\u002Fdiv>\n\nThis is the official repository for Pyramid Flow, a training-efficient **Autoregressive Video Generation** method based on **Flow Matching**. By training only on **open-source datasets**, it can generate high-quality 10-second videos at 768p resolution and 24 FPS, and naturally supports image-to-video generation.\n\n\u003Ctable class=\"center\" border=\"0\" style=\"width: 100%; text-align: left;\">\n\u003Ctr>\n  \u003Cth>10s, 768p, 24fps\u003C\u002Fth>\n  \u003Cth>5s, 768p, 24fps\u003C\u002Fth>\n  \u003Cth>Image-to-video\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F9935da83-ae56-4672-8747-0f46e90f7b2b\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F3412848b-64db-4d9e-8dbf-11403f6d02c5\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F3bd7251f-7b2c-4bee-951d-656fdb45f427\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n## News\n* `2024.11.13`  🚀🚀🚀 We release the [768p miniFLUX checkpoint](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) (up to 10s).\n\n  > We have switched the model structure from SD3 to a mini FLUX to fix human structure issues, please try our 1024p image checkpoint, 384p video checkpoint (up to 5s) and 768p video checkpoint (up to 10s). The new miniflux model shows great improvement on human structure and motion stability\n\n* `2024.10.29` ⚡️⚡️⚡️ We release [training code for VAE](#1-training-vae), [finetuning code for DiT](#2-finetuning-dit) and [new model checkpoints](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) with FLUX structure trained from scratch.\n\n\n* `2024.10.13`  ✨✨✨ [Multi-GPU inference](#3-multi-gpu-inference) and [CPU offloading](#cpu-offloading) are supported. Use it with **less than 8GB** of GPU memory, with great speedup on multiple GPUs.\n\n* `2024.10.11`  🤗🤗🤗 [Hugging Face demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow) is available. Thanks [@multimodalart](https:\u002F\u002Fhuggingface.co\u002Fmultimodalart) for the commit! \n\n* `2024.10.10`  🚀🚀🚀 We release the [technical report](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.05954), [project page](https:\u002F\u002Fpyramid-flow.github.io) and [model checkpoint](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3) of Pyramid Flow.\n\n## Table of Contents\n\n* [Introduction](#introduction)\n* [Installation](#installation)\n* [Inference](#inference)\n  1. [Quick Start with Gradio](#1-quick-start-with-gradio)\n  2. [Inference Code](#2-inference-code)\n  3. [Multi-GPU Inference](#3-multi-gpu-inference)\n  4. [Usage Tips](#4-usage-tips)\n* [Training](#Training)\n  1. [Training VAE](#training-vae)\n  2. [Finetuning DiT](#finetuning-dit)\n* [Gallery](#gallery)\n* [Comparison](#comparison)\n* [Acknowledgement](#acknowledgement)\n* [Citation](#citation)\n\n## Introduction\n\n![motivation](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_dc14b883c6cd.jpg)\n\nExisting video diffusion models operate at full resolution, spending a lot of computation on very noisy latents. By contrast, our method harnesses the flexibility of flow matching ([Lipman et al., 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=PqvMRDCJT9t); [Liu et al., 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=XVjTT1nw5z); [Albergo & Vanden-Eijnden, 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=li7qeBbCR1t)) to interpolate between latents of different resolutions and noise levels, allowing for simultaneous generation and decompression of visual content with better computational efficiency. The entire framework is end-to-end optimized with a single DiT ([Peebles & Xie, 2023](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FICCV2023\u002Fhtml\u002FPeebles_Scalable_Diffusion_Models_with_Transformers_ICCV_2023_paper.html)), generating high-quality 10-second videos at 768p resolution and 24 FPS within 20.7k A100 GPU training hours.\n\n## Installation\n\nWe recommend setting up the environment with conda. The codebase currently uses Python 3.8.10 and PyTorch 2.1.2 ([guide](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Fprevious-versions\u002F#v212)), and we are actively working to support a wider range of versions.\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\ncd Pyramid-Flow\n\n# create env using conda\nconda create -n pyramid python==3.8.10\nconda activate pyramid\npip install -r requirements.txt\n```\n\nThen, download the model from [Huggingface](https:\u002F\u002Fhuggingface.co\u002Frain1011) (there are two variants: [miniFLUX](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) or [SD3](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3)). The miniFLUX models support 1024p image, 384p and 768p video generation, and the SD3-based models support 768p and 384p video generation. The 384p checkpoint generates 5-second video at 24FPS, while the 768p checkpoint generates up to 10-second video at 24FPS.\n\n```python\nfrom huggingface_hub import snapshot_download\n\nmodel_path = 'PATH'   # The local directory to save downloaded checkpoint\nsnapshot_download(\"rain1011\u002Fpyramid-flow-miniflux\", local_dir=model_path, local_dir_use_symlinks=False, repo_type='model')\n```\n\n## Inference\n\n### 1. Quick start with Gradio\n\nTo get started, first install [Gradio](https:\u002F\u002Fwww.gradio.app\u002Fguides\u002Fquickstart), set your model path at [#L36](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002F3777f8b84bddfa2aa2b497ca919b3f40567712e6\u002Fapp.py#L36), and then run on your local machine:\n\n```bash\npython app.py\n```\n\nThe Gradio demo will be opened in a browser. Thanks to [@tpc2233](https:\u002F\u002Fgithub.com\u002Ftpc2233) the commit, see [#48](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F48) for details.\n\nOr, try it out effortlessly on [Hugging Face Space 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow) created by [@multimodalart](https:\u002F\u002Fhuggingface.co\u002Fmultimodalart). Due to GPU limits, this online demo can only generate 25 frames (export at 8FPS or 24FPS). Duplicate the space to generate longer videos.\n\n#### Quick Start on Google Colab\n\nTo quickly try out Pyramid Flow on Google Colab, run the code below:\n\n```\n# Setup\n!git clone https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\n%cd Pyramid-Flow\n!pip install -r requirements.txt\n!pip install gradio\n\n# This code downloads miniFLUX\nfrom huggingface_hub import snapshot_download\n\nmodel_path = '\u002Fcontent\u002FPyramid-Flow'\nsnapshot_download(\"rain1011\u002Fpyramid-flow-miniflux\", local_dir=model_path, local_dir_use_symlinks=False, repo_type='model')\n\n# Start\n!python app.py\n```\n\n### 2. Inference Code\n\nTo use our model, please follow the inference code in `video_generation_demo.ipynb` at [this link](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fvideo_generation_demo.ipynb). We strongly recommend you to try the latest published pyramid-miniflux, which shows great improvement on human structure and motion stability. Set the param `model_name` to `pyramid_flux` to use. We further simplify it into the following two-step procedure. First, load the downloaded model:\n\n```python\nimport torch\nfrom PIL import Image\nfrom pyramid_dit import PyramidDiTForVideoGeneration\nfrom diffusers.utils import load_image, export_to_video\n\ntorch.cuda.set_device(0)\nmodel_dtype, torch_dtype = 'bf16', torch.bfloat16   # Use bf16 (not support fp16 yet)\n\nmodel = PyramidDiTForVideoGeneration(\n    'PATH',                                         # The downloaded checkpoint dir\n    model_name=\"pyramid_flux\",\n    model_dtype=model_dtype,\n    model_variant='diffusion_transformer_768p',\n)\n\nmodel.vae.enable_tiling()\n# model.vae.to(\"cuda\")\n# model.dit.to(\"cuda\")\n# model.text_encoder.to(\"cuda\")\n\n# if you're not using sequential offloading bellow uncomment the lines above ^\nmodel.enable_sequential_cpu_offload()\n```\n\nThen, you can try text-to-video generation on your own prompts. Noting that the 384p version only support 5s now (set temp up to 16)! \n\n```python\nprompt = \"A movie trailer featuring the adventures of the 30 year old space man wearing a red wool knitted motorcycle helmet, blue sky, salt desert, cinematic style, shot on 35mm film, vivid colors\"\n\n# used for 384p model variant\n# width = 640\n# height = 384\n\n# used for 768p model variant\nwidth = 1280\nheight = 768\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate(\n        prompt=prompt,\n        num_inference_steps=[20, 20, 20],\n        video_num_inference_steps=[10, 10, 10],\n        height=height,     \n        width=width,\n        temp=16,                    # temp=16: 5s, temp=31: 10s\n        guidance_scale=7.0,         # The guidance for the first frame, set it to 7 for 384p variant\n        video_guidance_scale=5.0,   # The guidance for the other video latent\n        output_type=\"pil\",\n        save_memory=True,           # If you have enough GPU memory, set it to `False` to improve vae decoding speed\n    )\n\nexport_to_video(frames, \".\u002Ftext_to_video_sample.mp4\", fps=24)\n```\n\nAs an autoregressive model, our model also supports (text conditioned) image-to-video generation:\n\n```python\n# used for 384p model variant\n# width = 640\n# height = 384\n\n# used for 768p model variant\nwidth = 1280\nheight = 768\n\nimage = Image.open('assets\u002Fthe_great_wall.jpg').convert(\"RGB\").resize((width, height))\nprompt = \"FPV flying over the Great Wall\"\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate_i2v(\n        prompt=prompt,\n        input_image=image,\n        num_inference_steps=[10, 10, 10],\n        temp=16,\n        video_guidance_scale=4.0,\n        output_type=\"pil\",\n        save_memory=True,           # If you have enough GPU memory, set it to `False` to improve vae decoding speed\n    )\n\nexport_to_video(frames, \".\u002Fimage_to_video_sample.mp4\", fps=24)\n```\n\n#### CPU offloading\n\nWe also support two types of CPU offloading to reduce GPU memory requirements. Note that they may sacrifice efficiency.\n* Adding a `cpu_offloading=True` parameter to the generate function allows inference with **less than 12GB** of GPU memory. This feature was contributed by [@Ednaordinary](https:\u002F\u002Fgithub.com\u002FEdnaordinary), see [#23](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F23) for details.\n* Calling `model.enable_sequential_cpu_offload()` before the above procedure allows inference with **less than 8GB** of GPU memory. This feature was contributed by [@rodjjo](https:\u002F\u002Fgithub.com\u002Frodjjo), see [#75](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F75) for details.\n\n#### MPS backend\n\nThanks to [@niw](https:\u002F\u002Fgithub.com\u002Fniw), Apple Silicon users (e.g. MacBook Pro with M2 24GB) can also try our model using the MPS backend! Please see [#113](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F113) for the details.\n\n### 3. Multi-GPU Inference\n\nFor users with multiple GPUs, we provide an [inference script](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fscripts\u002Finference_multigpu.sh) that uses sequence parallelism to save memory on each GPU. This also brings a big speedup, taking only 2.5 minutes to generate a 5s, 768p, 24fps video on 4 A100 GPUs (vs. 5.5 minutes on a single A100 GPU). Run it on 2 GPUs with the following command:\n\n```bash\nCUDA_VISIBLE_DEVICES=0,1 sh scripts\u002Finference_multigpu.sh\n```\n\nIt currently supports 2 or 4 GPUs (For SD3 Version), with more configurations available in the original script. You can also launch a [multi-GPU Gradio demo](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fscripts\u002Fapp_multigpu_engine.sh) created by [@tpc2233](https:\u002F\u002Fgithub.com\u002Ftpc2233), see [#59](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F59) for details.\n\n  > Spoiler: We didn't even use sequence parallelism in training, thanks to our efficient pyramid flow designs.\n\n### 4. Usage tips\n\n* The `guidance_scale` parameter controls the visual quality. We suggest using a guidance within [7, 9] for the 768p checkpoint during text-to-video generation, and 7 for the 384p checkpoint.\n* The `video_guidance_scale` parameter controls the motion. A larger value increases the dynamic degree and mitigates the autoregressive generation degradation, while a smaller value stabilizes the video.\n* For 10-second video generation, we recommend using a guidance scale of 7 and a video guidance scale of 5.\n\n## Training\n\n### 1. Training VAE\n\nThe hardware requirements for training VAE are at least 8 A100 GPUs. Please refer to [this document](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fdocs\u002FVAE.md). This is a [MAGVIT-v2](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.05737) like continuous 3D VAE, which should be quite flexible. Feel free to build your own video generative model on this part of VAE training code.\n\n### 2. Finetuning DiT\n\nThe hardware requirements for finetuning DiT are at least 8 A100 GPUs. Please refer to [this document](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fdocs\u002FDiT.md). We provide instructions for both autoregressive and non-autoregressive versions of Pyramid Flow. The former is more research oriented and the latter is more stable (but less efficient without temporal pyramid).\n\n## Gallery\n\nThe following video examples are generated at 5s, 768p, 24fps. For more results, please visit our [project page](https:\u002F\u002Fpyramid-flow.github.io).\n\n\u003Ctable class=\"center\" border=\"0\" style=\"width: 100%; text-align: left;\">\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F5b44a57e-fa08-4554-84a2-2c7a99f2b343\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F5afd5970-de72-40e2-900d-a20d18308e8e\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F1d44daf8-017f-40e9-bf18-1e19c0a8983b\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F7f5dd901-b7d7-48cc-b67a-3c5f9e1546d2\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n## Comparison\n\nOn VBench ([Huang et al., 2024](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FVchitect\u002FVBench_Leaderboard)), our method surpasses all the compared open-source baselines. Even with only public video data, it achieves comparable performance to commercial models like Kling ([Kuaishou, 2024](https:\u002F\u002Fkling.kuaishou.com\u002Fen)) and Gen-3 Alpha ([Runway, 2024](https:\u002F\u002Frunwayml.com\u002Fresearch\u002Fintroducing-gen-3-alpha)), especially in the quality score (84.74 vs. 84.11 of Gen-3) and motion smoothness.\n\n![vbench](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_cef59f0ff0e0.jpg)\n\nWe conduct an additional user study with 20+ participants. As can be seen, our method is preferred over open-source models such as [Open-Sora](https:\u002F\u002Fgithub.com\u002Fhpcaitech\u002FOpen-Sora) and [CogVideoX-2B](https:\u002F\u002Fgithub.com\u002FTHUDM\u002FCogVideo) especially in terms of motion smoothness.\n\n![user_study](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_f8a92115615c.jpg)\n\n## Acknowledgement\n\nWe are grateful for the following awesome projects when implementing Pyramid Flow:\n\n* [SD3 Medium](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-3-medium) and [Flux 1.0](https:\u002F\u002Fhuggingface.co\u002Fblack-forest-labs\u002FFLUX.1-dev): State-of-the-art image generation models based on flow matching.\n* [Diffusion Forcing](https:\u002F\u002Fboyuan.space\u002Fdiffusion-forcing) and [GameNGen](https:\u002F\u002Fgamengen.github.io): Next-token prediction meets full-sequence diffusion.\n* [WebVid-10M](https:\u002F\u002Fgithub.com\u002Fm-bain\u002Fwebvid), [OpenVid-1M](https:\u002F\u002Fgithub.com\u002FNJU-PCALab\u002FOpenVid-1M) and [Open-Sora Plan](https:\u002F\u002Fgithub.com\u002FPKU-YuanGroup\u002FOpen-Sora-Plan): Large-scale datasets for text-to-video generation.\n* [CogVideoX](https:\u002F\u002Fgithub.com\u002FTHUDM\u002FCogVideo): An open-source text-to-video generation model that shares many training details.\n* [Video-LLaMA2](https:\u002F\u002Fgithub.com\u002FDAMO-NLP-SG\u002FVideoLLaMA2): An open-source video LLM for our video recaptioning.\n\n## Citation\n\nConsider giving this repository a star and cite Pyramid Flow in your publications if it helps your research.\n```\n@article{jin2024pyramidal,\n  title={Pyramidal Flow Matching for Efficient Video Generative Modeling},\n  author={Jin, Yang and Sun, Zhicheng and Li, Ningyuan and Xu, Kun and Xu, Kun and Jiang, Hao and Zhuang, Nan and Huang, Quzhe and Song, Yang and Mu, Yadong and Lin, Zhouchen},\n  jounal={arXiv preprint arXiv:2410.05954},\n  year={2024}\n}\n```\n","\u003Cdiv align=\"center\">\n\n# ⚡️Pyramid Flow⚡️\n\n[[论文]](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.05954) [[项目页面 ✨]](https:\u002F\u002Fpyramid-flow.github.io) [[miniFLUX模型 🚀]](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) [[SD3模型 ⚡️]](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3) [[演示 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow)]\n\n\u003C\u002Fdiv>\n\n这是 Pyramid Flow 的官方仓库，它是一种基于 **流匹配** 的高效训练型 **自回归视频生成** 方法。仅通过在 **开源数据集** 上进行训练，即可生成高质量的 768p 分辨率、24 FPS 的 10 秒视频，并且自然支持图像到视频的生成。\n\n\u003Ctable class=\"center\" border=\"0\" style=\"width: 100%; text-align: left;\">\n\u003Ctr>\n  \u003Cth>10s, 768p, 24fps\u003C\u002Fth>\n  \u003Cth>5s, 768p, 24fps\u003C\u002Fth>\n  \u003Cth>Image-to-video\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F9935da83-ae56-4672-8747-0f46e90f7b2b\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F3412848b-64db-4d9e-8dbf-11403f6d02c5\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F3bd7251f-7b2c-4bee-951d-656fdb45f427\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n## 最新消息\n* `2024.11.13`  🚀🚀🚀 我们发布了 [768p miniFLUX 检查点](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux)（最长 10 秒）。\n\n  > 我们已将模型结构从 SD3 切换为 mini FLUX，以解决人体结构问题。请尝试我们的 1024p 图像检查点、384p 视频检查点（最长 5 秒）以及 768p 视频检查点（最长 10 秒）。新的 miniflux 模型在人体结构和运动稳定性方面有了显著提升。\n\n* `2024.10.29` ⚡️⚡️⚡️ 我们发布了 [VAE 训练代码](#1-training-vae)、[DiT 微调代码](#2-finetuning-dit)以及使用 FLUX 结构从头开始训练的新模型检查点（[Hugging Face](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux)）。\n\n* `2024.10.13`  ✨✨✨ 支持 [多 GPU 推理](#3-multi-gpu-inference) 和 [CPU 张量卸载](#cpu-offloading)。只需不到 8GB 的 GPU 内存即可运行，在多 GPU 上还能获得显著加速。\n\n* `2024.10.11`  🤗🤗🤗 [Hugging Face 演示](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow) 已上线。感谢 [@multimodalart](https:\u002F\u002Fhuggingface.co\u002Fmultimodalart) 的贡献！\n\n* `2024.10.10`  🚀🚀🚀 我们发布了 Pyramid Flow 的 [技术报告](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.05954)、[项目主页](https:\u002F\u002Fpyramid-flow.github.io) 以及 [模型检查点](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3)。\n\n## 目录\n\n* [简介](#introduction)\n* [安装](#installation)\n* [推理](#inference)\n  1. [Gradio 快速入门](#1-quick-start-with-gradio)\n  2. [推理代码](#2-inference-code)\n  3. [多 GPU 推理](#3-multi-gpu-inference)\n  4. [使用技巧](#4-usage-tips)\n* [训练](#Training)\n  1. [训练 VAE](#training-vae)\n  2. [微调 DiT](#finetuning-dit)\n* [作品展示](#gallery)\n* [对比](#comparison)\n* [致谢](#acknowledgement)\n* [引用](#citation)\n\n## 简介\n\n![motivation](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_dc14b883c6cd.jpg)\n\n现有的视频扩散模型通常以全分辨率运行，大量计算资源都耗费在噪声极高的潜在空间上。相比之下，我们的方法利用流匹配的灵活性（[Lipman 等, 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=PqvMRDCJT9t)；[Liu 等, 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=XVjTT1nw5z)；[Albergo & Vanden-Eijnden, 2023](https:\u002F\u002Fopenreview.net\u002Fforum?id=li7qeBbCR1t)），在不同分辨率和噪声水平的潜在空间之间进行插值，从而实现视觉内容的同时生成与解压缩，计算效率更高。整个框架采用端到端优化设计，仅使用一个 DiT 模型（[Peebles & Xie, 2023](http:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FICCV2023\u002Fhtml\u002FPeebles_Scalable_Diffusion_Models_with_Transformers_ICCV_2023_paper.html)），在 20.7k A100 GPU 训练小时内，即可生成 768p 分辨率、24 FPS 的高质量 10 秒视频。\n\n## 安装\n\n我们建议使用 conda 来搭建环境。当前代码库使用 Python 3.8.10 和 PyTorch 2.1.2（[指南](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Fprevious-versions\u002F#v212)），我们正在积极适配更多版本的支持。\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\ncd Pyramid-Flow\n\n# 使用 conda 创建环境\nconda create -n pyramid python==3.8.10\nconda activate pyramid\npip install -r requirements.txt\n```\n\n然后，从 [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Frain1011) 下载模型（有两种版本：[miniFLUX](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-miniflux) 或 [SD3](https:\u002F\u002Fhuggingface.co\u002Frain1011\u002Fpyramid-flow-sd3)）。miniFLUX 模型支持 1024p 图像、384p 和 768p 视频生成，而基于 SD3 的模型则支持 768p 和 384p 视频生成。384p 检查点可生成 5 秒、24 FPS 的视频，768p 检查点则可生成最长 10 秒、24 FPS 的视频。\n\n```python\nfrom huggingface_hub import snapshot_download\n\nmodel_path = 'PATH'   # 用于保存下载检查点的本地目录\nsnapshot_download(\"rain1011\u002Fpyramid-flow-miniflux\", local_dir=model_path, local_dir_use_symlinks=False, repo_type='model')\n```\n\n## 推理\n\n### 1. Gradio 快速入门\n\n要开始使用，首先安装 [Gradio](https:\u002F\u002Fwww.gradio.app\u002Fguides\u002Fquickstart)，将模型路径设置为 [#L36](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002F3777f8b84bddfa2aa2b497ca919b3f40567712e6\u002Fapp.py#L36)，然后在本地运行：\n\n```bash\npython app.py\n```\n\nGradio 演示将在浏览器中打开。感谢 [@tpc2233](https:\u002F\u002Fgithub.com\u002Ftpc2233) 的贡献，详情请参见 [#48](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F48)。\n\n或者，您也可以在 [@multimodalart](https:\u002F\u002Fhuggingface.co\u002Fmultimodalart) 创建的 [Hugging Face Space 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FPyramid-Flow\u002Fpyramid-flow) 上轻松试用。由于 GPU 限制，此在线演示每次只能生成 25 帧（以 8 FPS 或 24 FPS 导出）。您可以复制该空间来生成更长的视频。\n\n#### Google Colab 快速入门\n\n要在 Google Colab 上快速试用 Pyramid Flow，请运行以下代码：\n\n```\n# 设置\n!git clone https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\n%cd Pyramid-Flow\n!pip install -r requirements.txt\n!pip install gradio\n\n# 此代码下载 miniFLUX\nfrom huggingface_hub import snapshot_download\n\nmodel_path = '\u002Fcontent\u002FPyramid-Flow'\nsnapshot_download(\"rain1011\u002Fpyramid-flow-miniflux\", local_dir=model_path, local_dir_use_symlinks=False, repo_type='model')\n\n# 启动\n!python app.py\n```\n\n### 2. 推理代码\n\n要使用我们的模型，请按照[此链接](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fvideo_generation_demo.ipynb)中的 `video_generation_demo.ipynb` 推理代码进行操作。我们强烈建议您尝试最新发布的 pyramid-miniflux，它在人体结构和运动稳定性方面有显著提升。请将参数 `model_name` 设置为 `pyramid_flux` 即可使用。我们进一步将其简化为以下两步流程。首先，加载下载的模型：\n\n```python\nimport torch\nfrom PIL import Image\nfrom pyramid_dit import PyramidDiTForVideoGeneration\nfrom diffusers.utils import load_image, export_to_video\n\ntorch.cuda.set_device(0)\nmodel_dtype, torch_dtype = 'bf16', torch.bfloat16   # 使用 bf16（暂不支持 fp16）\n\nmodel = PyramidDiTForVideoGeneration(\n    'PATH',                                         # 下载的检查点目录\n    model_name=\"pyramid_flux\",\n    model_dtype=model_dtype,\n    model_variant='diffusion_transformer_768p',\n)\n\nmodel.vae.enable_tiling()\n# model.vae.to(\"cuda\")\n# model.dit.to(\"cuda\")\n# model.text_encoder.to(\"cuda\")\n\n# 如果不使用顺序卸载，请取消注释上面的几行 ^\nmodel.enable_sequential_cpu_offload()\n```\n\n然后，您可以根据自己的提示词尝试文本到视频的生成。请注意，384p 版本目前仅支持 5 秒视频（temp 最高设置为 16）！\n\n```python\nprompt = \"一部电影预告片，讲述一位身穿红色羊毛针织摩托车头盔的30岁太空人的冒险故事，蓝天、盐碱沙漠，电影风格，采用35毫米胶片拍摄，色彩鲜艳\"\n\n# 用于384p模型版本\n# width = 640\n# height = 384\n\n# 用于768p模型版本\nwidth = 1280\nheight = 768\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate(\n        prompt=prompt,\n        num_inference_steps=[20, 20, 20],\n        video_num_inference_steps=[10, 10, 10],\n        height=height,     \n        width=width,\n        temp=16,                    # temp=16: 5秒，temp=31: 10秒\n        guidance_scale=7.0,         # 第一帧的指导权重，384p版本设为7\n        video_guidance_scale=5.0,   # 其他视频潜变量的指导权重\n        output_type=\"pil\",\n        save_memory=True,           # 如果GPU显存充足，可设为`False`以提高VAE解码速度\n    )\n\nexport_to_video(frames, \".\u002Ftext_to_video_sample.mp4\", fps=24)\n```\n\n作为自回归模型，我们的模型还支持（文本条件下的）图像到视频生成：\n\n```python\n# 用于384p模型版本\n# width = 640\n# height = 384\n\n# 用于768p模型版本\nwidth = 1280\nheight = 768\n\nimage = Image.open('assets\u002Fthe_great_wall.jpg').convert(\"RGB\").resize((width, height))\nprompt = \"FPV视角飞越长城\"\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate_i2v(\n        prompt=prompt,\n        input_image=image,\n        num_inference_steps=[10, 10, 10],\n        temp=16,\n        video_guidance_scale=4.0,\n        output_type=\"pil\",\n        save_memory=True,           # 如果GPU显存充足，可设为`False`以提高VAE解码速度\n    )\n\nexport_to_video(frames, \".\u002Fimage_to_video_sample.mp4\", fps=24)\n```\n\n#### CPU卸载\n\n我们还支持两种CPU卸载方式，以降低GPU显存需求。请注意，这些方法可能会牺牲效率。\n* 在生成函数中添加 `cpu_offloading=True` 参数，即可在**低于12GB**的GPU显存下进行推理。该功能由 [@Ednaordinary](https:\u002F\u002Fgithub.com\u002FEdnaordinary) 贡献，详情请参见 [#23](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F23)。\n* 在上述步骤之前调用 `model.enable_sequential_cpu_offload()`，则可在**低于8GB**的GPU显存下进行推理。该功能由 [@rodjjo](https:\u002F\u002Fgithub.com\u002Frodjjo) 贡献，详情请参见 [#75](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F75)。\n\n#### MPS后端\n\n感谢 [@niw](https:\u002F\u002Fgithub.com\u002Fniw)，Apple Silicon 用户（例如配备 M2 24GB 的 MacBook Pro）也可以使用 MPS 后端来体验我们的模型！详情请参见 [#113](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F113)。\n\n### 3. 多GPU推理\n\n对于拥有多个GPU的用户，我们提供了一个[推理脚本](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fscripts\u002Finference_multigpu.sh)，它利用序列并行技术来节省每张GPU上的显存。这也能带来显著的速度提升，仅需2.5分钟即可在4张A100 GPU上生成一段5秒、768p、24fps的视频（相比之下，单张A100 GPU需要5.5分钟）。您可以通过以下命令在2张GPU上运行该脚本：\n\n```bash\nCUDA_VISIBLE_DEVICES=0,1 sh scripts\u002Finference_multigpu.sh\n```\n\n目前该脚本支持2或4张GPU（适用于SD3版本），更多配置可在原始脚本中找到。此外，您还可以启动由 [@tpc2233](https:\u002F\u002Fgithub.com\u002Ftpc2233) 创建的[多GPU Gradio演示](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fscripts\u002Fapp_multigpu_engine.sh)，详情请参见 [#59](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fpull\u002F59)。\n\n  > 剧透：我们在训练过程中甚至没有使用序列并行技术，这都要归功于我们高效的金字塔流设计。\n\n### 4. 使用技巧\n\n* `guidance_scale` 参数控制视觉质量。我们建议在768p检查点的文本到视频生成中使用[7, 9]之间的指导权重，而在384p检查点中使用7。\n* `video_guidance_scale` 参数控制运动效果。较高的值会增加动态程度并缓解自回归生成带来的退化，而较低的值则会使视频更加稳定。\n* 对于10秒视频的生成，我们推荐使用7的指导权重和5的视频指导权重。\n\n## 训练\n\n### 1. VAE训练\n\n训练VAE的硬件要求至少需要8张A100 GPU。请参考[本文档](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fdocs\u002FVAE.md)。这是一个类似[MAGVIT-v2](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.05737)的连续3D VAE，应该具有相当高的灵活性。您可以基于这部分VAE训练代码构建自己的视频生成模型。\n\n### 2. DiT微调\n\n微调DiT的硬件要求至少需要8张A100 GPU。请参考[本文档](https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fblob\u002Fmain\u002Fdocs\u002FDiT.md)。我们提供了针对自回归和非自回归版本的金字塔流的训练说明。前者更偏向研究用途，后者则更为稳定（但在缺乏时序金字塔的情况下效率较低）。\n\n## 作品集\n\n以下视频示例以5秒、768p、24fps的规格生成。如需更多结果，请访问我们的[项目页面](https:\u002F\u002Fpyramid-flow.github.io)。\n\n\u003Ctable class=\"center\" border=\"0\" style=\"width: 100%; text-align: left;\">\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F5b44a57e-fa08-4554-84a2-2c7a99f2b343\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F5afd5970-de72-40e2-900d-a20d18308e8e\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F1d44daf8-017f-40e9-bf18-1e19c0a8983b\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n  \u003Ctd>\u003Cvideo src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F7f5dd901-b7d7-48cc-b67a-3c5f9e1546d2\" autoplay muted loop playsinline>\u003C\u002Fvideo>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n## 对比\n\n在VBench（Huang等，2024）上，我们的方法超越了所有对比的开源基线模型。即使仅使用公开视频数据，其性能也与Kling（快手，2024）和Gen-3 Alpha（Runway，2024）等商业模型相当，尤其是在质量得分（84.74 vs. Gen-3的84.11）和运动流畅度方面表现突出。\n\n![vbench](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_cef59f0ff0e0.jpg)\n\n我们还进行了一项包含20多名参与者的用户研究。结果显示，我们的方法在运动流畅性等方面明显优于Open-Sora（GitHub）和CogVideoX-2B（THUDM）等开源模型。\n\n![user_study](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_readme_f8a92115615c.jpg)\n\n## 致谢\n\n在实现Pyramid Flow的过程中，我们受益于以下优秀项目：\n\n* [SD3 Medium](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-3-medium) 和 [Flux 1.0](https:\u002F\u002Fhuggingface.co\u002Fblack-forest-labs\u002FFLUX.1-dev)：基于流匹配的最先进图像生成模型。\n* [Diffusion Forcing](https:\u002F\u002Fboyuan.space\u002Fdiffusion-forcing) 和 [GameNGen](https:\u002F\u002Fgamengen.github.io)：将下一帧预测与全序列扩散相结合。\n* [WebVid-10M](https:\u002F\u002Fgithub.com\u002Fm-bain\u002Fwebvid)、[OpenVid-1M](https:\u002F\u002Fgithub.com\u002FNJU-PCALab\u002FOpenVid-1M) 和 [Open-Sora Plan](https:\u002F\u002Fgithub.com\u002FPKU-YuanGroup\u002FOpen-Sora-Plan)：用于文本到视频生成的大规模数据集。\n* [CogVideoX](https:\u002F\u002Fgithub.com\u002FTHUDM\u002FCogVideo)：一款开源的文本到视频生成模型，共享许多训练细节。\n* [Video-LLaMA2](https:\u002F\u002Fgithub.com\u002FDAMO-NLP-SG\u002FVideoLLaMA2)：用于视频重述的开源视频大语言模型。\n\n## 引用\n\n如果您觉得本仓库对您的研究有所帮助，请为它点赞，并在您的论文中引用Pyramid Flow：\n```\n@article{jin2024pyramidal,\n  title={Pyramidal Flow Matching for Efficient Video Generative Modeling},\n  author={Jin, Yang and Sun, Zhicheng and Li, Ningyuan and Xu, Kun and Xu, Kun and Jiang, Hao and Zhuang, Nan and Huang, Quzhe and Song, Yang and Mu, Yadong and Lin, Zhouchen},\n  jounal={arXiv preprint arXiv:2410.05954},\n  year={2024}\n}\n```","# Pyramid-Flow 快速上手指南\n\nPyramid-Flow 是一种基于流匹配（Flow Matching）的高效自回归视频生成模型。它仅使用开源数据集训练，能够生成高质量的 10 秒长、768p 分辨率、24 FPS 的视频，并原生支持图生视频功能。最新发布的 **miniFLUX** 版本在人体结构和运动稳定性上有了显著提升。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐), macOS (支持 MPS 后端)\n*   **Python**: 3.8.10 (当前代码库主要验证版本)\n*   **PyTorch**: 2.1.2 (需匹配 CUDA 版本)\n*   **GPU 显存**:\n    *   基础推理：建议 12GB+\n    *   开启 CPU Offload 后：可低至 8GB\n    *   多卡推理：支持序列并行以节省单卡显存\n*   **依赖库**: `git`, `conda` (推荐用于环境管理)\n\n> **注意**：目前模型推理主要支持 `bf16` 精度，暂不支持 `fp16`。\n\n## 安装步骤\n\n### 1. 创建虚拟环境并安装依赖\n\n建议使用 Conda 管理环境，以确保依赖兼容性。\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\ncd Pyramid-Flow\n\n# 创建并激活 conda 环境\nconda create -n pyramid python==3.8.10\nconda activate pyramid\n\n# 安装 Python 依赖\npip install -r requirements.txt\n```\n\n### 2. 下载模型权重\n\n项目提供两种主要变体，推荐使用 **miniFLUX** 以获得更好的人体结构表现。\n*   **miniFLUX**: 支持 1024p 图像、384p\u002F768p 视频（最长 10 秒）。\n*   **SD3**: 支持 384p\u002F768p 视频。\n\n以下命令演示如何下载 miniFLUX 模型（请确保网络通畅，或使用国内镜像加速）：\n\n```python\nfrom huggingface_hub import snapshot_download\n\n# 设置本地保存路径\nmodel_path = '.\u002Fmodels\u002Fpyramid-flow-miniflux' \n\n# 下载模型权重\nsnapshot_download(\"rain1011\u002Fpyramid-flow-miniflux\", local_dir=model_path, local_dir_use_symlinks=False, repo_type='model')\n```\n\n## 基本使用\n\n### 方式一：使用 Gradio 快速体验（推荐新手）\n\n这是最简单的启动方式，会自动在浏览器中打开交互界面。\n\n1.  修改 `app.py` 文件第 36 行，将模型路径指向你刚才下载的目录。\n2.  运行以下命令启动服务：\n\n```bash\npython app.py\n```\n\n### 方式二：使用 Python 代码推理\n\n如果你需要集成到自己的项目中，可以使用以下代码进行文生视频或图生视频。\n\n#### 1. 加载模型\n\n```python\nimport torch\nfrom PIL import Image\nfrom pyramid_dit import PyramidDiTForVideoGeneration\nfrom diffusers.utils import load_image, export_to_video\n\n# 设置设备\ntorch.cuda.set_device(0)\nmodel_dtype, torch_dtype = 'bf16', torch.bfloat16   # 必须使用 bf16\n\n# 初始化模型\nmodel = PyramidDiTForVideoGeneration(\n    '.\u002Fmodels\u002Fpyramid-flow-miniflux',               # 模型下载路径\n    model_name=\"pyramid_flux\",                      # 推荐使用 miniFLUX\n    model_dtype=model_dtype,\n    model_variant='diffusion_transformer_768p',     # 可选：768p 或 384p\n)\n\n# 启用 VAE 分块以节省显存\nmodel.vae.enable_tiling()\n\n# 启用顺序 CPU Offload，可将显存需求降至 8GB 以下（若显存充足可注释此行以提升速度）\nmodel.enable_sequential_cpu_offload()\n```\n\n#### 2. 文生视频 (Text-to-Video)\n\n```python\nprompt = \"A movie trailer featuring the adventures of the 30 year old space man wearing a red wool knitted motorcycle helmet, blue sky, salt desert, cinematic style, shot on 35mm film, vivid colors\"\n\n# 分辨率设置\n# 384p 模型: width=640, height=384\n# 768p 模型: width=1280, height=768\nwidth = 1280\nheight = 768\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate(\n        prompt=prompt,\n        num_inference_steps=[20, 20, 20],\n        video_num_inference_steps=[10, 10, 10],\n        height=height,     \n        width=width,\n        temp=16,                    # 帧数控制时长：temp=16 (约 5 秒), temp=31 (约 10 秒)\n        guidance_scale=7.0,         # 首帧引导系数，768p 建议 7-9，384p 建议 7\n        video_guidance_scale=5.0,   # 后续视频帧引导系数\n        output_type=\"pil\",\n        save_memory=True,           # 显存不足时设为 True\n    )\n\nexport_to_video(frames, \".\u002Foutput_text2video.mp4\", fps=24)\n```\n\n#### 3. 图生视频 (Image-to-Video)\n\n```python\n# 准备输入图片并调整大小\nimage = Image.open('assets\u002Fthe_great_wall.jpg').convert(\"RGB\").resize((width, height))\nprompt = \"FPV flying over the Great Wall\"\n\nwith torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):\n    frames = model.generate_i2v(\n        prompt=prompt,\n        input_image=image,\n        num_inference_steps=[10, 10, 10],\n        temp=16,\n        video_guidance_scale=4.0,\n        output_type=\"pil\",\n        save_memory=True,\n    )\n\nexport_to_video(frames, \".\u002Foutput_img2video.mp4\", fps=24)\n```\n\n### 进阶提示：多卡加速\n\n如果你拥有多张 GPU（如 2 张或 4 张 A100），可以使用序列并行脚本大幅缩短生成时间（4 卡生成 5 秒视频仅需约 2.5 分钟）：\n\n```bash\nCUDA_VISIBLE_DEVICES=0,1 sh scripts\u002Finference_multigpu.sh\n```","某独立游戏开发团队需要为宣传短片快速生成一段 10 秒长、768p 分辨率且人物动作自然的开场动画，但面临算力有限且无商业数据集授权的困境。\n\n### 没有 Pyramid-Flow 时\n- **显存门槛高**：传统视频扩散模型需在全分辨率下处理高噪声潜变量，生成 768p 视频往往需要 24GB 以上显存，团队仅有的 8GB 显卡无法运行。\n- **人物结构崩坏**：现有开源模型在生成长视频时，人物肢体容易扭曲或闪烁，难以满足游戏宣传对角色形象的高要求。\n- **训练数据受限**：多数高性能模型依赖私有闭源数据训练，团队无法合法获取或微调，导致生成风格与游戏美术不匹配。\n- **生成效率低下**：为了保证清晰度，通常需要分片段生成再后期拼接，耗时耗力且难以保证时间连贯性。\n\n### 使用 Pyramid-Flow 后\n- **低显存流畅运行**：Pyramid-Flow 利用金字塔流匹配技术，支持 CPU 卸载和多 GPU 推理，仅需不到 8GB 显存即可生成 768p 高清视频。\n- **人物动作稳定自然**：基于 miniFLUX 架构的新版本专门优化了人体结构，生成的 10 秒视频中角色动作流畅，无明显变形或闪烁。\n- **纯开源数据训练**：该模型完全基于开源数据集训练，团队可合法下载权重并进行微调，轻松适配独特的游戏美术风格。\n- **端到端高效生成**：无需分片处理，Pyramid-Flow 能直接端到端生成完整的 10 秒 24fps 视频，大幅缩短从创意到成片的周期。\n\nPyramid-Flow 通过创新的金字塔流匹配机制，让中小团队在有限算力下也能低成本、高质量地创作长篇幅视频内容。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjy0205_Pyramid-Flow_dc14b883.jpg","jy0205",null,"https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fjy0205_7e935222.png","Computer Vision and Machine Learning","Peking University","Beijing, China","https:\u002F\u002Fjy0205.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fjy0205",[82,86,90],{"name":83,"color":84,"percentage":85},"Python","#3572A5",95,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",3.1,{"name":91,"color":92,"percentage":93},"Shell","#89e051",1.8,3178,301,"2026-03-31T10:39:36","MIT","Linux, macOS","NVIDIA GPU 必需（支持 CUDA），推荐 A100；最低显存 8GB（开启 CPU offload 模式），常规运行建议 12GB+，多卡推理支持 2 或 4 卡并行；Apple Silicon (MPS) 用户可使用 MacBook Pro (如 M2 24GB)","未说明",{"notes":102,"python":103,"dependencies":104},"1. 推荐使用 conda 创建环境。2. 模型精度仅支持 bf16 (bfloat16)，暂不支持 fp16。3. 提供两种模型变体：miniFLUX（修复人体结构问题，支持 1024p 图像及最长 10 秒视频）和 SD3。4. 可通过 enable_sequential_cpu_offload() 将显存需求降至 8GB 以下，但会牺牲速度。5. 768p 分辨率生成 10 秒视频在单张 A100 上约需 5.5 分钟，4 张 A100 仅需 2.5 分钟。","3.8.10",[105,106,107,108,109,110,111],"torch==2.1.2","diffusers","transformers","gradio","accelerate","huggingface_hub","Pillow",[15,61],[114,115,116],"diffusion-models","flow-matching","video-generation","2026-03-27T02:49:30.150509","2026-04-11T16:53:14.188129",[120,125,130,135,140,145,150],{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},22499,"项目的训练数据构成是怎样的？是否有公开数据集可用？","当前数据集主要关注人物视频（涵盖所有年龄和性别），典型视频长度大于 15 秒且为人像比例。社区用户正在协助提供额外数据（计划从 100 万扩展至 1 亿条视频）。目前主要挑战在于解决运动模糊等伪影，团队正在研究基于扩散的视频修复模型（类似 SUPIR 但针对视频运动模糊）以扩充高质量训练数据。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F80",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},22493,"运行 768p 和 384p 模型本地推理最少需要多少显存？双显卡（如双 3090）支持吗？","对于单卡显存不足的情况，可以启用 `cpu_offloading=True` 参数，但这会将部分模型卸载到 CPU。目前维护者正在开发多 GPU 推理功能以支持将模型分布在多个 GPU 上（例如双 3090），从而避免使用 CPU 卸载。在该功能完成前，建议先尝试开启 cpu_offloading。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F12",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},22494,"如何生成更长时间的视频（例如 1 分钟）？","要生成长达 1 分钟的视频，请切换到 384p 检查点（checkpoint）。该功能最近已集成到 UI 中，此前需要手动修改 `app.py` 代码。请确保通过 `git pull` 拉取最新代码库或手动下载最新版本以使用此功能。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F34",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},22495,"在 Apple Silicon (M1\u002FM2) Mac 上运行时出现奇怪的视频输出或精度错误怎么办？","Apple Silicon 现已获得支持。如果在 MPS 设备上遇到类型不匹配错误（如 Input type c10::Half 和 bias type c10::BFloat16 不一致），可能需要手动修改代码进行类型转换。例如在 `modeling_causal_conv.py` 的 forward 函数中，将输入强制转换为 bfloat16 后再计算：\n```python\ndtypeX = x.dtype\nx = self.conv(x.to(torch.bfloat16))\nx = x.to(dtypeX)\nreturn x\n```\n同时需确保 `scheduling_flow_matching.py` 中的 timesteps 和 sigmas 以及 `modeling_pyramid_mmdit.py` 中的 scale 计算都正确 cast 为 `torch.bfloat16`。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F101",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},22496,"`num_inference_steps` 和 `video_num_inference_steps` 的最佳设置值是多少？","默认值通常是最优的（例如 28 步）。尝试过高的值（如 image steps=20, video steps=50）反而可能导致结果变差。需要注意的是，在图生视频（Image-to-Video）模式下，第一帧直接使用输入图像而不需要重新生成，因此主要依赖 `video_num_inference_steps` 来控制后续帧的生成质量，而 `num_inference_steps` 主要用于文生视频的第一帧生成。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F49",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},22497,"遇到 'OSError: Unable to load weights from checkpoint file' 或找不到 .safetensors 文件错误如何解决？","该错误通常是因为模型文件未正确下载或路径配置错误。请检查 `checkpoints` 目录下是否存在对应的 `diffusion_pytorch_model.safetensors` 文件。如果是使用 huggingface_hub 下载，请确保网络通畅且使用了正确的 `snapshot_download` 参数（如 `local_dir_use_symlinks=False`）。如果文件确实缺失，请重新下载模型权重并放入正确的文件夹结构中。","https:\u002F\u002Fgithub.com\u002Fjy0205\u002FPyramid-Flow\u002Fissues\u002F19",{"id":151,"question_zh":152,"answer_zh":153,"source_url":134},22498,"环境配置出错或需要重置 Conda 环境时该怎么办？","如果需要重新开始或解决依赖冲突，可以使用命令 `conda remove -n pyramid --all` 彻底删除名为 pyramid 的环境并重建。此外，请根据本地 CUDA 版本，参考 PyTorch 官网安装对应版本的 PyTorch（推荐 2.1.2 版本），以避免 pip 依赖解析错误。",[]]