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 y,A as Ge,h as p,f as s,c as r,j as R,u as M,x as b,k as A,y as c,a,v as $,d as w,t as v,w as x}from"../chunks/index.abf12888.js";import{T as Ue}from"../chunks/Tip.230e2334.js";import{D as le}from"../chunks/Docstring.93f6f462.js";import{C as Ce}from"../chunks/CodeBlock.57fe6e13.js";import{E as Ze}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as he}from"../chunks/Heading.16916d63.js";function Be(N){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,f){a(d,n,f)},p:Ie,d(d){d&&s(n)}}}function Le(N){let n,_="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=_,d=i(),y(f.$$.fragment)},l(l){n=p(l,"P",{"data-svelte-h":!0}),b(n)!=="svelte-kvfsh7"&&(n.textContent=_),d=r(l),M(f.$$.fragment,l)},m(l,h){a(l,n,h),a(l,d,h),$(f,l,h),g=!0},p:Ie,i(l){g||(w(f.$$.fragment,l),g=!0)},o(l){v(f.$$.fragment,l),g=!1},d(l){l&&(s(n),s(d)),x(f,l)}}}function ke(N){let n,_,d,f,g,l,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.',O,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,C,ye='The original codebase can be found at <a href="https://github.com/facebookresearch/dit" rel="nofollow">facebookresearch/dit</a>.',Q,D,K,Z,ee,m,B,oe,V,Me="Pipeline for image generation based on a Transformer backbone instead of a UNet.",pe,H,$e=`This model inherits from <a href="/docs/diffusers/main/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,L,ce,S,we="The call function to the pipeline for generation.",me,P,fe,j,k,ue,F,ve="Map label strings from ImageNet to corresponding class ids.",te,W,se,I,E,ge,X,xe="Output class for image pipelines.",ne,Y,ae;return g=new he({props:{title:"DiT",local:"dit",headingTag:"h1"}}),D=new Ue({props:{$$slots:{default:[Be]},$$scope:{ctx:N}}}),Z=new he({props:{title:"DiTPipeline",local:"diffusers.DiTPipeline",headingTag:"h2"}}),B=new le({props:{name:"class diffusers.DiTPipeline",anchor:"diffusers.DiTPipeline",parameters:[{name:"transformer",val:": Transformer2DModel"},{name:"vae",val:": AutoencoderKL"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"id2label",val:": typing.Union[typing.Dict[int, str], NoneType] = None"}],parametersDescription:[{anchor:"diffusers.DiTPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/main/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/main/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/main/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/main/src/diffusers/pipelines/dit/pipeline_dit.py#L31"}}),L=new le({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/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/dit/pipeline_dit.py#L91",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/ddim#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/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),P=new Ze({props:{anchor:"diffusers.DiTPipeline.__call__.example",$$slots:{default:[Le]},$$scope:{ctx:N}}}),k=new le({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/main/src/diffusers/pipelines/dit/pipeline_dit.py#L66",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 he({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),E=new le({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/main/src/diffusers/pipelines/pipeline_utils.py#L110"}}),{c(){n=o("meta"),_=i(),d=o("p"),f=i(),y(g.$$.fragment),l=i(),h=o("p"),h.innerHTML=be,O=i(),G=o("p"),G.textContent=_e,q=i(),U=o("p"),U.innerHTML=Te,z=i(),C=o("p"),C.innerHTML=ye,Q=i(),y(D.$$.fragment),K=i(),y(Z.$$.fragment),ee=i(),m=o("div"),y(B.$$.fragment),oe=i(),V=o("p"),V.textContent=Me,pe=i(),H=o("p"),H.innerHTML=$e,de=i(),T=o("div"),y(L.$$.fragment),ce=i(),S=o("p"),S.textContent=we,me=i(),y(P.$$.fragment),fe=i(),j=o("div"),y(k.$$.fragment),ue=i(),F=o("p"),F.textContent=ve,te=i(),y(W.$$.fragment),se=i(),I=o("div"),y(E.$$.fragment),ge=i(),X=o("p"),X.textContent=xe,ne=i(),Y=o("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);n=p(t,"META",{name:!0,content:!0}),t.forEach(s),_=r(e),d=p(e,"P",{}),R(d).forEach(s),f=r(e),M(g.$$.fragment,e),l=r(e),h=p(e,"P",{"data-svelte-h":!0}),b(h)!=="svelte-utwfha"&&(h.innerHTML=be),O=r(e),G=p(e,"P",{"data-svelte-h":!0}),b(G)!=="svelte-1cwsb16"&&(G.textContent=_e),q=r(e),U=p(e,"P",{"data-svelte-h":!0}),b(U)!=="svelte-9gxrul"&&(U.innerHTML=Te),z=r(e),C=p(e,"P",{"data-svelte-h":!0}),b(C)!=="svelte-34bc3b"&&(C.innerHTML=ye),Q=r(e),M(D.$$.fragment,e),K=r(e),M(Z.$$.fragment,e),ee=r(e),m=p(e,"DIV",{class:!0});var u=R(m);M(B.$$.fragment,u),oe=r(u),V=p(u,"P",{"data-svelte-h":!0}),b(V)!=="svelte-1us2ddn"&&(V.textContent=Me),pe=r(u),H=p(u,"P",{"data-svelte-h":!0}),b(H)!=="svelte-496sm0"&&(H.innerHTML=$e),de=r(u),T=p(u,"DIV",{class:!0});var J=R(T);M(L.$$.fragment,J),ce=r(J),S=p(J,"P",{"data-svelte-h":!0}),b(S)!=="svelte-50j04k"&&(S.textContent=we),me=r(J),M(P.$$.fragment,J),J.forEach(s),fe=r(u),j=p(u,"DIV",{class:!0});var ie=R(j);M(k.$$.fragment,ie),ue=r(ie),F=p(ie,"P",{"data-svelte-h":!0}),b(F)!=="svelte-wsbjkk"&&(F.textContent=ve),ie.forEach(s),u.forEach(s),te=r(e),M(W.$$.fragment,e),se=r(e),I=p(e,"DIV",{class:!0});var re=R(I);M(E.$$.fragment,re),ge=r(re),X=p(re,"P",{"data-svelte-h":!0}),b(X)!=="svelte-19wetgi"&&(X.textContent=xe),re.forEach(s),ne=r(e),Y=p(e,"P",{}),R(Y).forEach(s),this.h()},h(){A(n,"name","hf:doc:metadata"),A(n,"content",We),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(m,"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,f,t),$(g,e,t),a(e,l,t),a(e,h,t),a(e,O,t),a(e,G,t),a(e,q,t),a(e,U,t),a(e,z,t),a(e,C,t),a(e,Q,t),$(D,e,t),a(e,K,t),$(Z,e,t),a(e,ee,t),a(e,m,t),$(B,m,null),c(m,oe),c(m,V),c(m,pe),c(m,H),c(m,de),c(m,T),$(L,T,null),c(T,ce),c(T,S),c(T,me),$(P,T,null),c(m,fe),c(m,j),$(k,j,null),c(j,ue),c(j,F),a(e,te,t),$(W,e,t),a(e,se,t),a(e,I,t),$(E,I,null),c(I,ge),c(I,X),a(e,ne,t),a(e,Y,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||(w(g.$$.fragment,e),w(D.$$.fragment,e),w(Z.$$.fragment,e),w(B.$$.fragment,e),w(L.$$.fragment,e),w(P.$$.fragment,e),w(k.$$.fragment,e),w(W.$$.fragment,e),w(E.$$.fragment,e),ae=!0)},o(e){v(g.$$.fragment,e),v(D.$$.fragment,e),v(Z.$$.fragment,e),v(B.$$.fragment,e),v(L.$$.fragment,e),v(P.$$.fragment,e),v(k.$$.fragment,e),v(W.$$.fragment,e),v(E.$$.fragment,e),ae=!1},d(e){e&&(s(_),s(d),s(f),s(l),s(h),s(O),s(G),s(q),s(U),s(z),s(C),s(Q),s(K),s(ee),s(m),s(te),s(se),s(I),s(ne),s(Y)),s(n),x(g,e),x(D,e),x(Z,e),x(B),x(L),x(P),x(k),x(W,e),x(E)}}}const We='{"title":"DiT","local":"dit","sections":[{"title":"DiTPipeline","local":"diffusers.DiTPipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function Ee(N){return De(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ae extends Pe{constructor(n){super(),je(this,n,Ee,ke,Je,{})}}export{Ae as component};
