import{s as Y,o as q,n as C}from"../chunks/scheduler.8c3d61f6.js";import{S as L,i as D,g as j,s as u,r as g,A as Q,h as $,f as p,c as d,j as N,u as M,x,k as X,y as A,a as o,v as b,d as J,t as y,w as Z}from"../chunks/index.da70eac4.js";import{C as k}from"../chunks/CodeBlock.a9c4becf.js";import{H as K,E as P}from"../chunks/getInferenceSnippets.28ca3596.js";import{H as O,a as H}from"../chunks/HfOption.6c3b4e77.js";function ee(h){let t,r,a,f='<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 k({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(){g(t.$$.fragment),r=u(),a=j("div"),a.innerHTML=f,this.h()},l(e){M(t.$$.fragment,e),r=d(e),a=$(e,"DIV",{class:!0,"data-svelte-h":!0}),x(a)!=="svelte-1wayd6q"&&(a.innerHTML=f),this.h()},h(){X(a,"class","flex gap-4")},m(e,i){b(t,e,i),o(e,r,i),o(e,a,i),n=!0},p:C,i(e){n||(J(t.$$.fragment,e),n=!0)},o(e){y(t.$$.fragment,e),n=!1},d(e){e&&(p(r),p(a)),Z(t,e)}}}function se(h){let t,r,a,f='<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 k({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(){g(t.$$.fragment),r=u(),a=j("div"),a.innerHTML=f,this.h()},l(e){M(t.$$.fragment,e),r=d(e),a=$(e,"DIV",{class:!0,"data-svelte-h":!0}),x(a)!=="svelte-80qe6y"&&(a.innerHTML=f),this.h()},h(){X(a,"class","flex gap-4")},m(e,i){b(t,e,i),o(e,r,i),o(e,a,i),n=!0},p:C,i(e){n||(J(t.$$.fragment,e),n=!0)},o(e){y(t.$$.fragment,e),n=!1},d(e){e&&(p(r),p(a)),Z(t,e)}}}function te(h){let t,r,a,f='<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 k({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(){g(t.$$.fragment),r=u(),a=j("div"),a.innerHTML=f,this.h()},l(e){M(t.$$.fragment,e),r=d(e),a=$(e,"DIV",{class:!0,"data-svelte-h":!0}),x(a)!=="svelte-1uy9my4"&&(a.innerHTML=f),this.h()},h(){X(a,"class","flex gap-4")},m(e,i){b(t,e,i),o(e,r,i),o(e,a,i),n=!0},p:C,i(e){n||(J(t.$$.fragment,e),n=!0)},o(e){y(t.$$.fragment,e),n=!1},d(e){e&&(p(r),p(a)),Z(t,e)}}}function ae(h){let t,r,a,f='<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 k({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(){g(t.$$.fragment),r=u(),a=j("div"),a.innerHTML=f,this.h()},l(e){M(t.$$.fragment,e),r=d(e),a=$(e,"DIV",{class:!0,"data-svelte-h":!0}),x(a)!=="svelte-3hke60"&&(a.innerHTML=f),this.h()},h(){X(a,"class","flex gap-4")},m(e,i){b(t,e,i),o(e,r,i),o(e,a,i),n=!0},p:C,i(e){n||(J(t.$$.fragment,e),n=!0)},o(e){y(t.$$.fragment,e),n=!1},d(e){e&&(p(r),p(a)),Z(t,e)}}}function le(h){let t,r,a,f,n,e,i,U;return t=new H({props:{id:"freeu",option:"Stable Diffusion v1-5",$$slots:{default:[ee]},$$scope:{ctx:h}}}),a=new H({props:{id:"freeu",option:"Stable Diffusion v2-1",$$slots:{default:[se]},$$scope:{ctx:h}}}),n=new H({props:{id:"freeu",option:"Stable Diffusion XL",$$slots:{default:[te]},$$scope:{ctx:h}}}),i=new H({props:{id:"freeu",option:"Zeroscope",$$slots:{default:[ae]},$$scope:{ctx:h}}}),{c(){g(t.$$.fragment),r=u(),g(a.$$.fragment),f=u(),g(n.$$.fragment),e=u(),g(i.$$.fragment)},l(l){M(t.$$.fragment,l),r=d(l),M(a.$$.fragment,l),f=d(l),M(n.$$.fragment,l),e=d(l),M(i.$$.fragment,l)},m(l,c){b(t,l,c),o(l,r,c),b(a,l,c),o(l,f,c),b(n,l,c),o(l,e,c),b(i,l,c),U=!0},p(l,c){const B={};c&2&&(B.$$scope={dirty:c,ctx:l}),t.$set(B);const T={};c&2&&(T.$$scope={dirty:c,ctx:l}),a.$set(T);const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),n.$set(w);const v={};c&2&&(v.$$scope={dirty:c,ctx:l}),i.$set(v)},i(l){U||(J(t.$$.fragment,l),J(a.$$.fragment,l),J(n.$$.fragment,l),J(i.$$.fragment,l),U=!0)},o(l){y(t.$$.fragment,l),y(a.$$.fragment,l),y(n.$$.fragment,l),y(i.$$.fragment,l),U=!1},d(l){l&&(p(r),p(f),p(e)),Z(t,l),Z(a,l),Z(n,l),Z(i,l)}}}function ne(h){let t,r,a,f,n,e,i,U='<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.',l,c,B='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.',T,w,v,W,F='Call the <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.StableDiffusionMixin.disable_freeu">disable_freeu()</a> method to disable FreeU.',_,G,V,I,R,E,z;return n=new K({props:{title:"FreeU",local:"freeu",headingTag:"h1"}}),w=new O({props:{id:"freeu",options:["Stable Diffusion v1-5","Stable Diffusion v2-1","Stable Diffusion XL","Zeroscope"],$$slots:{default:[le]},$$scope:{ctx:h}}}),G=new k({props:{code:"cGlwZWxpbmUuZGlzYWJsZV9mcmVldSgp",highlighted:"pipeline.disable_freeu()",wrap:!1}}),I=new P({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/image_quality.md"}}),{c(){t=j("meta"),r=u(),a=j("p"),f=u(),g(n.$$.fragment),e=u(),i=j("p"),i.innerHTML=U,l=u(),c=j("p"),c.innerHTML=B,T=u(),g(w.$$.fragment),v=u(),W=j("p"),W.innerHTML=F,_=u(),g(G.$$.fragment),V=u(),g(I.$$.fragment),R=u(),E=j("p"),this.h()},l(s){const m=Q("svelte-u9bgzb",document.head);t=$(m,"META",{name:!0,content:!0}),m.forEach(p),r=d(s),a=$(s,"P",{}),N(a).forEach(p),f=d(s),M(n.$$.fragment,s),e=d(s),i=$(s,"P",{"data-svelte-h":!0}),x(i)!=="svelte-47jju9"&&(i.innerHTML=U),l=d(s),c=$(s,"P",{"data-svelte-h":!0}),x(c)!=="svelte-18kclpc"&&(c.innerHTML=B),T=d(s),M(w.$$.fragment,s),v=d(s),W=$(s,"P",{"data-svelte-h":!0}),x(W)!=="svelte-sy4rw2"&&(W.innerHTML=F),_=d(s),M(G.$$.fragment,s),V=d(s),M(I.$$.fragment,s),R=d(s),E=$(s,"P",{}),N(E).forEach(p),this.h()},h(){X(t,"name","hf:doc:metadata"),X(t,"content",ie)},m(s,m){A(document.head,t),o(s,r,m),o(s,a,m),o(s,f,m),b(n,s,m),o(s,e,m),o(s,i,m),o(s,l,m),o(s,c,m),o(s,T,m),b(w,s,m),o(s,v,m),o(s,W,m),o(s,_,m),b(G,s,m),o(s,V,m),b(I,s,m),o(s,R,m),o(s,E,m),z=!0},p(s,[m]){const S={};m&2&&(S.$$scope={dirty:m,ctx:s}),w.$set(S)},i(s){z||(J(n.$$.fragment,s),J(w.$$.fragment,s),J(G.$$.fragment,s),J(I.$$.fragment,s),z=!0)},o(s){y(n.$$.fragment,s),y(w.$$.fragment,s),y(G.$$.fragment,s),y(I.$$.fragment,s),z=!1},d(s){s&&(p(r),p(a),p(f),p(e),p(i),p(l),p(c),p(T),p(v),p(W),p(_),p(V),p(R),p(E)),p(t),Z(n,s),Z(w,s),Z(G,s),Z(I,s)}}}const ie='{"title":"FreeU","local":"freeu","sections":[],"depth":1}';function re(h){return q(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ue extends L{constructor(t){super(),D(this,t,re,ne,Y,{})}}export{ue as component};
