Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"概述","local":"概述","sections":[{"title":"安装","local":"安装","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/diffusers/pr_12403/zh/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/entry/start.009fc24b.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/scheduler.5c93273d.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/singletons.c5d047c8.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/index.6d7dc09e.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/paths.ad38253d.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/entry/app.45dd6b31.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/index.e43dd92b.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/nodes/0.a6c0e1b8.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/nodes/48.e14149f5.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/CodeBlock.6896320e.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_12403/zh/_app/immutable/chunks/getInferenceSnippets.161194d2.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"概述","local":"概述","sections":[{"title":"安装","local":"安装","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="概述" 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="#概述"><span><svg class="" 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></h1> <p data-svelte-h="svelte-1neo90y">🤗 Diffusers 提供了一系列训练脚本供您训练自己的diffusion模型。您可以在 <a href="https://github.com/huggingface/diffusers/tree/main/examples" rel="nofollow">diffusers/examples</a> 找到所有训练脚本。</p> <p data-svelte-h="svelte-5pvswp">每个训练脚本具有以下特点:</p> <ul data-svelte-h="svelte-xoqjgx"><li><strong>独立完整</strong>:训练脚本不依赖任何本地文件,所有运行所需的包都通过 <code>requirements.txt</code> 文件安装</li> <li><strong>易于调整</strong>:这些脚本是针对特定任务的训练示例,并不能开箱即用地适用于所有训练场景。您可能需要根据具体用例调整脚本。为此,我们完全公开了数据预处理代码和训练循环,方便您进行修改</li> <li><strong>新手友好</strong>:脚本设计注重易懂性和入门友好性,而非包含最新最优方法以获得最具竞争力的结果。我们有意省略了过于复杂的训练方法</li> <li><strong>单一用途</strong>:每个脚本仅针对一个任务设计,确保代码可读性和可理解性</li></ul> <p data-svelte-h="svelte-14p5r7u">当前提供的训练脚本包括:</p> <table data-svelte-h="svelte-h8xzd3"><thead><tr><th>训练类型</th> <th>支持SDXL</th> <th>支持LoRA</th> <th>支持Flax</th></tr></thead> <tbody><tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/unconditional_image_generation" rel="nofollow">unconditional image generation</a> <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/training_example.ipynb" rel="nofollow"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a></td> <td></td> <td></td> <td></td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/text_to_image" rel="nofollow">text-to-image</a></td> <td>👍</td> <td>👍</td> <td>👍</td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/textual_inversion" rel="nofollow">textual inversion</a> <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/sd_textual_inversion_training.ipynb" rel="nofollow"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a></td> <td></td> <td></td> <td>👍</td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/dreambooth" rel="nofollow">DreamBooth</a> <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/sd_dreambooth_training.ipynb" rel="nofollow"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a></td> <td>👍</td> <td>👍</td> <td>👍</td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/controlnet" rel="nofollow">ControlNet</a></td> <td>👍</td> <td></td> <td>👍</td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/instruct_pix2pix" rel="nofollow">InstructPix2Pix</a></td> <td>👍</td> <td></td> <td></td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/custom_diffusion" rel="nofollow">Custom Diffusion</a></td> <td></td> <td></td> <td></td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/t2i_adapter" rel="nofollow">T2I-Adapters</a></td> <td>👍</td> <td></td> <td></td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/kandinsky2_2/text_to_image" rel="nofollow">Kandinsky 2.2</a></td> <td></td> <td>👍</td> <td></td></tr> <tr><td><a href="https://github.com/huggingface/diffusers/tree/main/examples/wuerstchen/text_to_image" rel="nofollow">Wuerstchen</a></td> <td></td> <td>👍</td> <td></td></tr></tbody></table> <p data-svelte-h="svelte-rleprd">这些示例处于<strong>积极维护</strong>状态,如果遇到问题请随时提交issue。如果您认为应该添加其他训练示例,欢迎创建<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&labels=&template=feature_request.md&title=" rel="nofollow">功能请求</a>与我们讨论,我们将评估其是否符合独立完整、易于调整、新手友好和单一用途的标准。</p> <h2 class="relative group"><a id="安装" 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="#安装"><span><svg class="" 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 data-svelte-h="svelte-tu9bzc">请按照以下步骤在新虚拟环境中从源码安装库,确保能成功运行最新版本的示例脚本:</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 class="" 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> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START -->git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers | |
| <span class="hljs-built_in">cd</span> diffusers | |
| pip install .<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-p14hlq">然后进入具体训练脚本目录(例如<a href="https://github.com/huggingface/diffusers/tree/main/examples/dreambooth" rel="nofollow">DreamBooth</a>),安装对应的<code>requirements.txt</code>文件。部分脚本针对SDXL、LoRA或Flax有特定要求文件,使用时请确保安装对应文件。</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 class="" 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> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-built_in">cd</span> examples/dreambooth | |
| pip install -r requirements.txt | |
| <span class="hljs-comment"># 如需用DreamBooth训练SDXL</span> | |
| pip install -r requirements_sdxl.txt<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-hdwswn">为加速训练并降低内存消耗,我们建议:</p> <ul data-svelte-h="svelte-18es2ri"><li>使用PyTorch 2.0或更高版本,自动启用<a href="../optimization/fp16#scaled-dot-product-attention">缩放点积注意力</a>(无需修改训练代码)</li> <li>安装<a href="../optimization/xformers">xFormers</a>以启用内存高效注意力机制</li></ul> <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/zh/training/overview.md" target="_blank"><span data-svelte-h="svelte-1kd6by1"><</span> <span data-svelte-h="svelte-x0xyl0">></span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_e2f86x = { | |
| assets: "/docs/diffusers/pr_12403/zh", | |
| base: "/docs/diffusers/pr_12403/zh", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/diffusers/pr_12403/zh/_app/immutable/entry/start.009fc24b.js"), | |
| import("/docs/diffusers/pr_12403/zh/_app/immutable/entry/app.45dd6b31.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 48], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 13.1 kB
- Xet hash:
- 2da63307277270658c24e662957444289ebc393bb5ad283bb4d2eb54458dee8b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.