Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"如何为 Diffusers 🧨 做出贡献","local":"how-to-contribute-to-diffusers-","sections":[{"title":"概述","local":"overview","sections":[{"title":"1. 在 GitHub Discussions 或 Discord 上提问和回答问题","local":"1-asking-and-answering-questions-on-github-discussions-or-on-discord","sections":[],"depth":3},{"title":"2. 在 GitHub issues 选项卡中创建新的 issue","local":"2-opening-new-issues-on-the-github-issues-tab","sections":[{"title":"2.1. 可复现的最小化错误报告","local":"21-reproducible-minimal-bug-reports","sections":[],"depth":4},{"title":"2.2. 功能请求","local":"22-feature-requests","sections":[],"depth":4},{"title":"2.3 反馈","local":"23-feedback","sections":[],"depth":4},{"title":"2.4 技术问题","local":"24-technical-questions","sections":[],"depth":4},{"title":"2.5 提议添加新的模型、调度器或流水线","local":"25-proposal-to-add-a-new-model-scheduler-or-pipeline","sections":[],"depth":4}],"depth":3},{"title":"3. 在 GitHub issues 选项卡中回复问题","local":"3-answering-issues-on-the-github-issues-tab","sections":[],"depth":3},{"title":"4. 解决一个“适合初学者的问题”","local":"4-fixing-a-good-first-issue","sections":[],"depth":3},{"title":"5. 为文档做出贡献","local":"5-contribute-to-the-documentation","sections":[],"depth":3},{"title":"6. 在 Hub 上发布流水线或模型","local":"6-publish-a-pipeline-or-model-on-the-hub","sections":[],"depth":3},{"title":"7. 贡献训练示例","local":"7-contribute-to-training-examples","sections":[],"depth":3},{"title":"8. 修复“适合第二项任务”","local":"8-fixing-a-good-second-issue","sections":[],"depth":3},{"title":"9. 认领 Diffusers MVP 问题","local":"9-taking-on-a-diffusers-mvp-issue","sections":[],"depth":3},{"title":"10. 添加流水线、模型和调度器","local":"10-adding-pipelines-models-schedulers","sections":[{"title":"当发布新的模型或流水线支持时","local":"when-new-model-or-pipeline-support-is-released","sections":[],"depth":4},{"title":"Copied from mechanism","local":"copied-from-mechanism","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"如何撰写一个高质量的 issue","local":"how-to-write-a-good-issue","sections":[],"depth":2},{"title":"如何撰写一份优质的 PR","local":"how-to-write-a-good-pr","sections":[],"depth":2},{"title":"如何提交 PR","local":"how-to-open-a-pr","sections":[{"title":"测试","local":"tests","sections":[],"depth":3},{"title":"将 fork 的 main 分支与上游(HuggingFace)main 分支同步","local":"syncing-forked-main-with-upstream-huggingface-main","sections":[],"depth":3},{"title":"样式指南","local":"style-guide","sections":[],"depth":3}],"depth":2},{"title":"使用 AI 智能体进行编程","local":"coding-with-ai-agents","sections":[{"title":"AI 辅助与智能体贡献","local":"ai-assisted-and-agentic-contributions","sections":[],"depth":3}],"depth":2}],"depth":1}"/> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/entry/start.1gaXe03k.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/BObs6oQO.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DPnyVmXs.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/entry/app.BwdYRbCn.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DSGUT_OW.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/C045MWWx.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/6tuJ3nyi.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/nodes/0.CornNeQR.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/IaDvMxLQ.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/nodes/304.D7A4xAiG.js" rel="modulepreload"> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/chunks/bKdwVYpU.js" rel="modulepreload"> | |
| <!--110sasa--><meta name="hf:doc:metadata" content="{"title":"How to contribute to Diffusers 🧨","local":"how-to-contribute-to-diffusers-","sections":[{"title":"Overview","local":"overview","sections":[{"title":"1. Asking and answering questions on GitHub Discussions or on Discord","local":"1-asking-and-answering-questions-on-github-discussions-or-on-discord","sections":[],"depth":3},{"title":"2. Opening new issues on the GitHub issues tab","local":"2-opening-new-issues-on-the-github-issues-tab","sections":[{"title":"2.1. Reproducible, minimal bug reports","local":"21-reproducible-minimal-bug-reports","sections":[],"depth":4},{"title":"2.2. Feature requests","local":"22-feature-requests","sections":[],"depth":4},{"title":"2.3 Feedback","local":"23-feedback","sections":[],"depth":4},{"title":"2.4 Technical questions","local":"24-technical-questions","sections":[],"depth":4},{"title":"2.5 Proposal to add a new model, scheduler, or pipeline","local":"25-proposal-to-add-a-new-model-scheduler-or-pipeline","sections":[],"depth":4}],"depth":3},{"title":"3. Answering issues on the GitHub issues tab","local":"3-answering-issues-on-the-github-issues-tab","sections":[],"depth":3},{"title":"4. Fixing a “Good first issue”","local":"4-fixing-a-good-first-issue","sections":[],"depth":3},{"title":"5. Contribute to the documentation","local":"5-contribute-to-the-documentation","sections":[],"depth":3},{"title":"6. Publish a pipeline or model on the Hub","local":"6-publish-a-pipeline-or-model-on-the-hub","sections":[],"depth":3},{"title":"7. Contribute to training examples","local":"7-contribute-to-training-examples","sections":[],"depth":3},{"title":"8. Fixing a “Good second issue”","local":"8-fixing-a-good-second-issue","sections":[],"depth":3},{"title":"9. Taking on a Diffusers MVP issue","local":"9-taking-on-a-diffusers-mvp-issue","sections":[],"depth":3},{"title":"10. Adding pipelines, models, schedulers","local":"10-adding-pipelines-models-schedulers","sections":[{"title":"When new model or pipeline support is released","local":"when-new-model-or-pipeline-support-is-released","sections":[],"depth":4},{"title":"Copied from mechanism","local":"copied-from-mechanism","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"How to write a good issue","local":"how-to-write-a-good-issue","sections":[],"depth":2},{"title":"How to write a good PR","local":"how-to-write-a-good-pr","sections":[],"depth":2},{"title":"How to open a PR","local":"how-to-open-a-pr","sections":[{"title":"Tests","local":"tests","sections":[],"depth":3},{"title":"Syncing forked main with upstream (HuggingFace) main","local":"syncing-forked-main-with-upstream-huggingface-main","sections":[],"depth":3},{"title":"Style guide","local":"style-guide","sections":[],"depth":3}],"depth":2},{"title":"Coding with AI agents","local":"coding-with-ai-agents","sections":[{"title":"AI-assisted and agentic contributions","local":"ai-assisted-and-agentic-contributions","sections":[],"depth":3}],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/diffusers/v0.43.0/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="how-to-contribute-to-diffusers-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-contribute-to-diffusers-"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->如何为 Diffusers 🧨 做出贡献<!----></span></h1><!--]--><!----> <blockquote class="tip"><p>如果您使用 AI 智能体进行贡献,请务必阅读<a href="#ai-assisted-and-agentic-contributions">AI 辅助与智能体贡献</a>部分,了解我们的期望和准则。</p></blockquote> <p>我们 ❤️ 来自开源社区的贡献!欢迎所有人参与,我们珍视并感激各种形式的参与——不仅仅是代码。回答问题、帮助他人、主动联系以及改进文档,这些对社区都极具价值,所以如果你愿意,请大胆参与进来!</p> <p>欢迎大家在公共 Discord 频道中打个招呼 👋。我们在这里讨论扩散模型的最新趋势、提问、分享个人项目、互相协助贡献,或者只是闲聊 ☕。<a href="https://Discord.gg/G7tWnz98XR"><img alt="Join us on Discord" src="https://img.shields.io/discord/823813159592001537?color=5865F2&logo=discord&logoColor=white"/></a></p> <p>无论您选择以何种方式做出贡献,我们都致力于成为一个开放、包容且友善的社区。请阅读我们的<a href="https://github.com/huggingface/diffusers/blob/main/CODE_OF_CONDUCT.md" rel="nofollow">行为准则</a>,并在互动过程中注意遵守该准则。我们还建议您熟悉指导我们项目的<a href="https://huggingface.co/docs/diffusers/conceptual/ethical_guidelines" rel="nofollow">道德准则</a>,并请您遵循同样的透明与责任原则。</p> <p>我们非常重视来自社区的反馈,因此,如果您认为自己的反馈有助于改进该库,请大胆提出——每一条消息、评论、issue 和 pull request (PR) 都会被阅读并予以考虑。</p> <!--[1--><h2 class="relative group"><a id="overview" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#overview"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->概述<!----></span></h2><!--]--><!----> <p>您可以通过多种方式做出贡献,从在 issues 和 discussions 中回答问题,到为核心库添加新的扩散模型。</p> <p>以下按所需时间投入从低到高,概述了不同的贡献方式。它们对社区都很有价值。</p> <ul><li><ol><li>在 <a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow">GitHub Discussions</a> 或 <a href="https://discord.gg/G7tWnz98XR" rel="nofollow">Discord</a> 上提问和回答问题。</li></ol></li> <li><ol start="2"><li>在 <a href="https://github.com/huggingface/diffusers/issues/new/choose" rel="nofollow">GitHub Issues 选项卡</a> 上打开新的 issue。</li></ol></li> <li><ol start="3"><li>在 <a href="https://github.com/huggingface/diffusers/issues" rel="nofollow">GitHub Issues 选项卡</a> 上回复问题。</li></ol></li> <li><ol start="4"><li>修复一个标记为“Good first issue”的简单问题,参见<a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22" rel="nofollow">此处</a>。</li></ol></li> <li><ol start="5"><li>为<a href="https://github.com/huggingface/diffusers/tree/main/docs/source" rel="nofollow">文档</a>做出贡献。</li></ol></li> <li><ol start="6"><li>使用 <a href="../modular_diffusers/overview">Modular Diffusers</a> 以远程代码的形式在 Hub 上发布流水线或模型。</li></ol></li> <li><ol start="7"><li>为 <a href="https://github.com/huggingface/diffusers/tree/main/examples" rel="nofollow">examples</a> 做出贡献。</li></ol></li> <li><ol start="8"><li>解决一个难度稍高的问题,该问题带有“Good second issue”标签,参见<a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22" rel="nofollow">此处</a>。</li></ol></li> <li><ol start="9"><li>参与 <a href="https://github.com/huggingface/diffusers/issues/12635" rel="nofollow">Diffusers MVP 计划</a> 中的某个 issue。</li></ol></li> <li><ol start="10"><li>向库中添加新的 pipeline、model 或 scheduler。对于此类贡献,我们通常直接与模型作者合作;作为社区贡献者,请从 Hub(6)开始。请查看已打开的 <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22" rel="nofollow">“New Pipeline/Model”</a> 和 <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22" rel="nofollow">“New scheduler”</a> issue,并先阅读 <a href="https://huggingface.co/docs/diffusers/main/en/conceptual/philosophy" rel="nofollow">Design Philosophy</a>。</li></ol></li></ul> <p>如前所述,<strong>所有贡献对社区都很有价值</strong>。 | |
| 接下来,我们将更详细地介绍每种贡献。</p> <p>对于贡献 4 到 10(6 除外,因为它位于 Hub 上),你需要提交一个 PR。<a href="#how-to-open-a-pr">创建拉取请求</a>中详细说明了操作方法。</p> <!--[2--><h3 class="relative group"><a id="1-asking-and-answering-questions-on-github-discussions-or-on-discord" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#1-asking-and-answering-questions-on-github-discussions-or-on-discord"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->1. 在 GitHub Discussions 或 Discord 上提问和回答问题<!----></span></h3><!--]--><!----> <p>有关 Diffusers 库的任何问题或评论,都可以在 <a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow">GitHub Discussions</a> 或 <a href="https://discord.gg/G7tWnz98XR" rel="nofollow">Discord</a> 上提出。此类问题和评论包括(但不限于):</p> <ul><li>报告训练或推理实验,以尝试分享知识</li> <li>个人项目展示</li> <li>非官方训练示例的问题</li> <li>项目提案</li> <li>总体反馈</li> <li>论文摘要</li> <li>在基于 Diffusers 库构建的个人项目中寻求帮助</li> <li>通用问题</li> <li>关于扩散模型的伦理问题</li> <li>…</li></ul> <p>在 GitHub Discussions 或 Discord 上提出的每一个问题,都在积极鼓励社区公开分享知识,并且很可能在未来帮助到与你面临相同问题的初学者。请尽管提出你心中的任何疑问。 | |
| 本着同样的精神,回答这些问题对社区也是极大的帮助,因为这样你就在公开地记录知识,供所有人学习。</p> <p><strong>请</strong>记住,你在提问或回答问题时投入的精力越多,公开文档中知识的质量就越高。同样,表述清晰且回答得当的问题会构建一个可供所有人访问的高质量知识库,而表述不当的问题或回答则会降低公共知识库的整体质量。 | |
| 简而言之,高质量的问题或回答应当是<em>精确的</em>、<em>简洁的</em>、<em>相关的</em>、<em>易于理解的</em>、<em>可访问的</em>,并且<em>格式良好/表述得当</em>。如需了解更多信息,请参阅<a href="#how-to-write-a-good-issue">如何撰写高质量的 issue</a>部分。</p> <p><strong>关于频道的说明</strong>:<a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow"><em>GitHub Discussions</em></a> 会被搜索引擎索引,且每个帖子都可以被链接,因此在那里发布的问题和答案对于遇到相同问题的下一个人来说仍然可以被找到。 | |
| 相比之下,<em>Discord</em> 采用类似聊天的格式,鼓励快速的双向交流。 | |
| 虽然你在 Discord 上获得问题的答案可能花费的时间更短,但你的问题随着时间推移将不再可见,而且查找很久以前发布的信息要困难得多。因此,我们建议将旨在长期保留的问题和答案发布到 GitHub Discussions。如果 Discord 上的对话得出了有趣的结论,请将结果作为讨论发布,以便未来的读者能够找到它。</p> <!--[2--><h3 class="relative group"><a id="2-opening-new-issues-on-the-github-issues-tab" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#2-opening-new-issues-on-the-github-issues-tab"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2. 在 GitHub issues 选项卡中创建新的 issue<!----></span></h3><!--]--><!----> <p>🧨 Diffusers 库之所以稳健可靠,离不开用户向我们反馈他们遇到的问题。感谢您报告此问题。</p> <p>请记住,GitHub issues 仅用于与 Diffusers 库直接相关的技术问题、错误报告、功能请求或关于库设计的反馈。</p> <p>简而言之,这意味着所有与<strong>Diffusers 库代码</strong>(包括文档)<strong>无关</strong>的内容,都<strong>不应</strong>以 issue 的形式提出,而应通过<a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow">GitHub Discussions</a>或<a href="https://discord.gg/G7tWnz98XR" rel="nofollow">Discord</a>进行提问。</p> <p><strong>在提交新问题之前,请考虑以下准则</strong>:</p> <ul><li>请确保在提交之前,您已在 GitHub 的 Issues 页面使用搜索栏查询过该问题是否已被提出。</li> <li>请勿在另一个(相关的)issue 中报告新问题。如果另一个 issue 高度相关,请仍然打开一个新的 issue,并链接到该相关 issue。</li> <li>请确保您的问题以英文撰写。</li> <li>请检查将 Diffusers 更新到最新版本是否能解决您的问题。在提交问题之前,请确保 <code>python -c "import diffusers; print(diffusers.__version__)"</code> 的版本号高于或等于最新的 Diffusers 版本。</li> <li>请记住,你在提交新问题时投入的精力越多,你获得回答的质量就越高,Diffusers 问题的整体质量也会越好。</li></ul> <p>新 issue 通常包含以下内容。</p> <!--[3--><h4 class="relative group"><a id="21-reproducible-minimal-bug-reports" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#21-reproducible-minimal-bug-reports"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2.1. 可复现的最小化错误报告<!----></span></h4><!--]--><!----> <p>Bug 报告应始终包含可复现的代码片段,并尽可能保持最小化和简洁。 | |
| 具体来说,这意味着:</p> <ul><li>尽可能缩小 bug 的范围,<strong>不要直接粘贴整个代码文件</strong>。</li> <li>格式化您的代码。</li> <li>请勿包含除 Diffusers 所依赖的外部库以外的任何外部库。</li> <li><strong>始终</strong>提供有关您环境的所有必要信息;为此,您可以在 shell 中运行 <code>diffusers-cli env</code>,并将显示的信息复制粘贴到 issue 中。</li> <li>解释问题所在。如果读者不了解问题是什么以及它为何构成问题,(他/她)就无法解决它。</li> <li><strong>始终</strong>确保读者能够以最小的努力复现你的问题。如果你的代码片段因缺少库或未定义变量而无法运行,读者就无法帮助你。请确保你的可复现代码片段尽可能精简,并且可以直接复制粘贴到简单的 Python 控制台中运行。</li> <li>如果需要模型和/或数据集才能复现您的问题,请确保读者能够访问该模型或数据集。您可以随时将模型或数据集上传到 <a href="https://huggingface.co" rel="nofollow">Hub</a>,以便轻松下载。请尽量保持模型和数据集尽可能小,以便尽可能轻松地复现您的问题。</li></ul> <p>有关更多信息,请参阅<a href="#how-to-write-a-good-issue">如何撰写好的 issue</a>部分。</p> <p>您可以在此处<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=bug&projects=&template=bug-report.yml" rel="nofollow">提交错误报告</a>。</p> <!--[3--><h4 class="relative group"><a id="22-feature-requests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#22-feature-requests"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2.2. 功能请求<!----></span></h4><!--]--><!----> <p>一个世界级的功能请求应涵盖以下要点:</p> <ol><li>首先说明动机:</li></ol> <ul><li>这与库的某个问题或困扰有关吗?如果是,请解释原因。最好提供一段代码片段来演示该问题。</li> <li>这与您在项目中需要的内容有关吗?我们非常乐意了解您的想法!</li> <li>这是您参与开发并认为能够造福社区的项目吗? | |
| 太棒了!请告诉我们它为您解决了什么问题。</li></ul> <ol start="2"><li>撰写一个<em>完整段落</em>来描述该功能;</li> <li>提供一个<strong>代码片段</strong>,展示其未来的用法;</li> <li>如果这与某篇论文相关,请附上链接;</li> <li>请附上您认为可能有帮助的任何附加信息(图纸、截图等)。</li></ol> <p>您可以在此处<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feature_request.md&title=" rel="nofollow">提交功能请求</a>。</p> <!--[3--><h4 class="relative group"><a id="23-feedback" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#23-feedback"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2.3 反馈<!----></span></h4><!--]--><!----> <p>关于库设计的反馈,以及说明其设计优劣,对核心维护者构建用户友好的库大有裨益。要了解当前设计哲学背后的理念,请参阅<a href="https://huggingface.co/docs/diffusers/conceptual/philosophy" rel="nofollow">此处</a>。如果您认为某个设计选择与当前的设计哲学不符,请说明原因以及应如何修改。如果某个设计选择过于严格地遵循设计哲学,从而限制了使用场景,也请说明原因以及应如何修改。 | |
| 如果某个设计选择对您非常有用,也请留下备注,这对未来的设计决策是极佳的反馈。</p> <p>您可以在此处<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=" rel="nofollow">提交反馈问题</a>。</p> <!--[3--><h4 class="relative group"><a id="24-technical-questions" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#24-technical-questions"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2.4 技术问题<!----></span></h4><!--]--><!----> <p>技术问题主要涉及库中某些代码为何以特定方式编写,或某段代码的具体功能。请务必链接到相关代码,并详细说明为何该部分代码难以理解。</p> <p>您可以在此处<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=bug&template=bug-report.yml" rel="nofollow">提交 issue</a> 来咨询技术问题。</p> <!--[3--><h4 class="relative group"><a id="25-proposal-to-add-a-new-model-scheduler-or-pipeline" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#25-proposal-to-add-a-new-model-scheduler-or-pipeline"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->2.5 提议添加新的模型、调度器或流水线<!----></span></h4><!--]--><!----> <p>如果扩散模型社区发布了您希望在 Diffusers 库中看到的新型模型、流水线或调度器,请提供以下信息:</p> <ul><li>扩散流水线、模型或调度器的简短描述,以及指向相关论文或公开发布版本的链接。</li> <li>链接到其任意一个开源实现。</li> <li>如果模型权重可用,请提供其链接。</li></ul> <p>另外,如果可以找到组件(模型、调度器、流水线等)的原作者,请记得通过其 GitHub 用户名对其进行标记。</p> <p>如果您想自行将模型引入 Diffusers,请参阅 <a href="#6-publish-a-pipeline-or-model-on-the-hub">在 Hub 上发布流水线或模型</a> 和 <a href="#10-adding-pipelines-models-schedulers">添加流水线、模型和调度器</a>。</p> <p>您可以在此处<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=New+model%2Fpipeline%2Fscheduler&template=new-model-addition.yml" rel="nofollow">提交</a>模型/流水线/调度器的请求。</p> <!--[2--><h3 class="relative group"><a id="3-answering-issues-on-the-github-issues-tab" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#3-answering-issues-on-the-github-issues-tab"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->3. 在 GitHub issues 选项卡中回复问题<!----></span></h3><!--]--><!----> <p>在 GitHub 上回复 issue 可能需要一些关于 Diffusers 的技术知识,但我们鼓励大家即使不能 100% 确定自己的回答是否正确,也尝试参与回答。 | |
| 以下是一些提供高质量 issue 回答的技巧:</p> <ul><li>尽可能简洁且精简。</li> <li>请紧扣主题。针对该问题的回答应仅涉及该问题本身。</li> <li>请提供代码、论文或其他来源的链接,以证明或支持您的观点。</li> <li>以代码作答。如果一段简单的代码片段就是该问题的答案,或展示了如何解决问题,请提供一个完全可复现的代码片段。</li></ul> <p>此外,许多问题往往只是偏离主题、与其他问题重复或无关紧要。如果你能回复此类问题,鼓励提问者表述得更精确、提供重复问题的链接,或引导他们前往 <a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow">GitHub Discussions</a> 或 <a href="https://discord.gg/G7tWnz98XR" rel="nofollow">Discord</a>,将对维护者大有裨益。</p> <p>如果您已确认所提交的 bug 报告属实,且需要修改源代码, | |
| 请查看以下章节。</p> <p>对于除 <a href="#6-publish-a-pipeline-or-model-on-the-hub">6</a> 之外的所有贡献,您都需要提交一个 PR。<a href="https://github.com/huggingface/diffusers/pull/15179/changes#how-to-open-a-pr" rel="nofollow">创建拉取请求</a> 部分将说明具体操作方法。</p> <!--[2--><h3 class="relative group"><a id="4-fixing-a-good-first-issue" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#4-fixing-a-good-first-issue"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->4. 解决一个“适合初学者的问题”<!----></span></h3><!--]--><!----> <p><em>Good first issues</em> 带有 <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22" rel="nofollow">Good first issue</a> 标签。通常,issue 中已经说明了潜在解决方案应如何呈现,以便更容易修复。如果该 issue 尚未关闭,且你希望尝试修复它,只需留言“I would like to try this issue.”即可。通常有以下三种情况:</p> <ul><li>a.) 问题描述中已经提出了修复方案。在这种情况下,如果该方案对你来说合理,你可以提交一个 PR 或草稿 PR 来修复它。</li> <li>b.) 问题描述中未提出修复方案。在这种情况下,请在该问题的评论中自行提出修复方案。用几句话描述思路即可。在提交 PR 之前,请等待 Diffusers 团队成员确认。</li> <li>c.) 已经有一个未合并的 PR 旨在修复该问题,但 issue 尚未关闭。如果该 PR 已长期未更新(stale),你可以直接提交一个新的 PR,并在其中链接到那个过时的 PR。PR 经常会出现这种情况,因为最初想要修复该问题的贡献者可能突然抽不出时间继续推进。这在开源社区中非常常见,属于正常现象。在这种情况下,如果你愿意重新尝试并借鉴现有 PR 中的经验,社区会非常欢迎。如果已经存在一个 PR 且仍在活跃维护中,你可以通过提出建议、审查该 PR,甚至询问是否可以参与该 PR 的贡献来帮助作者。</li></ul> <!--[2--><h3 class="relative group"><a id="5-contribute-to-the-documentation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#5-contribute-to-the-documentation"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->5. 为文档做出贡献<!----></span></h3><!--]--><!----> <p>一个优秀的库<strong>总是</strong>拥有出色的文档!官方文档通常是新用户接触该库的第一个入口,因此为文档做出贡献是一项<strong>极具价值的贡献</strong>。</p> <p>为库做出贡献可以有多种形式:</p> <ul><li>修正拼写或语法错误。</li> <li>修正文档字符串中不正确的格式。如果您发现官方文档显示异常或链接失效,我们非常欢迎您花些时间进行修正。</li> <li>修正文档字符串中输入或输出张量的形状或维度。</li> <li>澄清难以理解或不正确的文档。</li> <li>更新过时的代码示例。</li> <li>将文档翻译成其他语言。</li></ul> <p>在<a href="https://huggingface.co/docs/diffusers/index" rel="nofollow">Diffusers 官方文档页面</a>上显示的任何内容均属于官方文档的一部分,可在相应的<a href="https://github.com/huggingface/diffusers/tree/main/docs/source" rel="nofollow">文档源</a>中进行更正或调整。</p> <p>请查看<a href="https://github.com/huggingface/diffusers/tree/main/docs" rel="nofollow">此页面</a>,了解如何在本地验证对文档所做的更改。</p> <!--[2--><h3 class="relative group"><a id="6-publish-a-pipeline-or-model-on-the-hub" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#6-publish-a-pipeline-or-model-on-the-hub"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->6. 在 Hub 上发布流水线或模型<!----></span></h3><!--]--><!----> <p>借助 <a href="../modular_diffusers/overview">Modular Diffusers</a>,流水线可以作为远程代码存在于任何 Hub 仓库中。任何人都可以使用 <code>from_pretrained(..., trust_remote_code=True)</code> 加载它,而无需等待 Diffusers 发布新版本。如果你是社区贡献者,正在引入新的流水线或模型,请从这里开始。请参阅自定义块以发布流水线,请参阅自定义模型以发布模型。</p> <p>请在对应的 <a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=New+model%2Fpipeline%2Fscheduler&template=new-model-addition.yml" rel="nofollow">模型请求</a> 下告知我们(如果没有,请新建一个):我们会对实现提供反馈,并将我们喜欢的作品收录到我们的 <a href="https://huggingface.co/collections/diffusers-modular/community-modular-diffusers-blocks" rel="nofollow">Community Modular Diffusers Blocks</a> 集合中。随后,我们将决定如何在库中支持该模型:我们可能会将您的版本合并到上游,与作者合作开发官方版本,或者直接将用户引导至您的版本。也请告诉我们您在过程中遇到的任何阻碍:令人困惑的 API、缺失的文档、Bug 等。这些反馈对我们来说与 pipeline 本身同样重要。</p> <!--[2--><h3 class="relative group"><a id="7-contribute-to-training-examples" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#7-contribute-to-training-examples"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->7. 贡献训练示例<!----></span></h3><!--]--><!----> <p>Diffusers 示例是一组位于 <a href="https://github.com/huggingface/diffusers/tree/main/examples" rel="nofollow">examples</a> 中的训练脚本。</p> <p>我们支持两种类型的训练示例:</p> <ul><li>官方训练示例</li> <li>研究训练示例</li></ul> <p>研究训练示例位于 <a href="https://github.com/huggingface/diffusers/tree/main/examples/research_projects" rel="nofollow">examples/research_projects</a>,而官方训练示例包括 <a href="https://github.com/huggingface/diffusers/tree/main/examples" rel="nofollow">examples</a> 下的所有文件夹,但不包括 <code>research_projects</code> 和 <code>community</code> 文件夹。 | |
| 官方训练示例由 Diffusers 的核心维护者维护,而研究训练示例则由社区维护。 | |
| 这与该库在 Hub 上同时保留少量官方流水线(pipelines)和社区流水线的原因相同:核心维护者无法维护扩散模型的所有可能训练方法。 | |
| 如果 Diffusers 核心维护者和社区认为某种训练范式过于实验性或普及度不够,相应的训练代码应放置在 <code>research_projects</code> 文件夹中,并由作者自行维护。</p> <p>官方的训练和研究示例均由一个目录组成,其中包含一个或多个训练脚本、一个 <code>requirements.txt</code> 文件和一个 <code>README.md</code> 文件。为了使用这些训练示例,用户需要克隆该仓库:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers<!----></pre></div><!----> <p>以及安装训练所需的所有额外依赖项:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-built_in">cd</span> diffusers | |
| pip install -r examples/<your-example-folder>/requirements.txt<!----></pre></div><!----> <p>因此,在添加示例时,<code>requirements.txt</code> 文件应定义训练示例所需的所有 pip 依赖项,以便在安装完这些依赖项后,用户即可运行该示例的训练脚本。例如,参见 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/requirements.txt" rel="nofollow">DreamBooth 的 <code>requirements.txt</code> 文件</a>。</p> <p>Diffusers 库的训练示例应遵循以下原则:</p> <ul><li>运行示例所需的所有代码都应包含在一个 Python 文件中。</li> <li>应当能够使用 <code>python <your-example>.py --args</code> 从命令行运行该示例。</li> <li>示例应保持简洁,作为使用 Diffusers 进行训练的<strong>示例</strong>。示例脚本的目的<strong>并非</strong>创建最先进的扩散模型,而是复现已知的训练方案,同时避免添加过多的自定义逻辑。基于这一点,我们的示例也力求成为优质的教学材料。</li></ul> <p>要贡献一个示例,强烈建议参考已有的示例(例如 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">dreambooth</a>),以了解其应有的结构。 | |
| 我们强烈建议贡献者使用 <a href="https://github.com/huggingface/accelerate" rel="nofollow">Accelerate library</a>,因为它与 Diffusers 深度集成。 | |
| 当示例脚本可以正常运行后,请务必添加一份详尽的 <code>README.md</code>,准确说明如何使用该示例。此 README 应包含:</p> <ul><li>一个示例命令,演示如何运行如<a href="https://github.com/huggingface/diffusers/tree/main/examples/dreambooth#running-locally-with-pytorch" rel="nofollow">此处</a>所示的示例脚本。</li> <li>指向一些训练结果(日志、模型等)的链接,展示用户预期能达到的效果,如<a href="https://api.wandb.ai/report/patrickvonplaten/xm6cd5q5" rel="nofollow">此处</a>所示。</li> <li>如果您正在添加一个非官方/研究性质的训练示例,<strong>请别忘了</strong>添加一句说明,表明您正在维护该训练示例,并附上您的 git 用户名,如<a href="https://github.com/huggingface/diffusers/tree/main/examples/research_projects/intel_opts#diffusers-examples-with-intel-optimizations" rel="nofollow">此处</a>所示。</li></ul> <p>如果您正在为官方训练示例做出贡献,请确保在其文件夹中添加一个测试,例如 <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/test_dreambooth.py" rel="nofollow">examples/dreambooth/test_dreambooth.py</a>。对于非官方训练示例,则无需这样做。</p> <!--[2--><h3 class="relative group"><a id="8-fixing-a-good-second-issue" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#8-fixing-a-good-second-issue"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->8. 修复“适合第二项任务”<!----></span></h3><!--]--><!----> <p><em>适合第二次的任务</em>会标记为 <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+second+issue%22" rel="nofollow">Good second issue</a> 标签。它们通常比 <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22" rel="nofollow">适合第一次的任务</a> 更复杂,描述中提供的修复指引较少,并且需要对库有相当程度的理解。</p> <p>如果你对解决一个不错的二级问题感兴趣,请在评论中用几句话分享你对该问题的看法以及你计划采用的方法,并在提交 PR 之前获得维护者的确认。如果该问题已经有人提交了 PR 但未被合并,请先查看并了解原因,然后再提出新的方案。</p> <!--[2--><h3 class="relative group"><a id="9-taking-on-a-diffusers-mvp-issue" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#9-taking-on-a-diffusers-mvp-issue"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->9. 认领 Diffusers MVP 问题<!----></span></h3><!--]--><!----> <p><a href="https://github.com/huggingface/diffusers/issues/12635" rel="nofollow">Diffusers MVP 计划</a>列出了我们最希望获得帮助的议题。它们类似于“适合第二项贡献的议题”,但难度更高、耗时更长,该计划会奖励接手这些议题的贡献者。在提交 PR 之前,请先以评论的形式分享你的思路,并等待维护者的确认。该计划还设有<a href="https://github.com/huggingface/diffusers/issues/14529" rel="nofollow">创意赛道</a>:用几句话告诉我们一个能提升 Diffusers 影响力的想法,无需包含实现细节。</p> <!--[2--><h3 class="relative group"><a id="10-adding-pipelines-models-schedulers" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#10-adding-pipelines-models-schedulers"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->10. 添加流水线、模型和调度器<!----></span></h3><!--]--><!----> <blockquote class="tip"><p>如果您是模型的作者,请联系我们以便与您协调集成事宜:请提交一个功能请求,或者如果已有相关请求,请留下评论。</p> <p>如果您是社区贡献者,请先从 Hub 仓库开始,参见 <a href="#6-publish-a-pipeline-or-model-on-the-hub">在 Hub 上发布流水线或模型</a>,并在功能请求下告知我们您有兴趣将其上游化。</p></blockquote> <p>Pipelines、models 和 schedulers 是 Diffusers 库中最核心的组件。 | |
| 它们提供了对前沿扩散技术的便捷访问,从而使社区能够构建功能强大的生成式 AI 应用。</p> <p>通过添加新的模型、流水线或调度器,您可能会为任何依赖 Diffusers 的用户界面启用一种强大的新用例,这对整个生成式 AI 生态系统都具有巨大的价值。</p> <!--[3--><h4 class="relative group"><a id="when-new-model-or-pipeline-support-is-released" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#when-new-model-or-pipeline-support-is-released"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->当发布新的模型或流水线支持时<!----></span></h4><!--]--><!----> <p>如果您提前与 Diffusers 团队协调集成工作,新的模型或流水线可能会被纳入某个版本。请随时通过 Diffusers 仓库中的 issue 或发送邮件至 <code>diffusers@huggingface.co</code> 与我们联系。</p> <p>模型或流水线拉取请求合并后,不会自动触发版本发布。在发布之前,维护者会先确认集成已完成,并且发布测试通过。</p> <p>对新模型或流水线的支持通常会在下一个次要版本中发布。集成代码会合并到 <code>main</code> 分支,并基于该分支创建发布分支。该发布版本包含自上一个版本以来合并的所有更改,而不仅仅是模型或流水线的集成。</p> <p>发布说明会突出介绍新的模型或流水线,并总结该版本中包含的其他更改。补丁版本通常仅用于修复现有版本中的问题。</p> <p>Diffusers 针对所有三个组件都有一些开放的功能请求——如果您还不确定想要添加哪个具体组件,可以随意浏览一下:</p> <ul><li><a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+pipeline%2Fmodel%22" rel="nofollow">模型或流水线</a></li> <li><a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+scheduler%22" rel="nofollow">调度器</a></li></ul> <p>在添加上述三个组件中的任何一个之前,强烈建议您先阅读<a href="philosophy">设计哲学指南</a>,以便更好地理解这三个组件的设计。请注意,如果模型、调度器或流水线的添加内容与我们的设计哲学存在重大偏差,我们将无法合并,因为这会导致 API 不一致。如果您从根本上不同意某项设计决策,请改为提交一个<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feedback.md&title=" rel="nofollow">反馈问题</a>,以便讨论是否应在整个库中更改特定的设计模式/设计决策,以及我们是否应更新设计哲学。库内的一致性对我们非常重要。</p> <p>请务必在 PR 中添加指向原始代码库/论文的链接,并最好直接在 PR 中 @ 原始作者,以便他们能够跟进进展,并可能协助解答相关问题。</p> <p>如果您对 PR 感到不确定或卡住了,请随时留言请求初步审查或帮助。</p> <!--[3--><h4 class="relative group"><a id="copied-from-mechanism" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#copied-from-mechanism"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->Copied from mechanism<!----></span></h4><!--]--><!----> <p>在添加任何 pipeline、model 或 scheduler 代码时,需要理解一个独特且重要的特性,即 <code># Copied from</code> 机制。你会在 Diffusers 代码库中随处可见它,我们使用它的原因是为了让代码库易于理解和维护。使用 <code># Copied from</code> 机制标记代码会强制被标记的代码与其来源代码保持完全一致。这样,每次运行 <code>make fix-copies</code> 时,都可以轻松地在多个文件中更新并传播更改。</p> <p>例如,在下面的代码示例中,<a href="/docs/diffusers/v0.43.0/zh/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> 是原始代码,而 <code>AltDiffusionPipelineOutput</code> 使用 <code># Copied from</code> 机制将其复制过来。唯一的区别是将类前缀从 <code>Stable</code> 更改为 <code>Alt</code>。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-comment"># Copied from diffusers.pipelines.stable_diffusion.pipeline_output.StableDiffusionPipelineOutput with Stable->Alt</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">AltDiffusionPipelineOutput</span>(<span class="hljs-title class_ inherited__">BaseOutput</span>): | |
| <span class="hljs-string">""" | |
| Output class for Alt Diffusion pipelines. | |
| Args: | |
| images (`List[PIL.Image.Image]` or `np.ndarray`) | |
| List of denoised PIL images of length `batch_size` or NumPy array of shape `(batch_size, height, width, | |
| num_channels)`. | |
| nsfw_content_detected (`List[bool]`) | |
| List indicating whether the corresponding generated image contains "not-safe-for-work" (nsfw) content or | |
| `None` if safety checking could not be performed. | |
| """</span><!----></pre></div><!----> <p>欲了解更多信息,请阅读这篇 <a href="https://huggingface.co/blog/transformers-design-philosophy#4-machine-learning-models-are-static" rel="nofollow">~Don’t~ Repeat Yourself*</a> 博客文章中的相关章节。</p> <!--[1--><h2 class="relative group"><a id="how-to-write-a-good-issue" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-write-a-good-issue"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->如何撰写一个高质量的 issue<!----></span></h2><!--]--><!----> <p><strong>问题描述得越清晰,越有可能被快速解决。</strong></p> <ol><li>请确保你针对该问题使用了正确的模板。你可以选择 <em>Bug Report</em>、<em>Feature Request</em>、<em>Feedback about API Design</em>、<em>New model/pipeline/scheduler addition</em> 或空白问题。在打开 <a href="https://github.com/huggingface/diffusers/issues/new/choose" rel="nofollow">a new issue</a> 时,请务必选择正确的模板。使用类问题应发布在 <a href="https://github.com/huggingface/diffusers/discussions" rel="nofollow">GitHub Discussions</a> 中,而不是作为 issue 提交。</li> <li><strong>表述精确</strong>:为你的问题起一个贴切的标题。尽量用简洁的语言描述问题。提交问题时表述得越精确,理解并解决该问题所需的时间就越短。请确保每个 issue 只针对一个问题,不要将多个问题混在一起。如果你发现了多个问题,请分别提交多个 issue。如果你的问题是 bug,请尽可能精确地说明具体是什么 bug——不要只写“diffusers 中出现错误”。</li> <li><strong>可复现性</strong>:没有可复现的代码片段就等于没有解决方案。如果您遇到 bug,维护者必须能够<strong>复现</strong>该问题。请确保您包含一段可以复制粘贴到 Python 解释器中运行以复现问题的代码片段。请确保您的代码片段可以正常运行,<em>即</em>没有缺失的导入或指向图像的缺失链接等。您的 issue 应包含错误消息<strong>以及</strong>一段无需任何修改即可复制粘贴并复现完全相同错误消息的代码片段。如果您的 issue 使用了读者无法访问的本地模型权重或本地数据,则该 issue 无法解决。如果您无法共享您的数据或模型,请尝试创建一个虚拟模型或虚拟数据。</li> <li><strong>极简主义</strong>:在尽可能简洁的前提下,帮助读者尽快理解问题。删除所有与问题无关的代码和信息。如果发现了一个 bug,请尝试编写最简单的代码示例来复现该问题,而不是在发现 bug 后就将整个工作流直接粘贴到 issue 中。例如,如果你在训练模型时在某处遇到错误,应首先尝试确定是哪部分训练代码导致了该错误,并尝试用几行代码来复现它。请尽量使用虚拟数据,而不是完整的数据集。</li> <li><strong>背景</strong>:请告诉我们,在遇到该 bug 或需要该功能时,你正在做什么工作,例如基于 Diffusers 构建的应用、研究项目,或你运行用于在库中查找 bug 的智能体。一两句话即可,附上项目链接更佳。我们收到的 issue 和 PR 数量远超当前处理能力,因此背景信息有助于我们根据影响程度进行优先级排序。</li> <li>添加链接。如果你指的是某个特定的命名、方法或模型,请确保提供链接,以便读者更好地理解你的意思。如果你指的是某个具体的 PR 或 issue,请确保将其链接到你的 issue。不要假设读者知道你在说什么。你在 issue 中添加的链接越多越好。</li> <li>格式规范。请妥善格式化你的 issue,将代码格式化为 Python 代码语法,将错误信息格式化为普通代码语法。有关更多信息,请参阅 <a href="https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax" rel="nofollow">GitHub 官方格式文档</a>。</li> <li>请将你的问题视为一部精心撰写的百科全书中一个精彩的条目,而非一张待解决的工单。每一个新增的问题都是对公开知识体系的贡献。撰写一份条理清晰的问题报告,不仅能让维护者更轻松地解决你的问题,也有助于整个社区更好地理解该库的某个特定方面。</li></ol> <!--[1--><h2 class="relative group"><a id="how-to-write-a-good-pr" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-write-a-good-pr"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->如何撰写一份优质的 PR<!----></span></h2><!--]--><!----> <ol><li>请始终从 issue 开始。找到你的 pull request 所解决的 issue,或者如果还没有人提出,就自己开一个,并在编写代码之前给维护者留出回应的时间。对我们来说效果最好的工作流程是:先开一个 issue,然后讨论解决方案,最后基于该讨论提交 PR。这让我们能够将时间集中在影响最大的 issue 上,在代码出现之前就就范围达成一致,并避免重复劳动。请在 PR 描述中提及 issue 编号(例如 <code>Fixes #1234</code>),以便将两者关联起来。</li> <li>像变色龙一样。理解现有的设计模式和语法,确保你新增的代码能够无缝融入现有代码库。与现有设计模式或用户界面存在显著差异的 Pull Request 将不会被合并。</li> <li>保持专注。一个拉取请求(pull request)应只解决一个问题,且仅解决该问题。请避免陷入“既然在添加功能,顺便也修复另一个问题”的陷阱。同时解决多个不相关问题的拉取请求会大大增加代码审查的难度。</li> <li>修复模式,而非孤例。一个问题可能横跨多个文件:如果同一个 bug 在代码库中反复出现,请搜索所有实例,并在一个 PR 中全部修复,同时明确且系统地界定范围(例如“修复所有调度器中的可变默认值”),而不是为每个实例单独提交一个 PR。</li> <li>您的拉取请求(pull request)标题应是对该贡献的摘要。若要表示工作正在进行中,请在标题前加上 <code>[WIP]</code> 前缀;这样可以避免重复劳动,并将该 PR 与已准备好合并的 PR 区分开来。</li> <li>请按照<a href="#how-to-write-a-good-issue">如何撰写高质量的 issue</a>中的说明,尝试组织并格式化你的文本。</li> <li>在提交 PR 之前,请先自行审查你的 diff。像评审者一样阅读它,并修复你发现的问题。我们强烈建议运行 <a href="https://github.com/huggingface/diffusers/blob/main/.ai/skills/self-review/SKILL.md" rel="nofollow"><code>self-review</code></a> 技能:它会执行与 <code>@claude</code> CI 评审者相同的评分标准。按照 <a href="#coding-with-ai-agents">使用 AI 智能体进行编码</a> 中的说明配置你的智能体,并遵循 <a href="#ai-assisted-and-agentic-contributions">AI 辅助和智能体贡献</a>。在描述中说明你有意保留未改动的发现,以便评审者知道这是你的决定,而非疏忽。</li> <li>确保现有测试通过。</li> <li>添加高覆盖率的测试。没有质量测试 = 不予合并。</li></ol> <ul><li>如果您正在添加新的 <code>@slow</code> 测试,请确保使用 <code>RUN_SLOW=1 python -m pytest tests/test_my_new_model.py</code> 时它们能够通过。 | |
| CircleCI 不会运行慢速测试,但 GitHub Actions 每晚都会运行!</li></ul> <ol start="10"><li>所有公共方法都必须包含信息丰富的文档字符串,并且能够很好地与 Markdown 配合使用。示例请参见 <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py" rel="nofollow"><code>pipeline_latent_diffusion.py</code></a>。</li> <li>由于仓库正在快速增长,确保不会添加任何会显著增加仓库体积的文件至关重要。这包括图像、视频以及其他非文本文件。我们倾向于使用由 hf.co 托管的 <code>dataset</code>(例如 <a href="https://huggingface.co/hf-internal-testing" rel="nofollow"><code>hf-internal-testing</code></a> 或 <a href="https://huggingface.co/datasets/huggingface/documentation-images" rel="nofollow">huggingface/documentation-images</a>)来存放这些文件。 | |
| 如果是外部贡献,您可以将图像添加到您的 PR 中,并请求 Hugging Face 成员将您的图像迁移到该数据集。</li></ol> <!--[1--><h2 class="relative group"><a id="how-to-open-a-pr" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-open-a-pr"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->如何提交 PR<!----></span></h2><!--]--><!----> <p>在编写代码之前,我们强烈建议您先搜索现有的 PR 或 issue,以确认是否已有人正在处理相同的问题。如果您不确定,最好先提交一个 issue 来获取一些反馈。</p> <p>要参与 🧨 Diffusers 的贡献,你需要具备基本的 <code>git</code> 技能。<code>git</code> 并不是最容易上手的工具,但它拥有最出色的手册。在终端中输入 <code>git --help</code> 即可开始探索。如果你更喜欢书籍,<a href="https://git-scm.com/book/en/v2" rel="nofollow">Pro Git</a> 是一本非常优秀的参考书。</p> <p>按照以下步骤开始贡献(<a href="https://github.com/huggingface/diffusers/blob/83bc6c94eaeb6f7704a2a428931cf2d9ad973ae9/setup.py#L270" rel="nofollow">支持的 Python 版本</a>):</p> <ol><li><p>点击仓库页面上的“Fork”按钮,<a href="https://github.com/huggingface/diffusers" rel="nofollow">fork 该仓库</a>。这会在你的 GitHub 用户账户下创建一份代码副本。</p></li> <li><p>将您的 fork 克隆到本地磁盘,并将基础仓库添加为远程仓库:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git <span class="hljs-built_in">clone</span> git@github.com:<your GitHub handle>/diffusers.git | |
| $ <span class="hljs-built_in">cd</span> diffusers | |
| $ git remote add upstream https://github.com/huggingface/diffusers.git<!----></pre></div><!----></li> <li><p>创建一个新分支来保存你的开发更改:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git checkout -b a-descriptive-name-for-my-changes<!----></pre></div><!----></li></ol> <p><strong>请勿</strong>在 <code>main</code> 分支上工作。</p> <ol start="4"><li><p>在虚拟环境中运行以下命令来设置开发环境:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ pip install -e <span class="hljs-string">".[dev]"</span><!----></pre></div><!----></li></ol> <p>如果您已经克隆了该仓库,可能需要执行 <code>git pull</code> 以获取该库的最新更改。</p> <ol start="5"><li>在您的分支上开发功能。</li></ol> <p>在开发功能时,请确保测试套件通过。您应该以如下方式运行受您更改影响的测试:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ pytest tests/<TEST_TO_RUN>.py<!----></pre></div><!----> <p>在运行测试之前,请确保已安装测试所需的依赖项。您可以使用以下命令完成安装:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ pip install -e <span class="hljs-string">".[test]"</span><!----></pre></div><!----> <p>你也可以使用以下命令运行完整的测试套件,但由于 Diffusers 已经大幅扩展,现在需要一台性能强劲的机器才能在合理的时间内得出结果。命令如下:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ make <span class="hljs-built_in">test</span><!----></pre></div><!----> <p>🧨 Diffusers 依赖 <code>black</code> 和 <code>isort</code> 来统一格式化其源代码。 | |
| 在做出更改后,使用以下命令一次性应用自动样式修正和无法自动化的代码验证:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ make style<!----></pre></div><!----> <p>🧨 Diffusers 还使用 <code>ruff</code> 和一些自定义脚本来检查编码错误。质量控制会在 CI 中运行,但您也可以使用以下命令运行相同的检查:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ make quality<!----></pre></div><!----> <p>当您对所做的更改感到满意后,使用 <code>git add</code> 添加已更改的文件,并使用 <code>git commit</code> 创建提交以在本地记录您的更改:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git add modified_file.py | |
| $ git commit -m <span class="hljs-string">"A descriptive message about your changes."</span><!----></pre></div><!----> <p>定期将您的代码副本与原始仓库同步是个好主意。这样您可以快速跟进变更:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git pull upstream main<!----></pre></div><!----> <p>使用以下命令将更改推送到您的账户:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git push -u origin a-descriptive-name-for-my-changes<!----></pre></div><!----> <ol start="6"><li><p>一旦您确认无误,请前往您在 GitHub 上 fork 的仓库网页。点击“Pull request”,将您的更改发送给项目维护者进行审查。</p></li> <li><p>维护者要求你进行修改是很正常的,核心贡献者也会遇到这种情况!为了让所有人都能在 Pull request 中看到这些更改,请在你的本地分支上工作,并将更改推送到你的 fork。这些更改会自动出现在 pull request 中。</p></li></ol> <!--[2--><h3 class="relative group"><a id="tests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tests"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->测试<!----></span></h3><!--]--><!----> <p>该库附带了全面的测试套件,用于测试库的行为以及多个示例。库的测试位于 <a href="https://github.com/huggingface/diffusers/tree/main/tests" rel="nofollow">tests 文件夹</a> 中。</p> <p>我们喜欢 <code>pytest</code> 和 <code>pytest-xdist</code>,因为它速度更快。在仓库根目录下,使用 <code>pytest</code> 运行该库测试的方法如下:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ python -m pytest -n auto --dist=loadfile -s -v ./tests/<!----></pre></div><!----> <p>事实上,<code>make test</code> 就是这样实现的!</p> <p>您可以指定一个较小的测试集,以仅测试您正在开发的功能。</p> <p>默认情况下,慢速测试会被跳过。将 <code>RUN_SLOW</code> 环境变量设置为 <code>yes</code> 即可运行这些测试。这将下载数 GB 的模型——请确保你有足够的磁盘空间和良好的网络连接,或者做好长时间等待的准备!</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ RUN_SLOW=<span class="hljs-built_in">yes</span> python -m pytest -n auto --dist=loadfile -s -v ./tests/<!----></pre></div><!----> <p><code>unittest</code> 完全受支持,以下是如何使用它运行测试:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ python -m unittest discover -s tests -t . -v | |
| $ python -m unittest discover -s examples -t examples -v<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="syncing-forked-main-with-upstream-huggingface-main" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#syncing-forked-main-with-upstream-huggingface-main"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->将 fork 的 main 分支与上游(HuggingFace)main 分支同步<!----></span></h3><!--]--><!----> <p>为避免向上游仓库发送 ping(这会在每个上游 PR 中添加引用备注,并向参与这些 PR 的开发者发送不必要的通知),在同步 fork 仓库的主分支时,请遵循以下步骤:</p> <ol><li>在可能的情况下,避免通过分支和 PR 在 fork 仓库中与上游同步。相反,应直接合并到 fork 的 main 分支。</li> <li>如果确实需要提交 PR,请在检出你的分支后执行以下步骤:</li></ol> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> 已复制</div><!----></button><!----></div> <pre class="language-bash "><!---->$ git checkout -b your-branch-for-syncing | |
| $ git pull --squash --no-commit upstream main | |
| $ git commit -m <span class="hljs-string">'<your message without GitHub references>'</span> | |
| $ git push --set-upstream origin your-branch-for-syncing<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="style-guide" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#style-guide"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->样式指南<!----></span></h3><!--]--><!----> <p>对于文档字符串,🧨 Diffusers 遵循 <a href="https://google.github.io/styleguide/pyguide.html" rel="nofollow">Google 风格</a>。</p> <!--[1--><h2 class="relative group"><a id="coding-with-ai-agents" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#coding-with-ai-agents"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->使用 AI 智能体进行编程<!----></span></h2><!--]--><!----> <p>该仓库将 AI 智能体配置保存在 <a href="https://github.com/huggingface/diffusers/tree/main/.ai" rel="nofollow"><code>.ai/</code></a> 中,同时以智能体插件的形式发布,以便按需任务技能能够一步安装。</p> <ul><li><strong>对贡献者只读</strong> — <code>.ai/</code> 由核心维护者管理。请勿在您的 PR 中编辑 <code>.ai/</code> 下的文件(或根目录下的 <code>AGENTS.md</code> / <code>CLAUDE.md</code> 符号链接,或已安装的 <code>.agents/skills</code> / <code>.claude/skills</code>)。如果您发现内容缺失或错误,请提交 issue 或在 PR 中指出,维护者会进行更新。</li> <li><strong>Guidelines</strong> — <code>.ai/AGENTS.md</code> 通过根目录下的 <code>AGENTS.md</code> / <code>CLAUDE.md</code> 符号链接加载到每个 agent 会话中; <code>.ai/references/</code> 下的参考指南会在跟随链接时按需读取: <ul><li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/AGENTS.md" rel="nofollow"><code>.ai/AGENTS.md</code></a> — 顶层编码规范</li> <li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/models.md" rel="nofollow"><code>.ai/references/models.md</code></a> — 注意力模式、模型实现规则、通用约定</li> <li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/pipelines.md" rel="nofollow"><code>.ai/references/pipelines.md</code></a> — 流水线约定</li> <li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/modular.md" rel="nofollow"><code>.ai/references/modular.md</code></a> — 模块化流水线约定与转换检查清单</li> <li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/testing.md" rel="nofollow"><code>.ai/references/testing.md</code></a> — 必需的测试层级、测试器混入、dummy-component 规则</li> <li><a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/review-rules.md" rel="nofollow"><code>.ai/references/review-rules.md</code></a> — 评审人员关注的要点</li></ul></li> <li><strong>Skills</strong> (under <a href="https://github.com/huggingface/diffusers/tree/main/.ai/skills" rel="nofollow"><code>.ai/skills/</code></a>, ,按需加载以处理特定任务): <ul><li><code>model-integration</code> — 端到端地将新模型或流水线添加到 diffusers(文件结构、集成检查清单、测试布局、权重转换)</li> <li><code>self-review</code> — 在提交 PR 之前,根据项目规则审查你的更改</li> <li><code>diffusers-cli</code> — 在终端中运行流水线并检查架构</li> <li><code>custom-blocks</code> — 将 <code>ModularPipelineBlocks</code> 子类打包到 Hub</li></ul></li></ul> <p>无论您选择哪种方式,在开始之前,请先让您的智能体确认其自身的配置——<code>python utils/check_ai.py</code> 用于检查指南和技能是否一致,而 <code>diffusers-cli skills list</code> 则显示它实际拥有的技能。</p> <!--[2--><h3 class="relative group"><a id="ai-assisted-and-agentic-contributions" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#ai-assisted-and-agentic-contributions"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->AI 辅助与智能体贡献<!----></span></h3><!--]--><!----> <p>欢迎 AI 智能体为 Diffusers 做出贡献。我们建议您使用 Diffusers 的 <a href="https://github.com/huggingface/diffusers/blob/main/.ai/AGENTS.md" rel="nofollow">智能体指南</a> 来配置您的智能体,并使用相关的特定任务技能,例如 <code>model-integration</code> 和 <code>self-review</code>。按照上述说明安装插件(或单个技能),然后遵循指南来界定范围、实现、测试并审查您的贡献。您仍需负责理解、测试和维护 PR 中的更改。</p> <p>欢迎通过 AI 辅助进行贡献,但必须对其进行协调、限定范围并加以验证,以将审查工作量控制在可管理的范围内。未遵循这些准则的 PR 可能会被直接关闭,而不会进行详细审查。</p> <ul><li><strong>在提交 PR 之前请先进行协调。</strong>查找或创建一个 issue,查看相关的 PR(包括已打开和最近已关闭的),并在该 issue 上等待维护者的明确确认后再提交 PR。这能让我们有机会讨论范围、避免重复工作并确认实现方案。</li> <li><strong>修复模式,而非孤立问题。</strong> 如果你发现一个反复出现的问题,请在代码库中搜索类似的实例,并针对一个清晰、系统性的范围(例如“修复所有调度器中的可变默认值”)提交一个<em>单一</em>的 issue,而不是为每个单独实例提交多个 issue 或 PR。</li> <li><strong>在提交前进行自查。</strong> 运行 <a href="https://github.com/huggingface/diffusers/blob/main/.ai/skills/self-review/SKILL.md" rel="nofollow"><code>self-review</code></a> 技能——它会依据 <a href="https://github.com/huggingface/diffusers/blob/main/.ai/references/review-rules.md" rel="nofollow"><code>.ai/references/review-rules.md</code></a> 审查你的 diff,该文件与 <code>@claude</code> CI 审查员使用的标准一致——并处理其报告的问题。该技能只是一个辅助工具,并非权威,也可能出错。请重点关注那些你认为合理的阻塞性问题,并尽可能清理无用/未使用的代码。如果你不同意某条建议,可以将其留给审查员在 PR 打开后讨论——你分享的备注(见下文)会告知审查员这是你有意为之的决定。</li> <li><strong>分享你的自查笔记。</strong>请在 PR 中发布最终的自查报告——即反映你所提交 diff 的那一轮——将其放在描述中或作为评论,并包含你有意未修复的问题及其原因。这有助于审阅者了解哪些内容已经检查过、哪些决定是有意为之,通常也能省去几轮来回沟通。</li> <li><strong>保持 PR 沟通简洁。</strong> 审查者在你的 PR 中阅读的所有内容——描述、提交信息、评论和回复、代码注释——都必须让人类易于理解。如果是由你的 agent 起草的,不要只是粗略浏览。请仔细阅读,并要求 agent 修改,直到内容合理、简洁,且是你自己会写出的风格。你是你所发布的所有内容的作者。</li> <li><strong>Include in the PR description:</strong> <ul><li>指向维护者已确认该工作的 issue 或讨论的<strong>协调链接</strong>。</li> <li>你运行的 <strong>测试命令</strong> 及其结果(请粘贴相关输出,而不仅仅是“测试通过”)。</li> <li>如上所述,您的<strong>自我审查笔记</strong>(或包含这些笔记的 PR 评论链接)。</li></ul></li></ul> <p>如果您是模型作者,或属于官方维护某个模型的团队,我们鼓励您使用智能体来完成新模型的集成。请遵循该仓库的<a href="https://github.com/huggingface/diffusers/blob/main/.ai/AGENTS.md" rel="nofollow">推荐配置</a>,并使用<a href="https://github.com/huggingface/diffusers/blob/main/.ai/skills/model-integration/SKILL.md" rel="nofollow"><code>model-integration</code></a>技能。在提交 PR 之前,请先与维护者协调好范围——参见<a href="#10-adding-pipelines-models-schedulers">添加流水线、模型和调度器</a>。</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/diffusers/blob/main/docs/source/en/conceptual/contribution.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]--> | |
| <script> | |
| { | |
| __sveltekit_ywq9g6 = { | |
| base: "/docs/diffusers/v0.43.0/en", | |
| assets: "/docs/diffusers/v0.43.0/en" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/diffusers/v0.43.0/en/_app/immutable/entry/start.1gaXe03k.js"), | |
| import("/docs/diffusers/v0.43.0/en/_app/immutable/entry/app.BwdYRbCn.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 304], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 118 kB
- Xet hash:
- a16fd89531feb4fad1ab5a443a312929cd94daf20866eb8e2bc7ba632561b9dc
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.