import{S as zt,i as Lt,s as Ot,e as n,k as c,w as C,t as i,M as Nt,c as o,d as s,m as u,a,x as b,h as r,b as l,G as t,g as m,y as x,q as I,o as J,B as U,v as Pt,L as Xt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as re}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Bt}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as gt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ft}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Rt(we){let p,V,_,w,A,v,T,j;return T=new Bt({props:{code:"cCh4XyU3QnQtMSU3RCUyMCU3QyUyMHhfdCklMjAlM0QlMjBzdW0oJTIwcSh4X3QlMjAlN0MlMjB4XyU3QnQtMSU3RCklMjAqJTIwcSh4XyU3QnQtMSU3RCUyMCU3QyUyMHhfMCklMjAqJTIwcCh4XzApJTIwJTJGJTIwcSh4X3QlMjAlN0MlMjB4XzApJTIwKQ==",highlighted:'p(<span class="hljs-keyword">x</span><span class="hljs-number">_</span>{t-<span class="hljs-number">1</span>} | x_t) = sum( <span class="hljs-string">q(x_t | x_{t-1})</span> * <span class="hljs-string">q(x_{t-1} | x_0)</span> * p(x_<span class="hljs-number">0</span>) / <span class="hljs-string">q(x_t | x_0)</span> )'}}),{c(){p=n("p"),V=i("Calculates the log probabilities for the predicted classes of the image at timestep "),_=n("code"),w=i("t-1"),A=i(":"),v=c(),C(T.$$.fragment)},l(f){p=o(f,"P",{});var M=a(p);V=r(M,"Calculates the log probabilities for the predicted classes of the image at timestep "),_=o(M,"CODE",{});var y=a(_);w=r(y,"t-1"),y.forEach(s),A=r(M,":"),M.forEach(s),v=u(f),b(T.$$.fragment,f)},m(f,M){m(f,p,M),t(p,V),t(p,_),t(_,w),t(p,A),m(f,v,M),x(T,f,M),j=!0},p:Xt,i(f){j||(I(T.$$.fragment,f),j=!0)},o(f){J(T.$$.fragment,f),j=!1},d(f){f&&s(p),f&&s(v),U(T,f)}}}function Wt(we){let p,V,_,w,A,v,T,j,f,M,y,le,Ee,qe,P,ke,ze,ve,te,Le,ye,se,ce,Oe,Te,D,E,ue,X,Ne,de,Pe,Ce,h,B,Xe,fe,Be,Fe,Q,Re,ne,We,Ge,oe,He,Ke,Ye,q,F,Ze,R,et,he,tt,st,nt,k,W,ot,z,at,L,G,it,pe,rt,lt,O,H,ct,K,ut,ae,dt,ft,be,$,N,me,Y,ht,_e,pt,xe,S,Z,mt,ge,_t,Ie;return v=new gt({}),X=new gt({}),B=new re({props:{name:"class diffusers.VQDiffusionScheduler",anchor:"diffusers.VQDiffusionScheduler",parameters:[{name:"num_vec_classes",val:": int"},{name:"num_train_timesteps",val:": int = 100"},{name:"alpha_cum_start",val:": float = 0.99999"},{name:"alpha_cum_end",val:": float = 9e-06"},{name:"gamma_cum_start",val:": float = 9e-06"},{name:"gamma_cum_end",val:": float = 0.99999"}],parametersDescription:[{anchor:"diffusers.VQDiffusionScheduler.num_vec_classes",description:`<strong>num_vec_classes</strong> (<code>int</code>) &#x2014;
The number of classes of the vector embeddings of the latent pixels. Includes the class for the masked
latent pixel.`,name:"num_vec_classes"},{anchor:"diffusers.VQDiffusionScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 100) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.VQDiffusionScheduler.alpha_cum_start",description:`<strong>alpha_cum_start</strong> (<code>float</code>, defaults to 0.99999) &#x2014;
The starting cumulative alpha value.`,name:"alpha_cum_start"},{anchor:"diffusers.VQDiffusionScheduler.alpha_cum_end",description:`<strong>alpha_cum_end</strong> (<code>float</code>, defaults to 0.00009) &#x2014;
The ending cumulative alpha value.`,name:"alpha_cum_end"},{anchor:"diffusers.VQDiffusionScheduler.gamma_cum_start",description:`<strong>gamma_cum_start</strong> (<code>float</code>, defaults to 0.00009) &#x2014;
The starting cumulative gamma value.`,name:"gamma_cum_start"},{anchor:"diffusers.VQDiffusionScheduler.gamma_cum_end",description:`<strong>gamma_cum_end</strong> (<code>float</code>, defaults to 0.99999) &#x2014;
The ending cumulative gamma value.`,name:"gamma_cum_end"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L106"}}),F=new re({props:{name:"log_Q_t_transitioning_to_known_class",anchor:"diffusers.VQDiffusionScheduler.log_Q_t_transitioning_to_known_class",parameters:[{name:"t",val:": torch.int32"},{name:"x_t",val:": LongTensor"},{name:"log_onehot_x_t",val:": FloatTensor"},{name:"cumulative",val:": bool"}],parametersDescription:[{anchor:"diffusers.VQDiffusionScheduler.log_Q_t_transitioning_to_known_class.t",description:`<strong>t</strong> (<code>torch.Long</code>) &#x2014;
The timestep that determines which transition matrix is used.`,name:"t"},{anchor:"diffusers.VQDiffusionScheduler.log_Q_t_transitioning_to_known_class.x_t",description:`<strong>x_t</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code>) &#x2014;
The classes of each latent pixel at time <code>t</code>.`,name:"x_t"},{anchor:"diffusers.VQDiffusionScheduler.log_Q_t_transitioning_to_known_class.log_onehot_x_t",description:`<strong>log_onehot_x_t</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, num classes, num latent pixels)</code>) &#x2014;
The log one-hot vectors of <code>x_t</code>.`,name:"log_onehot_x_t"},{anchor:"diffusers.VQDiffusionScheduler.log_Q_t_transitioning_to_known_class.cumulative",description:`<strong>cumulative</strong> (<code>bool</code>) &#x2014;
If cumulative is <code>False</code>, the single step transition matrix <code>t-1</code>-&gt;<code>t</code> is used. If cumulative is
<code>True</code>, the cumulative transition matrix <code>0</code>-&gt;<code>t</code> is used.`,name:"cumulative"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L356",returnDescription:`
<p>Each <em>column</em> of the returned matrix is a <em>row</em> of log probabilities of the complete probability
transition matrix.</p>
<p>When non cumulative, returns <code>self.num_classes - 1</code> rows because the initial latent pixel cannot be
masked.</p>
<p>Where:</p>
<ul>
<li><code>q_n</code> is the probability distribution for the forward process of the <code>n</code>th latent pixel.</li>
<li>C_0 is a class of a latent pixel embedding</li>
<li>C_k is the class of the masked latent pixel</li>
</ul>
<p>non-cumulative result (omitting logarithms):</p>

	<CodeBlock 
		code={\`cV8wKHhfdCUyMCU3QyUyMHhfJTdCdC0xJTdEJTIwJTNEJTIwQ18wKSUyMC4uLiUyMHFfbih4X3QlMjAlN0MlMjB4XyU3QnQtMSU3RCUyMCUzRCUyMENfMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMC4lMEFxXzAoeF90JTIwJTdDJTIweF8lN0J0LTElN0QlMjAlM0QlMjBDX2spJTIwLi4uJTIwcV9uKHhfdCUyMCU3QyUyMHhfJTdCdC0xJTdEJTIwJTNEJTIwQ19rKQ==\`}
		highlighted={\`q<span class="hljs-constructor">_0(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_</span>{<span class="hljs-params">t</span>-1\\} = C_0)</span><span class="hljs-operator"> ... </span>q<span class="hljs-constructor">_n(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_</span>{<span class="hljs-params">t</span>-1\\} = C_0)</span>
          .      .                     .
          .               .            .
          .                      .     .
q<span class="hljs-constructor">_0(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_</span>{<span class="hljs-params">t</span>-1\\} = C_k)</span><span class="hljs-operator"> ... </span>q<span class="hljs-constructor">_n(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_</span>{<span class="hljs-params">t</span>-1\\} = C_k)</span>\`}
	/>
<p>cumulative result (omitting logarithms):</p>

	<CodeBlock 
		code={\`cV8wX2N1bXVsYXRpdmUoeF90JTIwJTdDJTIweF8wJTIwJTNEJTIwQ18wKSUyMCUyMCUyMCUyMC4uLiUyMCUyMHFfbl9jdW11bGF0aXZlKHhfdCUyMCU3QyUyMHhfMCUyMCUzRCUyMENfMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4lMEFxXzBfY3VtdWxhdGl2ZSh4X3QlMjAlN0MlMjB4XzAlMjAlM0QlMjBDXyU3QmstMSU3RCklMjAuLi4lMjBxX25fY3VtdWxhdGl2ZSh4X3QlMjAlN0MlMjB4XzAlMjAlM0QlMjBDXyU3QmstMSU3RCk=\`}
		highlighted={\`q<span class="hljs-constructor">_0_cumulative(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_0</span> = C_0)</span><span class="hljs-operator">    ...  </span>q<span class="hljs-constructor">_n_cumulative(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_0</span> = C_0)</span>
          .               .                          .
          .                        .                 .
          .                               .          .
q<span class="hljs-constructor">_0_cumulative(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_0</span> = C_{<span class="hljs-params">k</span>-1\\})</span><span class="hljs-operator"> ... </span>q<span class="hljs-constructor">_n_cumulative(<span class="hljs-params">x_t</span> | <span class="hljs-params">x_0</span> = C_{<span class="hljs-params">k</span>-1\\})</span>\`}
	/>
`,returnType:`
<p><code>torch.FloatTensor</code> of shape <code>(batch size, num classes - 1, num latent pixels)</code></p>
`}}),W=new re({props:{name:"q_posterior",anchor:"diffusers.VQDiffusionScheduler.q_posterior",parameters:[{name:"log_p_x_0",val:""},{name:"x_t",val:""},{name:"t",val:""}],parametersDescription:[{anchor:"diffusers.VQDiffusionScheduler.q_posterior.log_p_x_0",description:`<strong>log_p_x_0</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, num classes - 1, num latent pixels)</code>) &#x2014;
The log probabilities for the predicted classes of the initial latent pixels. Does not include a
prediction for the masked class as the initial unnoised image cannot be masked.`,name:"log_p_x_0"},{anchor:"diffusers.VQDiffusionScheduler.q_posterior.x_t",description:`<strong>x_t</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code>) &#x2014;
The classes of each latent pixel at time <code>t</code>.`,name:"x_t"},{anchor:"diffusers.VQDiffusionScheduler.q_posterior.t",description:`<strong>t</strong> (<code>torch.Long</code>) &#x2014;
The timestep that determines which transition matrix is used.`,name:"t"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L245",returnDescription:`
<p>The log probabilities for the predicted classes of the image at timestep <code>t-1</code>.</p>
`,returnType:`
<p><code>torch.FloatTensor</code> of shape <code>(batch size, num classes, num latent pixels)</code></p>
`}}),z=new Ft({props:{anchor:"diffusers.VQDiffusionScheduler.q_posterior.example",$$slots:{default:[Rt]},$$scope:{ctx:we}}}),G=new re({props:{name:"set_timesteps",anchor:"diffusers.VQDiffusionScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.VQDiffusionScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"},{anchor:"diffusers.VQDiffusionScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps and diffusion process parameters (alpha, beta, gamma) should be moved
to.`,name:"device"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L178"}}),H=new re({props:{name:"step",anchor:"diffusers.VQDiffusionScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": torch.int64"},{name:"sample",val:": LongTensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.VQDiffusionScheduler.step.t",description:`<strong>t</strong> (<code>torch.long</code>) &#x2014;
The timestep that determines which transition matrices are used.`,name:"t"},{anchor:"diffusers.VQDiffusionScheduler.step.x_t",description:`<strong>x_t</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code>) &#x2014;
The classes of each latent pixel at time <code>t</code>.`,name:"x_t"},{anchor:"diffusers.VQDiffusionScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, or <code>None</code>) &#x2014;
A random number generator for the noise applied to <code>p(x_{t-1} | x_t)</code> before it is sampled from.`,name:"generator"},{anchor:"diffusers.VQDiffusionScheduler.step.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/schedulers/vq_diffusion#diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput">VQDiffusionSchedulerOutput</a> or
<code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L200",returnDescription:`
<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/schedulers/vq_diffusion#diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput"
>VQDiffusionSchedulerOutput</a> is
returned, otherwise a tuple is returned where the first element is the sample tensor.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/schedulers/vq_diffusion#diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput"
>VQDiffusionSchedulerOutput</a> or <code>tuple</code></p>
`}}),Y=new gt({}),Z=new re({props:{name:"class diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput",anchor:"diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput",parameters:[{name:"prev_sample",val:": LongTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code>) &#x2014;
Computed sample x_{t-1} of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_vq_diffusion.py#L28"}}),{c(){p=n("meta"),V=c(),_=n("h1"),w=n("a"),A=n("span"),C(v.$$.fragment),T=c(),j=n("span"),f=i("VQDiffusionScheduler"),M=c(),y=n("p"),le=n("code"),Ee=i("VQDiffusionScheduler"),qe=i(" converts the transformer model\u2019s output into a sample for the unnoised image at the previous diffusion timestep. It was introduced in "),P=n("a"),ke=i("Vector Quantized Diffusion Model for Text-to-Image Synthesis"),ze=i(" by Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, Baining Guo."),ve=c(),te=n("p"),Le=i("The abstract from the paper is:"),ye=c(),se=n("p"),ce=n("em"),Oe=i("We present the vector quantized diffusion (VQ-Diffusion) model for text-to-image generation. This method is based on a vector quantized variational autoencoder (VQ-VAE) whose latent space is modeled by a conditional variant of the recently developed Denoising Diffusion Probabilistic Model (DDPM). We find that this latent-space method is well-suited for text-to-image generation tasks because it not only eliminates the unidirectional bias with existing methods but also allows us to incorporate a mask-and-replace diffusion strategy to avoid the accumulation of errors, which is a serious problem with existing methods. Our experiments show that the VQ-Diffusion produces significantly better text-to-image generation results when compared with conventional autoregressive (AR) models with similar numbers of parameters. Compared with previous GAN-based text-to-image methods, our VQ-Diffusion can handle more complex scenes and improve the synthesized image quality by a large margin. Finally, we show that the image generation computation in our method can be made highly efficient by reparameterization. With traditional AR methods, the text-to-image generation time increases linearly with the output image resolution and hence is quite time consuming even for normal size images. The VQ-Diffusion allows us to achieve a better trade-off between quality and speed. Our experiments indicate that the VQ-Diffusion model with the reparameterization is fifteen times faster than traditional AR methods while achieving a better image quality."),Te=c(),D=n("h2"),E=n("a"),ue=n("span"),C(X.$$.fragment),Ne=c(),de=n("span"),Pe=i("VQDiffusionScheduler"),Ce=c(),h=n("div"),C(B.$$.fragment),Xe=c(),fe=n("p"),Be=i("A scheduler for vector quantized diffusion."),Fe=c(),Q=n("p"),Re=i("This model inherits from "),ne=n("a"),We=i("SchedulerMixin"),Ge=i(" and "),oe=n("a"),He=i("ConfigMixin"),Ke=i(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Ye=c(),q=n("div"),C(F.$$.fragment),Ze=c(),R=n("p"),et=i(`Calculates the log probabilities of the rows from the (cumulative or non-cumulative) transition matrix for each
latent pixel in `),he=n("code"),tt=i("x_t"),st=i("."),nt=c(),k=n("div"),C(W.$$.fragment),ot=c(),C(z.$$.fragment),at=c(),L=n("div"),C(G.$$.fragment),it=c(),pe=n("p"),rt=i("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),lt=c(),O=n("div"),C(H.$$.fragment),ct=c(),K=n("p"),ut=i(`Predict the sample from the previous timestep by the reverse transition distribution. See
`),ae=n("a"),dt=i("q_posterior()"),ft=i(" for more details about how the distribution is computer."),be=c(),$=n("h2"),N=n("a"),me=n("span"),C(Y.$$.fragment),ht=c(),_e=n("span"),pt=i("VQDiffusionSchedulerOutput"),xe=c(),S=n("div"),C(Z.$$.fragment),mt=c(),ge=n("p"),_t=i("Output class for the scheduler\u2019s step function output."),this.h()},l(e){const d=Nt('[data-svelte="svelte-1phssyn"]',document.head);p=o(d,"META",{name:!0,content:!0}),d.forEach(s),V=u(e),_=o(e,"H1",{class:!0});var ee=a(_);w=o(ee,"A",{id:!0,class:!0,href:!0});var Mt=a(w);A=o(Mt,"SPAN",{});var wt=a(A);b(v.$$.fragment,wt),wt.forEach(s),Mt.forEach(s),T=u(ee),j=o(ee,"SPAN",{});var vt=a(j);f=r(vt,"VQDiffusionScheduler"),vt.forEach(s),ee.forEach(s),M=u(e),y=o(e,"P",{});var Me=a(y);le=o(Me,"CODE",{});var yt=a(le);Ee=r(yt,"VQDiffusionScheduler"),yt.forEach(s),qe=r(Me," converts the transformer model\u2019s output into a sample for the unnoised image at the previous diffusion timestep. It was introduced in "),P=o(Me,"A",{href:!0,rel:!0});var Tt=a(P);ke=r(Tt,"Vector Quantized Diffusion Model for Text-to-Image Synthesis"),Tt.forEach(s),ze=r(Me," by Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, Baining Guo."),Me.forEach(s),ve=u(e),te=o(e,"P",{});var Ct=a(te);Le=r(Ct,"The abstract from the paper is:"),Ct.forEach(s),ye=u(e),se=o(e,"P",{});var bt=a(se);ce=o(bt,"EM",{});var xt=a(ce);Oe=r(xt,"We present the vector quantized diffusion (VQ-Diffusion) model for text-to-image generation. This method is based on a vector quantized variational autoencoder (VQ-VAE) whose latent space is modeled by a conditional variant of the recently developed Denoising Diffusion Probabilistic Model (DDPM). We find that this latent-space method is well-suited for text-to-image generation tasks because it not only eliminates the unidirectional bias with existing methods but also allows us to incorporate a mask-and-replace diffusion strategy to avoid the accumulation of errors, which is a serious problem with existing methods. Our experiments show that the VQ-Diffusion produces significantly better text-to-image generation results when compared with conventional autoregressive (AR) models with similar numbers of parameters. Compared with previous GAN-based text-to-image methods, our VQ-Diffusion can handle more complex scenes and improve the synthesized image quality by a large margin. Finally, we show that the image generation computation in our method can be made highly efficient by reparameterization. With traditional AR methods, the text-to-image generation time increases linearly with the output image resolution and hence is quite time consuming even for normal size images. The VQ-Diffusion allows us to achieve a better trade-off between quality and speed. Our experiments indicate that the VQ-Diffusion model with the reparameterization is fifteen times faster than traditional AR methods while achieving a better image quality."),xt.forEach(s),bt.forEach(s),Te=u(e),D=o(e,"H2",{class:!0});var Je=a(D);E=o(Je,"A",{id:!0,class:!0,href:!0});var It=a(E);ue=o(It,"SPAN",{});var Jt=a(ue);b(X.$$.fragment,Jt),Jt.forEach(s),It.forEach(s),Ne=u(Je),de=o(Je,"SPAN",{});var Ut=a(de);Pe=r(Ut,"VQDiffusionScheduler"),Ut.forEach(s),Je.forEach(s),Ce=u(e),h=o(e,"DIV",{class:!0});var g=a(h);b(B.$$.fragment,g),Xe=u(g),fe=o(g,"P",{});var jt=a(fe);Be=r(jt,"A scheduler for vector quantized diffusion."),jt.forEach(s),Fe=u(g),Q=o(g,"P",{});var ie=a(Q);Re=r(ie,"This model inherits from "),ne=o(ie,"A",{href:!0});var At=a(ne);We=r(At,"SchedulerMixin"),At.forEach(s),Ge=r(ie," and "),oe=o(ie,"A",{href:!0});var Dt=a(oe);He=r(Dt,"ConfigMixin"),Dt.forEach(s),Ke=r(ie,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),ie.forEach(s),Ye=u(g),q=o(g,"DIV",{class:!0});var Ue=a(q);b(F.$$.fragment,Ue),Ze=u(Ue),R=o(Ue,"P",{});var je=a(R);et=r(je,`Calculates the log probabilities of the rows from the (cumulative or non-cumulative) transition matrix for each
latent pixel in `),he=o(je,"CODE",{});var Qt=a(he);tt=r(Qt,"x_t"),Qt.forEach(s),st=r(je,"."),je.forEach(s),Ue.forEach(s),nt=u(g),k=o(g,"DIV",{class:!0});var Ae=a(k);b(W.$$.fragment,Ae),ot=u(Ae),b(z.$$.fragment,Ae),Ae.forEach(s),at=u(g),L=o(g,"DIV",{class:!0});var De=a(L);b(G.$$.fragment,De),it=u(De),pe=o(De,"P",{});var $t=a(pe);rt=r($t,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),$t.forEach(s),De.forEach(s),lt=u(g),O=o(g,"DIV",{class:!0});var Qe=a(O);b(H.$$.fragment,Qe),ct=u(Qe),K=o(Qe,"P",{});var $e=a(K);ut=r($e,`Predict the sample from the previous timestep by the reverse transition distribution. See
`),ae=o($e,"A",{href:!0});var St=a(ae);dt=r(St,"q_posterior()"),St.forEach(s),ft=r($e," for more details about how the distribution is computer."),$e.forEach(s),Qe.forEach(s),g.forEach(s),be=u(e),$=o(e,"H2",{class:!0});var Se=a($);N=o(Se,"A",{id:!0,class:!0,href:!0});var Vt=a(N);me=o(Vt,"SPAN",{});var Et=a(me);b(Y.$$.fragment,Et),Et.forEach(s),Vt.forEach(s),ht=u(Se),_e=o(Se,"SPAN",{});var qt=a(_e);pt=r(qt,"VQDiffusionSchedulerOutput"),qt.forEach(s),Se.forEach(s),xe=u(e),S=o(e,"DIV",{class:!0});var Ve=a(S);b(Z.$$.fragment,Ve),mt=u(Ve),ge=o(Ve,"P",{});var kt=a(ge);_t=r(kt,"Output class for the scheduler\u2019s step function output."),kt.forEach(s),Ve.forEach(s),this.h()},h(){l(p,"name","hf:doc:metadata"),l(p,"content",JSON.stringify(Gt)),l(w,"id","vqdiffusionscheduler"),l(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(w,"href","#vqdiffusionscheduler"),l(_,"class","relative group"),l(P,"href","https://huggingface.co/papers/2111.14822"),l(P,"rel","nofollow"),l(E,"id","diffusers.VQDiffusionScheduler"),l(E,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(E,"href","#diffusers.VQDiffusionScheduler"),l(D,"class","relative group"),l(ne,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),l(oe,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),l(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(ae,"href","/docs/diffusers/main/en/api/schedulers/vq_diffusion#diffusers.VQDiffusionScheduler.q_posterior"),l(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"id","diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput"),l(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(N,"href","#diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput"),l($,"class","relative group"),l(S,"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,d){t(document.head,p),m(e,V,d),m(e,_,d),t(_,w),t(w,A),x(v,A,null),t(_,T),t(_,j),t(j,f),m(e,M,d),m(e,y,d),t(y,le),t(le,Ee),t(y,qe),t(y,P),t(P,ke),t(y,ze),m(e,ve,d),m(e,te,d),t(te,Le),m(e,ye,d),m(e,se,d),t(se,ce),t(ce,Oe),m(e,Te,d),m(e,D,d),t(D,E),t(E,ue),x(X,ue,null),t(D,Ne),t(D,de),t(de,Pe),m(e,Ce,d),m(e,h,d),x(B,h,null),t(h,Xe),t(h,fe),t(fe,Be),t(h,Fe),t(h,Q),t(Q,Re),t(Q,ne),t(ne,We),t(Q,Ge),t(Q,oe),t(oe,He),t(Q,Ke),t(h,Ye),t(h,q),x(F,q,null),t(q,Ze),t(q,R),t(R,et),t(R,he),t(he,tt),t(R,st),t(h,nt),t(h,k),x(W,k,null),t(k,ot),x(z,k,null),t(h,at),t(h,L),x(G,L,null),t(L,it),t(L,pe),t(pe,rt),t(h,lt),t(h,O),x(H,O,null),t(O,ct),t(O,K),t(K,ut),t(K,ae),t(ae,dt),t(K,ft),m(e,be,d),m(e,$,d),t($,N),t(N,me),x(Y,me,null),t($,ht),t($,_e),t(_e,pt),m(e,xe,d),m(e,S,d),x(Z,S,null),t(S,mt),t(S,ge),t(ge,_t),Ie=!0},p(e,[d]){const ee={};d&2&&(ee.$$scope={dirty:d,ctx:e}),z.$set(ee)},i(e){Ie||(I(v.$$.fragment,e),I(X.$$.fragment,e),I(B.$$.fragment,e),I(F.$$.fragment,e),I(W.$$.fragment,e),I(z.$$.fragment,e),I(G.$$.fragment,e),I(H.$$.fragment,e),I(Y.$$.fragment,e),I(Z.$$.fragment,e),Ie=!0)},o(e){J(v.$$.fragment,e),J(X.$$.fragment,e),J(B.$$.fragment,e),J(F.$$.fragment,e),J(W.$$.fragment,e),J(z.$$.fragment,e),J(G.$$.fragment,e),J(H.$$.fragment,e),J(Y.$$.fragment,e),J(Z.$$.fragment,e),Ie=!1},d(e){s(p),e&&s(V),e&&s(_),U(v),e&&s(M),e&&s(y),e&&s(ve),e&&s(te),e&&s(ye),e&&s(se),e&&s(Te),e&&s(D),U(X),e&&s(Ce),e&&s(h),U(B),U(F),U(W),U(z),U(G),U(H),e&&s(be),e&&s($),U(Y),e&&s(xe),e&&s(S),U(Z)}}}const Gt={local:"vqdiffusionscheduler",sections:[{local:"diffusers.VQDiffusionScheduler",title:"VQDiffusionScheduler"},{local:"diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput",title:"VQDiffusionSchedulerOutput"}],title:"VQDiffusionScheduler"};function Ht(we){return Pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ss extends zt{constructor(p){super();Lt(this,p,Ht,Wt,Ot,{})}}export{ss as default,Gt as metadata};
