import{s as pt,n as ut,o as gt}from"../chunks/scheduler.5c93273d.js";import{S as ht,i as ct,g as n,s as a,r as L,A as bt,h as o,f as l,c as i,j as rt,u as J,x as r,k as dt,y as xt,a as s,v as H,d as U,t as B,w as P}from"../chunks/index.e43dd92b.js";import{C as ft}from"../chunks/CodeBlock.6896320e.js";import{H as mt,E as _t}from"../chunks/getInferenceSnippets.d410b42d.js";function wt(O){let d,j,y,I,f,R,m,Q='🤗 Diffusers 提供了一系列训练脚本供您训练自己的diffusion模型。您可以在 <a href="https://github.com/huggingface/diffusers/tree/main/examples" rel="nofollow">diffusers/examples</a> 找到所有训练脚本。',k,p,K="每个训练脚本具有以下特点：",E,u,tt="<li><strong>独立完整</strong>：训练脚本不依赖任何本地文件，所有运行所需的包都通过 <code>requirements.txt</code> 文件安装</li> <li><strong>易于调整</strong>：这些脚本是针对特定任务的训练示例，并不能开箱即用地适用于所有训练场景。您可能需要根据具体用例调整脚本。为此，我们完全公开了数据预处理代码和训练循环，方便您进行修改</li> <li><strong>新手友好</strong>：脚本设计注重易懂性和入门友好性，而非包含最新最优方法以获得最具竞争力的结果。我们有意省略了过于复杂的训练方法</li> <li><strong>单一用途</strong>：每个脚本仅针对一个任务设计，确保代码可读性和可理解性</li>",F,g,et="当前提供的训练脚本包括：",W,h,lt='<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>',X,c,st='这些示例处于<strong>积极维护</strong>状态，如果遇到问题请随时提交issue。如果您认为应该添加其他训练示例，欢迎创建<a href="https://github.com/huggingface/diffusers/issues/new?assignees=&amp;labels=&amp;template=feature_request.md&amp;title=" rel="nofollow">功能请求</a>与我们讨论，我们将评估其是否符合独立完整、易于调整、新手友好和单一用途的标准。',Z,b,z,x,at="请按照以下步骤在新虚拟环境中从源码安装库，确保能成功运行最新版本的示例脚本：",D,_,S,w,it='然后进入具体训练脚本目录（例如<a href="https://github.com/huggingface/diffusers/tree/main/examples/dreambooth" rel="nofollow">DreamBooth</a>），安装对应的<code>requirements.txt</code>文件。部分脚本针对SDXL、LoRA或Flax有特定要求文件，使用时请确保安装对应文件。',V,$,q,v,nt="为加速训练并降低内存消耗，我们建议：",A,C,ot='<li>使用PyTorch 2.0或更高版本，自动启用<a href="../optimization/fp16#scaled-dot-product-attention">缩放点积注意力</a>（无需修改训练代码）</li> <li>安装<a href="../optimization/xformers">xFormers</a>以启用内存高效注意力机制</li>',G,T,N,M,Y;return f=new mt({props:{title:"概述",local:"概述",headingTag:"h1"}}),b=new mt({props:{title:"安装",local:"安装",headingTag:"h2"}}),_=new ft({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install .`,wrap:!1}}),$=new ft({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0JTBBJTIzJTIwJUU1JUE2JTgyJUU5JTlDJTgwJUU3JTk0JUE4RHJlYW1Cb290aCVFOCVBRSVBRCVFNyVCQiU4M1NEWEwlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfc2R4bC50eHQ=",highlighted:`<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`,wrap:!1}}),T=new _t({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/overview.md"}}),{c(){d=n("meta"),j=a(),y=n("p"),I=a(),L(f.$$.fragment),R=a(),m=n("p"),m.innerHTML=Q,k=a(),p=n("p"),p.textContent=K,E=a(),u=n("ul"),u.innerHTML=tt,F=a(),g=n("p"),g.textContent=et,W=a(),h=n("table"),h.innerHTML=lt,X=a(),c=n("p"),c.innerHTML=st,Z=a(),L(b.$$.fragment),z=a(),x=n("p"),x.textContent=at,D=a(),L(_.$$.fragment),S=a(),w=n("p"),w.innerHTML=it,V=a(),L($.$$.fragment),q=a(),v=n("p"),v.textContent=nt,A=a(),C=n("ul"),C.innerHTML=ot,G=a(),L(T.$$.fragment),N=a(),M=n("p"),this.h()},l(t){const e=bt("svelte-u9bgzb",document.head);d=o(e,"META",{name:!0,content:!0}),e.forEach(l),j=i(t),y=o(t,"P",{}),rt(y).forEach(l),I=i(t),J(f.$$.fragment,t),R=i(t),m=o(t,"P",{"data-svelte-h":!0}),r(m)!=="svelte-1neo90y"&&(m.innerHTML=Q),k=i(t),p=o(t,"P",{"data-svelte-h":!0}),r(p)!=="svelte-5pvswp"&&(p.textContent=K),E=i(t),u=o(t,"UL",{"data-svelte-h":!0}),r(u)!=="svelte-xoqjgx"&&(u.innerHTML=tt),F=i(t),g=o(t,"P",{"data-svelte-h":!0}),r(g)!=="svelte-14p5r7u"&&(g.textContent=et),W=i(t),h=o(t,"TABLE",{"data-svelte-h":!0}),r(h)!=="svelte-h8xzd3"&&(h.innerHTML=lt),X=i(t),c=o(t,"P",{"data-svelte-h":!0}),r(c)!=="svelte-rleprd"&&(c.innerHTML=st),Z=i(t),J(b.$$.fragment,t),z=i(t),x=o(t,"P",{"data-svelte-h":!0}),r(x)!=="svelte-tu9bzc"&&(x.textContent=at),D=i(t),J(_.$$.fragment,t),S=i(t),w=o(t,"P",{"data-svelte-h":!0}),r(w)!=="svelte-p14hlq"&&(w.innerHTML=it),V=i(t),J($.$$.fragment,t),q=i(t),v=o(t,"P",{"data-svelte-h":!0}),r(v)!=="svelte-hdwswn"&&(v.textContent=nt),A=i(t),C=o(t,"UL",{"data-svelte-h":!0}),r(C)!=="svelte-18es2ri"&&(C.innerHTML=ot),G=i(t),J(T.$$.fragment,t),N=i(t),M=o(t,"P",{}),rt(M).forEach(l),this.h()},h(){dt(d,"name","hf:doc:metadata"),dt(d,"content",$t)},m(t,e){xt(document.head,d),s(t,j,e),s(t,y,e),s(t,I,e),H(f,t,e),s(t,R,e),s(t,m,e),s(t,k,e),s(t,p,e),s(t,E,e),s(t,u,e),s(t,F,e),s(t,g,e),s(t,W,e),s(t,h,e),s(t,X,e),s(t,c,e),s(t,Z,e),H(b,t,e),s(t,z,e),s(t,x,e),s(t,D,e),H(_,t,e),s(t,S,e),s(t,w,e),s(t,V,e),H($,t,e),s(t,q,e),s(t,v,e),s(t,A,e),s(t,C,e),s(t,G,e),H(T,t,e),s(t,N,e),s(t,M,e),Y=!0},p:ut,i(t){Y||(U(f.$$.fragment,t),U(b.$$.fragment,t),U(_.$$.fragment,t),U($.$$.fragment,t),U(T.$$.fragment,t),Y=!0)},o(t){B(f.$$.fragment,t),B(b.$$.fragment,t),B(_.$$.fragment,t),B($.$$.fragment,t),B(T.$$.fragment,t),Y=!1},d(t){t&&(l(j),l(y),l(I),l(R),l(m),l(k),l(p),l(E),l(u),l(F),l(g),l(W),l(h),l(X),l(c),l(Z),l(z),l(x),l(D),l(S),l(w),l(V),l(q),l(v),l(A),l(C),l(G),l(N),l(M)),l(d),P(f,t),P(b,t),P(_,t),P($,t),P(T,t)}}}const $t='{"title":"概述","local":"概述","sections":[{"title":"安装","local":"安装","sections":[],"depth":2}],"depth":1}';function vt(O){return gt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Lt extends ht{constructor(d){super(),ct(this,d,vt,wt,pt,{})}}export{Lt as component};
