import{s as le,o as ie,n as ne}from"../chunks/scheduler.182ea377.js";import{S as ae,i as oe,g as r,s as n,r as v,A as re,h as p,f as s,c as a,j as se,u as x,x as u,k as Q,y as pe,a as l,v as G,d as I,t as j,w as Z}from"../chunks/index.abf12888.js";import{T as ce}from"../chunks/Tip.230e2334.js";import{C as E}from"../chunks/CodeBlock.57fe6e13.js";import{H as me}from"../chunks/Heading.16916d63.js";function ue(V){let i,f="💡 Take a look at the paper linked above for more details about the proposed solutions!";return{c(){i=r("p"),i.textContent=f},l(o){i=p(o,"P",{"data-svelte-h":!0}),u(i)!=="svelte-pl5qbq"&&(i.textContent=f)},m(o,$){l(o,i,$)},p:ne,d(o){o&&s(i)}}}function fe(V){let i,f,o,$,d,B,h,P='The Stable Diffusion pipeline is mediocre at generating images that are either very bright or dark as explained in the <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample Steps are Flawed</a> paper. The solutions proposed in the paper are currently implemented in the <a href="/docs/diffusers/v0.26.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> which you can use to improve the lighting in your images.',W,c,S,y,Y='One of the solutions is to train a model with <em>v prediction</em> and <em>v loss</em>. Add the following flag to the <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py" rel="nofollow"><code>train_text_to_image.py</code></a> or <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py" rel="nofollow"><code>train_text_to_image_lora.py</code></a> scripts to enable <code>v_prediction</code>:',C,g,D,M,F='For example, let’s use the <a href="https://huggingface.co/ptx0/pseudo-journey-v2" rel="nofollow"><code>ptx0/pseudo-journey-v2</code></a> checkpoint which has been finetuned with <code>v_prediction</code>.',H,T,A='Next, configure the following parameters in the <a href="/docs/diffusers/v0.26.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>:',R,_,K="<li><code>rescale_betas_zero_snr=True</code>, rescales the noise schedule to zero terminal signal-to-noise ratio (SNR)</li> <li><code>timestep_spacing=&quot;trailing&quot;</code>, starts sampling from the last timestep</li>",k,w,N,b,O="Finally, in your call to the pipeline, set <code>guidance_rescale</code> to prevent overexposure:",L,J,q,m,ee='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/zero_snr.png"/>',z,U,X;return d=new me({props:{title:"Control image brightness",local:"control-image-brightness",headingTag:"h1"}}),c=new ce({props:{$$slots:{default:[ue]},$$scope:{ctx:V}}}),g=new E({props:{code:"LS1wcmVkaWN0aW9uX3R5cGUlM0QlMjJ2X3ByZWRpY3Rpb24lMjI=",highlighted:'--prediction_type=<span class="hljs-string">&quot;v_prediction&quot;</span>',wrap:!1}}),w=new E({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwRERJTVNjaGVkdWxlciUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnB0eDAlMkZwc2V1ZG8tam91cm5leS12MiUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBJTBBJTIzJTIwc3dpdGNoJTIwdGhlJTIwc2NoZWR1bGVyJTIwaW4lMjB0aGUlMjBwaXBlbGluZSUyMHRvJTIwdXNlJTIwdGhlJTIwRERJTVNjaGVkdWxlciUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcoJTBBJTIwJTIwJTIwJTIwcGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHJlc2NhbGVfYmV0YXNfemVyb19zbnIlM0RUcnVlJTJDJTIwdGltZXN0ZXBfc3BhY2luZyUzRCUyMnRyYWlsaW5nJTIyJTBBKSUwQXBpcGVsaW5lLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, DDIMScheduler

pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;ptx0/pseudo-journey-v2&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># switch the scheduler in the pipeline to use the DDIMScheduler</span>
pipeline.scheduler = DDIMScheduler.from_config(
    pipeline.scheduler.config, rescale_betas_zero_snr=<span class="hljs-literal">True</span>, timestep_spacing=<span class="hljs-string">&quot;trailing&quot;</span>
)
pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),J=new E({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyQSUyMGxpb24lMjBpbiUyMGdhbGF4aWVzJTJDJTIwc3BpcmFscyUyQyUyMG5lYnVsYWUlMkMlMjBzdGFycyUyQyUyMHNtb2tlJTJDJTIwaXJpZGVzY2VudCUyQyUyMGludHJpY2F0ZSUyMGRldGFpbCUyQyUyMG9jdGFuZSUyMHJlbmRlciUyQyUyMDhrJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBndWlkYW5jZV9yZXNjYWxlJTNEMC43KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`prompt = <span class="hljs-string">&quot;A lion in galaxies, spirals, nebulae, stars, smoke, iridescent, intricate detail, octane render, 8k&quot;</span>
image = pipeline(prompt, guidance_rescale=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){i=r("meta"),f=n(),o=r("p"),$=n(),v(d.$$.fragment),B=n(),h=r("p"),h.innerHTML=P,W=n(),v(c.$$.fragment),S=n(),y=r("p"),y.innerHTML=Y,C=n(),v(g.$$.fragment),D=n(),M=r("p"),M.innerHTML=F,H=n(),T=r("p"),T.innerHTML=A,R=n(),_=r("ol"),_.innerHTML=K,k=n(),v(w.$$.fragment),N=n(),b=r("p"),b.innerHTML=O,L=n(),v(J.$$.fragment),q=n(),m=r("div"),m.innerHTML=ee,z=n(),U=r("p"),this.h()},l(e){const t=re("svelte-u9bgzb",document.head);i=p(t,"META",{name:!0,content:!0}),t.forEach(s),f=a(e),o=p(e,"P",{}),se(o).forEach(s),$=a(e),x(d.$$.fragment,e),B=a(e),h=p(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-15yp710"&&(h.innerHTML=P),W=a(e),x(c.$$.fragment,e),S=a(e),y=p(e,"P",{"data-svelte-h":!0}),u(y)!=="svelte-116mx1h"&&(y.innerHTML=Y),C=a(e),x(g.$$.fragment,e),D=a(e),M=p(e,"P",{"data-svelte-h":!0}),u(M)!=="svelte-1uuaxw4"&&(M.innerHTML=F),H=a(e),T=p(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-1yjig3o"&&(T.innerHTML=A),R=a(e),_=p(e,"OL",{"data-svelte-h":!0}),u(_)!=="svelte-1rg1cr0"&&(_.innerHTML=K),k=a(e),x(w.$$.fragment,e),N=a(e),b=p(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-xfpf26"&&(b.innerHTML=O),L=a(e),x(J.$$.fragment,e),q=a(e),m=p(e,"DIV",{class:!0,"data-svelte-h":!0}),u(m)!=="svelte-1fieqb3"&&(m.innerHTML=ee),z=a(e),U=p(e,"P",{}),se(U).forEach(s),this.h()},h(){Q(i,"name","hf:doc:metadata"),Q(i,"content",de),Q(m,"class","flex justify-center")},m(e,t){pe(document.head,i),l(e,f,t),l(e,o,t),l(e,$,t),G(d,e,t),l(e,B,t),l(e,h,t),l(e,W,t),G(c,e,t),l(e,S,t),l(e,y,t),l(e,C,t),G(g,e,t),l(e,D,t),l(e,M,t),l(e,H,t),l(e,T,t),l(e,R,t),l(e,_,t),l(e,k,t),G(w,e,t),l(e,N,t),l(e,b,t),l(e,L,t),G(J,e,t),l(e,q,t),l(e,m,t),l(e,z,t),l(e,U,t),X=!0},p(e,[t]){const te={};t&2&&(te.$$scope={dirty:t,ctx:e}),c.$set(te)},i(e){X||(I(d.$$.fragment,e),I(c.$$.fragment,e),I(g.$$.fragment,e),I(w.$$.fragment,e),I(J.$$.fragment,e),X=!0)},o(e){j(d.$$.fragment,e),j(c.$$.fragment,e),j(g.$$.fragment,e),j(w.$$.fragment,e),j(J.$$.fragment,e),X=!1},d(e){e&&(s(f),s(o),s($),s(B),s(h),s(W),s(S),s(y),s(C),s(D),s(M),s(H),s(T),s(R),s(_),s(k),s(N),s(b),s(L),s(q),s(m),s(z),s(U)),s(i),Z(d,e),Z(c,e),Z(g,e),Z(w,e),Z(J,e)}}}const de='{"title":"Control image brightness","local":"control-image-brightness","sections":[],"depth":1}';function he(V){return ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class we extends ae{constructor(i){super(),oe(this,i,he,fe,le,{})}}export{we as component};
