import{s as ds,o as fs,n as ue}from"../chunks/scheduler.182ea377.js";import{S as ms,i as hs,g as f,s as i,r as h,A as Ms,h as m,f as l,c as r,j as us,u as M,x as J,k as Ye,y as ys,a as t,v as y,d as b,t as w,w as g}from"../chunks/index.abf12888.js";import{T as bs}from"../chunks/Tip.230e2334.js";import{C as $}from"../chunks/CodeBlock.57fe6e13.js";import{D as ws}from"../chunks/DocNotebookDropdown.5fa27ace.js";import{H as ce}from"../chunks/Heading.16916d63.js";import{H as gs,a as qe}from"../chunks/HfOption.fc88c804.js";function Us(Z){let n,U='<a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a> typically generates higher quality images than the default scheduler.',c,o,u;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExNU0Rpc2NyZXRlU2NoZWR1bGVyJTBBJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwTE1TRGlzY3JldGVTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvcikuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LMSDiscreteScheduler

pipeline.scheduler = LMSDiscreteScheduler.from_config(pipeline.scheduler.config)
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=U,c=i(),h(o.$$.fragment)},l(a){n=m(a,"P",{"data-svelte-h":!0}),J(n)!=="svelte-1u7n96v"&&(n.innerHTML=U),c=r(a),M(o.$$.fragment,a)},m(a,d){t(a,n,d),t(a,c,d),y(o,a,d),u=!0},p:ue,i(a){u||(b(o.$$.fragment,a),u=!0)},o(a){w(o.$$.fragment,a),u=!1},d(a){a&&(l(n),l(c)),g(o,a)}}}function Js(Z){let n,U='<a href="/docs/diffusers/main/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a> can generate higher quality images in just 30 steps.',c,o,u;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEV1bGVyRGlzY3JldGVTY2hlZHVsZXIlMEElMEFwaXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBFdWxlckRpc2NyZXRlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> EulerDiscreteScheduler

pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=U,c=i(),h(o.$$.fragment)},l(a){n=m(a,"P",{"data-svelte-h":!0}),J(n)!=="svelte-1aj8vh5"&&(n.innerHTML=U),c=r(a),M(o.$$.fragment,a)},m(a,d){t(a,n,d),t(a,c,d),y(o,a,d),u=!0},p:ue,i(a){u||(b(o.$$.fragment,a),u=!0)},o(a){w(o.$$.fragment,a),u=!1},d(a){a&&(l(n),l(c)),g(o,a)}}}function Ts(Z){let n,U='<a href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler">EulerAncestralDiscreteScheduler</a> can generate higher quality images in just 30 steps.',c,o,u;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEV1bGVyQW5jZXN0cmFsRGlzY3JldGVTY2hlZHVsZXIlMEElMEFwaXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBFdWxlckFuY2VzdHJhbERpc2NyZXRlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> EulerAncestralDiscreteScheduler

pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(pipeline.scheduler.config)
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=U,c=i(),h(o.$$.fragment)},l(a){n=m(a,"P",{"data-svelte-h":!0}),J(n)!=="svelte-e3tbp7"&&(n.innerHTML=U),c=r(a),M(o.$$.fragment,a)},m(a,d){t(a,n,d),t(a,c,d),y(o,a,d),u=!0},p:ue,i(a){u||(b(o.$$.fragment,a),u=!0)},o(a){w(o.$$.fragment,a),u=!1},d(a){a&&(l(n),l(c)),g(o,a)}}}function Zs(Z){let n,U='<a href="/docs/diffusers/main/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler">DPMSolverMultistepScheduler</a> provides a balance between speed and quality and can generate higher quality images in just 20 steps.',c,o,u;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlciUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlci5mcm9tX2NvbmZpZyhwaXBlbGluZS5zY2hlZHVsZXIuY29uZmlnKSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler

pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=U,c=i(),h(o.$$.fragment)},l(a){n=m(a,"P",{"data-svelte-h":!0}),J(n)!=="svelte-1coadql"&&(n.innerHTML=U),c=r(a),M(o.$$.fragment,a)},m(a,d){t(a,n,d),t(a,c,d),y(o,a,d),u=!0},p:ue,i(a){u||(b(o.$$.fragment,a),u=!0)},o(a){w(o.$$.fragment,a),u=!1},d(a){a&&(l(n),l(c)),g(o,a)}}}function $s(Z){let n,U,c,o,u,a,d,v;return n=new qe({props:{id:"schedulers",option:"LMSDiscreteScheduler",$$slots:{default:[Us]},$$scope:{ctx:Z}}}),c=new qe({props:{id:"schedulers",option:"EulerDiscreteScheduler",$$slots:{default:[Js]},$$scope:{ctx:Z}}}),u=new qe({props:{id:"schedulers",option:"EulerAncestralDiscreteScheduler",$$slots:{default:[Ts]},$$scope:{ctx:Z}}}),d=new qe({props:{id:"schedulers",option:"DPMSolverMultistepScheduler",$$slots:{default:[Zs]},$$scope:{ctx:Z}}}),{c(){h(n.$$.fragment),U=i(),h(c.$$.fragment),o=i(),h(u.$$.fragment),a=i(),h(d.$$.fragment)},l(p){M(n.$$.fragment,p),U=r(p),M(c.$$.fragment,p),o=r(p),M(u.$$.fragment,p),a=r(p),M(d.$$.fragment,p)},m(p,T){y(n,p,T),t(p,U,T),y(c,p,T),t(p,o,T),y(u,p,T),t(p,a,T),y(d,p,T),v=!0},p(p,T){const V={};T&2&&(V.$$scope={dirty:T,ctx:p}),n.$set(V);const j={};T&2&&(j.$$scope={dirty:T,ctx:p}),c.$set(j);const pe={};T&2&&(pe.$$scope={dirty:T,ctx:p}),u.$set(pe);const k={};T&2&&(k.$$scope={dirty:T,ctx:p}),d.$set(k)},i(p){v||(b(n.$$.fragment,p),b(c.$$.fragment,p),b(u.$$.fragment,p),b(d.$$.fragment,p),v=!0)},o(p){w(n.$$.fragment,p),w(c.$$.fragment,p),w(u.$$.fragment,p),w(d.$$.fragment,p),v=!1},d(p){p&&(l(U),l(o),l(a)),g(n,p),g(c,p),g(u,p),g(d,p)}}}function js(Z){let n,U='The <code>FlaxLMSDiscreteScheduler</code> and <code>FlaxDDPMScheduler</code> are not compatible with the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.FlaxStableDiffusionPipeline">FlaxStableDiffusionPipeline</a> yet.';return{c(){n=f("p"),n.innerHTML=U},l(c){n=m(c,"P",{"data-svelte-h":!0}),J(n)!=="svelte-qumirb"&&(n.innerHTML=U)},m(c,o){t(c,n,o)},p:ue,d(c){c&&l(n)}}}function vs(Z){let n,U,c,o,u,a,d,v,p,T="Diffusion pipelines are a collection of interchangeable schedulers and models that can be mixed and matched to tailor a pipeline to a specific use case. The scheduler encapsulates the entire denoising process such as the number of denoising steps and the algorithm for finding the denoised sample. A scheduler is not parameterized or trained so they don’t take very much memory. The model is usually only concerned with the forward pass of going from a noisy input to a less noisy sample.",V,j,pe='This guide will show you how to load schedulers and models to customize a pipeline. You’ll use the <a href="https://hf.co/runwayml/stable-diffusion-v1-5" rel="nofollow">runwayml/stable-diffusion-v1-5</a> checkpoint throughout this guide, so let’s load it first.',k,C,de,x,De="You can see what scheduler this pipeline uses with the <code>pipeline.scheduler</code> attribute.",fe,I,me,R,he,B,ze='Schedulers are defined by a configuration file that can be used by a variety of schedulers. Load a scheduler with the <a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained">SchedulerMixin.from_pretrained()</a> method, and specify the <code>subfolder</code> parameter to load the configuration file into the correct subfolder of the pipeline repository.',Me,N,Le='For example, to load the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>:',ye,X,be,E,Pe="Then you can pass the newly loaded scheduler to the pipeline.",we,H,ge,F,Ue,Q,Ae="Schedulers have their own unique strengths and weaknesses, making it difficult to quantitatively compare which scheduler works best for a pipeline. You typically have to make a trade-off between denoising speed and denoising quality. We recommend trying out different schedulers to find one that works best for your use case. Call the <code>pipeline.scheduler.compatibles</code> attribute to see what schedulers are compatible with a pipeline.",Je,Y,Ke='Let’s compare the <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler">EulerAncestralDiscreteScheduler</a>, and the <a href="/docs/diffusers/main/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler">DPMSolverMultistepScheduler</a> on the following prompt and seed.',Te,q,Ze,D,Oe='To change the pipelines scheduler, use the <a href="/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin.from_config">from_config()</a> method to load a different scheduler’s <code>pipeline.scheduler.config</code> into the pipeline.',$e,W,je,G,es='<div><img class="rounded-xl" src="https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/diffusers_docs/astronaut_lms.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">LMSDiscreteScheduler</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/diffusers_docs/astronaut_euler_discrete.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">EulerDiscreteScheduler</figcaption></div>',ve,_,ss='<div><img class="rounded-xl" src="https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/diffusers_docs/astronaut_euler_ancestral.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">EulerAncestralDiscreteScheduler</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/diffusers_docs/astronaut_dpm.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">DPMSolverMultistepScheduler</figcaption></div>',We,z,ls="Most images look very similar and are comparable in quality. Again, it often comes down to your specific use case so a good approach is to run multiple different schedulers and compare the results.",Ge,L,_e,P,ts='To compare Flax schedulers, you need to additionally load the scheduler state into the model parameters. For example, let’s change the default scheduler in <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.FlaxStableDiffusionPipeline">FlaxStableDiffusionPipeline</a> to use the super fast <code>FlaxDPMSolverMultistepScheduler</code>.',Se,S,Ve,A,ke,K,as="Then you can take advantage of Flax’s compatibility with TPUs to generate a number of images in parallel. You’ll need to make a copy of the model parameters for each available device and then split the inputs across them to generate your desired number of images.",Ce,O,xe,ee,Ie,se,ns='Models are loaded from the <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">ModelMixin.from_pretrained()</a> method, which downloads and caches the latest version of the model weights and configurations. If the latest files are available in the local cache, <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a> reuses files in the cache instead of re-downloading them.',Re,le,is='Models can be loaded from a subfolder with the <code>subfolder</code> argument. For example, the model weights for <a href="https://hf.co/runwayml/stable-diffusion-v1-5" rel="nofollow">runwayml/stable-diffusion-v1-5</a> are stored in the <a href="https://hf.co/runwayml/stable-diffusion-v1-5/tree/main/unet" rel="nofollow">unet</a> subfolder.',Be,te,Ne,ae,rs='They can also be directly loaded from a <a href="https://huggingface.co/google/ddpm-cifar10-32/tree/main" rel="nofollow">repository</a>.',Xe,ne,Ee,ie,ps='To load and save model variants, specify the <code>variant</code> argument in <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">ModelMixin.from_pretrained()</a> and <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.save_pretrained">ModelMixin.save_pretrained()</a>.',He,re,Fe,oe,Qe;return u=new ce({props:{title:"Load schedulers and models",local:"load-schedulers-and-models",headingTag:"h1"}}),d=new ws({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/schedulers.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/schedulers.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/schedulers.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/schedulers.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/schedulers.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/schedulers.ipynb"}]}}),C=new $({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),I=new $({props:{code:"cGlwZWxpbmUuc2NoZWR1bGVyJTBBUE5ETVNjaGVkdWxlciUyMCU3QiUwQSUyMCUyMCUyMl9jbGFzc19uYW1lJTIyJTNBJTIwJTIyUE5ETVNjaGVkdWxlciUyMiUyQyUwQSUyMCUyMCUyMl9kaWZmdXNlcnNfdmVyc2lvbiUyMiUzQSUyMCUyMjAuMjEuNCUyMiUyQyUwQSUyMCUyMCUyMmJldGFfZW5kJTIyJTNBJTIwMC4wMTIlMkMlMEElMjAlMjAlMjJiZXRhX3NjaGVkdWxlJTIyJTNBJTIwJTIyc2NhbGVkX2xpbmVhciUyMiUyQyUwQSUyMCUyMCUyMmJldGFfc3RhcnQlMjIlM0ElMjAwLjAwMDg1JTJDJTBBJTIwJTIwJTIyY2xpcF9zYW1wbGUlMjIlM0ElMjBmYWxzZSUyQyUwQSUyMCUyMCUyMm51bV90cmFpbl90aW1lc3RlcHMlMjIlM0ElMjAxMDAwJTJDJTBBJTIwJTIwJTIyc2V0X2FscGhhX3RvX29uZSUyMiUzQSUyMGZhbHNlJTJDJTBBJTIwJTIwJTIyc2tpcF9wcmtfc3RlcHMlMjIlM0ElMjB0cnVlJTJDJTBBJTIwJTIwJTIyc3RlcHNfb2Zmc2V0JTIyJTNBJTIwMSUyQyUwQSUyMCUyMCUyMnRpbWVzdGVwX3NwYWNpbmclMjIlM0ElMjAlMjJsZWFkaW5nJTIyJTJDJTBBJTIwJTIwJTIydHJhaW5lZF9iZXRhcyUyMiUzQSUyMG51bGwlMEElN0Q=",highlighted:`pipeline.scheduler
PNDMScheduler {
  <span class="hljs-string">&quot;_class_name&quot;</span>: <span class="hljs-string">&quot;PNDMScheduler&quot;</span>,
  <span class="hljs-string">&quot;_diffusers_version&quot;</span>: <span class="hljs-string">&quot;0.21.4&quot;</span>,
  <span class="hljs-string">&quot;beta_end&quot;</span>: <span class="hljs-number">0.012</span>,
  <span class="hljs-string">&quot;beta_schedule&quot;</span>: <span class="hljs-string">&quot;scaled_linear&quot;</span>,
  <span class="hljs-string">&quot;beta_start&quot;</span>: <span class="hljs-number">0.00085</span>,
  <span class="hljs-string">&quot;clip_sample&quot;</span>: false,
  <span class="hljs-string">&quot;num_train_timesteps&quot;</span>: <span class="hljs-number">1000</span>,
  <span class="hljs-string">&quot;set_alpha_to_one&quot;</span>: false,
  <span class="hljs-string">&quot;skip_prk_steps&quot;</span>: true,
  <span class="hljs-string">&quot;steps_offset&quot;</span>: <span class="hljs-number">1</span>,
  <span class="hljs-string">&quot;timestep_spacing&quot;</span>: <span class="hljs-string">&quot;leading&quot;</span>,
  <span class="hljs-string">&quot;trained_betas&quot;</span>: null
}`,wrap:!1}}),R=new ce({props:{title:"Load a scheduler",local:"load-a-scheduler",headingTag:"h2"}}),X=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERESU1TY2hlZHVsZXIlMkMlMjBEaWZmdXNpb25QaXBlbGluZSUwQSUwQWRkaW0lMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMScheduler, DiffusionPipeline

ddim = DDIMScheduler.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)`,wrap:!1}}),H=new $({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjBzY2hlZHVsZXIlM0RkZGltJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSkudG8oJTIyY3VkYSUyMik=",highlighted:`pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, scheduler=ddim, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),F=new ce({props:{title:"Compare schedulers",local:"compare-schedulers",headingTag:"h2"}}),q=new $({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMHBob3RvZ3JhcGglMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwb24lMjBNYXJzJTJDJTIwaGlnaCUyMHJlc29sdXRpb24lMkMlMjBoaWdoJTIwZGVmaW5pdGlvbi4lMjIlMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoZGV2aWNlJTNEJTIyY3VkYSUyMikubWFudWFsX3NlZWQoOCk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A photograph of an astronaut riding a horse on Mars, high resolution, high definition.&quot;</span>
generator = torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">8</span>)`,wrap:!1}}),W=new gs({props:{id:"schedulers",options:["LMSDiscreteScheduler","EulerDiscreteScheduler","EulerAncestralDiscreteScheduler","DPMSolverMultistepScheduler"],$$slots:{default:[$s]},$$scope:{ctx:Z}}}),L=new ce({props:{title:"Flax schedulers",local:"flax-schedulers",headingTag:"h3"}}),S=new bs({props:{warning:!0,$$slots:{default:[js]},$$scope:{ctx:Z}}}),A=new $({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTJDJTIwRmxheERQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlciUwQSUwQXNjaGVkdWxlciUyQyUyMHNjaGVkdWxlcl9zdGF0ZSUyMCUzRCUyMEZsYXhEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwc3ViZm9sZGVyJTNEJTIyc2NoZWR1bGVyJTIyJTBBKSUwQXBpcGVsaW5lJTJDJTIwcGFyYW1zJTIwJTNEJTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUwQSUyMCUyMCUyMCUyMHNjaGVkdWxlciUzRHNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMHJldmlzaW9uJTNEJTIyYmYxNiUyMiUyQyUwQSUyMCUyMCUyMCUyMGR0eXBlJTNEamF4Lm51bXB5LmJmbG9hdDE2JTJDJTBBKSUwQXBhcmFtcyU1QiUyMnNjaGVkdWxlciUyMiU1RCUyMCUzRCUyMHNjaGVkdWxlcl9zdGF0ZQ==",highlighted:`<span class="hljs-keyword">import</span> jax
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> flax.jax_utils <span class="hljs-keyword">import</span> replicate
<span class="hljs-keyword">from</span> flax.training.common_utils <span class="hljs-keyword">import</span> shard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlaxStableDiffusionPipeline, FlaxDPMSolverMultistepScheduler

scheduler, scheduler_state = FlaxDPMSolverMultistepScheduler.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>,
    subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>
)
pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>,
    scheduler=scheduler,
    revision=<span class="hljs-string">&quot;bf16&quot;</span>,
    dtype=jax.numpy.bfloat16,
)
params[<span class="hljs-string">&quot;scheduler&quot;</span>] = scheduler_state`,wrap:!1}}),O=new $({props:{code:"JTIzJTIwR2VuZXJhdGUlMjAxJTIwaW1hZ2UlMjBwZXIlMjBwYXJhbGxlbCUyMGRldmljZSUyMCg4JTIwb24lMjBUUFV2Mi04JTIwb3IlMjBUUFV2My04KSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBwaG90b2dyYXBoJTIwb2YlMjBhbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMG9uJTIwTWFycyUyQyUyMGhpZ2glMjByZXNvbHV0aW9uJTJDJTIwaGlnaCUyMGRlZmluaXRpb24uJTIyJTBBbnVtX3NhbXBsZXMlMjAlM0QlMjBqYXguZGV2aWNlX2NvdW50KCklMEFwcm9tcHRfaWRzJTIwJTNEJTIwcGlwZWxpbmUucHJlcGFyZV9pbnB1dHMoJTVCcHJvbXB0JTVEJTIwKiUyMG51bV9zYW1wbGVzKSUwQSUwQXBybmdfc2VlZCUyMCUzRCUyMGpheC5yYW5kb20uUFJOR0tleSgwKSUwQW51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjAyNSUwQSUwQSUyMyUyMHNoYXJkJTIwaW5wdXRzJTIwYW5kJTIwcm5nJTBBcGFyYW1zJTIwJTNEJTIwcmVwbGljYXRlKHBhcmFtcyklMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLnNwbGl0KHBybmdfc2VlZCUyQyUyMGpheC5kZXZpY2VfY291bnQoKSklMEFwcm9tcHRfaWRzJTIwJTNEJTIwc2hhcmQocHJvbXB0X2lkcyklMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShwcm9tcHRfaWRzJTJDJTIwcGFyYW1zJTJDJTIwcHJuZ19zZWVkJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUyQyUyMGppdCUzRFRydWUpLmltYWdlcyUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lLm51bXB5X3RvX3BpbChucC5hc2FycmF5KGltYWdlcy5yZXNoYXBlKChudW1fc2FtcGxlcyUyQyklMjAlMkIlMjBpbWFnZXMuc2hhcGUlNUItMyUzQSU1RCkpKQ==",highlighted:`<span class="hljs-comment"># Generate 1 image per parallel device (8 on TPUv2-8 or TPUv3-8)</span>
prompt = <span class="hljs-string">&quot;A photograph of an astronaut riding a horse on Mars, high resolution, high definition.&quot;</span>
num_samples = jax.device_count()
prompt_ids = pipeline.prepare_inputs([prompt] * num_samples)

prng_seed = jax.random.PRNGKey(<span class="hljs-number">0</span>)
num_inference_steps = <span class="hljs-number">25</span>

<span class="hljs-comment"># shard inputs and rng</span>
params = replicate(params)
prng_seed = jax.random.split(prng_seed, jax.device_count())
prompt_ids = shard(prompt_ids)

images = pipeline(prompt_ids, params, prng_seed, num_inference_steps, jit=<span class="hljs-literal">True</span>).images
images = pipeline.numpy_to_pil(np.asarray(images.reshape((num_samples,) + images.shape[-<span class="hljs-number">3</span>:])))`,wrap:!1}}),ee=new ce({props:{title:"Models",local:"models",headingTag:"h2"}}),te=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnVuZXQlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel

