Buckets:

rtrm's picture
download
raw
7.66 kB
import{s as re,o as pe,n as ce}from"../chunks/scheduler.182ea377.js";import{S as me,i as ue,g as r,s as i,p as I,A as he,h as p,f as s,c as o,j as F,q as Z,m,k as U,v as j,a as l,r as V,d as B,t as S,u as C}from"../chunks/index.008d68e4.js";import{T as de}from"../chunks/Tip.4f096367.js";import{I as fe}from"../chunks/IconCopyLink.96bbb92b.js";import{C as A}from"../chunks/CodeBlock.5ed6eb7b.js";function ye(W){let n,d="💡 Take a look at the paper linked above for more details about the proposed solutions!";return{c(){n=r("p"),n.textContent=d},l(a){n=p(a,"P",{"data-svelte-h":!0}),m(n)!=="svelte-pl5qbq"&&(n.textContent=d)},m(a,c){l(a,n,c)},p:ce,d(a){a&&s(n)}}}function ge(W){let n,d,a,c,G,f,Y,x,K="Control image brightness",k,y,O='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.25.0/pt/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> which you can use to improve the lighting in your images.',D,u,N,g,ee='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>:',R,_,H,M,te='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>.',L,T,se='Next, configure the following parameters in the <a href="/docs/diffusers/v0.25.0/pt/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>:',q,w,le="<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>",X,v,z,b,ne="Finally, in your call to the pipeline, set <code>guidance_rescale</code> to prevent overexposure:",E,J,Q,h,ae='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/zero_snr.png"/>',P;return f=new fe({}),u=new de({props:{$$slots:{default:[ye]},$$scope:{ctx:W}}}),_=new A({props:{code:"LS1wcmVkaWN0aW9uX3R5cGUlM0QlMjJ2X3ByZWRpY3Rpb24lMjI=",highlighted:'--prediction_type=<span class="hljs-string">&quot;v_prediction&quot;</span>'}}),v=new A({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>)`}}),J=new A({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`}}),{c(){n=r("meta"),d=i(),a=r("h1"),c=r("a"),G=r("span"),I(f.$$.fragment),Y=i(),x=r("span"),x.textContent=K,k=i(),y=r("p"),y.innerHTML=O,D=i(),I(u.$$.fragment),N=i(),g=r("p"),g.innerHTML=ee,R=i(),I(_.$$.fragment),H=i(),M=r("p"),M.innerHTML=te,L=i(),T=r("p"),T.innerHTML=se,q=i(),w=r("ol"),w.innerHTML=le,X=i(),I(v.$$.fragment),z=i(),b=r("p"),b.innerHTML=ne,E=i(),I(J.$$.fragment),Q=i(),h=r("div"),h.innerHTML=ae,this.h()},l(e){const t=he("svelte-1phssyn",document.head);n=p(t,"META",{name:!0,content:!0}),t.forEach(s),d=o(e),a=p(e,"H1",{class:!0});var $=F(a);c=p($,"A",{id:!0,class:!0,href:!0});var ie=F(c);G=p(ie,"SPAN",{});var oe=F(G);Z(f.$$.fragment,oe),oe.forEach(s),ie.forEach(s),Y=o($),x=p($,"SPAN",{"data-svelte-h":!0}),m(x)!=="svelte-a5e88s"&&(x.textContent=K),$.forEach(s),k=o(e),y=p(e,"P",{"data-svelte-h":!0}),m(y)!=="svelte-lnq7ys"&&(y.innerHTML=O),D=o(e),Z(u.$$.fragment,e),N=o(e),g=p(e,"P",{"data-svelte-h":!0}),m(g)!=="svelte-116mx1h"&&(g.innerHTML=ee),R=o(e),Z(_.$$.fragment,e),H=o(e),M=p(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-1uuaxw4"&&(M.innerHTML=te),L=o(e),T=p(e,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1qu68h4"&&(T.innerHTML=se),q=o(e),w=p(e,"OL",{"data-svelte-h":!0}),m(w)!=="svelte-1rg1cr0"&&(w.innerHTML=le),X=o(e),Z(v.$$.fragment,e),z=o(e),b=p(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-xfpf26"&&(b.innerHTML=ne),E=o(e),Z(J.$$.fragment,e),Q=o(e),h=p(e,"DIV",{class:!0,"data-svelte-h":!0}),m(h)!=="svelte-1fieqb3"&&(h.innerHTML=ae),this.h()},h(){U(n,"name","hf:doc:metadata"),U(n,"content",JSON.stringify(_e)),U(c,"id","control-image-brightness"),U(c,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),U(c,"href","#control-image-brightness"),U(a,"class","relative group"),U(h,"class","flex justify-center")},m(e,t){j(document.head,n),l(e,d,t),l(e,a,t),j(a,c),j(c,G),V(f,G,null),j(a,Y),j(a,x),l(e,k,t),l(e,y,t),l(e,D,t),V(u,e,t),l(e,N,t),l(e,g,t),l(e,R,t),V(_,e,t),l(e,H,t),l(e,M,t),l(e,L,t),l(e,T,t),l(e,q,t),l(e,w,t),l(e,X,t),V(v,e,t),l(e,z,t),l(e,b,t),l(e,E,t),V(J,e,t),l(e,Q,t),l(e,h,t),P=!0},p(e,[t]){const $={};t&2&&($.$$scope={dirty:t,ctx:e}),u.$set($)},i(e){P||(B(f.$$.fragment,e),B(u.$$.fragment,e),B(_.$$.fragment,e),B(v.$$.fragment,e),B(J.$$.fragment,e),P=!0)},o(e){S(f.$$.fragment,e),S(u.$$.fragment,e),S(_.$$.fragment,e),S(v.$$.fragment,e),S(J.$$.fragment,e),P=!1},d(e){e&&(s(d),s(a),s(k),s(y),s(D),s(N),s(g),s(R),s(H),s(M),s(L),s(T),s(q),s(w),s(X),s(z),s(b),s(E),s(Q),s(h)),s(n),C(f),C(u,e),C(_,e),C(v,e),C(J,e)}}}const _e={local:"control-image-brightness",title:"Control image brightness"};function Me(W){return pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $e extends me{constructor(n){super(),ue(this,n,Me,ge,re,{})}}export{$e as component};

Xet Storage Details

Size:
7.66 kB
·
Xet hash:
428a37fa1119eb6f699c51d22b56f3ca6b5f37224e2b42e9246838dadf83e586

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.