import{s as Pe,o as je,n as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as Ge,i as Ce,g as o,s as i,r as _,A as Ue,h as p,f as s,c as r,j as A,u as b,x as w,k as O,y as c,a,v as T,d as $,t as y,w as M}from"../chunks/index.da70eac4.js";import{T as Ze}from"../chunks/Tip.1d9b8c37.js";import{D as pe}from"../chunks/Docstring.6b390b9a.js";import{C as Be}from"../chunks/CodeBlock.00a903b3.js";import{E as Le}from"../chunks/ExampleCodeBlock.db12be95.js";import{H as be,E as Ee}from"../chunks/EditOnGithub.1e64e623.js";function ke(V){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}),w(n)!=="svelte-1wmc0l4"&&(n.innerHTML=v)},m(d,f){a(d,n,f)},p:Je,d(d){d&&s(n)}}}function We(V){let n,v="Examples:",d,f,g;return f=new Be({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(),_(f.$$.fragment)},l(l){n=p(l,"P",{"data-svelte-h":!0}),w(n)!=="svelte-kvfsh7"&&(n.textContent=v),d=r(l),b(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){y(f.$$.fragment,l),g=!1},d(l){l&&(s(n),s(d)),M(f,l)}}}function Ne(V){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,C,ye="<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,U,Me='The original codebase can be found at <a href="https://github.com/facebookresearch/dit" rel="nofollow">facebookresearch/dit</a>.',K,J,ee,Z,te,m,B,de,H,we="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_10012/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,L,fe,F,xe="The call function to the pipeline for generation.",ue,P,ge,j,E,he,X,Ie="Map label strings from ImageNet to corresponding class ids.",se,k,ne,I,W,_e,R,De="Output class for image pipelines.",ae,N,ie,Y,re;return g=new be({props:{title:"DiT",local:"dit",headingTag:"h1"}}),J=new Ze({props:{$$slots:{default:[ke]},$$scope:{ctx:V}}}),Z=new be({props:{title:"DiTPipeline",local:"diffusers.DiTPipeline",headingTag:"h2"}}),B=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:": typing.Optional[typing.Dict[int, str]] = None"}],parametersDescription:[{anchor:"diffusers.DiTPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_10012/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_10012/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_10012/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_10012/src/diffusers/pipelines/dit/pipeline_dit.py#L31"}}),L=new pe({props:{name:"__call__",anchor:"diffusers.DiTPipeline.__call__",parameters:[{name:"class_labels",val:": typing.List[int]"},{name:"guidance_scale",val:": float = 4.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"output_type",val:": typing.Optional[str] = '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_10012/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_10012/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_10012/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/pr_10012/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),P=new Le({props:{anchor:"diffusers.DiTPipeline.__call__.example",$$slots:{default:[We]},$$scope:{ctx:V}}}),E=new pe({props:{name:"get_label_ids",anchor:"diffusers.DiTPipeline.get_label_ids",parameters:[{name:"label",val:": typing.Union[str, typing.List[str]]"}],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_10012/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>
`}}),k=new be({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),W=new pe({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"}],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_10012/src/diffusers/pipelines/pipeline_utils.py#L106"}}),N=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(),_(g.$$.fragment),l=i(),h=o("p"),h.innerHTML=Te,q=i(),G=o("p"),G.textContent=$e,z=i(),C=o("p"),C.innerHTML=ye,Q=i(),U=o("p"),U.innerHTML=Me,K=i(),_(J.$$.fragment),ee=i(),_(Z.$$.fragment),te=i(),m=o("div"),_(B.$$.fragment),de=i(),H=o("p"),H.textContent=we,ce=i(),S=o("p"),S.innerHTML=ve,me=i(),x=o("div"),_(L.$$.fragment),fe=i(),F=o("p"),F.textContent=xe,ue=i(),_(P.$$.fragment),ge=i(),j=o("div"),_(E.$$.fragment),he=i(),X=o("p"),X.textContent=Ie,se=i(),_(k.$$.fragment),ne=i(),I=o("div"),_(W.$$.fragment),_e=i(),R=o("p"),R.textContent=De,ae=i(),_(N.$$.fragment),ie=i(),Y=o("p"),this.h()},l(e){const t=Ue("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),b(g.$$.fragment,e),l=r(e),h=p(e,"P",{"data-svelte-h":!0}),w(h)!=="svelte-utwfha"&&(h.innerHTML=Te),q=r(e),G=p(e,"P",{"data-svelte-h":!0}),w(G)!=="svelte-1cwsb16"&&(G.textContent=$e),z=r(e),C=p(e,"P",{"data-svelte-h":!0}),w(C)!=="svelte-9gxrul"&&(C.innerHTML=ye),Q=r(e),U=p(e,"P",{"data-svelte-h":!0}),w(U)!=="svelte-34bc3b"&&(U.innerHTML=Me),K=r(e),b(J.$$.fragment,e),ee=r(e),b(Z.$$.fragment,e),te=r(e),m=p(e,"DIV",{class:!0});var u=A(m);b(B.$$.fragment,u),de=r(u),H=p(u,"P",{"data-svelte-h":!0}),w(H)!=="svelte-1us2ddn"&&(H.textContent=we),ce=r(u),S=p(u,"P",{"data-svelte-h":!0}),w(S)!=="svelte-ovqa7g"&&(S.innerHTML=ve),me=r(u),x=p(u,"DIV",{class:!0});var D=A(x);b(L.$$.fragment,D),fe=r(D),F=p(D,"P",{"data-svelte-h":!0}),w(F)!=="svelte-50j04k"&&(F.textContent=xe),ue=r(D),b(P.$$.fragment,D),D.forEach(s),ge=r(u),j=p(u,"DIV",{class:!0});var le=A(j);b(E.$$.fragment,le),he=r(le),X=p(le,"P",{"data-svelte-h":!0}),w(X)!=="svelte-wsbjkk"&&(X.textContent=Ie),le.forEach(s),u.forEach(s),se=r(e),b(k.$$.fragment,e),ne=r(e),I=p(e,"DIV",{class:!0});var oe=A(I);b(W.$$.fragment,oe),_e=r(oe),R=p(oe,"P",{"data-svelte-h":!0}),w(R)!=="svelte-19wetgi"&&(R.textContent=De),oe.forEach(s),ae=r(e),b(N.$$.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",Ve),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(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,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,C,t),a(e,Q,t),a(e,U,t),a(e,K,t),T(J,e,t),a(e,ee,t),T(Z,e,t),a(e,te,t),a(e,m,t),T(B,m,null),c(m,de),c(m,H),c(m,ce),c(m,S),c(m,me),c(m,x),T(L,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(k,e,t),a(e,ne,t),a(e,I,t),T(W,I,null),c(I,_e),c(I,R),a(e,ae,t),T(N,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 D={};t&2&&(D.$$scope={dirty:t,ctx:e}),P.$set(D)},i(e){re||($(g.$$.fragment,e),$(J.$$.fragment,e),$(Z.$$.fragment,e),$(B.$$.fragment,e),$(L.$$.fragment,e),$(P.$$.fragment,e),$(E.$$.fragment,e),$(k.$$.fragment,e),$(W.$$.fragment,e),$(N.$$.fragment,e),re=!0)},o(e){y(g.$$.fragment,e),y(J.$$.fragment,e),y(Z.$$.fragment,e),y(B.$$.fragment,e),y(L.$$.fragment,e),y(P.$$.fragment,e),y(E.$$.fragment,e),y(k.$$.fragment,e),y(W.$$.fragment,e),y(N.$$.fragment,e),re=!1},d(e){e&&(s(v),s(d),s(f),s(l),s(h),s(q),s(G),s(z),s(C),s(Q),s(U),s(K),s(ee),s(te),s(m),s(se),s(ne),s(I),s(ae),s(ie),s(Y)),s(n),M(g,e),M(J,e),M(Z,e),M(B),M(L),M(P),M(E),M(k,e),M(W),M(N,e)}}}const Ve='{"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(V){return je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends Ge{constructor(n){super(),Ce(this,n,He,Ne,Pe,{})}}export{qe as component};
