import{s as Je,o as De,n as Ie}from"../chunks/scheduler.182ea377.js";import{S as Pe,i as je,g as o,s as i,r as M,A as Ge,h as p,f as s,c as l,j as R,u as $,x as b,k as A,y as c,a,v as w,d as y,t as v,w as x}from"../chunks/index.abf12888.js";import{T as Ue}from"../chunks/Tip.230e2334.js";import{D as re}from"../chunks/Docstring.93f6f462.js";import{C as Ze}from"../chunks/CodeBlock.57fe6e13.js";import{E as Be}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as he}from"../chunks/Heading.16916d63.js";function Ce(V){let n,_='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){n=o("p"),n.innerHTML=_},l(d){n=p(d,"P",{"data-svelte-h":!0}),b(n)!=="svelte-1wmc0l4"&&(n.innerHTML=_)},m(d,m){a(d,n,m)},p:Ie,d(d){d&&s(n)}}}function ke(V){let n,_="Examples:",d,m,g;return m=new Ze({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpVFBpcGVsaW5lJTJDJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwRGlUUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGRGlULVhMLTItMjU2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMHBpY2slMjB3b3JkcyUyMGZyb20lMjBJbWFnZW5ldCUyMGNsYXNzJTIwbGFiZWxzJTBBcGlwZS5sYWJlbHMlMjAlMjAlMjMlMjB0byUyMHByaW50JTIwYWxsJTIwYXZhaWxhYmxlJTIwd29yZHMlMEElMEElMjMlMjBwaWNrJTIwd29yZHMlMjB0aGF0JTIwZXhpc3QlMjBpbiUyMEltYWdlTmV0JTBBd29yZHMlMjAlM0QlMjAlNUIlMjJ3aGl0ZSUyMHNoYXJrJTIyJTJDJTIwJTIydW1icmVsbGElMjIlNUQlMEElMEFjbGFzc19pZHMlMjAlM0QlMjBwaXBlLmdldF9sYWJlbF9pZHMod29yZHMpJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2gubWFudWFsX3NlZWQoMzMpJTBBb3V0cHV0JTIwJTNEJTIwcGlwZShjbGFzc19sYWJlbHMlM0RjbGFzc19pZHMlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpJTBBJTBBaW1hZ2UlMjAlM0QlMjBvdXRwdXQuaW1hZ2VzJTVCMCU1RCUyMCUyMCUyMyUyMGxhYmVsJTIwJ3doaXRlJTIwc2hhcmsn",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiTPipeline, DPMSolverMultistepScheduler
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DiTPipeline.from_pretrained(<span class="hljs-string">&quot;facebook/DiT-XL-2-256&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># pick words from Imagenet class labels</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.labels  <span class="hljs-comment"># to print all available words</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># pick words that exist in ImageNet</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>words = [<span class="hljs-string">&quot;white shark&quot;</span>, <span class="hljs-string">&quot;umbrella&quot;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>class_ids = pipe.get_label_ids(words)

<span class="hljs-meta">&gt;&gt;&gt; </span>generator = torch.manual_seed(<span class="hljs-number">33</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>output = pipe(class_labels=class_ids, num_inference_steps=<span class="hljs-number">25</span>, generator=generator)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = output.images[<span class="hljs-number">0</span>]  <span class="hljs-comment"># label &#x27;white shark&#x27;</span>`,wrap:!1}}),{c(){n=o("p"),n.textContent=_,d=i(),M(m.$$.fragment)},l(r){n=p(r,"P",{"data-svelte-h":!0}),b(n)!=="svelte-kvfsh7"&&(n.textContent=_),d=l(r),$(m.$$.fragment,r)},m(r,h){a(r,n,h),a(r,d,h),w(m,r,h),g=!0},p:Ie,i(r){g||(y(m.$$.fragment,r),g=!0)},o(r){v(m.$$.fragment,r),g=!1},d(r){r&&(s(n),s(d)),x(m,r)}}}function We(V){let n,_,d,m,g,r,h,be='<a href="https://huggingface.co/papers/2212.09748" rel="nofollow">Scalable Diffusion Models with Transformers</a> (DiT) is by William Peebles and Saining Xie.',Y,G,_e="The abstract from the paper is:",q,U,Te="<em>We explore a new class of diffusion models based on the transformer architecture. We train latent diffusion models of images, replacing the commonly-used U-Net backbone with a transformer that operates on latent patches. We analyze the scalability of our Diffusion Transformers (DiTs) through the lens of forward pass complexity as measured by Gflops. We find that DiTs with higher Gflops — through increased transformer depth/width or increased number of input tokens — consistently have lower FID. In addition to possessing good scalability properties, our largest DiT-XL/2 models outperform all prior diffusion models on the class-conditional ImageNet 512x512 and 256x256 benchmarks, achieving a state-of-the-art FID of 2.27 on the latter.</em>",z,Z,Me='The original codebase can be found at <a href="https://github.com/facebookresearch/dit" rel="nofollow">facebookresearch/dit</a>.',Q,D,K,B,ee,f,C,oe,N,$e="Pipeline for image generation based on a Transformer backbone instead of a UNet.",pe,H,we=`This model inherits from <a href="/docs/diffusers/v0.26.1/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,de,T,k,ce,S,ye="The call function to the pipeline for generation.",fe,P,me,j,W,ue,F,ve="Map label strings from ImageNet to corresponding class ids.",te,E,se,I,L,ge,X,xe="Output class for image pipelines.",ne,O,ae;return g=new he({props:{title:"DiT",local:"dit",headingTag:"h1"}}),D=new Ue({props:{$$slots:{default:[Ce]},$$scope:{ctx:V}}}),B=new he({props:{title:"DiTPipeline",local:"diffusers.DiTPipeline",headingTag:"h2"}}),C=new re({props:{name:"class diffusers.DiTPipeline",anchor:"diffusers.DiTPipeline",parameters:[{name:"transformer",val:": Transformer2DModel"},{name:"vae",val:": AutoencoderKL"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"id2label",val:": Optional = None"}],parametersDescription:[{anchor:"diffusers.DiTPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/v0.26.1/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>) &#x2014;
A class conditioned <code>Transformer2DModel</code> to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.DiTPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.26.1/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.DiTPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.26.1/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.26.1/src/diffusers/pipelines/dit/pipeline_dit.py#L31"}}),k=new re({props:{name:"__call__",anchor:"diffusers.DiTPipeline.__call__",parameters:[{name:"class_labels",val:": List"},{name:"guidance_scale",val:": float = 4.0"},{name:"generator",val:": Union = None"},{name:"num_inference_steps",val:": int = 50"},{name:"output_type",val:": Optional = 'pil'"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DiTPipeline.__call__.class_labels",description:`<strong>class_labels</strong> (List[int]) &#x2014;
List of ImageNet class labels for the images to be generated.`,name:"class_labels"},{anchor:"diffusers.DiTPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.DiTPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.DiTPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 250) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.DiTPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.DiTPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.26.1/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.26.1/src/diffusers/pipelines/dit/pipeline_dit.py#L92",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.26.1/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/v0.26.1/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),P=new Be({props:{anchor:"diffusers.DiTPipeline.__call__.example",$$slots:{default:[ke]},$$scope:{ctx:V}}}),W=new re({props:{name:"get_label_ids",anchor:"diffusers.DiTPipeline.get_label_ids",parameters:[{name:"label",val:": Union"}],parametersDescription:[{anchor:"diffusers.DiTPipeline.get_label_ids.label",description:`<strong>label</strong> (<code>str</code> or <code>dict</code> of <code>str</code>) &#x2014;
Label strings to be mapped to class ids.`,name:"label"}],source:"https://github.com/huggingface/diffusers/blob/v0.26.1/src/diffusers/pipelines/dit/pipeline_dit.py#L67",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Class ids to be processed by pipeline.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>list</code> of <code>int</code></p>
`}}),E=new he({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),L=new re({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": Union"}],parametersDescription:[{anchor:"diffusers.ImagePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}],source:"https://github.com/huggingface/diffusers/blob/v0.26.1/src/diffusers/pipelines/pipeline_utils.py#L116"}}),{c(){n=o("meta"),_=i(),d=o("p"),m=i(),M(g.$$.fragment),r=i(),h=o("p"),h.innerHTML=be,Y=i(),G=o("p"),G.textContent=_e,q=i(),U=o("p"),U.innerHTML=Te,z=i(),Z=o("p"),Z.innerHTML=Me,Q=i(),M(D.$$.fragment),K=i(),M(B.$$.fragment),ee=i(),f=o("div"),M(C.$$.fragment),oe=i(),N=o("p"),N.textContent=$e,pe=i(),H=o("p"),H.innerHTML=we,de=i(),T=o("div"),M(k.$$.fragment),ce=i(),S=o("p"),S.textContent=ye,fe=i(),M(P.$$.fragment),me=i(),j=o("div"),M(W.$$.fragment),ue=i(),F=o("p"),F.textContent=ve,te=i(),M(E.$$.fragment),se=i(),I=o("div"),M(L.$$.fragment),ge=i(),X=o("p"),X.textContent=xe,ne=i(),O=o("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);n=p(t,"META",{name:!0,content:!0}),t.forEach(s),_=l(e),d=p(e,"P",{}),R(d).forEach(s),m=l(e),$(g.$$.fragment,e),r=l(e),h=p(e,"P",{"data-svelte-h":!0}),b(h)!=="svelte-utwfha"&&(h.innerHTML=be),Y=l(e),G=p(e,"P",{"data-svelte-h":!0}),b(G)!=="svelte-1cwsb16"&&(G.textContent=_e),q=l(e),U=p(e,"P",{"data-svelte-h":!0}),b(U)!=="svelte-9gxrul"&&(U.innerHTML=Te),z=l(e),Z=p(e,"P",{"data-svelte-h":!0}),b(Z)!=="svelte-34bc3b"&&(Z.innerHTML=Me),Q=l(e),$(D.$$.fragment,e),K=l(e),$(B.$$.fragment,e),ee=l(e),f=p(e,"DIV",{class:!0});var u=R(f);$(C.$$.fragment,u),oe=l(u),N=p(u,"P",{"data-svelte-h":!0}),b(N)!=="svelte-1us2ddn"&&(N.textContent=$e),pe=l(u),H=p(u,"P",{"data-svelte-h":!0}),b(H)!=="svelte-1wq4yle"&&(H.innerHTML=we),de=l(u),T=p(u,"DIV",{class:!0});var J=R(T);$(k.$$.fragment,J),ce=l(J),S=p(J,"P",{"data-svelte-h":!0}),b(S)!=="svelte-50j04k"&&(S.textContent=ye),fe=l(J),$(P.$$.fragment,J),J.forEach(s),me=l(u),j=p(u,"DIV",{class:!0});var ie=R(j);$(W.$$.fragment,ie),ue=l(ie),F=p(ie,"P",{"data-svelte-h":!0}),b(F)!=="svelte-wsbjkk"&&(F.textContent=ve),ie.forEach(s),u.forEach(s),te=l(e),$(E.$$.fragment,e),se=l(e),I=p(e,"DIV",{class:!0});var le=R(I);$(L.$$.fragment,le),ge=l(le),X=p(le,"P",{"data-svelte-h":!0}),b(X)!=="svelte-19wetgi"&&(X.textContent=xe),le.forEach(s),ne=l(e),O=p(e,"P",{}),R(O).forEach(s),this.h()},h(){A(n,"name","hf:doc:metadata"),A(n,"content",Ee),A(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){c(document.head,n),a(e,_,t),a(e,d,t),a(e,m,t),w(g,e,t),a(e,r,t),a(e,h,t),a(e,Y,t),a(e,G,t),a(e,q,t),a(e,U,t),a(e,z,t),a(e,Z,t),a(e,Q,t),w(D,e,t),a(e,K,t),w(B,e,t),a(e,ee,t),a(e,f,t),w(C,f,null),c(f,oe),c(f,N),c(f,pe),c(f,H),c(f,de),c(f,T),w(k,T,null),c(T,ce),c(T,S),c(T,fe),w(P,T,null),c(f,me),c(f,j),w(W,j,null),c(j,ue),c(j,F),a(e,te,t),w(E,e,t),a(e,se,t),a(e,I,t),w(L,I,null),c(I,ge),c(I,X),a(e,ne,t),a(e,O,t),ae=!0},p(e,[t]){const u={};t&2&&(u.$$scope={dirty:t,ctx:e}),D.$set(u);const J={};t&2&&(J.$$scope={dirty:t,ctx:e}),P.$set(J)},i(e){ae||(y(g.$$.fragment,e),y(D.$$.fragment,e),y(B.$$.fragment,e),y(C.$$.fragment,e),y(k.$$.fragment,e),y(P.$$.fragment,e),y(W.$$.fragment,e),y(E.$$.fragment,e),y(L.$$.fragment,e),ae=!0)},o(e){v(g.$$.fragment,e),v(D.$$.fragment,e),v(B.$$.fragment,e),v(C.$$.fragment,e),v(k.$$.fragment,e),v(P.$$.fragment,e),v(W.$$.fragment,e),v(E.$$.fragment,e),v(L.$$.fragment,e),ae=!1},d(e){e&&(s(_),s(d),s(m),s(r),s(h),s(Y),s(G),s(q),s(U),s(z),s(Z),s(Q),s(K),s(ee),s(f),s(te),s(se),s(I),s(ne),s(O)),s(n),x(g,e),x(D,e),x(B,e),x(C),x(k),x(P),x(W),x(E,e),x(L)}}}const Ee='{"title":"DiT","local":"dit","sections":[{"title":"DiTPipeline","local":"diffusers.DiTPipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function Le(V){return De(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ae extends Pe{constructor(n){super(),je(this,n,Le,We,Je,{})}}export{Ae as component};
