import{s as Pe,o as je,n as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as Ge,i as Ue,g as o,s as i,r as b,A as Ze,h as p,f as s,c as r,j as A,u as _,x as y,k as O,y as c,a,v as T,d as $,t as w,w as M}from"../chunks/index.da70eac4.js";import{T as Be}from"../chunks/Tip.1d9b8c37.js";import{D as pe}from"../chunks/Docstring.ee4b6913.js";import{C as Ce}from"../chunks/CodeBlock.00a903b3.js";import{E as ke}from"../chunks/ExampleCodeBlock.f7bd2c1f.js";import{H as _e,E as Ee}from"../chunks/EditOnGithub.1e64e623.js";function We(N){let n,v='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=v},l(d){n=p(d,"P",{"data-svelte-h":!0}),y(n)!=="svelte-1wmc0l4"&&(n.innerHTML=v)},m(d,f){a(d,n,f)},p:Je,d(d){d&&s(n)}}}function Le(N){let n,v="Examples:",d,f,g;return f=new Ce({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=v,d=i(),b(f.$$.fragment)},l(l){n=p(l,"P",{"data-svelte-h":!0}),y(n)!=="svelte-kvfsh7"&&(n.textContent=v),d=r(l),_(f.$$.fragment,l)},m(l,h){a(l,n,h),a(l,d,h),T(f,l,h),g=!0},p:Je,i(l){g||($(f.$$.fragment,l),g=!0)},o(l){w(f.$$.fragment,l),g=!1},d(l){l&&(s(n),s(d)),M(f,l)}}}function Ve(N){let n,v,d,f,g,l,h,Te='<a href="https://huggingface.co/papers/2212.09748" rel="nofollow">Scalable Diffusion Models with Transformers</a> (DiT) is by William Peebles and Saining Xie.',q,G,$e="The abstract from the paper is:",z,U,we="<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>",Q,Z,Me='The original codebase can be found at <a href="https://github.com/facebookresearch/dit" rel="nofollow">facebookresearch/dit</a>.',K,J,ee,B,te,m,C,de,H,ye="Pipeline for image generation based on a Transformer backbone instead of a UNet.",ce,S,ve=`This model inherits from <a href="/docs/diffusers/pr_7873/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.).`,me,x,k,fe,F,xe="The call function to the pipeline for generation.",ue,P,ge,j,E,he,X,De="Map label strings from ImageNet to corresponding class ids.",se,W,ne,D,L,be,R,Ie="Output class for image pipelines.",ae,V,ie,Y,re;return g=new _e({props:{title:"DiT",local:"dit",headingTag:"h1"}}),J=new Be({props:{$$slots:{default:[We]},$$scope:{ctx:N}}}),B=new _e({props:{title:"DiTPipeline",local:"diffusers.DiTPipeline",headingTag:"h2"}}),C=new pe({props:{name:"class diffusers.DiTPipeline",anchor:"diffusers.DiTPipeline",parameters:[{name:"transformer",val:": DiTTransformer2DModel"},{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/pr_7873/en/api/models/dit_transformer2d#diffusers.DiTTransformer2DModel">DiTTransformer2DModel</a>) &#x2014;
A class conditioned <code>DiTTransformer2DModel</code> to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.DiTPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_7873/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/pr_7873/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/vr_7873/src/diffusers/pipelines/dit/pipeline_dit.py#L31"}}),k=new pe({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/pr_7873/en/api/pipelines/unclip#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_7873/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/pr_7873/en/api/pipelines/unclip#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/pr_7873/en/api/pipelines/unclip#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),P=new ke({props:{anchor:"diffusers.DiTPipeline.__call__.example",$$slots:{default:[Le]},$$scope:{ctx:N}}}),E=new pe({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/vr_7873/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>
`}}),W=new _e({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),L=new pe({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/vr_7873/src/diffusers/pipelines/pipeline_utils.py#L100"}}),V=new Ee({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/dit.md"}}),{c(){n=o("meta"),v=i(),d=o("p"),f=i(),b(g.$$.fragment),l=i(),h=o("p"),h.innerHTML=Te,q=i(),G=o("p"),G.textContent=$e,z=i(),U=o("p"),U.innerHTML=we,Q=i(),Z=o("p"),Z.innerHTML=Me,K=i(),b(J.$$.fragment),ee=i(),b(B.$$.fragment),te=i(),m=o("div"),b(C.$$.fragment),de=i(),H=o("p"),H.textContent=ye,ce=i(),S=o("p"),S.innerHTML=ve,me=i(),x=o("div"),b(k.$$.fragment),fe=i(),F=o("p"),F.textContent=xe,ue=i(),b(P.$$.fragment),ge=i(),j=o("div"),b(E.$$.fragment),he=i(),X=o("p"),X.textContent=De,se=i(),b(W.$$.fragment),ne=i(),D=o("div"),b(L.$$.fragment),be=i(),R=o("p"),R.textContent=Ie,ae=i(),b(V.$$.fragment),ie=i(),Y=o("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);n=p(t,"META",{name:!0,content:!0}),t.forEach(s),v=r(e),d=p(e,"P",{}),A(d).forEach(s),f=r(e),_(g.$$.fragment,e),l=r(e),h=p(e,"P",{"data-svelte-h":!0}),y(h)!=="svelte-utwfha"&&(h.innerHTML=Te),q=r(e),G=p(e,"P",{"data-svelte-h":!0}),y(G)!=="svelte-1cwsb16"&&(G.textContent=$e),z=r(e),U=p(e,"P",{"data-svelte-h":!0}),y(U)!=="svelte-9gxrul"&&(U.innerHTML=we),Q=r(e),Z=p(e,"P",{"data-svelte-h":!0}),y(Z)!=="svelte-34bc3b"&&(Z.innerHTML=Me),K=r(e),_(J.$$.fragment,e),ee=r(e),_(B.$$.fragment,e),te=r(e),m=p(e,"DIV",{class:!0});var u=A(m);_(C.$$.fragment,u),de=r(u),H=p(u,"P",{"data-svelte-h":!0}),y(H)!=="svelte-1us2ddn"&&(H.textContent=ye),ce=r(u),S=p(u,"P",{"data-svelte-h":!0}),y(S)!=="svelte-9wwklh"&&(S.innerHTML=ve),me=r(u),x=p(u,"DIV",{class:!0});var I=A(x);_(k.$$.fragment,I),fe=r(I),F=p(I,"P",{"data-svelte-h":!0}),y(F)!=="svelte-50j04k"&&(F.textContent=xe),ue=r(I),_(P.$$.fragment,I),I.forEach(s),ge=r(u),j=p(u,"DIV",{class:!0});var le=A(j);_(E.$$.fragment,le),he=r(le),X=p(le,"P",{"data-svelte-h":!0}),y(X)!=="svelte-wsbjkk"&&(X.textContent=De),le.forEach(s),u.forEach(s),se=r(e),_(W.$$.fragment,e),ne=r(e),D=p(e,"DIV",{class:!0});var oe=A(D);_(L.$$.fragment,oe),be=r(oe),R=p(oe,"P",{"data-svelte-h":!0}),y(R)!=="svelte-19wetgi"&&(R.textContent=Ie),oe.forEach(s),ae=r(e),_(V.$$.fragment,e),ie=r(e),Y=p(e,"P",{}),A(Y).forEach(s),this.h()},h(){O(n,"name","hf:doc:metadata"),O(n,"content",Ne),O(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),O(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),O(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),O(D,"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,v,t),a(e,d,t),a(e,f,t),T(g,e,t),a(e,l,t),a(e,h,t),a(e,q,t),a(e,G,t),a(e,z,t),a(e,U,t),a(e,Q,t),a(e,Z,t),a(e,K,t),T(J,e,t),a(e,ee,t),T(B,e,t),a(e,te,t),a(e,m,t),T(C,m,null),c(m,de),c(m,H),c(m,ce),c(m,S),c(m,me),c(m,x),T(k,x,null),c(x,fe),c(x,F),c(x,ue),T(P,x,null),c(m,ge),c(m,j),T(E,j,null),c(j,he),c(j,X),a(e,se,t),T(W,e,t),a(e,ne,t),a(e,D,t),T(L,D,null),c(D,be),c(D,R),a(e,ae,t),T(V,e,t),a(e,ie,t),a(e,Y,t),re=!0},p(e,[t]){const u={};t&2&&(u.$$scope={dirty:t,ctx:e}),J.$set(u);const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),P.$set(I)},i(e){re||($(g.$$.fragment,e),$(J.$$.fragment,e),$(B.$$.fragment,e),$(C.$$.fragment,e),$(k.$$.fragment,e),$(P.$$.fragment,e),$(E.$$.fragment,e),$(W.$$.fragment,e),$(L.$$.fragment,e),$(V.$$.fragment,e),re=!0)},o(e){w(g.$$.fragment,e),w(J.$$.fragment,e),w(B.$$.fragment,e),w(C.$$.fragment,e),w(k.$$.fragment,e),w(P.$$.fragment,e),w(E.$$.fragment,e),w(W.$$.fragment,e),w(L.$$.fragment,e),w(V.$$.fragment,e),re=!1},d(e){e&&(s(v),s(d),s(f),s(l),s(h),s(q),s(G),s(z),s(U),s(Q),s(Z),s(K),s(ee),s(te),s(m),s(se),s(ne),s(D),s(ae),s(ie),s(Y)),s(n),M(g,e),M(J,e),M(B,e),M(C),M(k),M(P),M(E),M(W,e),M(L),M(V,e)}}}const Ne='{"title":"DiT","local":"dit","sections":[{"title":"DiTPipeline","local":"diffusers.DiTPipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function He(N){return je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends Ge{constructor(n){super(),Ue(this,n,He,Ve,Pe,{})}}export{qe as component};
