File size: 3,316 Bytes
626f025
1
import{B as e,C as t,Ct as n,H as r,S as i,T as a,_ as o,b as s,dt as c,et as l,g as u,m as d,v as f,yt as p}from"./modules/shiki-CJZsCeMT.js";import{t as m}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as h}from"./slidev/context-DB-9afGB.js";import{C as g,E as _,b as v,l as y,m as b,p as x,x as S}from"./useGenerative-DhxjRRg5.js";import{n as C,t as w}from"./StepButton-BHTS1uiY.js";import{t as T}from"./Plot2D-ifvwvNLG.js";import{t as E}from"./PlotPoints-Cxs9FmbK.js";import{t as D}from"./Slider-C2M0Z0oG.js";import{t as O}from"./PlotLine-CUED7wZE.js";var k={class:`dl-diff__out`},A={class:`dl-diff__note`},j=m(a({__name:`DiffusionLab`,props:{reverse:{type:Boolean,default:!1},field:{type:Boolean,default:!1}},setup(a){let{$slidev:m,$nav:j,$clicksContext:M,$clicks:N,$page:P,$renderContext:F,$frontmatter:I}=h(),L=a,{alphaBar:R,steps:z}=b(),B=c(L.reverse?`reverse`:`forward`),V=c(L.field),H=c(L.reverse?z-1:0),U=S(20),W=(()=>{let e=_(31337);return U.map(()=>({x:e(),y:e()}))})(),G=u(()=>R.map(e=>U.map((t,n)=>y(t,e,W[n])))),K=u(()=>{let e=Array(z),t=g(20);e[z-1]=t;for(let n=z-1;n>0;n--)t=t.map(e=>v(e,R[n],R[n-1])),e[n-1]=t;return e}),q=u(()=>(B.value===`forward`?G.value:K.value)[H.value]),J=u(()=>R[H.value]),Y=u(()=>{if(!V.value)return[];let e=[],t=.6;for(let n=-3;n<=3;n+=1.5)for(let r=-2;r<=2;r+=1.33){let i=x({x:n,y:r},J.value),a=Math.hypot(i.x,i.y);a<1e-9||e.push({from:[n,r],to:[n+i.x/a*t,r+i.y/a*t]})}return e});function X(e){H.value=Math.min(Math.max(e,0),z-1)}return(a,c)=>{let u=O,m=E,h=T,g=D,_=w,v=C;return e(),f(v,{"max-width":`44rem`},{controls:l(()=>[t(g,{modelValue:H.value,"onUpdate:modelValue":c[0]||=e=>H.value=e,label:B.value===`forward`?`noise level t`:`sampling step t`,min:0,max:p(z)-1,step:1,precision:0},null,8,[`modelValue`,`label`,`max`]),t(_,{label:B.value===`forward`?`forward — add noise`:`reverse — remove it`,variant:`ghost`,glyph:`⇄`,onClick:c[1]||=e=>B.value=B.value===`forward`?`reverse`:`forward`},null,8,[`label`]),t(_,{label:`t = 0`,variant:`ghost`,onClick:c[2]||=e=>X(0)}),t(_,{label:`t = ${p(z)-1}`,variant:`ghost`,onClick:c[3]||=e=>X(p(z)-1)},null,8,[`label`]),t(_,{label:V.value?`hide the field`:`show the field`,variant:`ghost`,onClick:c[4]||=e=>V.value=!V.value},null,8,[`label`])]),readout:l(()=>[o(`div`,k,[o(`span`,null,[c[5]||=i(`t = `,-1),o(`b`,null,n(H.value),1),i(` of `+n(p(z)-1),1)]),o(`span`,null,[c[6]||=i(`√ᾱ`,-1),c[7]||=o(`sub`,null,`t`,-1),c[8]||=i(` = `,-1),o(`b`,null,n(Math.sqrt(J.value).toFixed(3)),1),c[9]||=i(` of the image`,-1)]),o(`span`,null,[c[10]||=i(`√(1−ᾱ`,-1),c[11]||=o(`sub`,null,`t`,-1),c[12]||=i(`) = `,-1),o(`b`,null,n(Math.sqrt(1-J.value).toFixed(3)),1),c[13]||=i(` of noise`,-1)]),o(`span`,A,n(B.value===`forward`?`every frame computed from x₀ in one step — no chain simulated`:`each frame needs the one before it — this is why sampling is slow`),1)])]),default:l(()=>[t(h,{"x-domain":[-4,4],"y-domain":[-2.8,2.8],width:470,height:252,"x-ticks":[-4,-2,0,2,4],"y-ticks":[-2,0,2]},{default:l(()=>[(e(!0),s(d,null,r(Y.value,(t,n)=>(e(),f(u,{key:`a${n}`,from:t.from,to:t.to,color:`var(--dl-muted)`,width:1.2,opacity:.55,arrow:``},null,8,[`from`,`to`]))),128)),t(m,{points:q.value,radius:4.2,color:`var(--dl-accent)`},null,8,[`points`])]),_:1})]),_:1})}}}),[[`__scopeId`,`data-v-22c227ee`]]);export{j as t};