import{s as le,o as ae,n as ne}from"../chunks/scheduler.182ea377.js";import{S as ie,i as pe,g as o,s as n,r as J,A as oe,h as r,f as s,c as i,j as se,u as v,x as u,k as F,y as re,a as l,v as U,d as Z,t as G,w as V}from"../chunks/index.abf12888.js";import{T as ce}from"../chunks/Tip.230e2334.js";import{C as P}from"../chunks/CodeBlock.57fe6e13.js";import{H as me}from"../chunks/Heading.16916d63.js";function ue(I){let a,f="💡 Take a look at the paper linked above for more details about the proposed solutions!";return{c(){a=o("p"),a.textContent=f},l(p){a=r(p,"P",{"data-svelte-h":!0}),u(a)!=="svelte-pl5qbq"&&(a.textContent=f)},m(p,x){l(p,a,x)},p:ne,d(p){p&&s(a)}}}function fe(I){let a,f,p,x,d,S,h,X='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/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> which you can use to improve the lighting in your images.',k,c,D,g,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>:',W,y,H,M,Q='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>.',B,_,A='Next, configure the following parameters in the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>:',C,T,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>",R,w,q,b,O="Finally, in your call to the pipeline, set <code>guidance_rescale</code> to prevent overexposure:",E,$,L,m,ee='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/zero_snr.png"/>',N,j,z;return d=new me({props:{title:"Control image brightness",local:"control-image-brightness",headingTag:"h1"}}),c=new ce({props:{$$slots:{default:[ue]},$$scope:{ctx:I}}}),y=new P({props:{code:"LS1wcmVkaWN0aW9uX3R5cGUlM0QlMjJ2X3ByZWRpY3Rpb24lMjI=",highlighted:'--prediction_type=<span class="hljs-string">&quot;v_prediction&quot;</span>',wrap:!1}}),w=new P({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwRERJTVNjaGVkdWxlciUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnB0eDAlMkZwc2V1ZG8tam91cm5leS12MiUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwRERJTVNjaGVkdWxlci5mcm9tX2NvbmZpZyglMEElMjAlMjAlMjAlMjBwaXBlbGluZS5zY2hlZHVsZXIuY29uZmlnJTJDJTIwcmVzY2FsZV9iZXRhc196ZXJvX3NuciUzRFRydWUlMkMlMjB0aW1lc3RlcF9zcGFjaW5nJTNEJTIydHJhaWxpbmclMjIlMEEpJTBBcGlwZWxpbmUudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, DDIMScheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>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>

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