import{s as Ge,o as Ce,n as Le}from"../chunks/scheduler.53228c21.js";import{S as Ue,i as Be,e as l,s as a,c as h,h as Ze,a as o,d as s,b as i,f as q,g as b,j as _,k as V,l as d,m as n,n as T,t as y,o as M,p as $}from"../chunks/index.100fac89.js";import{C as ke}from"../chunks/CopyLLMTxtMenu.2cdbb51f.js";import{D as ce}from"../chunks/Docstring.d46840f1.js";import{C as Ee}from"../chunks/CodeBlock.d30a6509.js";import{E as We}from"../chunks/ExampleCodeBlock.220b4f6e.js";import{H as ye,E as Ne}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fcbbc76.js";function Ve(Y){let p,P="Examples:",w,f,u;return f=new Ee({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(){p=l("p"),p.textContent=P,w=a(),h(f.$$.fragment)},l(r){p=o(r,"P",{"data-svelte-h":!0}),_(p)!=="svelte-kvfsh7"&&(p.textContent=P),w=i(r),b(f.$$.fragment,r)},m(r,g){n(r,p,g),n(r,w,g),T(f,r,g),u=!0},p:Le,i(r){u||(y(f.$$.fragment,r),u=!0)},o(r){M(f.$$.fragment,r),u=!1},d(r){r&&(s(p),s(w)),$(f,r)}}}function He(Y){let p,P,w,f,u,r,g,z,j,Me='<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:",K,C,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>",ee,L,xe='The original codebase can be found at <a href="https://github.com/facebookresearch/dit" rel="nofollow">facebookresearch/dit</a>.',te,I,ve='<p>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-a-pipeline">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.</p>',se,U,ne,c,B,me,H,Ie="Pipeline for image generation based on a Transformer backbone instead of a UNet.",fe,S,De=`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.).`,ue,x,Z,ge,X,Je="The call function to the pipeline for generation.",he,D,be,J,k,_e,F,Pe="Map label strings from ImageNet to corresponding class ids.",ae,E,ie,v,W,Te,O,je="Output class for image pipelines.",re,N,le,A,oe;return u=new ke({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),g=new ye({props:{title:"DiT",local:"dit",headingTag:"h1"}}),U=new ye({props:{title:"DiTPipeline",local:"diffusers.DiTPipeline",headingTag:"h2"}}),B=new ce({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/main/en/api/models/dit_transformer2d#diffusers.DiTTransformer2DModel">DiTTransformer2DModel</a>) &#x2014;
A class conditioned <code>DiTTransformer2DModel</code> to denoise the encoded image latents. Initially published as
<a href="https://huggingface.co/facebook/DiT-XL-2-256/blob/main/transformer/config.json#L2" rel="nofollow"><code>Transformer2DModel</code></a>
in the config, but the mismatch can be ignored.`,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#L40"}}),Z=new ce({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/dit#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#L103",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/dit#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/dit#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),D=new We({props:{anchor:"diffusers.DiTPipeline.__call__.example",$$slots:{default:[Ve]},$$scope:{ctx:Y}}}),k=new ce({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#L78",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 ye({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),W=new ce({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#L118"}}),N=new Ne({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/dit.md"}}),{c(){p=l("meta"),P=a(),w=l("p"),f=a(),h(u.$$.fragment),r=a(),h(g.$$.fragment),z=a(),j=l("p"),j.innerHTML=Me,Q=a(),G=l("p"),G.textContent=$e,K=a(),C=l("p"),C.innerHTML=we,ee=a(),L=l("p"),L.innerHTML=xe,te=a(),I=l("blockquote"),I.innerHTML=ve,se=a(),h(U.$$.fragment),ne=a(),c=l("div"),h(B.$$.fragment),me=a(),H=l("p"),H.textContent=Ie,fe=a(),S=l("p"),S.innerHTML=De,ue=a(),x=l("div"),h(Z.$$.fragment),ge=a(),X=l("p"),X.textContent=Je,he=a(),h(D.$$.fragment),be=a(),J=l("div"),h(k.$$.fragment),_e=a(),F=l("p"),F.textContent=Pe,ae=a(),h(E.$$.fragment),ie=a(),v=l("div"),h(W.$$.fragment),Te=a(),O=l("p"),O.textContent=je,re=a(),h(N.$$.fragment),le=a(),A=l("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(s),P=i(e),w=o(e,"P",{}),q(w).forEach(s),f=i(e),b(u.$$.fragment,e),r=i(e),b(g.$$.fragment,e),z=i(e),j=o(e,"P",{"data-svelte-h":!0}),_(j)!=="svelte-utwfha"&&(j.innerHTML=Me),Q=i(e),G=o(e,"P",{"data-svelte-h":!0}),_(G)!=="svelte-1cwsb16"&&(G.textContent=$e),K=i(e),C=o(e,"P",{"data-svelte-h":!0}),_(C)!=="svelte-9gxrul"&&(C.innerHTML=we),ee=i(e),L=o(e,"P",{"data-svelte-h":!0}),_(L)!=="svelte-34bc3b"&&(L.innerHTML=xe),te=i(e),I=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),_(I)!=="svelte-r1jcqf"&&(I.innerHTML=ve),se=i(e),b(U.$$.fragment,e),ne=i(e),c=o(e,"DIV",{class:!0});var m=q(c);b(B.$$.fragment,m),me=i(m),H=o(m,"P",{"data-svelte-h":!0}),_(H)!=="svelte-1us2ddn"&&(H.textContent=Ie),fe=i(m),S=o(m,"P",{"data-svelte-h":!0}),_(S)!=="svelte-496sm0"&&(S.innerHTML=De),ue=i(m),x=o(m,"DIV",{class:!0});var R=q(x);b(Z.$$.fragment,R),ge=i(R),X=o(R,"P",{"data-svelte-h":!0}),_(X)!=="svelte-50j04k"&&(X.textContent=Je),he=i(R),b(D.$$.fragment,R),R.forEach(s),be=i(m),J=o(m,"DIV",{class:!0});var pe=q(J);b(k.$$.fragment,pe),_e=i(pe),F=o(pe,"P",{"data-svelte-h":!0}),_(F)!=="svelte-wsbjkk"&&(F.textContent=Pe),pe.forEach(s),m.forEach(s),ae=i(e),b(E.$$.fragment,e),ie=i(e),v=o(e,"DIV",{class:!0});var de=q(v);b(W.$$.fragment,de),Te=i(de),O=o(de,"P",{"data-svelte-h":!0}),_(O)!=="svelte-19wetgi"&&(O.textContent=je),de.forEach(s),re=i(e),b(N.$$.fragment,e),le=i(e),A=o(e,"P",{}),q(A).forEach(s),this.h()},h(){V(p,"name","hf:doc:metadata"),V(p,"content",Se),V(I,"class","tip"),V(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(v,"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){d(document.head,p),n(e,P,t),n(e,w,t),n(e,f,t),T(u,e,t),n(e,r,t),T(g,e,t),n(e,z,t),n(e,j,t),n(e,Q,t),n(e,G,t),n(e,K,t),n(e,C,t),n(e,ee,t),n(e,L,t),n(e,te,t),n(e,I,t),n(e,se,t),T(U,e,t),n(e,ne,t),n(e,c,t),T(B,c,null),d(c,me),d(c,H),d(c,fe),d(c,S),d(c,ue),d(c,x),T(Z,x,null),d(x,ge),d(x,X),d(x,he),T(D,x,null),d(c,be),d(c,J),T(k,J,null),d(J,_e),d(J,F),n(e,ae,t),T(E,e,t),n(e,ie,t),n(e,v,t),T(W,v,null),d(v,Te),d(v,O),n(e,re,t),T(N,e,t),n(e,le,t),n(e,A,t),oe=!0},p(e,[t]){const m={};t&2&&(m.$$scope={dirty:t,ctx:e}),D.$set(m)},i(e){oe||(y(u.$$.fragment,e),y(g.$$.fragment,e),y(U.$$.fragment,e),y(B.$$.fragment,e),y(Z.$$.fragment,e),y(D.$$.fragment,e),y(k.$$.fragment,e),y(E.$$.fragment,e),y(W.$$.fragment,e),y(N.$$.fragment,e),oe=!0)},o(e){M(u.$$.fragment,e),M(g.$$.fragment,e),M(U.$$.fragment,e),M(B.$$.fragment,e),M(Z.$$.fragment,e),M(D.$$.fragment,e),M(k.$$.fragment,e),M(E.$$.fragment,e),M(W.$$.fragment,e),M(N.$$.fragment,e),oe=!1},d(e){e&&(s(P),s(w),s(f),s(r),s(z),s(j),s(Q),s(G),s(K),s(C),s(ee),s(L),s(te),s(I),s(se),s(ne),s(c),s(ae),s(ie),s(v),s(re),s(le),s(A)),s(p),$(u,e),$(g,e),$(U,e),$(B),$(Z),$(D),$(k),$(E,e),$(W),$(N,e)}}}const Se='{"title":"DiT","local":"dit","sections":[{"title":"DiTPipeline","local":"diffusers.DiTPipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function Xe(Y){return Ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends Ue{constructor(p){super(),Be(this,p,Xe,He,Ge,{})}}export{Qe as component};