unet = UNet2DConditionModel.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)`,wrap:!1}}),ne=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFVOZXQyRE1vZGVsJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZkZHBtLWNpZmFyMTAtMzIlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DModel

unet = UNet2DModel.from_pretrained(<span class="hljs-string">&quot;google/ddpm-cifar10-32&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)`,wrap:!1}}),re=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnVuZXQlMjIlMkMlMjB2YXJpYW50JTNEJTIybm9uX2VtYSUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpJTBBdW5ldC5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRmxvY2FsLXVuZXQlMjIlMkMlMjB2YXJpYW50JTNEJTIybm9uX2VtYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel

unet = UNet2DConditionModel.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, variant=<span class="hljs-string">&quot;non_ema&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>
)
unet.save_pretrained(<span class="hljs-string">&quot;./local-unet&quot;</span>, variant=<span class="hljs-string">&quot;non_ema&quot;</span>)`,wrap:!1}}),{c(){n=f("meta"),U=i(),c=f("p"),o=i(),h(u.$$.fragment),a=i(),h(d.$$.fragment),v=i(),p=f("p"),p.textContent=T,V=i(),j=f("p"),j.innerHTML=pe,k=i(),h(C.$$.fragment),de=i(),x=f("p"),x.innerHTML=De,fe=i(),h(I.$$.fragment),me=i(),h(R.$$.fragment),he=i(),B=f("p"),B.innerHTML=ze,Me=i(),N=f("p"),N.innerHTML=Le,ye=i(),h(X.$$.fragment),be=i(),E=f("p"),E.textContent=Pe,we=i(),h(H.$$.fragment),ge=i(),h(F.$$.fragment),Ue=i(),Q=f("p"),Q.innerHTML=Ae,Je=i(),Y=f("p"),Y.innerHTML=Ke,Te=i(),h(q.$$.fragment),Ze=i(),D=f("p"),D.innerHTML=Oe,$e=i(),h(W.$$.fragment),je=i(),G=f("div"),G.innerHTML=es,ve=i(),_=f("div"),_.innerHTML=ss,We=i(),z=f("p"),z.textContent=ls,Ge=i(),h(L.$$.fragment),_e=i(),P=f("p"),P.innerHTML=ts,Se=i(),h(S.$$.fragment),Ve=i(),h(A.$$.fragment),ke=i(),K=f("p"),K.textContent=as,Ce=i(),h(O.$$.fragment),xe=i(),h(ee.$$.fragment),Ie=i(),se=f("p"),se.innerHTML=ns,Re=i(),le=f("p"),le.innerHTML=is,Be=i(),h(te.$$.fragment),Ne=i(),ae=f("p"),ae.innerHTML=rs,Xe=i(),h(ne.$$.fragment),Ee=i(),ie=f("p"),ie.innerHTML=ps,He=i(),h(re.$$.fragment),Fe=i(),oe=f("p"),this.h()},l(e){const s=Ms("svelte-u9bgzb",document.head);n=m(s,"META",{name:!0,content:!0}),s.forEach(l),U=r(e),c=m(e,"P",{}),us(c).forEach(l),o=r(e),M(u.$$.fragment,e),a=r(e),M(d.$$.fragment,e),v=r(e),p=m(e,"P",{"data-svelte-h":!0}),J(p)!=="svelte-147f8qd"&&(p.textContent=T),V=r(e),j=m(e,"P",{"data-svelte-h":!0}),J(j)!=="svelte-yswnun"&&(j.innerHTML=pe),k=r(e),M(C.$$.fragment,e),de=r(e),x=m(e,"P",{"data-svelte-h":!0}),J(x)!=="svelte-bntjs"&&(x.innerHTML=De),fe=r(e),M(I.$$.fragment,e),me=r(e),M(R.$$.fragment,e),he=r(e),B=m(e,"P",{"data-svelte-h":!0}),J(B)!=="svelte-12wcj3l"&&(B.innerHTML=ze),Me=r(e),N=m(e,"P",{"data-svelte-h":!0}),J(N)!=="svelte-1qzt247"&&(N.innerHTML=Le),ye=r(e),M(X.$$.fragment,e),be=r(e),E=m(e,"P",{"data-svelte-h":!0}),J(E)!=="svelte-1gk96nj"&&(E.textContent=Pe),we=r(e),M(H.$$.fragment,e),ge=r(e),M(F.$$.fragment,e),Ue=r(e),Q=m(e,"P",{"data-svelte-h":!0}),J(Q)!=="svelte-gbqn3x"&&(Q.innerHTML=Ae),Je=r(e),Y=m(e,"P",{"data-svelte-h":!0}),J(Y)!=="svelte-1baxatv"&&(Y.innerHTML=Ke),Te=r(e),M(q.$$.fragment,e),Ze=r(e),D=m(e,"P",{"data-svelte-h":!0}),J(D)!=="svelte-c6ot8t"&&(D.innerHTML=Oe),$e=r(e),M(W.$$.fragment,e),je=r(e),G=m(e,"DIV",{class:!0,"data-svelte-h":!0}),J(G)!=="svelte-k6zsrl"&&(G.innerHTML=es),ve=r(e),_=m(e,"DIV",{class:!0,"data-svelte-h":!0}),J(_)!=="svelte-8ii4fv"&&(_.innerHTML=ss),We=r(e),z=m(e,"P",{"data-svelte-h":!0}),J(z)!=="svelte-95mtrv"&&(z.textContent=ls),Ge=r(e),M(L.$$.fragment,e),_e=r(e),P=m(e,"P",{"data-svelte-h":!0}),J(P)!=="svelte-17sfnhx"&&(P.innerHTML=ts),Se=r(e),M(S.$$.fragment,e),Ve=r(e),M(A.$$.fragment,e),ke=r(e),K=m(e,"P",{"data-svelte-h":!0}),J(K)!=="svelte-cu42wu"&&(K.textContent=as),Ce=r(e),M(O.$$.fragment,e),xe=r(e),M(ee.$$.fragment,e),Ie=r(e),se=m(e,"P",{"data-svelte-h":!0}),J(se)!=="svelte-1cl76mo"&&(se.innerHTML=ns),Re=r(e),le=m(e,"P",{"data-svelte-h":!0}),J(le)!=="svelte-12b8wvr"&&(le.innerHTML=is),Be=r(e),M(te.$$.fragment,e),Ne=r(e),ae=m(e,"P",{"data-svelte-h":!0}),J(ae)!=="svelte-1r8gmv0"&&(ae.innerHTML=rs),Xe=r(e),M(ne.$$.fragment,e),Ee=r(e),ie=m(e,"P",{"data-svelte-h":!0}),J(ie)!=="svelte-12qu4qt"&&(ie.innerHTML=ps),He=r(e),M(re.$$.fragment,e),Fe=r(e),oe=m(e,"P",{}),us(oe).forEach(l),this.h()},h(){Ye(n,"name","hf:doc:metadata"),Ye(n,"content",Ws),Ye(G,"class","flex gap-4"),Ye(_,"class","flex gap-4")},m(e,s){ys(document.head,n),t(e,U,s),t(e,c,s),t(e,o,s),y(u,e,s),t(e,a,s),y(d,e,s),t(e,v,s),t(e,p,s),t(e,V,s),t(e,j,s),t(e,k,s),y(C,e,s),t(e,de,s),t(e,x,s),t(e,fe,s),y(I,e,s),t(e,me,s),y(R,e,s),t(e,he,s),t(e,B,s),t(e,Me,s),t(e,N,s),t(e,ye,s),y(X,e,s),t(e,be,s),t(e,E,s),t(e,we,s),y(H,e,s),t(e,ge,s),y(F,e,s),t(e,Ue,s),t(e,Q,s),t(e,Je,s),t(e,Y,s),t(e,Te,s),y(q,e,s),t(e,Ze,s),t(e,D,s),t(e,$e,s),y(W,e,s),t(e,je,s),t(e,G,s),t(e,ve,s),t(e,_,s),t(e,We,s),t(e,z,s),t(e,Ge,s),y(L,e,s),t(e,_e,s),t(e,P,s),t(e,Se,s),y(S,e,s),t(e,Ve,s),y(A,e,s),t(e,ke,s),t(e,K,s),t(e,Ce,s),y(O,e,s),t(e,xe,s),y(ee,e,s),t(e,Ie,s),t(e,se,s),t(e,Re,s),t(e,le,s),t(e,Be,s),y(te,e,s),t(e,Ne,s),t(e,ae,s),t(e,Xe,s),y(ne,e,s),t(e,Ee,s),t(e,ie,s),t(e,He,s),y(re,e,s),t(e,Fe,s),t(e,oe,s),Qe=!0},p(e,[s]){const os={};s&2&&(os.$$scope={dirty:s,ctx:e}),W.$set(os);const cs={};s&2&&(cs.$$scope={dirty:s,ctx:e}),S.$set(cs)},i(e){Qe||(b(u.$$.fragment,e),b(d.$$.fragment,e),b(C.$$.fragment,e),b(I.$$.fragment,e),b(R.$$.fragment,e),b(X.$$.fragment,e),b(H.$$.fragment,e),b(F.$$.fragment,e),b(q.$$.fragment,e),b(W.$$.fragment,e),b(L.$$.fragment,e),b(S.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(ne.$$.fragment,e),b(re.$$.fragment,e),Qe=!0)},o(e){w(u.$$.fragment,e),w(d.$$.fragment,e),w(C.$$.fragment,e),w(I.$$.fragment,e),w(R.$$.fragment,e),w(X.$$.fragment,e),w(H.$$.fragment,e),w(F.$$.fragment,e),w(q.$$.fragment,e),w(W.$$.fragment,e),w(L.$$.fragment,e),w(S.$$.fragment,e),w(A.$$.fragment,e),w(O.$$.fragment,e),w(ee.$$.fragment,e),w(te.$$.fragment,e),w(ne.$$.fragment,e),w(re.$$.fragment,e),Qe=!1},d(e){e&&(l(U),l(c),l(o),l(a),l(v),l(p),l(V),l(j),l(k),l(de),l(x),l(fe),l(me),l(he),l(B),l(Me),l(N),l(ye),l(be),l(E),l(we),l(ge),l(Ue),l(Q),l(Je),l(Y),l(Te),l(Ze),l(D),l($e),l(je),l(G),l(ve),l(_),l(We),l(z),l(Ge),l(_e),l(P),l(Se),l(Ve),l(ke),l(K),l(Ce),l(xe),l(Ie),l(se),l(Re),l(le),l(Be),l(Ne),l(ae),l(Xe),l(Ee),l(ie),l(He),l(Fe),l(oe)),l(n),g(u,e),g(d,e),g(C,e),g(I,e),g(R,e),g(X,e),g(H,e),g(F,e),g(q,e),g(W,e),g(L,e),g(S,e),g(A,e),g(O,e),g(ee,e),g(te,e),g(ne,e),g(re,e)}}}const Ws='{"title":"Load schedulers and models","local":"load-schedulers-and-models","sections":[{"title":"Load a scheduler","local":"load-a-scheduler","sections":[],"depth":2},{"title":"Compare schedulers","local":"compare-schedulers","sections":[{"title":"Flax schedulers","local":"flax-schedulers","sections":[],"depth":3}],"depth":2},{"title":"Models","local":"models","sections":[],"depth":2}],"depth":1}';function Gs(Z){return fs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Rs extends ms{constructor(n){super(),hs(this,n,Gs,vs,ds,{})}}export{Rs as component};
