import{S as us,i as hs,s as fs,e as n,k as d,w as _,t as l,M as gs,c as a,d as s,m,a as o,x as w,h as i,b as r,G as t,g as p,y as M,q as T,o as J,B as v,v as bs,L as ys}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Ae}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as ms}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as He}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as _s}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function ws(ve){let h,N,b,f,I;return f=new ms({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lJTBBJTBBZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQSUyMyUyMExvYWQlMjB0aGUlMjBjZF9pbWFnZW5ldDY0X2wyJTIwY2hlY2twb2ludC4lMEFtb2RlbF9pZF9vcl9wYXRoJTIwJTNEJTIwJTIyb3BlbmFpJTJGZGlmZnVzZXJzLWNkX2ltYWdlbmV0NjRfbDIlMjIlMEFwaXBlJTIwJTNEJTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZF9vcl9wYXRoJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUudG8oZGV2aWNlKSUwQSUwQSUyMyUyME9uZXN0ZXAlMjBTYW1wbGluZyUwQWltYWdlJTIwJTNEJTIwcGlwZShudW1faW5mZXJlbmNlX3N0ZXBzJTNEMSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyY2RfaW1hZ2VuZXQ2NF9sMl9vbmVzdGVwX3NhbXBsZS5wbmclMjIpJTBBJTBBJTIzJTIwT25lc3RlcCUyMHNhbXBsaW5nJTJDJTIwY2xhc3MtY29uZGl0aW9uYWwlMjBpbWFnZSUyMGd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s-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"),N=l("Examples:"),b=d(),_(f.$$.fragment)},l(u){h=a(u,"P",{});var j=o(h);N=i(j,"Examples:"),j.forEach(s),b=m(u),w(f.$$.fragment,u)},m(u,j){p(u,h,j),t(h,N),p(u,b,j),M(f,u,j),I=!0},p:ys,i(u){I||(T(f.$$.fragment,u),I=!0)},o(u){J(f.$$.fragment,u),I=!1},d(u){u&&s(h),u&&s(b),v(f,u)}}}function Ms(ve){let h,N,b,f,I,u,j,pe,qe,Ie,W,Le,S,Qe,Oe,je,oe,Ke,Ue,le,de,et,Be,U,tt,R,st,nt,D,at,ot,Ce,B,lt,A,it,rt,H,ct,pt,Ge,G,P,me,q,dt,ue,mt,Ze,x,ut,he,ht,ft,$e,L,Ee,Z,k,fe,Q,gt,ge,bt,Ne,g,O,yt,be,_t,wt,K,Mt,ie,Tt,Jt,vt,Y,ee,It,V,jt,F,te,Ut,y,Bt,ye,Ct,Gt,_e,Zt,$t,we,Et,Nt,We,$,X,Me,se,Wt,Te,Pt,Pe,E,ne,xt,Je,kt,xe;return u=new He({}),q=new He({}),L=new ms({props:{code:"JTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMjAlMjBmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29uc2lzdGVuY3lNb2RlbFBpcGVsaW5lJTBBJTBBJTIwJTIwZGV2aWNlJTIwJTNEJTIwJTIyY3VkYSUyMiUwQSUyMCUyMCUyMyUyMExvYWQlMjB0aGUlMjBjZF9iZW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MCUyMCUyMGltYWdlLnNob3coKQ==",highlighted:`  import torch
  from diffusers import 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()`}}),Q=new He({}),O=new Ae({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/main/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/main/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/main/en/api/schedulers/cm_stochastic_iterative#diffusers.CMStochasticIterativeScheduler">CMStochasticIterativeScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/consistency_models/pipeline_consistency_models.py#L51"}}),ee=new Ae({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/main/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/main/src/diffusers/pipelines/consistency_models/pipeline_consistency_models.py#L181",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/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/main/en/api/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),V=new _s({props:{anchor:"diffusers.ConsistencyModelPipeline.__call__.example",$$slots:{default:[ws]},$$scope:{ctx:ve}}}),te=new Ae({props:{name:"enable_model_cpu_offload",anchor:"diffusers.ConsistencyModelPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/consistency_models/pipeline_consistency_models.py#L76"}}),se=new He({}),ne=new Ae({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#L112"}}),{c(){h=n("meta"),N=d(),b=n("h1"),f=n("a"),I=n("span"),_(u.$$.fragment),j=d(),pe=n("span"),qe=l("Consistency Models"),Ie=d(),W=n("p"),Le=l("Consistency Models were proposed in "),S=n("a"),Qe=l("Consistency Models"),Oe=l(" by Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever."),je=d(),oe=n("p"),Ke=l("The abstract from the paper is:"),Ue=d(),le=n("p"),de=n("em"),et=l("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."),Be=d(),U=n("p"),tt=l("The original codebase can be found at "),R=n("a"),st=l("openai/consistency_models"),nt=l(", and additional checkpoints are available at "),D=n("a"),at=l("openai"),ot=l("."),Ce=d(),B=n("p"),lt=l("The pipeline was contributed by "),A=n("a"),it=l("dg845"),rt=l(" and "),H=n("a"),ct=l("ayushtues"),pt=l(". \u2764\uFE0F"),Ge=d(),G=n("h2"),P=n("a"),me=n("span"),_(q.$$.fragment),dt=d(),ue=n("span"),mt=l("Tips"),Ze=d(),x=n("p"),ut=l("For an additional speed-up, use "),he=n("code"),ht=l("torch.compile"),ft=l(" to generate multiple images in <1 second:"),$e=d(),_(L.$$.fragment),Ee=d(),Z=n("h2"),k=n("a"),fe=n("span"),_(Q.$$.fragment),gt=d(),ge=n("span"),bt=l("ConsistencyModelPipeline"),Ne=d(),g=n("div"),_(O.$$.fragment),yt=d(),be=n("p"),_t=l("Pipeline for unconditional or class-conditional image generation."),wt=d(),K=n("p"),Mt=l("This model inherits from "),ie=n("a"),Tt=l("DiffusionPipeline"),Jt=l(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),vt=d(),Y=n("div"),_(ee.$$.fragment),It=d(),_(V.$$.fragment),jt=d(),F=n("div"),_(te.$$.fragment),Ut=d(),y=n("p"),Bt=l(`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ye=n("code"),Ct=l("forward"),Gt=l(` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),_e=n("code"),Zt=l("enable_sequential_cpu_offload"),$t=l(`, but performance is much better due to the
iterative execution of the `),we=n("code"),Et=l("unet"),Nt=l("."),We=d(),$=n("h2"),X=n("a"),Me=n("span"),_(se.$$.fragment),Wt=d(),Te=n("span"),Pt=l("ImagePipelineOutput"),Pe=d(),E=n("div"),_(ne.$$.fragment),xt=d(),Je=n("p"),kt=l("Output class for image pipelines."),this.h()},l(e){const c=gs('[data-svelte="svelte-1phssyn"]',document.head);h=a(c,"META",{name:!0,content:!0}),c.forEach(s),N=m(e),b=a(e,"H1",{class:!0});var ae=o(b);f=a(ae,"A",{id:!0,class:!0,href:!0});var Yt=o(f);I=a(Yt,"SPAN",{});var Vt=o(I);w(u.$$.fragment,Vt),Vt.forEach(s),Yt.forEach(s),j=m(ae),pe=a(ae,"SPAN",{});var Ft=o(pe);qe=i(Ft,"Consistency Models"),Ft.forEach(s),ae.forEach(s),Ie=m(e),W=a(e,"P",{});var ke=o(W);Le=i(ke,"Consistency Models were proposed in "),S=a(ke,"A",{href:!0,rel:!0});var Xt=o(S);Qe=i(Xt,"Consistency Models"),Xt.forEach(s),Oe=i(ke," by Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever."),ke.forEach(s),je=m(e),oe=a(e,"P",{});var zt=o(oe);Ke=i(zt,"The abstract from the paper is:"),zt.forEach(s),Ue=m(e),le=a(e,"P",{});var St=o(le);de=a(St,"EM",{});var Rt=o(de);et=i(Rt,"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."),Rt.forEach(s),St.forEach(s),Be=m(e),U=a(e,"P",{});var re=o(U);tt=i(re,"The original codebase can be found at "),R=a(re,"A",{href:!0,rel:!0});var Dt=o(R);st=i(Dt,"openai/consistency_models"),Dt.forEach(s),nt=i(re,", and additional checkpoints are available at "),D=a(re,"A",{href:!0,rel:!0});var At=o(D);at=i(At,"openai"),At.forEach(s),ot=i(re,"."),re.forEach(s),Ce=m(e),B=a(e,"P",{});var ce=o(B);lt=i(ce,"The pipeline was contributed by "),A=a(ce,"A",{href:!0,rel:!0});var Ht=o(A);it=i(Ht,"dg845"),Ht.forEach(s),rt=i(ce," and "),H=a(ce,"A",{href:!0,rel:!0});var qt=o(H);ct=i(qt,"ayushtues"),qt.forEach(s),pt=i(ce,". \u2764\uFE0F"),ce.forEach(s),Ge=m(e),G=a(e,"H2",{class:!0});var Ye=o(G);P=a(Ye,"A",{id:!0,class:!0,href:!0});var Lt=o(P);me=a(Lt,"SPAN",{});var Qt=o(me);w(q.$$.fragment,Qt),Qt.forEach(s),Lt.forEach(s),dt=m(Ye),ue=a(Ye,"SPAN",{});var Ot=o(ue);mt=i(Ot,"Tips"),Ot.forEach(s),Ye.forEach(s),Ze=m(e),x=a(e,"P",{});var Ve=o(x);ut=i(Ve,"For an additional speed-up, use "),he=a(Ve,"CODE",{});var Kt=o(he);ht=i(Kt,"torch.compile"),Kt.forEach(s),ft=i(Ve," to generate multiple images in <1 second:"),Ve.forEach(s),$e=m(e),w(L.$$.fragment,e),Ee=m(e),Z=a(e,"H2",{class:!0});var Fe=o(Z);k=a(Fe,"A",{id:!0,class:!0,href:!0});var es=o(k);fe=a(es,"SPAN",{});var ts=o(fe);w(Q.$$.fragment,ts),ts.forEach(s),es.forEach(s),gt=m(Fe),ge=a(Fe,"SPAN",{});var ss=o(ge);bt=i(ss,"ConsistencyModelPipeline"),ss.forEach(s),Fe.forEach(s),Ne=m(e),g=a(e,"DIV",{class:!0});var C=o(g);w(O.$$.fragment,C),yt=m(C),be=a(C,"P",{});var ns=o(be);_t=i(ns,"Pipeline for unconditional or class-conditional image generation."),ns.forEach(s),wt=m(C),K=a(C,"P",{});var Xe=o(K);Mt=i(Xe,"This model inherits from "),ie=a(Xe,"A",{href:!0});var as=o(ie);Tt=i(as,"DiffusionPipeline"),as.forEach(s),Jt=i(Xe,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Xe.forEach(s),vt=m(C),Y=a(C,"DIV",{class:!0});var ze=o(Y);w(ee.$$.fragment,ze),It=m(ze),w(V.$$.fragment,ze),ze.forEach(s),jt=m(C),F=a(C,"DIV",{class:!0});var Se=o(F);w(te.$$.fragment,Se),Ut=m(Se),y=a(Se,"P",{});var z=o(y);Bt=i(z,`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ye=a(z,"CODE",{});var os=o(ye);Ct=i(os,"forward"),os.forEach(s),Gt=i(z,` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),_e=a(z,"CODE",{});var ls=o(_e);Zt=i(ls,"enable_sequential_cpu_offload"),ls.forEach(s),$t=i(z,`, but performance is much better due to the
iterative execution of the `),we=a(z,"CODE",{});var is=o(we);Et=i(is,"unet"),is.forEach(s),Nt=i(z,"."),z.forEach(s),Se.forEach(s),C.forEach(s),We=m(e),$=a(e,"H2",{class:!0});var Re=o($);X=a(Re,"A",{id:!0,class:!0,href:!0});var rs=o(X);Me=a(rs,"SPAN",{});var cs=o(Me);w(se.$$.fragment,cs),cs.forEach(s),rs.forEach(s),Wt=m(Re),Te=a(Re,"SPAN",{});var ps=o(Te);Pt=i(ps,"ImagePipelineOutput"),ps.forEach(s),Re.forEach(s),Pe=m(e),E=a(e,"DIV",{class:!0});var De=o(E);w(ne.$$.fragment,De),xt=m(De),Je=a(De,"P",{});var ds=o(Je);kt=i(ds,"Output class for image pipelines."),ds.forEach(s),De.forEach(s),this.h()},h(){r(h,"name","hf:doc:metadata"),r(h,"content",JSON.stringify(Ts)),r(f,"id","consistency-models"),r(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"),r(f,"href","#consistency-models"),r(b,"class","relative group"),r(S,"href","https://huggingface.co/papers/2303.01469"),r(S,"rel","nofollow"),r(R,"href","https://github.com/openai/consistency_models"),r(R,"rel","nofollow"),r(D,"href","https://huggingface.co/openai"),r(D,"rel","nofollow"),r(A,"href","https://github.com/dg845"),r(A,"rel","nofollow"),r(H,"href","https://huggingface.co/ayushtues"),r(H,"rel","nofollow"),r(P,"id","tips"),r(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"),r(P,"href","#tips"),r(G,"class","relative group"),r(k,"id","diffusers.ConsistencyModelPipeline"),r(k,"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"),r(k,"href","#diffusers.ConsistencyModelPipeline"),r(Z,"class","relative group"),r(ie,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),r(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(X,"id","diffusers.ImagePipelineOutput"),r(X,"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"),r(X,"href","#diffusers.ImagePipelineOutput"),r($,"class","relative group"),r(E,"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,c){t(document.head,h),p(e,N,c),p(e,b,c),t(b,f),t(f,I),M(u,I,null),t(b,j),t(b,pe),t(pe,qe),p(e,Ie,c),p(e,W,c),t(W,Le),t(W,S),t(S,Qe),t(W,Oe),p(e,je,c),p(e,oe,c),t(oe,Ke),p(e,Ue,c),p(e,le,c),t(le,de),t(de,et),p(e,Be,c),p(e,U,c),t(U,tt),t(U,R),t(R,st),t(U,nt),t(U,D),t(D,at),t(U,ot),p(e,Ce,c),p(e,B,c),t(B,lt),t(B,A),t(A,it),t(B,rt),t(B,H),t(H,ct),t(B,pt),p(e,Ge,c),p(e,G,c),t(G,P),t(P,me),M(q,me,null),t(G,dt),t(G,ue),t(ue,mt),p(e,Ze,c),p(e,x,c),t(x,ut),t(x,he),t(he,ht),t(x,ft),p(e,$e,c),M(L,e,c),p(e,Ee,c),p(e,Z,c),t(Z,k),t(k,fe),M(Q,fe,null),t(Z,gt),t(Z,ge),t(ge,bt),p(e,Ne,c),p(e,g,c),M(O,g,null),t(g,yt),t(g,be),t(be,_t),t(g,wt),t(g,K),t(K,Mt),t(K,ie),t(ie,Tt),t(K,Jt),t(g,vt),t(g,Y),M(ee,Y,null),t(Y,It),M(V,Y,null),t(g,jt),t(g,F),M(te,F,null),t(F,Ut),t(F,y),t(y,Bt),t(y,ye),t(ye,Ct),t(y,Gt),t(y,_e),t(_e,Zt),t(y,$t),t(y,we),t(we,Et),t(y,Nt),p(e,We,c),p(e,$,c),t($,X),t(X,Me),M(se,Me,null),t($,Wt),t($,Te),t(Te,Pt),p(e,Pe,c),p(e,E,c),M(ne,E,null),t(E,xt),t(E,Je),t(Je,kt),xe=!0},p(e,[c]){const ae={};c&2&&(ae.$$scope={dirty:c,ctx:e}),V.$set(ae)},i(e){xe||(T(u.$$.fragment,e),T(q.$$.fragment,e),T(L.$$.fragment,e),T(Q.$$.fragment,e),T(O.$$.fragment,e),T(ee.$$.fragment,e),T(V.$$.fragment,e),T(te.$$.fragment,e),T(se.$$.fragment,e),T(ne.$$.fragment,e),xe=!0)},o(e){J(u.$$.fragment,e),J(q.$$.fragment,e),J(L.$$.fragment,e),J(Q.$$.fragment,e),J(O.$$.fragment,e),J(ee.$$.fragment,e),J(V.$$.fragment,e),J(te.$$.fragment,e),J(se.$$.fragment,e),J(ne.$$.fragment,e),xe=!1},d(e){s(h),e&&s(N),e&&s(b),v(u),e&&s(Ie),e&&s(W),e&&s(je),e&&s(oe),e&&s(Ue),e&&s(le),e&&s(Be),e&&s(U),e&&s(Ce),e&&s(B),e&&s(Ge),e&&s(G),v(q),e&&s(Ze),e&&s(x),e&&s($e),v(L,e),e&&s(Ee),e&&s(Z),v(Q),e&&s(Ne),e&&s(g),v(O),v(ee),v(V),v(te),e&&s(We),e&&s($),v(se),e&&s(Pe),e&&s(E),v(ne)}}}const Ts={local:"consistency-models",sections:[{local:"tips",title:"Tips"},{local:"diffusers.ConsistencyModelPipeline",title:"ConsistencyModelPipeline"},{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"Consistency Models"};function Js(ve){return bs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cs extends us{constructor(h){super();hs(this,h,Js,Ms,fs,{})}}export{Cs as default,Ts as metadata};
