import{s as q,o as D,n as S}from"../chunks/scheduler.53228c21.js";import{S as Q,i as A,e as $,s as u,c as h,h as K,a as j,d as r,b as d,f as L,g,j as X,k as B,l as P,m,n as M,t as b,o as J,p as y}from"../chunks/index.100fac89.js";import{C as O}from"../chunks/CopyLLMTxtMenu.fb2ec027.js";import{C as _}from"../chunks/CodeBlock.d30a6509.js";import{H as ee,E as se}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.09d4dba9.js";import{H as te,a as F}from"../chunks/HfOption.fad27e59.js";function ae(Z){let t,p,a,c='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdv15-no-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU disabled</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdv15-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU enabled</figcaption></div>',n;return t=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjBzYWZldHlfY2hlY2tlciUzRE5vbmUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuZW5hYmxlX2ZyZWV1KHMxJTNEMC45JTJDJTIwczIlM0QwLjIlMkMlMjBiMSUzRDEuNSUyQyUyMGIyJTNEMS42KSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjcHUlMjIpLm1hbnVhbF9zZWVkKDMzKSUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",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;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, safety_checker=<span class="hljs-literal">None</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_freeu(s1=<span class="hljs-number">0.9</span>, s2=<span class="hljs-number">0.2</span>, b1=<span class="hljs-number">1.5</span>, b2=<span class="hljs-number">1.6</span>)
generator = torch.Generator(device=<span class="hljs-string">&quot;cpu&quot;</span>).manual_seed(<span class="hljs-number">33</span>)
prompt = <span class="hljs-string">&quot;&quot;</span>
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){h(t.$$.fragment),p=u(),a=$("div"),a.innerHTML=c,this.h()},l(e){g(t.$$.fragment,e),p=d(e),a=j(e,"DIV",{class:!0,"data-svelte-h":!0}),X(a)!=="svelte-1wayd6q"&&(a.innerHTML=c),this.h()},h(){B(a,"class","flex gap-4")},m(e,i){M(t,e,i),m(e,p,i),m(e,a,i),n=!0},p:S,i(e){n||(b(t.$$.fragment,e),n=!0)},o(e){J(t.$$.fragment,e),n=!1},d(e){e&&(r(p),r(a)),y(t,e)}}}function le(Z){let t,p,a,c='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdv21-no-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU disabled</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdv21-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU enabled</figcaption></div>',n;return t=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24tMi0xJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwc2FmZXR5X2NoZWNrZXIlM0ROb25lJTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmVuYWJsZV9mcmVldShzMSUzRDAuOSUyQyUyMHMyJTNEMC4yJTJDJTIwYjElM0QxLjQlMkMlMjBiMiUzRDEuNiklMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoZGV2aWNlJTNEJTIyY3B1JTIyKS5tYW51YWxfc2VlZCg4MCklMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwc3F1aXJyZWwlMjBlYXRpbmclMjBhJTIwYnVyZ2VyJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",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;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16, safety_checker=<span class="hljs-literal">None</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_freeu(s1=<span class="hljs-number">0.9</span>, s2=<span class="hljs-number">0.2</span>, b1=<span class="hljs-number">1.4</span>, b2=<span class="hljs-number">1.6</span>)
generator = torch.Generator(device=<span class="hljs-string">&quot;cpu&quot;</span>).manual_seed(<span class="hljs-number">80</span>)
prompt = <span class="hljs-string">&quot;A squirrel eating a burger&quot;</span>
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){h(t.$$.fragment),p=u(),a=$("div"),a.innerHTML=c,this.h()},l(e){g(t.$$.fragment,e),p=d(e),a=j(e,"DIV",{class:!0,"data-svelte-h":!0}),X(a)!=="svelte-80qe6y"&&(a.innerHTML=c),this.h()},h(){B(a,"class","flex gap-4")},m(e,i){M(t,e,i),m(e,p,i),m(e,a,i),n=!0},p:S,i(e){n||(b(t.$$.fragment,e),n=!0)},o(e){J(t.$$.fragment,e),n=!1},d(e){e&&(r(p),r(a)),y(t,e)}}}function ne(Z){let t,p,a,c='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-no-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU disabled</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-freeu.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU enabled</figcaption></div>',n;return t=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuZW5hYmxlX2ZyZWV1KHMxJTNEMC45JTJDJTIwczIlM0QwLjIlMkMlMjBiMSUzRDEuMyUyQyUyMGIyJTNEMS40KSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjcHUlMjIpLm1hbnVhbF9zZWVkKDEzKSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBzcXVpcnJlbCUyMGVhdGluZyUyMGElMjBidXJnZXIlMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvcikuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_freeu(s1=<span class="hljs-number">0.9</span>, s2=<span class="hljs-number">0.2</span>, b1=<span class="hljs-number">1.3</span>, b2=<span class="hljs-number">1.4</span>)
generator = torch.Generator(device=<span class="hljs-string">&quot;cpu&quot;</span>).manual_seed(<span class="hljs-number">13</span>)
prompt = <span class="hljs-string">&quot;A squirrel eating a burger&quot;</span>
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){h(t.$$.fragment),p=u(),a=$("div"),a.innerHTML=c,this.h()},l(e){g(t.$$.fragment,e),p=d(e),a=j(e,"DIV",{class:!0,"data-svelte-h":!0}),X(a)!=="svelte-1uy9my4"&&(a.innerHTML=c),this.h()},h(){B(a,"class","flex gap-4")},m(e,i){M(t,e,i),m(e,p,i),m(e,a,i),n=!0},p:S,i(e){n||(b(t.$$.fragment,e),n=!0)},o(e){J(t.$$.fragment,e),n=!1},d(e){e&&(r(p),r(a)),y(t,e)}}}function ie(Z){let t,p,a,c='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/video-no-freeu.gif"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU disabled</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/video-freeu.gif"/> <figcaption class="mt-2 text-center text-sm text-gray-500">FreeU enabled</figcaption></div>',n;return t=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZGFtby12aWxhYiUyRnRleHQtdG8tdmlkZW8tbXMtMS43YiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMjMlMjB2YWx1ZXMlMjBjb21lJTIwZnJvbSUyMGh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmx5bi1yZ2IlMkZGcmVlVV9EaWZmdXNlcnMlMjN2aWRlby1waXBlbGluZXMlMEFwaXBlbGluZS5lbmFibGVfZnJlZXUoYjElM0QxLjIlMkMlMjBiMiUzRDEuNCUyQyUyMHMxJTNEMC45JTJDJTIwczIlM0QwLjIpJTBBcHJvbXB0JTIwJTNEJTIwJTIyQ29uZmlkZW50JTIwdGVkZHklMjBiZWFyJTIwc3VyZmVyJTIwcmlkZXMlMjB0aGUlMjB3YXZlJTIwaW4lMjB0aGUlMjB0cm9waWNzJTIyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRCUyMmNwdSUyMikubWFudWFsX3NlZWQoNDcpJTBBdmlkZW9fZnJhbWVzJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5mcmFtZXMlNUIwJTVEJTBBZXhwb3J0X3RvX3ZpZGVvKHZpZGVvX2ZyYW1lcyUyQyUyMCUyMnRlZGR5X2JlYXIubXA0JTIyJTJDJTIwZnBzJTNEMTAp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;damo-vilab/text-to-video-ms-1.7b&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># values come from https://github.com/lyn-rgb/FreeU_Diffusers#video-pipelines</span>
pipeline.enable_freeu(b1=<span class="hljs-number">1.2</span>, b2=<span class="hljs-number">1.4</span>, s1=<span class="hljs-number">0.9</span>, s2=<span class="hljs-number">0.2</span>)
prompt = <span class="hljs-string">&quot;Confident teddy bear surfer rides the wave in the tropics&quot;</span>
generator = torch.Generator(device=<span class="hljs-string">&quot;cpu&quot;</span>).manual_seed(<span class="hljs-number">47</span>)
video_frames = pipeline(prompt, generator=generator).frames[<span class="hljs-number">0</span>]
export_to_video(video_frames, <span class="hljs-string">&quot;teddy_bear.mp4&quot;</span>, fps=<span class="hljs-number">10</span>)`,wrap:!1}}),{c(){h(t.$$.fragment),p=u(),a=$("div"),a.innerHTML=c,this.h()},l(e){g(t.$$.fragment,e),p=d(e),a=j(e,"DIV",{class:!0,"data-svelte-h":!0}),X(a)!=="svelte-3hke60"&&(a.innerHTML=c),this.h()},h(){B(a,"class","flex gap-4")},m(e,i){M(t,e,i),m(e,p,i),m(e,a,i),n=!0},p:S,i(e){n||(b(t.$$.fragment,e),n=!0)},o(e){J(t.$$.fragment,e),n=!1},d(e){e&&(r(p),r(a)),y(t,e)}}}function re(Z){let t,p,a,c,n,e,i,U;return t=new F({props:{id:"freeu",option:"Stable Diffusion v1-5",$$slots:{default:[ae]},$$scope:{ctx:Z}}}),a=new F({props:{id:"freeu",option:"Stable Diffusion v2-1",$$slots:{default:[le]},$$scope:{ctx:Z}}}),n=new F({props:{id:"freeu",option:"Stable Diffusion XL",$$slots:{default:[ne]},$$scope:{ctx:Z}}}),i=new F({props:{id:"freeu",option:"Zeroscope",$$slots:{default:[ie]},$$scope:{ctx:Z}}}),{c(){h(t.$$.fragment),p=u(),h(a.$$.fragment),c=u(),h(n.$$.fragment),e=u(),h(i.$$.fragment)},l(l){g(t.$$.fragment,l),p=d(l),g(a.$$.fragment,l),c=d(l),g(n.$$.fragment,l),e=d(l),g(i.$$.fragment,l)},m(l,f){M(t,l,f),m(l,p,f),M(a,l,f),m(l,c,f),M(n,l,f),m(l,e,f),M(i,l,f),U=!0},p(l,f){const v={};f&2&&(v.$$scope={dirty:f,ctx:l}),t.$set(v);const w={};f&2&&(w.$$scope={dirty:f,ctx:l}),a.$set(w);const E={};f&2&&(E.$$scope={dirty:f,ctx:l}),n.$set(E);const W={};f&2&&(W.$$scope={dirty:f,ctx:l}),i.$set(W)},i(l){U||(b(t.$$.fragment,l),b(a.$$.fragment,l),b(n.$$.fragment,l),b(i.$$.fragment,l),U=!0)},o(l){J(t.$$.fragment,l),J(a.$$.fragment,l),J(n.$$.fragment,l),J(i.$$.fragment,l),U=!1},d(l){l&&(r(p),r(c),r(e)),y(t,l),y(a,l),y(n,l),y(i,l)}}}function pe(Z){let t,p,a,c,n,e,i,U,l,f='<a href="https://hf.co/papers/2309.11497" rel="nofollow">FreeU</a> improves image details by rebalancing the UNet’s backbone and skip connection weights. The skip connections can cause the model to overlook some of the backbone semantics which may lead to unnatural image details in the generated image. This technique does not require any additional training and can be applied on the fly during inference for tasks like image-to-image and text-to-video.',v,w,E='Use the <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.StableDiffusionMixin.enable_freeu">enable_freeu()</a> method on your pipeline and configure the scaling factors for the backbone (<code>b1</code> and <code>b2</code>) and skip connections (<code>s1</code> and <code>s2</code>). The number after each scaling factor corresponds to the stage in the UNet where the factor is applied. Take a look at the <a href="https://github.com/ChenyangSi/FreeU#parameters" rel="nofollow">FreeU</a> repository for reference hyperparameters for different models.',W,T,V,x,N='Call the <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.StableDiffusionMixin.disable_freeu">disable_freeu()</a> method to disable FreeU.',R,G,z,I,C,k,H;return n=new O({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),i=new ee({props:{title:"FreeU",local:"freeu",headingTag:"h1"}}),T=new te({props:{id:"freeu",options:["Stable Diffusion v1-5","Stable Diffusion v2-1","Stable Diffusion XL","Zeroscope"],$$slots:{default:[re]},$$scope:{ctx:Z}}}),G=new _({props:{code:"cGlwZWxpbmUuZGlzYWJsZV9mcmVldSgp",highlighted:"pipeline.disable_freeu()",wrap:!1}}),I=new se({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/image_quality.md"}}),{c(){t=$("meta"),p=u(),a=$("p"),c=u(),h(n.$$.fragment),e=u(),h(i.$$.fragment),U=u(),l=$("p"),l.innerHTML=f,v=u(),w=$("p"),w.innerHTML=E,W=u(),h(T.$$.fragment),V=u(),x=$("p"),x.innerHTML=N,R=u(),h(G.$$.fragment),z=u(),h(I.$$.fragment),C=u(),k=$("p"),this.h()},l(s){const o=K("svelte-u9bgzb",document.head);t=j(o,"META",{name:!0,content:!0}),o.forEach(r),p=d(s),a=j(s,"P",{}),L(a).forEach(r),c=d(s),g(n.$$.fragment,s),e=d(s),g(i.$$.fragment,s),U=d(s),l=j(s,"P",{"data-svelte-h":!0}),X(l)!=="svelte-47jju9"&&(l.innerHTML=f),v=d(s),w=j(s,"P",{"data-svelte-h":!0}),X(w)!=="svelte-18kclpc"&&(w.innerHTML=E),W=d(s),g(T.$$.fragment,s),V=d(s),x=j(s,"P",{"data-svelte-h":!0}),X(x)!=="svelte-sy4rw2"&&(x.innerHTML=N),R=d(s),g(G.$$.fragment,s),z=d(s),g(I.$$.fragment,s),C=d(s),k=j(s,"P",{}),L(k).forEach(r),this.h()},h(){B(t,"name","hf:doc:metadata"),B(t,"content",oe)},m(s,o){P(document.head,t),m(s,p,o),m(s,a,o),m(s,c,o),M(n,s,o),m(s,e,o),M(i,s,o),m(s,U,o),m(s,l,o),m(s,v,o),m(s,w,o),m(s,W,o),M(T,s,o),m(s,V,o),m(s,x,o),m(s,R,o),M(G,s,o),m(s,z,o),M(I,s,o),m(s,C,o),m(s,k,o),H=!0},p(s,[o]){const Y={};o&2&&(Y.$$scope={dirty:o,ctx:s}),T.$set(Y)},i(s){H||(b(n.$$.fragment,s),b(i.$$.fragment,s),b(T.$$.fragment,s),b(G.$$.fragment,s),b(I.$$.fragment,s),H=!0)},o(s){J(n.$$.fragment,s),J(i.$$.fragment,s),J(T.$$.fragment,s),J(G.$$.fragment,s),J(I.$$.fragment,s),H=!1},d(s){s&&(r(p),r(a),r(c),r(e),r(U),r(l),r(v),r(w),r(W),r(V),r(x),r(R),r(z),r(C),r(k)),r(t),y(n,s),y(i,s),y(T,s),y(G,s),y(I,s)}}}const oe='{"title":"FreeU","local":"freeu","sections":[],"depth":1}';function me(Z){return D(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Me extends Q{constructor(t){super(),A(this,t,me,pe,q,{})}}export{Me as component};
