import{s as ve,n as _e,o as Te}from"../chunks/scheduler.182ea377.js";import{S as $e,i as Ce,g as s,s as a,r as H,m as Le,A as ke,h as l,f as n,c as o,j as be,u as P,x as r,n as Me,k as ye,y as Ie,a as i,v as q,d as U,t as A,w as E}from"../chunks/index.abf12888.js";import{C as we}from"../chunks/CodeBlock.57fe6e13.js";import{H as ie}from"../chunks/Heading.16916d63.js";function He(ae){let f,R,M,S,d,z,p,oe=`Diffusers training examples are a collection of scripts to demonstrate how to effectively use the <code>diffusers</code> library
for a variety of use cases.`,W,m,se=`<strong>Note</strong>: If you are looking for <strong>official</strong> examples on how to use <code>diffusers</code> for inference,
please have a look at <a href="https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines" rel="nofollow">src/diffusers/pipelines</a>`,D,u,le=`Our examples aspire to be <strong>self-contained</strong>, <strong>easy-to-tweak</strong>, <strong>beginner-friendly</strong> and for <strong>one-purpose-only</strong>.
More specifically, this means:`,Z,g,re=`<li><strong>Self-contained</strong>: An example script shall only depend on “pip-install-able” Python packages that can be found in a <code>requirements.txt</code> file. Example scripts shall <strong>not</strong> depend on any local files. This means that one can simply download an example script, <em>e.g.</em> <a href="https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/train_unconditional.py" rel="nofollow">train_unconditional.py</a>, install the required dependencies, <em>e.g.</em> <a href="https://github.com/huggingface/diffusers/blob/main/examples/unconditional_image_generation/requirements.txt" rel="nofollow">requirements.txt</a> and execute the example script.</li> <li><strong>Easy-to-tweak</strong>: While we strive to present as many use cases as possible, the example scripts are just that - examples. It is expected that they won’t work out-of-the box on your specific problem and that you will be required to change a few lines of code to adapt them to your needs. To help you with that, most of the examples fully expose the preprocessing of the data and the training loop to allow you to tweak and edit them as required.</li> <li><strong>Beginner-friendly</strong>: We do not aim for providing state-of-the-art training scripts for the newest models, but rather examples that can be used as a way to better understand diffusion models and how to use them with the <code>diffusers</code> library. We often purposefully leave out certain state-of-the-art methods if we consider them too complex for beginners.</li> <li><strong>One-purpose-only</strong>: Examples should show one task and one task only. Even if a task is from a modeling
point of view very similar, <em>e.g.</em> image super-resolution and image modification tend to use the same model and training method, we want examples to showcase only one task to keep them as readable and easy-to-understand as possible.</li>`,j,h,fe=`We provide <strong>official</strong> examples that cover the most popular tasks of diffusion models.
<em>Official</em> examples are <strong>actively</strong> maintained by the <code>diffusers</code> maintainers and we try to rigorously follow our example philosophy as defined above.
If you feel like another important example should exist, we are more than happy to welcome a <a href="https://github.com/huggingface/diffusers/issues/new?assignees=&amp;labels=&amp;template=feature_request.md&amp;title=" rel="nofollow">Feature Request</a> or directly a <a href="https://github.com/huggingface/diffusers/compare" rel="nofollow">Pull Request</a> from you!`,G,c,de="Training examples show how to pretrain or fine-tune diffusion models for a variety of tasks. Currently we support:",J,x,pe='<li><a href="./unconditional_training">Unconditional Training</a></li> <li><a href="./text2image">Text-to-Image Training</a><sup>*</sup></li> <li><a href="./text_inversion">Text Inversion</a></li> <li><a href="./dreambooth">Dreambooth</a><sup>*</sup></li> <li><a href="./lora">LoRA Support</a><sup>*</sup></li> <li><a href="./controlnet">ControlNet</a><sup>*</sup></li> <li><a href="./instructpix2pix">InstructPix2Pix</a><sup>*</sup></li> <li><a href="./custom_diffusion">Custom Diffusion</a></li> <li><a href="./t2i_adapters">T2I-Adapters</a><sup>*</sup></li>',B,b,me="*",F,y,ue='If possible, please <a href="../optimization/xformers">install xFormers</a> for memory efficient attention. This could help make your training faster and less memory intensive.',O,w,ge='<thead><tr><th>Task</th> <th>🤗 Accelerate</th> <th align="center">🤗 Datasets</th> <th align="center">Colab</th></tr></thead> <tbody><tr><td><a href="./unconditional_training"><strong>Unconditional Image Generation</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center"><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></tr> <tr><td><a href="./text2image"><strong>Text-to-Image fine-tuning</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center"></td></tr> <tr><td><a href="./text_inversion"><strong>Textual Inversion</strong></a></td> <td>✅</td> <td align="center">-</td> <td align="center"><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></tr> <tr><td><a href="./dreambooth"><strong>Dreambooth</strong></a></td> <td>✅</td> <td align="center">-</td> <td align="center"><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></tr> <tr><td><a href="./lora"><strong>Training with LoRA</strong></a></td> <td>✅</td> <td align="center">-</td> <td align="center">-</td></tr> <tr><td><a href="./controlnet"><strong>ControlNet</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center">-</td></tr> <tr><td><a href="./instructpix2pix"><strong>InstructPix2Pix</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center">-</td></tr> <tr><td><a href="./custom_diffusion"><strong>Custom Diffusion</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center">-</td></tr> <tr><td><a href="./t2i_adapters"><strong>T2I Adapters</strong></a></td> <td>✅</td> <td align="center">✅</td> <td align="center">-</td></tr></tbody>',N,v,V,_,he=`In addition, we provide <strong>community</strong> examples, which are examples added and maintained by our community.
Community examples can consist of both <em>training</em> examples or <em>inference</em> pipelines.
For such examples, we are more lenient regarding the philosophy defined above and also cannot guarantee to provide maintenance for every issue.
Examples that are useful for the community, but are either not yet deemed popular or not yet following our above philosophy should go into the <a href="https://github.com/huggingface/diffusers/tree/main/examples/community" rel="nofollow">community examples</a> folder. The community folder therefore includes training examples and inference pipelines.
<strong>Note</strong>: Community examples can be a <a href="https://github.com/huggingface/diffusers/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22" rel="nofollow">great first contribution</a> to show to the community how you like to use <code>diffusers</code> 🪄.`,X,T,Q,$,ce="To make sure you can successfully run the latest versions of the example scripts, you have to <strong>install the library from source</strong> and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:",Y,C,K,L,xe="Then cd in the example folder of your choice and run",ee,k,te,I,ne;return d=new ie({props:{title:"🧨 Diffusers Training Examples",local:"-diffusers-training-examples",headingTag:"h1"}}),v=new ie({props:{title:"Community",local:"community",headingTag:"h2"}}),T=new ie({props:{title:"Important note",local:"important-note",headingTag:"h2"}}),C=new we({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}}),k=new we({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dA==",highlighted:"pip install -r requirements.txt",wrap:!1}}),{c(){f=s("meta"),R=a(),M=s("p"),S=a(),H(d.$$.fragment),z=a(),p=s("p"),p.innerHTML=oe,W=a(),m=s("p"),m.innerHTML=se,D=a(),u=s("p"),u.innerHTML=le,Z=a(),g=s("ul"),g.innerHTML=re,j=a(),h=s("p"),h.innerHTML=fe,G=a(),c=s("p"),c.textContent=de,J=a(),x=s("ul"),x.innerHTML=pe,B=a(),b=s("sup"),b.textContent=me,F=Le(`: Supports [Stable Diffusion XL](../api/pipelines/stable_diffusion/stable_diffusion_xl).
`),y=s("p"),y.innerHTML=ue,O=a(),w=s("table"),w.innerHTML=ge,N=a(),H(v.$$.fragment),V=a(),_=s("p"),_.innerHTML=he,X=a(),H(T.$$.fragment),Q=a(),$=s("p"),$.innerHTML=ce,Y=a(),H(C.$$.fragment),K=a(),L=s("p"),L.textContent=xe,ee=a(),H(k.$$.fragment),te=a(),I=s("p"),this.h()},l(e){const t=ke("svelte-u9bgzb",document.head);f=l(t,"META",{name:!0,content:!0}),t.forEach(n),R=o(e),M=l(e,"P",{}),be(M).forEach(n),S=o(e),P(d.$$.fragment,e),z=o(e),p=l(e,"P",{"data-svelte-h":!0}),r(p)!=="svelte-1082zqa"&&(p.innerHTML=oe),W=o(e),m=l(e,"P",{"data-svelte-h":!0}),r(m)!=="svelte-1wlaraf"&&(m.innerHTML=se),D=o(e),u=l(e,"P",{"data-svelte-h":!0}),r(u)!=="svelte-1x8dds5"&&(u.innerHTML=le),Z=o(e),g=l(e,"UL",{"data-svelte-h":!0}),r(g)!=="svelte-xrfy8r"&&(g.innerHTML=re),j=o(e),h=l(e,"P",{"data-svelte-h":!0}),r(h)!=="svelte-10ihwxn"&&(h.innerHTML=fe),G=o(e),c=l(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-11lmcpx"&&(c.textContent=de),J=o(e),x=l(e,"UL",{"data-svelte-h":!0}),r(x)!=="svelte-5zq2nq"&&(x.innerHTML=pe),B=o(e),b=l(e,"SUP",{"data-svelte-h":!0}),r(b)!=="svelte-1ruaeze"&&(b.textContent=me),F=Me(e,`: Supports [Stable Diffusion XL](../api/pipelines/stable_diffusion/stable_diffusion_xl).
`),y=l(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-1ujwbe8"&&(y.innerHTML=ue),O=o(e),w=l(e,"TABLE",{"data-svelte-h":!0}),r(w)!=="svelte-roqoa9"&&(w.innerHTML=ge),N=o(e),P(v.$$.fragment,e),V=o(e),_=l(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1n45xd3"&&(_.innerHTML=he),X=o(e),P(T.$$.fragment,e),Q=o(e),$=l(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1p4ghgy"&&($.innerHTML=ce),Y=o(e),P(C.$$.fragment,e),K=o(e),L=l(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-1y5cojp"&&(L.textContent=xe),ee=o(e),P(k.$$.fragment,e),te=o(e),I=l(e,"P",{}),be(I).forEach(n),this.h()},h(){ye(f,"name","hf:doc:metadata"),ye(f,"content",Pe)},m(e,t){Ie(document.head,f),i(e,R,t),i(e,M,t),i(e,S,t),q(d,e,t),i(e,z,t),i(e,p,t),i(e,W,t),i(e,m,t),i(e,D,t),i(e,u,t),i(e,Z,t),i(e,g,t),i(e,j,t),i(e,h,t),i(e,G,t),i(e,c,t),i(e,J,t),i(e,x,t),i(e,B,t),i(e,b,t),i(e,F,t),i(e,y,t),i(e,O,t),i(e,w,t),i(e,N,t),q(v,e,t),i(e,V,t),i(e,_,t),i(e,X,t),q(T,e,t),i(e,Q,t),i(e,$,t),i(e,Y,t),q(C,e,t),i(e,K,t),i(e,L,t),i(e,ee,t),q(k,e,t),i(e,te,t),i(e,I,t),ne=!0},p:_e,i(e){ne||(U(d.$$.fragment,e),U(v.$$.fragment,e),U(T.$$.fragment,e),U(C.$$.fragment,e),U(k.$$.fragment,e),ne=!0)},o(e){A(d.$$.fragment,e),A(v.$$.fragment,e),A(T.$$.fragment,e),A(C.$$.fragment,e),A(k.$$.fragment,e),ne=!1},d(e){e&&(n(R),n(M),n(S),n(z),n(p),n(W),n(m),n(D),n(u),n(Z),n(g),n(j),n(h),n(G),n(c),n(J),n(x),n(B),n(b),n(F),n(y),n(O),n(w),n(N),n(V),n(_),n(X),n(Q),n($),n(Y),n(K),n(L),n(ee),n(te),n(I)),n(f),E(d,e),E(v,e),E(T,e),E(C,e),E(k,e)}}}const Pe='{"title":"🧨 Diffusers Training Examples","local":"-diffusers-training-examples","sections":[{"title":"Community","local":"community","sections":[],"depth":2},{"title":"Important note","local":"important-note","sections":[],"depth":2}],"depth":1}';function qe(ae){return Te(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Se extends $e{constructor(f){super(),Ce(this,f,qe,He,ve,{})}}export{Se as component};
