import{S as At,i as Ht,s as Lt,e as n,k as m,w as T,t as r,M as qt,c as a,d as t,m as u,a as l,x as J,h as p,b as i,G as s,g as c,y as v,q as I,o as j,B,v as Qt,L as Ot}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Mt}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Dt}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ye}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Kt}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function es(ye){let h,$,g,f,b;return f=new Dt({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQSUyMyUyMExvYWQlMjB0aGUlMjBjZF9pbWFnZW5ldDY0X2wyJTIwY2hlY2twb2ludC4lMEFtb2RlbF9pZF9vcl9wYXRoJTIwJTNEJTIwJTIyb3BlbmFpJTJGZGlmZnVzZXJzLWNkX2ltYWdlbmV0NjRfbDIlMjIlMEFwaXBlJTIwJTNEJTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZF9vcl9wYXRoJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUudG8oZGV2aWNlKSUwQSUwQSUyMyUyME9uZXN0ZXAlMjBTYW1wbGluZyUwQWltYWdlJTIwJTNEJTIwcGlwZShudW1faW5mZXJlbmNlX3N0ZXBzJTNEMSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyY2RfaW1hZ2VuZXQ2NF9sMl9vbmVzdGVwX3NhbXBsZS5wbmclMjIpJTBBJTBBJTIzJTIwT25lc3RlcCUyMHNhbXBsaW5nJTJDJTIwY2xhc3MtY29uZGl0aW9uYWwlMjBpbWF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</span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ConsistencyModelPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Load the cd_imagenet64_l2 checkpoint.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_id_or_path = <span class="hljs-string">&quot;openai/diffusers-cd_imagenet64_l2&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = ConsistencyModelPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Onestep Sampling</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(num_inference_steps=<span class="hljs-number">1</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;cd_imagenet64_l2_onestep_sample.png&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Onestep sampling, class-conditional image generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ImageNet-64 class label 145 corresponds to king penguins</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(num_inference_steps=<span class="hljs-number">1</span>, class_labels=<span class="hljs-number">145</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;cd_imagenet64_l2_onestep_sample_penguin.png&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Multistep sampling, class-conditional image generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Timesteps can be explicitly specified; the particular timesteps below are from the original Github repo:</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># https://github.com/openai/consistency_models/blob/main/scripts/launch.sh#L77</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(num_inference_steps=<span class="hljs-literal">None</span>, timesteps=[<span class="hljs-number">22</span>, <span class="hljs-number">0</span>], class_labels=<span class="hljs-number">145</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;cd_imagenet64_l2_multistep_sample_penguin.png&quot;</span>)`}}),{c(){h=n("p"),$=r("Examples:"),g=m(),T(f.$$.fragment)},l(d){h=a(d,"P",{});var _=l(h);$=p(_,"Examples:"),_.forEach(t),g=u(d),J(f.$$.fragment,d)},m(d,_){c(d,h,_),s(h,$),c(d,g,_),v(f,d,_),b=!0},p:Ot,i(d){b||(I(f.$$.fragment,d),b=!0)},o(d){j(f.$$.fragment,d),b=!1},d(d){d&&t(h),d&&t(g),B(f,d)}}}function ts(ye){let h,$,g,f,b,d,_,oe,Ve,be,N,Fe,F,Xe,ze,_e,te,Se,we,se,ie,Re,Me,w,De,X,Ae,He,z,Le,qe,Te,M,Qe,S,Oe,Ke,R,et,tt,Je,Z,W,re,D,st,pe,nt,ve,E,at,ce,lt,ot,Ie,A,je,U,P,de,H,it,me,rt,Be,y,L,pt,ue,ct,dt,q,mt,ne,ut,ht,ft,x,Q,gt,k,Ze,G,Y,he,O,yt,fe,bt,Ue,C,K,_t,ge,wt,Ge;return d=new Ye({}),D=new Ye({}),A=new Dt({props:{code:"JTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMjAlMjBmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lJTBBJTBBJTIwJTIwZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQSUyMCUyMCUyMyUyMExvYWQlMjB0aGUlMjBjZF9iZWRyb29tMjU2X2xwaXBzJTIwY2hlY2twb2ludC4lMEElMjAlMj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ConsistencyModelPipeline

  device = &quot;cuda&quot;
  # Load the cd_bedroom256_lpips checkpoint.
  model_id_or_path = &quot;openai/diffusers-cd_bedroom256_lpips&quot;
  pipe = ConsistencyModelPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
  pipe.to(device)

<span class="hljs-addition">+ pipe.unet = torch.compile(pipe.unet, mode=&quot;reduce-overhead&quot;, fullgraph=True)</span>

  # Multistep sampling
  # Timesteps can be explicitly specified; the particular timesteps below are from the original Github repo:
  # https://github.com/openai/consistency_models/blob/main/scripts/launch.sh#L83
  for _ in range(10):
      image = pipe(timesteps=[17, 0]).images[0]
      image.show()`}}),H=new Ye({}),L=new Mt({props:{name:"class diffusers.ConsistencyModelPipeline",anchor:"diffusers.ConsistencyModelPipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": CMStochasticIterativeScheduler"}],parametersDescription:[{anchor:"diffusers.ConsistencyModelPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.21.0/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.ConsistencyModelPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.21.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Currently only
compatible with <a href="/docs/diffusers/v0.21.0/en/api/schedulers/cm_stochastic_iterative#diffusers.CMStochasticIterativeScheduler">CMStochasticIterativeScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/consistency_models/pipeline_consistency_models.py#L49"}}),Q=new Mt({props:{name:"__call__",anchor:"diffusers.ConsistencyModelPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"class_labels",val:": typing.Union[torch.Tensor, typing.List[int], int, NoneType] = None"},{name:"num_inference_steps",val:": int = 1"},{name:"timesteps",val:": typing.List[int] = None"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"}],parametersDescription:[{anchor:"diffusers.ConsistencyModelPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate.`,name:"batch_size"},{anchor:"diffusers.ConsistencyModelPipeline.__call__.class_labels",description:`<strong>class_labels</strong> (<code>torch.Tensor</code> or <code>List[int]</code> or <code>int</code>, <em>optional</em>) &#x2014;
Optional class labels for conditioning class-conditional consistency models. Not used if the model is
not class-conditional.`,name:"class_labels"},{anchor:"diffusers.ConsistencyModelPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#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.ConsistencyModelPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps to use for the denoising process. If not defined, equal spaced <code>num_inference_steps</code>
timesteps are used. Must be in descending order.`,name:"timesteps"},{anchor:"diffusers.ConsistencyModelPipeline.__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.ConsistencyModelPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.ConsistencyModelPipeline.__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.ConsistencyModelPipeline.__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/v0.21.0/en/api/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.ConsistencyModelPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.ConsistencyModelPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function is called. If not specified, the callback is called at
every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/consistency_models/pipeline_consistency_models.py#L152",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.21.0/en/api/pipelines/latent_diffusion_uncond#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:`
<p><a
  href="/docs/diffusers/v0.21.0/en/api/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),k=new Kt({props:{anchor:"diffusers.ConsistencyModelPipeline.__call__.example",$$slots:{default:[es]},$$scope:{ctx:ye}}}),O=new Ye({}),K=new Mt({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/v0.21.0/src/diffusers/pipelines/pipeline_utils.py#L112"}}),{c(){h=n("meta"),$=m(),g=n("h1"),f=n("a"),b=n("span"),T(d.$$.fragment),_=m(),oe=n("span"),Ve=r("Consistency Models"),be=m(),N=n("p"),Fe=r("Consistency Models were proposed in "),F=n("a"),Xe=r("Consistency Models"),ze=r(" by Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever."),_e=m(),te=n("p"),Se=r("The abstract from the paper is:"),we=m(),se=n("p"),ie=n("em"),Re=r("Diffusion models have significantly advanced the fields of image, audio, and video generation, but they depend on an iterative sampling process that causes slow generation. To overcome this limitation, we propose consistency models, a new family of models that generate high quality samples by directly mapping noise to data. They support fast one-step generation by design, while still allowing multistep sampling to trade compute for sample quality. They also support zero-shot data editing, such as image inpainting, colorization, and super-resolution, without requiring explicit training on these tasks. Consistency models can be trained either by distilling pre-trained diffusion models, or as standalone generative models altogether. Through extensive experiments, we demonstrate that they outperform existing distillation techniques for diffusion models in one- and few-step sampling, achieving the new state-of-the-art FID of 3.55 on CIFAR-10 and 6.20 on ImageNet 64x64 for one-step generation. When trained in isolation, consistency models become a new family of generative models that can outperform existing one-step, non-adversarial generative models on standard benchmarks such as CIFAR-10, ImageNet 64x64 and LSUN 256x256."),Me=m(),w=n("p"),De=r("The original codebase can be found at "),X=n("a"),Ae=r("openai/consistency_models"),He=r(", and additional checkpoints are available at "),z=n("a"),Le=r("openai"),qe=r("."),Te=m(),M=n("p"),Qe=r("The pipeline was contributed by "),S=n("a"),Oe=r("dg845"),Ke=r(" and "),R=n("a"),et=r("ayushtues"),tt=r(". \u2764\uFE0F"),Je=m(),Z=n("h2"),W=n("a"),re=n("span"),T(D.$$.fragment),st=m(),pe=n("span"),nt=r("Tips"),ve=m(),E=n("p"),at=r("For an additional speed-up, use "),ce=n("code"),lt=r("torch.compile"),ot=r(" to generate multiple images in <1 second:"),Ie=m(),T(A.$$.fragment),je=m(),U=n("h2"),P=n("a"),de=n("span"),T(H.$$.fragment),it=m(),me=n("span"),rt=r("ConsistencyModelPipeline"),Be=m(),y=n("div"),T(L.$$.fragment),pt=m(),ue=n("p"),ct=r("Pipeline for unconditional or class-conditional image generation."),dt=m(),q=n("p"),mt=r("This model inherits from "),ne=n("a"),ut=r("DiffusionPipeline"),ht=r(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ft=m(),x=n("div"),T(Q.$$.fragment),gt=m(),T(k.$$.fragment),Ze=m(),G=n("h2"),Y=n("a"),he=n("span"),T(O.$$.fragment),yt=m(),fe=n("span"),bt=r("ImagePipelineOutput"),Ue=m(),C=n("div"),T(K.$$.fragment),_t=m(),ge=n("p"),wt=r("Output class for image pipelines."),this.h()},l(e){const o=qt('[data-svelte="svelte-1phssyn"]',document.head);h=a(o,"META",{name:!0,content:!0}),o.forEach(t),$=u(e),g=a(e,"H1",{class:!0});var ee=l(g);f=a(ee,"A",{id:!0,class:!0,href:!0});var Tt=l(f);b=a(Tt,"SPAN",{});var Jt=l(b);J(d.$$.fragment,Jt),Jt.forEach(t),Tt.forEach(t),_=u(ee),oe=a(ee,"SPAN",{});var vt=l(oe);Ve=p(vt,"Consistency Models"),vt.forEach(t),ee.forEach(t),be=u(e),N=a(e,"P",{});var Ce=l(N);Fe=p(Ce,"Consistency Models were proposed in "),F=a(Ce,"A",{href:!0,rel:!0});var It=l(F);Xe=p(It,"Consistency Models"),It.forEach(t),ze=p(Ce," by Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever."),Ce.forEach(t),_e=u(e),te=a(e,"P",{});var jt=l(te);Se=p(jt,"The abstract from the paper is:"),jt.forEach(t),we=u(e),se=a(e,"P",{});var Bt=l(se);ie=a(Bt,"EM",{});var Zt=l(ie);Re=p(Zt,"Diffusion models have significantly advanced the fields of image, audio, and video generation, but they depend on an iterative sampling process that causes slow generation. To overcome this limitation, we propose consistency models, a new family of models that generate high quality samples by directly mapping noise to data. They support fast one-step generation by design, while still allowing multistep sampling to trade compute for sample quality. They also support zero-shot data editing, such as image inpainting, colorization, and super-resolution, without requiring explicit training on these tasks. Consistency models can be trained either by distilling pre-trained diffusion models, or as standalone generative models altogether. Through extensive experiments, we demonstrate that they outperform existing distillation techniques for diffusion models in one- and few-step sampling, achieving the new state-of-the-art FID of 3.55 on CIFAR-10 and 6.20 on ImageNet 64x64 for one-step generation. When trained in isolation, consistency models become a new family of generative models that can outperform existing one-step, non-adversarial generative models on standard benchmarks such as CIFAR-10, ImageNet 64x64 and LSUN 256x256."),Zt.forEach(t),Bt.forEach(t),Me=u(e),w=a(e,"P",{});var ae=l(w);De=p(ae,"The original codebase can be found at "),X=a(ae,"A",{href:!0,rel:!0});var Ut=l(X);Ae=p(Ut,"openai/consistency_models"),Ut.forEach(t),He=p(ae,", and additional checkpoints are available at "),z=a(ae,"A",{href:!0,rel:!0});var Gt=l(z);Le=p(Gt,"openai"),Gt.forEach(t),qe=p(ae,"."),ae.forEach(t),Te=u(e),M=a(e,"P",{});var le=l(M);Qe=p(le,"The pipeline was contributed by "),S=a(le,"A",{href:!0,rel:!0});var Ct=l(S);Oe=p(Ct,"dg845"),Ct.forEach(t),Ke=p(le," and "),R=a(le,"A",{href:!0,rel:!0});var $t=l(R);et=p($t,"ayushtues"),$t.forEach(t),tt=p(le,". \u2764\uFE0F"),le.forEach(t),Je=u(e),Z=a(e,"H2",{class:!0});var $e=l(Z);W=a($e,"A",{id:!0,class:!0,href:!0});var Nt=l(W);re=a(Nt,"SPAN",{});var Wt=l(re);J(D.$$.fragment,Wt),Wt.forEach(t),Nt.forEach(t),st=u($e),pe=a($e,"SPAN",{});var Et=l(pe);nt=p(Et,"Tips"),Et.forEach(t),$e.forEach(t),ve=u(e),E=a(e,"P",{});var Ne=l(E);at=p(Ne,"For an additional speed-up, use "),ce=a(Ne,"CODE",{});var Pt=l(ce);lt=p(Pt,"torch.compile"),Pt.forEach(t),ot=p(Ne," to generate multiple images in <1 second:"),Ne.forEach(t),Ie=u(e),J(A.$$.fragment,e),je=u(e),U=a(e,"H2",{class:!0});var We=l(U);P=a(We,"A",{id:!0,class:!0,href:!0});var xt=l(P);de=a(xt,"SPAN",{});var kt=l(de);J(H.$$.fragment,kt),kt.forEach(t),xt.forEach(t),it=u(We),me=a(We,"SPAN",{});var Yt=l(me);rt=p(Yt,"ConsistencyModelPipeline"),Yt.forEach(t),We.forEach(t),Be=u(e),y=a(e,"DIV",{class:!0});var V=l(y);J(L.$$.fragment,V),pt=u(V),ue=a(V,"P",{});var Vt=l(ue);ct=p(Vt,"Pipeline for unconditional or class-conditional image generation."),Vt.forEach(t),dt=u(V),q=a(V,"P",{});var Ee=l(q);mt=p(Ee,"This model inherits from "),ne=a(Ee,"A",{href:!0});var Ft=l(ne);ut=p(Ft,"DiffusionPipeline"),Ft.forEach(t),ht=p(Ee,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ee.forEach(t),ft=u(V),x=a(V,"DIV",{class:!0});var Pe=l(x);J(Q.$$.fragment,Pe),gt=u(Pe),J(k.$$.fragment,Pe),Pe.forEach(t),V.forEach(t),Ze=u(e),G=a(e,"H2",{class:!0});var xe=l(G);Y=a(xe,"A",{id:!0,class:!0,href:!0});var Xt=l(Y);he=a(Xt,"SPAN",{});var zt=l(he);J(O.$$.fragment,zt),zt.forEach(t),Xt.forEach(t),yt=u(xe),fe=a(xe,"SPAN",{});var St=l(fe);bt=p(St,"ImagePipelineOutput"),St.forEach(t),xe.forEach(t),Ue=u(e),C=a(e,"DIV",{class:!0});var ke=l(C);J(K.$$.fragment,ke),_t=u(ke),ge=a(ke,"P",{});var Rt=l(ge);wt=p(Rt,"Output class for image pipelines."),Rt.forEach(t),ke.forEach(t),this.h()},h(){i(h,"name","hf:doc:metadata"),i(h,"content",JSON.stringify(ss)),i(f,"id","consistency-models"),i(f,"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"),i(f,"href","#consistency-models"),i(g,"class","relative group"),i(F,"href","https://huggingface.co/papers/2303.01469"),i(F,"rel","nofollow"),i(X,"href","https://github.com/openai/consistency_models"),i(X,"rel","nofollow"),i(z,"href","https://huggingface.co/openai"),i(z,"rel","nofollow"),i(S,"href","https://github.com/dg845"),i(S,"rel","nofollow"),i(R,"href","https://huggingface.co/ayushtues"),i(R,"rel","nofollow"),i(W,"id","tips"),i(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"),i(W,"href","#tips"),i(Z,"class","relative group"),i(P,"id","diffusers.ConsistencyModelPipeline"),i(P,"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"),i(P,"href","#diffusers.ConsistencyModelPipeline"),i(U,"class","relative group"),i(ne,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),i(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(Y,"id","diffusers.ImagePipelineOutput"),i(Y,"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"),i(Y,"href","#diffusers.ImagePipelineOutput"),i(G,"class","relative group"),i(C,"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,o){s(document.head,h),c(e,$,o),c(e,g,o),s(g,f),s(f,b),v(d,b,null),s(g,_),s(g,oe),s(oe,Ve),c(e,be,o),c(e,N,o),s(N,Fe),s(N,F),s(F,Xe),s(N,ze),c(e,_e,o),c(e,te,o),s(te,Se),c(e,we,o),c(e,se,o),s(se,ie),s(ie,Re),c(e,Me,o),c(e,w,o),s(w,De),s(w,X),s(X,Ae),s(w,He),s(w,z),s(z,Le),s(w,qe),c(e,Te,o),c(e,M,o),s(M,Qe),s(M,S),s(S,Oe),s(M,Ke),s(M,R),s(R,et),s(M,tt),c(e,Je,o),c(e,Z,o),s(Z,W),s(W,re),v(D,re,null),s(Z,st),s(Z,pe),s(pe,nt),c(e,ve,o),c(e,E,o),s(E,at),s(E,ce),s(ce,lt),s(E,ot),c(e,Ie,o),v(A,e,o),c(e,je,o),c(e,U,o),s(U,P),s(P,de),v(H,de,null),s(U,it),s(U,me),s(me,rt),c(e,Be,o),c(e,y,o),v(L,y,null),s(y,pt),s(y,ue),s(ue,ct),s(y,dt),s(y,q),s(q,mt),s(q,ne),s(ne,ut),s(q,ht),s(y,ft),s(y,x),v(Q,x,null),s(x,gt),v(k,x,null),c(e,Ze,o),c(e,G,o),s(G,Y),s(Y,he),v(O,he,null),s(G,yt),s(G,fe),s(fe,bt),c(e,Ue,o),c(e,C,o),v(K,C,null),s(C,_t),s(C,ge),s(ge,wt),Ge=!0},p(e,[o]){const ee={};o&2&&(ee.$$scope={dirty:o,ctx:e}),k.$set(ee)},i(e){Ge||(I(d.$$.fragment,e),I(D.$$.fragment,e),I(A.$$.fragment,e),I(H.$$.fragment,e),I(L.$$.fragment,e),I(Q.$$.fragment,e),I(k.$$.fragment,e),I(O.$$.fragment,e),I(K.$$.fragment,e),Ge=!0)},o(e){j(d.$$.fragment,e),j(D.$$.fragment,e),j(A.$$.fragment,e),j(H.$$.fragment,e),j(L.$$.fragment,e),j(Q.$$.fragment,e),j(k.$$.fragment,e),j(O.$$.fragment,e),j(K.$$.fragment,e),Ge=!1},d(e){t(h),e&&t($),e&&t(g),B(d),e&&t(be),e&&t(N),e&&t(_e),e&&t(te),e&&t(we),e&&t(se),e&&t(Me),e&&t(w),e&&t(Te),e&&t(M),e&&t(Je),e&&t(Z),B(D),e&&t(ve),e&&t(E),e&&t(Ie),B(A,e),e&&t(je),e&&t(U),B(H),e&&t(Be),e&&t(y),B(L),B(Q),B(k),e&&t(Ze),e&&t(G),B(O),e&&t(Ue),e&&t(C),B(K)}}}const ss={local:"consistency-models",sections:[{local:"tips",title:"Tips"},{local:"diffusers.ConsistencyModelPipeline",title:"ConsistencyModelPipeline"},{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"Consistency Models"};function ns(ye){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ps extends At{constructor(h){super();Ht(this,h,ns,ts,Lt,{})}}export{ps as default,ss as metadata};
