[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-PeterL1n--RobustVideoMatting":3,"tool-PeterL1n--RobustVideoMatting":61},[4,18,26,36,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},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",151314,2,"2026-04-11T23:32:58",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"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,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"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",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"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":76,"owner_location":77,"owner_email":76,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":85,"forks":86,"last_commit_at":87,"license":88,"difficulty_score":10,"env_os":89,"env_gpu":90,"env_ram":91,"env_deps":92,"category_tags":99,"github_topics":100,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":106,"updated_at":107,"faqs":108,"releases":144},6798,"PeterL1n\u002FRobustVideoMatting","RobustVideoMatting","Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!","RobustVideoMatting 是一款专为视频人像抠图打造的开源 AI 模型，由字节跳动研发并发表于 WACV 2022。它致力于解决传统抠图技术在处理动态视频时常见的闪烁、边缘抖动以及对额外输入（如绿幕或深度图）依赖过强等痛点。\n\n与以往将视频帧视为独立图片处理的模型不同，RobustVideoMatting 的核心亮点在于引入了循环神经网络（RNN）架构，具备“时间记忆”能力。这意味着它能理解视频的前后连贯性，从而在无需任何辅助输入的情况下，自动输出稳定、流畅且高分辨率的抠图结果。其性能表现卓越，在 Nvidia GTX 1080 Ti 显卡上即可实现 4K 分辨率 76FPS 或高清分辨率 104FPS 的实时处理速度。\n\n该工具非常适合视频开发者、算法研究人员以及需要高效后期处理流程的设计师使用。它不仅提供了 PyTorch、TensorFlow 等多种主流框架的预训练模型，还支持 TensorFlow.js 和 CoreML，方便直接部署于网页或移动端。无论是想在自己的项目中集成实时背景替换功能，还是希望通过 Colab 快速体验高质量视频抠图效果，RobustVide","RobustVideoMatting 是一款专为视频人像抠图打造的开源 AI 模型，由字节跳动研发并发表于 WACV 2022。它致力于解决传统抠图技术在处理动态视频时常见的闪烁、边缘抖动以及对额外输入（如绿幕或深度图）依赖过强等痛点。\n\n与以往将视频帧视为独立图片处理的模型不同，RobustVideoMatting 的核心亮点在于引入了循环神经网络（RNN）架构，具备“时间记忆”能力。这意味着它能理解视频的前后连贯性，从而在无需任何辅助输入的情况下，自动输出稳定、流畅且高分辨率的抠图结果。其性能表现卓越，在 Nvidia GTX 1080 Ti 显卡上即可实现 4K 分辨率 76FPS 或高清分辨率 104FPS 的实时处理速度。\n\n该工具非常适合视频开发者、算法研究人员以及需要高效后期处理流程的设计师使用。它不仅提供了 PyTorch、TensorFlow 等多种主流框架的预训练模型，还支持 TensorFlow.js 和 CoreML，方便直接部署于网页或移动端。无论是想在自己的项目中集成实时背景替换功能，还是希望通过 Colab 快速体验高质量视频抠图效果，RobustVideoMatting 都是一个轻量、鲁棒且易于上手的选择。","# Robust Video Matting (RVM)\n\n![Teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPeterL1n_RobustVideoMatting_readme_abdb8077aa8b.gif)\n\n\u003Cp align=\"center\">English | \u003Ca href=\"README_zh_Hans.md\">中文\u003C\u002Fa>\u003C\u002Fp>\n\nOfficial repository for the paper [Robust High-Resolution Video Matting with Temporal Guidance](https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F). RVM is specifically designed for robust human video matting. Unlike existing neural models that process frames as independent images, RVM uses a recurrent neural network to process videos with temporal memory. RVM can perform matting in real-time on any videos without additional inputs. It achieves **4K 76FPS** and **HD 104FPS** on an Nvidia GTX 1080 Ti GPU. The project was developed at [ByteDance Inc.](https:\u002F\u002Fwww.bytedance.com\u002F)\n\n\u003Cbr>\n\n## News\n\n* [Nov 03 2021] Fixed a bug in [train.py](https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fcommit\u002F48effc91576a9e0e7a8519f3da687c0d3522045f).\n* [Sep 16 2021] Code is re-released under GPL-3.0 license.\n* [Aug 25 2021] Source code and pretrained models are published.\n* [Jul 27 2021] Paper is accepted by WACV 2022.\n\n\u003Cbr>\n\n## Showreel\nWatch the showreel video ([YouTube](https:\u002F\u002Fyoutu.be\u002FJvzltozpbpk), [Bilibili](https:\u002F\u002Fwww.bilibili.com\u002Fvideo\u002FBV1Z3411B7g7\u002F)) to see the model's performance. \n\n\u003Cp align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Fyoutu.be\u002FJvzltozpbpk\">\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPeterL1n_RobustVideoMatting_readme_39474d1e27cb.gif\">\n    \u003C\u002Fa>\n\u003C\u002Fp>\n\nAll footage in the video are available in [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1VFnWwuu-YXDKG-N6vcjK_nL7YZMFapMU?usp=sharing).\n\n\u003Cbr>\n\n\n## Demo\n* [Webcam Demo](https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F#\u002Fdemo): Run the model live in your browser. Visualize recurrent states.\n* [Colab Demo](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F10z-pNKRnVNsp0Lq9tH1J_XPZ7CBC_uHm?usp=sharing): Test our model on your own videos with free GPU. \n\n\u003Cbr>\n\n## Download\n\nWe recommend MobileNetv3 models for most use cases. ResNet50 models are the larger variant with small performance improvements. Our model is available on various inference frameworks. See [inference documentation](documentation\u002Finference.md) for more instructions.\n\n\u003Ctable>\n    \u003Cthead>\n        \u003Ctr>\n            \u003Ctd>Framework\u003C\u002Ftd>\n            \u003Ctd>Download\u003C\u002Ftd>\n            \u003Ctd>Notes\u003C\u002Ftd>\n        \u003C\u002Ftr>\n    \u003C\u002Fthead>\n    \u003Ctbody>\n        \u003Ctr>\n            \u003Ctd>PyTorch\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3.pth\">rvm_mobilenetv3.pth\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50.pth\">rvm_resnet50.pth\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                Official weights for PyTorch. \u003Ca href=\"documentation\u002Finference.md#pytorch\">Doc\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TorchHub\u003C\u002Ftd>\n            \u003Ctd>\n                Nothing to Download.\n            \u003C\u002Ftd>\n            \u003Ctd>\n                Easiest way to use our model in your PyTorch project. \u003Ca href=\"documentation\u002Finference.md#torchhub\">Doc\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TorchScript\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp32.torchscript\">rvm_mobilenetv3_fp32.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp16.torchscript\">rvm_mobilenetv3_fp16.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp32.torchscript\">rvm_resnet50_fp32.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp16.torchscript\">rvm_resnet50_fp16.torchscript\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                If inference on mobile, consider export int8 quantized models yourself. \u003Ca href=\"documentation\u002Finference.md#torchscript\">Doc\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>ONNX\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp32.onnx\">rvm_mobilenetv3_fp32.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp16.onnx\">rvm_mobilenetv3_fp16.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp32.onnx\">rvm_resnet50_fp32.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp16.onnx\">rvm_resnet50_fp16.onnx\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                Tested on ONNX Runtime with CPU and CUDA backends. Provided models use opset 12. \u003Ca href=\"documentation\u002Finference.md#onnx\">Doc\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Fonnx\">Exporter\u003C\u002Fa>.\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TensorFlow\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_tf.zip\">rvm_mobilenetv3_tf.zip\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_tf.zip\">rvm_resnet50_tf.zip\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                TensorFlow 2 SavedModel. \u003Ca href=\"documentation\u002Finference.md#tensorflow\">Doc\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TensorFlow.js\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_tfjs_int8.zip\">rvm_mobilenetv3_tfjs_int8.zip\u003C\u002Fa>\u003Cbr>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                Run the model on the web. \u003Ca href=\"https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F#\u002Fdemo\">Demo\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Ftfjs\">Starter Code\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>CoreML\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1280x720_s0.375_fp16.mlmodel\">rvm_mobilenetv3_1280x720_s0.375_fp16.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1280x720_s0.375_int8.mlmodel\">rvm_mobilenetv3_1280x720_s0.375_int8.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1920x1080_s0.25_fp16.mlmodel\">rvm_mobilenetv3_1920x1080_s0.25_fp16.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1920x1080_s0.25_int8.mlmodel\">rvm_mobilenetv3_1920x1080_s0.25_int8.mlmodel\u003C\u002Fa>\u003Cbr>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                CoreML does not support dynamic resolution. Other resolutions can be exported yourself. Models require iOS 13+. \u003Ccode>s\u003C\u002Fcode> denotes \u003Ccode>downsample_ratio\u003C\u002Fcode>. \u003Ca href=\"documentation\u002Finference.md#coreml\">Doc\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Fcoreml\">Exporter\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n    \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\nAll models are available in [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pBsG-SCTatv-95SnEuxmnvvlRx208VKj?usp=sharing) and [Baidu Pan](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1puPSxQqgBFOVpW4W7AolkA) (code: gym7).\n\n\u003Cbr>\n\n## PyTorch Example\n\n1. Install dependencies:\n```sh\npip install -r requirements_inference.txt\n```\n\n2. Load the model:\n\n```python\nimport torch\nfrom model import MattingNetwork\n\nmodel = MattingNetwork('mobilenetv3').eval().cuda()  # or \"resnet50\"\nmodel.load_state_dict(torch.load('rvm_mobilenetv3.pth'))\n```\n\n3. To convert videos, we provide a simple conversion API:\n\n```python\nfrom inference import convert_video\n\nconvert_video(\n    model,                           # The model, can be on any device (cpu or cuda).\n    input_source='input.mp4',        # A video file or an image sequence directory.\n    output_type='video',             # Choose \"video\" or \"png_sequence\"\n    output_composition='com.mp4',    # File path if video; directory path if png sequence.\n    output_alpha=\"pha.mp4\",          # [Optional] Output the raw alpha prediction.\n    output_foreground=\"fgr.mp4\",     # [Optional] Output the raw foreground prediction.\n    output_video_mbps=4,             # Output video mbps. Not needed for png sequence.\n    downsample_ratio=None,           # A hyperparameter to adjust or use None for auto.\n    seq_chunk=12,                    # Process n frames at once for better parallelism.\n)\n```\n\n4. Or write your own inference code:\n```python\nfrom torch.utils.data import DataLoader\nfrom torchvision.transforms import ToTensor\nfrom inference_utils import VideoReader, VideoWriter\n\nreader = VideoReader('input.mp4', transform=ToTensor())\nwriter = VideoWriter('output.mp4', frame_rate=30)\n\nbgr = torch.tensor([.47, 1, .6]).view(3, 1, 1).cuda()  # Green background.\nrec = [None] * 4                                       # Initial recurrent states.\ndownsample_ratio = 0.25                                # Adjust based on your video.\n\nwith torch.no_grad():\n    for src in DataLoader(reader):                     # RGB tensor normalized to 0 ~ 1.\n        fgr, pha, *rec = model(src.cuda(), *rec, downsample_ratio)  # Cycle the recurrent states.\n        com = fgr * pha + bgr * (1 - pha)              # Composite to green background. \n        writer.write(com)                              # Write frame.\n```\n\n5. The models and converter API are also available through TorchHub.\n\n```python\n# Load the model.\nmodel = torch.hub.load(\"PeterL1n\u002FRobustVideoMatting\", \"mobilenetv3\") # or \"resnet50\"\n\n# Converter API.\nconvert_video = torch.hub.load(\"PeterL1n\u002FRobustVideoMatting\", \"converter\")\n```\n\nPlease see [inference documentation](documentation\u002Finference.md) for details on `downsample_ratio` hyperparameter, more converter arguments, and more advanced usage.\n\n\u003Cbr>\n\n## Training and Evaluation\n\nPlease refer to the [training documentation](documentation\u002Ftraining.md) to train and evaluate your own model.\n\n\u003Cbr>\n\n## Speed\n\nSpeed is measured with `inference_speed_test.py` for reference.\n\n| GPU            | dType | HD (1920x1080) | 4K (3840x2160) |\n| -------------- | ----- | -------------- |----------------|\n| RTX 3090       | FP16  | 172 FPS        | 154 FPS        |\n| RTX 2060 Super | FP16  | 134 FPS        | 108 FPS        |\n| GTX 1080 Ti    | FP32  | 104 FPS        | 74 FPS         |\n\n* Note 1: HD uses `downsample_ratio=0.25`, 4K uses `downsample_ratio=0.125`. All tests use batch size 1 and frame chunk 1.\n* Note 2: GPUs before Turing architecture does not support FP16 inference, so GTX 1080 Ti uses FP32.\n* Note 3: We only measure tensor throughput. The provided video conversion script in this repo is expected to be much slower, because it does not utilize hardware video encoding\u002Fdecoding and does not have the tensor transfer done on parallel threads. If you are interested in implementing hardware video encoding\u002Fdecoding in Python, please refer to [PyNvCodec](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FVideoProcessingFramework).\n\n\u003Cbr>  \n\n## Project Members\n* [Shanchuan Lin](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fshanchuanlin\u002F)\n* [Linjie Yang](https:\u002F\u002Fsites.google.com\u002Fsite\u002Flinjieyang89\u002F)\n* [Imran Saleemi](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fimran-saleemi\u002F)\n* [Soumyadip Sengupta](https:\u002F\u002Fhomes.cs.washington.edu\u002F~soumya91\u002F)\n\n\u003Cbr>\n\n## Third-Party Projects\n\n* [NCNN C++ Android](https:\u002F\u002Fgithub.com\u002FFeiGeChuanShu\u002Fncnn_Android_RobustVideoMatting) ([@FeiGeChuanShu](https:\u002F\u002Fgithub.com\u002FFeiGeChuanShu))\n* [lite.ai.toolkit](https:\u002F\u002Fgithub.com\u002FDefTruth\u002FRobustVideoMatting.lite.ai.toolkit) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))\n* [Gradio Web Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fakhaliq\u002FRobust-Video-Matting) ([@AK391](https:\u002F\u002Fgithub.com\u002FAK391))\n* [Unity Engine demo with NatML](https:\u002F\u002Fhub.natml.ai\u002F@natsuite\u002Frobust-video-matting) ([@natsuite](https:\u002F\u002Fgithub.com\u002Fnatsuite))  \n* [MNN C++ Demo](https:\u002F\u002Fgithub.com\u002FDefTruth\u002Flite.ai.toolkit\u002Fblob\u002Fmain\u002Flite\u002Fmnn\u002Fcv\u002Fmnn_rvm.cpp) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))\n* [TNN C++ Demo](https:\u002F\u002Fgithub.com\u002FDefTruth\u002Flite.ai.toolkit\u002Fblob\u002Fmain\u002Flite\u002Ftnn\u002Fcv\u002Ftnn_rvm.cpp) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))\n\n","# 鲁棒视频抠图 (RVM)\n\n![预告片](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPeterL1n_RobustVideoMatting_readme_abdb8077aa8b.gif)\n\n\u003Cp align=\"center\">English | \u003Ca href=\"README_zh_Hans.md\">中文\u003C\u002Fa>\u003C\u002Fp>\n\n本仓库为论文 [具有时间引导的鲁棒高分辨率视频抠图](https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F) 的官方代码库。RVM 专门用于鲁棒的人体视频抠图。与现有将每一帧视为独立图像处理的神经网络模型不同，RVM 使用循环神经网络结合时间记忆来处理视频。RVM 可以在没有任何额外输入的情况下对任意视频进行实时抠图，在 Nvidia GTX 1080 Ti 显卡上分别达到 **4K 76FPS** 和 **HD 104FPS** 的速度。该项目由 [字节跳动](https:\u002F\u002Fwww.bytedance.com\u002F) 开发。\n\n\u003Cbr>\n\n## 最新消息\n\n* [2021年11月3日] 修复了 [train.py](https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fcommit\u002F48effc91576a9e0e7a8519f3da687c0d3522045f) 中的一个 bug。\n* [2021年9月16日] 代码以 GPL-3.0 许可证重新发布。\n* [2021年8月25日] 源代码和预训练模型正式公开。\n* [2021年7月27日] 论文被 WACV 2022 接收。\n\n\u003Cbr>\n\n## 展示视频\n观看展示视频（[YouTube](https:\u002F\u002Fyoutu.be\u002FJvzltozpbpk)、[Bilibili](https:\u002F\u002Fwww.bilibili.com\u002Fvideo\u002FBV1Z3411B7g7\u002F)），了解模型的实际效果。\n\n\u003Cp align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Fyoutu.be\u002FJvzltozpbpk\">\n        \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPeterL1n_RobustVideoMatting_readme_39474d1e27cb.gif\">\n    \u003C\u002Fa>\n\u003C\u002Fp>\n\n视频中使用的所有素材均可在 [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1VFnWwuu-YXDKG-N6vcjK_nL7YZMFapMU?usp=sharing) 中找到。\n\n\u003Cbr>\n\n\n## 示例演示\n* [摄像头演示](https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F#\u002Fdemo)：在浏览器中实时运行模型，并可视化循环状态。\n* [Colab 演示](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F10z-pNKRnVNsp0Lq9tH1J_XPZ7CBC_uHm?usp=sharing)：使用免费 GPU 在您自己的视频上测试我们的模型。\n\n\u003Cbr>\n\n## 下载\n\n我们推荐在大多数用例中使用 MobileNetv3 模型。ResNet50 模型是规模更大的版本，性能提升较小。我们的模型适用于多种推理框架。更多说明请参阅 [推理文档](documentation\u002Finference.md)。\n\n\u003Ctable>\n    \u003Cthead>\n        \u003Ctr>\n            \u003Ctd>框架\u003C\u002Ftd>\n            \u003Ctd>下载\u003C\u002Ftd>\n            \u003Ctd>备注\u003C\u002Ftd>\n        \u003C\u002Ftr>\n    \u003C\u002Fthead>\n    \u003Ctbody>\n        \u003Ctr>\n            \u003Ctd>PyTorch\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3.pth\">rvm_mobilenetv3.pth\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50.pth\">rvm_resnet50.pth\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                PyTorch 官方权重。 \u003Ca href=\"documentation\u002Finference.md#pytorch\">文档\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TorchHub\u003C\u002Ftd>\n            \u003Ctd>\n                无需下载。\n            \u003C\u002Ftd>\n            \u003Ctd>\n                在您的 PyTorch 项目中使用我们模型的最简单方式。 \u003Ca href=\"documentation\u002Finference.md#torchhub\">文档\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TorchScript\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp32.torchscript\">rvm_mobilenetv3_fp32.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp16.torchscript\">rvm_mobilenetv3_fp16.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp32.torchscript\">rvm_resnet50_fp32.torchscript\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp16.torchscript\">rvm_resnet50_fp16.torchscript\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                如果要在移动端进行推理，建议您自行导出 int8 量化模型。 \u003Ca href=\"documentation\u002Finference.md#torchscript\">文档\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>ONNX\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp32.onnx\">rvm_mobilenetv3_fp32.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_fp16.onnx\">rvm_mobilenetv3_fp16.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp32.onnx\">rvm_resnet50_fp32.onnx\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_fp16.onnx\">rvm_resnet50_fp16.onnx\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                已在 ONNX Runtime 的 CPU 和 CUDA 后端上测试通过。提供的模型使用 opset 12。 \u003Ca href=\"documentation\u002Finference.md#onnx\">文档\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Fonnx\">导出工具\u003C\u002Fa>。\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TensorFlow\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_tf.zip\">rvm_mobilenetv3_tf.zip\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_resnet50_tf.zip\">rvm_resnet50_tf.zip\u003C\u002Fa>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                TensorFlow 2 SavedModel 格式。 \u003Ca href=\"documentation\u002Finference.md#tensorflow\">文档\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>TensorFlow.js\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_tfjs_int8.zip\">rvm_mobilenetv3_tfjs_int8.zip\u003C\u002Fa>\u003Cbr>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                在网页上运行模型。 \u003Ca href=\"https:\u002F\u002Fpeterl1n.github.io\u002FRobustVideoMatting\u002F#\u002Fdemo\">演示\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Ftfjs\">入门代码\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n        \u003Ctr>\n            \u003Ctd>CoreML\u003C\u002Ftd>\n            \u003Ctd>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1280x720_s0.375_fp16.mlmodel\">rvm_mobilenetv3_1280x720_s0.375_fp16.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1280x720_s0.375_int8.mlmodel\">rvm_mobilenetv3_1280x720_s0.375_int8.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1920x1080_s0.25_fp16.mlmodel\">rvm_mobilenetv3_1920x1080_s0.25_fp16.mlmodel\u003C\u002Fa>\u003Cbr>\n                \u003Ca  href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Freleases\u002Fdownload\u002Fv1.0.0\u002Frvm_mobilenetv3_1920x1080_s0.25_int8.mlmodel\">rvm_mobilenetv3_1920x1080_s0.25_int8.mlmodel\u003C\u002Fa>\u003Cbr>\n            \u003C\u002Ftd>\n            \u003Ctd>\n                CoreML 不支持动态分辨率。其他分辨率可由您自行导出。模型需要 iOS 13 或更高版本。\u003Ccode>s\u003C\u002Fcode> 表示\u003Ccode>downsample_ratio\u003C\u002Fcode>。 \u003Ca href=\"documentation\u002Finference.md#coreml\">文档\u003C\u002Fa>, \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Ftree\u002Fcoreml\">导出工具\u003C\u002Fa>\n            \u003C\u002Ftd>\n        \u003C\u002Ftr>\n    \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n所有模型也可在 [Google Drive](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1pBsG-SCTatv-95SnEuxmnvvlRx208VKj?usp=sharing) 和 [Baidu Pan](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1puPSxQqgBFOVpW4W7AolkA)（提取码：gym7）中找到。\n\n\u003Cbr>\n\n## PyTorch 示例\n\n1. 安装依赖：\n```sh\npip install -r requirements_inference.txt\n```\n\n2. 加载模型：\n\n```python\nimport torch\nfrom model import MattingNetwork\n\nmodel = MattingNetwork('mobilenetv3').eval().cuda()  # 或 \"resnet50\"\nmodel.load_state_dict(torch.load('rvm_mobilenetv3.pth'))\n```\n\n3. 为了转换视频，我们提供了一个简单的转换 API：\n\n```python\nfrom inference import convert_video\n\nconvert_video(\n    model,                           # 模型，可以在任何设备上（CPU 或 CUDA）。\n    input_source='input.mp4',        # 视频文件或图像序列目录。\n    output_type='video',             # 选择“video”或“png_sequence”\n    output_composition='com.mp4',    # 如果是视频，则为文件路径；如果是 PNG 序列，则为目录路径。\n    output_alpha=\"pha.mp4\",          # 【可选】输出原始的 alpha 预测。\n    output_foreground=\"fgr.mp4\",     # 【可选】输出原始的前景预测。\n    output_video_mbps=4,             # 输出视频的码率。PNG 序列不需要此参数。\n    downsample_ratio=None,           # 超参数，用于调整；若设为 None，则自动调整。\n    seq_chunk=12,                    # 每次处理 n 帧，以提高并行性。\n)\n```\n\n4. 或者编写自己的推理代码：\n```python\nfrom torch.utils.data import DataLoader\nfrom torchvision.transforms import ToTensor\nfrom inference_utils import VideoReader, VideoWriter\n\nreader = VideoReader('input.mp4', transform=ToTensor())\nwriter = VideoWriter('output.mp4', frame_rate=30)\n\nbgr = torch.tensor([.47, 1, .6]).view(3, 1, 1).cuda()  # 绿色背景。\nrec = [None] * 4                                       # 初始循环状态。\ndownsample_ratio = 0.25                                # 根据你的视频调整。\n\nwith torch.no_grad():\n    for src in DataLoader(reader):                     # RGB 张量归一化到 0 ~ 1。\n        fgr, pha, *rec = model(src.cuda(), *rec, downsample_ratio)  # 更新循环状态。\n        com = fgr * pha + bgr * (1 - pha)              # 合成到绿色背景上。\n        writer.write(com)                              # 写入帧。\n```\n\n5. 模型和转换器 API 也可以通过 TorchHub 获取。\n\n```python\n# 加载模型。\nmodel = torch.hub.load(\"PeterL1n\u002FRobustVideoMatting\", \"mobilenetv3\") # 或 \"resnet50\"\n\n# 转换器 API。\nconvert_video = torch.hub.load(\"PeterL1n\u002FRobustVideoMatting\", \"converter\")\n```\n\n有关 `downsample_ratio` 超参数、更多转换参数以及高级用法的详细信息，请参阅 [推理文档](documentation\u002Finference.md)。\n\n\u003Cbr>\n\n## 训练与评估\n\n请参考 [训练文档](documentation\u002Ftraining.md)，以训练和评估您自己的模型。\n\n\u003Cbr>\n\n## 速度\n\n速度测量使用 `inference_speed_test.py` 进行，供参考。\n\n| GPU            | 数据类型 | HD (1920x1080) | 4K (3840x2160) |\n| -------------- | ----- | -------------- |----------------|\n| RTX 3090       | FP16  | 172 FPS        | 154 FPS        |\n| RTX 2060 Super | FP16  | 134 FPS        | 108 FPS        |\n| GTX 1080 Ti    | FP32  | 104 FPS        | 74 FPS         |\n\n* 注 1：HD 使用 `downsample_ratio=0.25`，4K 使用 `downsample_ratio=0.125`。所有测试均采用批量大小 1 和每批 1 帧。\n* 注 2：图灵架构之前的 GPU 不支持 FP16 推理，因此 GTX 1080 Ti 使用 FP32。\n* 注 3：我们仅测量张量吞吐量。本仓库提供的视频转换脚本预计会慢得多，因为它没有利用硬件视频编码\u002F解码功能，且张量传输未在并行线程中完成。如果您有兴趣在 Python 中实现硬件视频编码\u002F解码，请参阅 [PyNvCodec](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FVideoProcessingFramework)。\n\n\u003Cbr>  \n\n## 项目成员\n* [Shanchuan Lin](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fshanchuanlin\u002F)\n* [Linjie Yang](https:\u002F\u002Fsites.google.com\u002Fsite\u002Flinjieyang89\u002F)\n* [Imran Saleemi](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fimran-saleemi\u002F)\n* [Soumyadip Sengupta](https:\u002F\u002Fhomes.cs.washington.edu\u002F~soumya91\u002F)\n\n\u003Cbr>\n\n## 第三方项目\n\n* [NCNN C++ Android](https:\u002F\u002Fgithub.com\u002FFeiGeChuanShu\u002Fncnn_Android_RobustVideoMatting) ([@FeiGeChuanShu](https:\u002F\u002Fgithub.com\u002FFeiGeChuanShu))\n* [lite.ai.toolkit](https:\u002F\u002Fgithub.com\u002FDefTruth\u002FRobustVideoMatting.lite.ai.toolkit) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))\n* [Gradio Web Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fakhaliq\u002FRobust-Video-Matting) ([@AK391](https:\u002F\u002Fgithub.com\u002FAK391))\n* [Unity Engine demo with NatML](https:\u002F\u002Fhub.natml.ai\u002F@natsuite\u002Frobust-video-matting) ([@natsuite](https:\u002F\u002Fgithub.com\u002Fnatsuite))  \n* [MNN C++ Demo](https:\u002F\u002Fgithub.com\u002FDefTruth\u002Flite.ai.toolkit\u002Fblob\u002Fmain\u002Flite\u002Fmnn\u002Fcv\u002Fmnn_rvm.cpp) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))\n* [TNN C++ Demo](https:\u002F\u002Fgithub.com\u002FDefTruth\u002Flite.ai.toolkit\u002Fblob\u002Fmain\u002Flite\u002Ftnn\u002Fcv\u002Ftnn_rvm.cpp) ([@DefTruth](https:\u002F\u002Fgithub.com\u002FDefTruth))","# RobustVideoMatting 快速上手指南\n\nRobustVideoMatting (RVM) 是一个专为鲁棒人像视频抠图设计的开源项目。它利用循环神经网络（RNN）处理视频的时间记忆，无需额外输入即可实时处理任意视频。在 Nvidia GTX 1080 Ti 上可实现 **4K 76FPS** 和 **HD 104FPS** 的推理速度。\n\n## 环境准备\n\n*   **操作系统**: Linux, macOS, Windows\n*   **Python**: 3.7+\n*   **深度学习框架**: PyTorch 1.7+ (推荐 CUDA 版本以获取最佳性能)\n*   **硬件要求**: 支持 CUDA 的 NVIDIA GPU (推荐显存 4GB 以上)。若无 GPU，可使用 CPU 运行但速度较慢。\n*   **前置依赖**:\n    *   `ffmpeg`: 用于视频读写（系统层面安装）。\n    *   Python 依赖库：`torch`, `torchvision`, `numpy`, `Pillow`, `tqdm` 等。\n\n## 安装步骤\n\n### 1. 安装系统依赖 (FFmpeg)\n确保系统中已安装 `ffmpeg`。\n*   **Ubuntu\u002FDebian**: `sudo apt-get update && sudo apt-get install ffmpeg`\n*   **macOS**: `brew install ffmpeg`\n*   **Windows**: 下载并安装 [ffmpeg-builds](https:\u002F\u002Fwww.gyan.dev\u002Fffmpeg\u002Fbuilds\u002F) 或将 ffmpeg.exe 添加到环境变量 PATH 中。\n\n### 2. 克隆代码库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting.git\ncd RobustVideoMatting\n```\n\n### 3. 安装 Python 依赖\n推荐使用国内镜像源加速安装（如清华源）：\n```bash\npip install -r requirements_inference.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 4. 下载预训练模型\n对于大多数应用场景，推荐使用 **MobileNetv3** 模型（速度快、体积小）。如需更高精度可选 ResNet50。\n\n**方式 A：直接下载 (推荐国内用户使用百度网盘)**\n*   **百度网盘**: [链接](https:\u002F\u002Fpan.baidu.com\u002Fs\u002F1puPSxQqgBFOVpW4W7AolkA) (提取码：`gym7`)\n*   下载 `rvm_mobilenetv3.pth` 并放置在项目根目录。\n\n**方式 B：使用 TorchHub (无需手动下载)**\n后续代码示例中将展示如何自动加载。\n\n## 基本使用\n\n以下提供两种最简单的使用方式：**一键视频转换** 和 **自定义推理代码**。\n\n### 方式一：使用官方转换 API (最简单)\n\n此方法适合直接对视频文件进行批量抠图处理。\n\n创建文件 `inference_demo.py`：\n\n```python\nimport torch\nfrom model import MattingNetwork\nfrom inference import convert_video\n\n# 1. 加载模型 (自动下载或使用本地文件)\n# 使用 TorchHub 加载 (首次运行会自动下载权重)\nmodel = torch.hub.load(\"PeterL1n\u002FRobustVideoMatting\", \"mobilenetv3\").eval().cuda()\n\n# 或者手动加载本地权重:\n# model = MattingNetwork('mobilenetv3').eval().cuda()\n# model.load_state_dict(torch.load('rvm_mobilenetv3.pth'))\n\n# 2. 执行视频转换\nconvert_video(\n    model,                           # 模型实例\n    input_source='input.mp4',        # 输入视频路径\n    output_type='video',             # 输出类型：\"video\" 或 \"png_sequence\"\n    output_composition='com.mp4',    # 输出合成视频路径 (前景 + 新背景)\n    output_alpha=\"pha.mp4\",          # [可选] 输出纯 Alpha 通道视频\n    output_foreground=\"fgr.mp4\",     # [可选] 输出纯前景视频\n    output_video_mbps=4,             # 输出视频码率\n    downsample_ratio=None,           # 下采样比例，None 表示根据分辨率自动调整\n    seq_chunk=12,                    # 并行处理的帧数块大小，提升速度\n)\n```\n\n**运行命令:**\n```bash\npython inference_demo.py\n```\n\n### 方式二：自定义推理循环 (进阶)\n\n如果你需要将抠图结果实时合成到特定背景，或集成到自己的 pipeline 中：\n\n```python\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torchvision.transforms import ToTensor\nfrom model import MattingNetwork\nfrom inference_utils import VideoReader, VideoWriter\n\n# 1. 初始化\nmodel = MattingNetwork('mobilenetv3').eval().cuda()\nmodel.load_state_dict(torch.load('rvm_mobilenetv3.pth'))\n\nreader = VideoReader('input.mp4', transform=ToTensor())\nwriter = VideoWriter('output.mp4', frame_rate=30)\n\n# 设置绿色背景 (BGR 格式，归一化到 0-1)\nbgr = torch.tensor([.47, 1, .6]).view(3, 1, 1).cuda()\nrec = [None] * 4               # 初始化循环状态 (Recurrent States)\ndownsample_ratio = 0.25        # 根据视频分辨率调整，高分辨率建议设小 (如 0.125)\n\n# 2. 逐帧推理\nwith torch.no_grad():\n    for src in DataLoader(reader):\n        # src: [B, C, H, W], 归一化到 0~1\n        fgr, pha, *rec = model(src.cuda(), *rec, downsample_ratio)\n        \n        # 合成公式：前景 * Alpha + 背景 * (1 - Alpha)\n        com = fgr * pha + bgr * (1 - pha)\n        \n        writer.write(com)\n```\n\n### 关键参数说明\n*   **`downsample_ratio`**: 重要的超参数。\n    *   `None`: 自动根据分辨率选择（推荐）。\n    *   `0.25`: 适用于 1080P (HD) 视频。\n    *   `0.125`: 适用于 4K 视频。\n    *   值越小速度越快，但边缘细节可能略有损失。\n*   **`seq_chunk`**: 每次并行处理的帧数。增大此值可利用 GPU 并行能力加速，但会增加显存占用。","某短视频 MCN 机构的制作团队需要每天处理大量户外采访视频，要求快速去除复杂背景并替换为品牌虚拟演播室。\n\n### 没有 RobustVideoMatting 时\n- 传统绿幕拍摄受限极大，艺人必须前往特定影棚，无法利用丰富的户外实景素材。\n- 使用基于单帧图像的抠图模型处理视频时，人物边缘会出现严重的闪烁和抖动，画面极不自然。\n- 为了获得可用效果，后期人员不得不逐帧手动修饰遮罩（Mask），处理一条 1 分钟的视频耗时数小时。\n- 现有高精度方案对硬件要求苛刻，无法在普通工作站上实现实时预览，严重拖慢创作迭代节奏。\n\n### 使用 RobustVideoMatting 后\n- 直接导入任意户外拍摄素材，无需绿幕即可自动识别人物，彻底解放了拍摄场地限制。\n- 得益于其特有的时序记忆循环神经网络，人物发丝边缘过渡平滑稳定，完全消除了帧间闪烁现象。\n- 实现了全自动化处理，原本需要数小时的手工修图工作缩短至几分钟的推理时间，效率提升数十倍。\n- 在常见的 GTX 1080 Ti 显卡上即可跑满 4K 分辨率 76FPS，制作人员能实时看到合成效果并即时调整。\n\nRobustVideoMatting 通过引入时序引导技术，将高保真视频抠图从昂贵的手工劳动转变为高效的实时自动化流程。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPeterL1n_RobustVideoMatting_abdb8077.gif","PeterL1n","Peter Lin","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FPeterL1n_1a898bac.jpg",null,"New York, New York, US","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fshanchuanlin\u002F","https:\u002F\u002Fgithub.com\u002FPeterL1n",[81],{"name":82,"color":83,"percentage":84},"Python","#3572A5",100,9302,1195,"2026-04-11T17:50:29","GPL-3.0","Linux, macOS, Windows","非必需（支持 CPU 推理），但推荐 NVIDIA GPU 以获得实时性能。测试基于 GTX 1080 Ti (FP32) 及 RTX 20\u002F30 系列 (FP16)。Turing 架构之前的显卡不支持 FP16 推理。显存需求未明确说明，但处理 4K 视频建议较大显存。","未说明",{"notes":93,"python":91,"dependencies":94},"该工具支持多种推理框架（PyTorch, TorchScript, ONNX, TensorFlow, CoreML, TensorFlow.js）。官方示例代码通过 'requirements_inference.txt' 安装依赖。在移动端使用 TorchScript 时建议自行导出 int8 量化模型。CoreML 模型需要 iOS 13+ 且不支持动态分辨率。官方提供的视频转换脚本因未利用硬件编解码，速度慢于理论张量吞吐量，高性能需求可参考 PyNvCodec。",[95,96,97,98],"torch","torchvision","onnxruntime (可选，用于 ONNX 推理)","tensorflow (可选，用于 TF 推理)",[13,14,15],[101,102,103,104,105],"computer-vision","machine-learning","ai","matting","deep-learning","2026-03-27T02:49:30.150509","2026-04-12T13:58:52.590821",[109,114,119,124,129,134,139],{"id":110,"question_zh":111,"answer_zh":112,"source_url":113},30657,"训练第一阶段的前景预测图整体偏红或偏绿，如何解决？","这是一个已知问题，通常由 train.py 中的 bug 引起。维护者已修复了相关代码，请参考 Issue #100 中的修复内容。此外，请检查您的训练参数是否与论文中的设置完全一致，参数不匹配也可能导致此类颜色偏差。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F67",{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},30658,"如何将 PyTorch 模型导出为 ONNX 格式并处理 HardSigmoid 算子？","在导出 ONNX 时，HardSigmoid 会被转换为带有 alpha 参数的算子。根据官方文档，alpha 值为 1\u002F6（即公式 x*relu6(x+3)\u002F6 中的系数）。如果在特定推理引擎（如 Barracuda）中遇到不支持 HardSigmoid 的错误，可能需要修改 torch\u002Fonnx\u002Fsymbolic_opset9.py 文件，将其替换为基本算子组合，或者移除 export 函数中的 dynamic_axes 参数以解决部分兼容性问题。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F47",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},30659,"如何使用 TensorRT (torch2trt) 部署该模型？","可以使用 torch2trt 进行转换，但在构建过程中可能会遇到分段错误（Segmentation fault）。这通常是由于 TensorRT 库的交叉链接问题或反序列化后的操作引起的，而非模型本身的问题。解决方法包括重新编译 TensorRT 库。如果 trtexec 在构建时报错核心转储（core dump），请检查 Resize 算子的输入维度，并确保引擎文件生成后通过示例代码验证其功能。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F219",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},30660,"如何在多 GPU 训练时解决 'ProcessExitedException: SIGKILL' 错误？","该错误通常由于显存不足或序列长度（seq-length）设置过大导致进程被系统杀死。解决方案包括：1. 减少序列长度以适应显存限制；2. 改用 torch.distributed.launch 方法启动多进程训练，这比直接使用 mp.spawn 更稳定。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F82",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},30661,"如何将训练好的 .pth 模型转换为 LibTorch 可用的 .torchscript 模型？","可以通过 PyTorch 的脚本化功能将 .pth 模型转换为 .torchscript 模型。对于量化需求，可以使用 QAT（量化感知训练），量化成功后模型会包含 scale 和 zero_point 参数（可在 Netron 中查看）。具体实现可参考 PyTorch FX 进行改写，注意区分动态量化和静态量化，确保输入和模型同时被正确量化以避免推理出错。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F116",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},30662,"ONNX 模型推理时形状（shape）推断维度不正确怎么办？","当使用 onnx.infer_shape 推理形状时，如果发现维度不是预期的（例如得到 4 而不是具体的 1,64,12,20），导致无法传递给下一层，这通常是因为模型中存在动态轴或算子支持问题。尝试在导出 ONNX 时移除 dynamic_axes 参数，或者检查模型中是否有切片（slice）和拼接（concat）操作导致的维度不确定性，必要时需固定输入尺寸进行导出。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F108",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},30663,"是否支持使用 GIF 或 MP4 视频作为背景进行合成？","原生代码主要设计用于静态图片背景，但用户可以通过修改数据加载逻辑来支持视频背景。社区用户曾讨论过此需求，虽然官方未直接提供开关，但可以通过自定义数据集类读取视频帧（使用 OpenCV 或 ffmpeg）替代静态图像路径，从而实现动态背景合成。","https:\u002F\u002Fgithub.com\u002FPeterL1n\u002FRobustVideoMatting\u002Fissues\u002F207",[145],{"id":146,"version":147,"summary_zh":76,"released_at":148},222541,"v1.0.0","2021-09-17T07:31:29"]