|
import{S as ut,i as mt,s as gt,k as o,a as M,q as p,H as wt,l as s,m as i,h as r,c as N,r as u,n,I as ze,p as bt,F as e,b as De,J as it,K as le,L as vt,M as yt,A as lt,N as _t,o as Et,z as It,O as Dt,P as Ke}from"../../chunks/index-c0a82f06.js";const{document:ye,window:ct}=Dt;function Ct(h){let R,c,A,I,J,D,x,m,L,j,G,P,l,y,U,f,S,g,ne,k,ce,Q,de,H,he,X,z,F,q,fe,re,oe,v,O,t,a,d,_,w,V,C,pe,T,ue,K,Ce,Ae,Z,xe,Pe,me,Se,Te,W,Le,$,je,ke,ee,Be,Me,ge,Ne,Re,Y,Oe,te,Ve,qe,ae,Fe,Ue,Ye;return{c(){R=o("link"),c=o("script"),I=o("script"),D=o("script"),m=M(),L=o("div"),j=o("canvas"),P=M(),l=o("div"),y=o("div"),U=M(),f=o("div"),S=o("div"),g=o("input"),ne=M(),k=o("button"),ce=p("diffuse the f rest"),de=M(),H=o("p"),he=p("pro tip: upload img by pasting OR dropping on the canvas"),X=M(),z=o("div"),F=o("label"),q=o("input"),fe=p(` |
|
upload img`),He.forEach(r),Qe.forEach(r),se.forEach(r),Ee.forEach(r),_e.forEach(r),oe=N(b),v=s(b,"ARTICLE",{class:!0});var B=i(v);O=s(B,"P",{});var ie=i(O);t=u(ie,"Model by "),a=s(ie,"A",{href:!0,rel:!0});var Xe=i(a);d=u(Xe,"CompVis"),Xe.forEach(r),_=u(ie," and "),w=s(ie,"A",{href:!0,rel:!0});var Ze=i(w);V=u(Ze,"Stability AI"),Ze.forEach(r),C=u(ie," - Demo by \u{1F917} Hugging Face"),ie.forEach(r),pe=N(B),T=s(B,"P",{});var we=i(T);ue=u(we,"Powered by "),K=s(we,"A",{href:!0,rel:!0});var $e=i(K);Ce=u($e,"\u{1F917} Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch"),$e.forEach(r),Ae=u(we,". Based on "),Z=s(we,"A",{href:!0,rel:!0});var et=i(Z);xe=u(et,"notebook by @psuraj28"),et.forEach(r),we.forEach(r),Pe=N(B),me=s(B,"H3",{});var tt=i(me);Se=u(tt,"LICENSE"),tt.forEach(r),Te=N(B),W=s(B,"P",{});var be=i(W);Le=u(be,"The model is licensed with a "),$=s(be,"A",{href:!0,rel:!0});var at=i($);je=u(at,"CreativeML Open RAIL-M"),at.forEach(r),ke=u(be," license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please "),ee=s(be,"A",{href:!0,rel:!0});var nt=i(ee);Be=u(nt,"read the license"),nt.forEach(r),be.forEach(r),Me=N(B),ge=s(B,"H3",{});var rt=i(ge);Ne=u(rt,"Biases and content acknowledgment"),rt.forEach(r),Re=N(B),Y=s(B,"P",{});var ve=i(Y);Oe=u(ve,"Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the "),te=s(ve,"A",{href:!0,rel:!0});var ot=i(te);Ve=u(ot,"LAION-5B dataset"),ot.forEach(r),qe=u(ve,", which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the "),ae=s(ve,"A",{href:!0,rel:!0});var st=i(ae);Fe=u(st,"model card"),st.forEach(r),ve.forEach(r),B.forEach(r),this.h()},h(){n(R,"href","https://cdnjs.cloudflare.com/ajax/libs/drawingboard.js/0.4.2/drawingboard.css"),n(R,"rel","stylesheet"),ze(c.src,A="https://code.jquery.com/jquery-1.12.4.min.js")||n(c,"src",A),ze(I.src,J="https://cdnjs.cloudflare.com/ajax/libs/drawingboard.js/0.4.2/drawingboard.min.js")||n(I,"src",J),ze(D.src,x="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js")||n(D,"src",x),n(j,"class",G="border-[1.2px] desktop:mt-[34px] "+(h[5]?"":"hidden")),n(y,"id","board-container"),n(g,"type","text"),n(g,"class","border-2 py-1"),n(g,"placeholder","Add prompt"),n(k,"class","bg-blue-500 hover:bg-blue-700 text-white font-bold py-1.5 px-4"),n(S,"class",Q="flex gap-x-2 mt-3 items-center justify-center "+(h[1]?"animate-pulse":"")),n(H,"class","no-hover:hidden mt-2 opacity-50"),n(q,"accept","image/*"),bt(q,"display","none"),n(q,"type","file"),n(F,"class","with-hover:hidden border py-1 px-1.5 bg-slate-200 cursor-pointer"),n(z,"class","mt-2"),n(l,"class",re="flex flex-col items-center "+(h[1]?"pointer-events-none":"")),n(L,"class","flex flex-wrap gap-x-4 gap-y-2 justify-center my-8"),n(a,"href","https://huggingface.co/CompVis"),n(a,"rel","nofollow"),n(w,"href","https://huggingface.co/stabilityai"),n(w,"rel","nofollow"),n(K,"href","https://github.com/huggingface/diffusers"),n(K,"rel","nofollow"),n(Z,"href","https://twitter.com/psuraj28/status/1562039265126670339"),n(Z,"rel","nofollow"),n($,"href","https://huggingface.co/spaces/CompVis/stable-diffusion-license"),n($,"rel","nofollow"),n(ee,"href","https://huggingface.co/spaces/CompVis/stable-diffusion-license"),n(ee,"rel","nofollow"),n(te,"href","https://laion.ai/blog/laion-5b/"),n(te,"rel","nofollow"),n(ae,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),n(ae,"rel","nofollow"),n(v,"class","prose-sm px-24 mb-8")},m(b,E){e(ye.head,R),e(ye.head,c),e(ye.head,I),e(ye.head,D),De(b,m,E),De(b,L,E),e(L,j),h[11](j),e(L,P),e(L,l),e(l,y),h[12](y),e(l,U),e(l,f),e(f,S),e(S,g),it(g,h[0]),e(S,ne),e(S,k),e(k,ce),e(f,de),e(f,H),e(H,he),e(f,X),e(f,z),e(z,F),e(F,q),h[14](q),e(F,fe),De(b,oe,E),De(b,v,E),e(v,O),e(O,t),e(O,a),e(a,d),e(O,_),e(O,w),e(w,V),e(O,C),e(v,pe),e(v,T),e(T,ue),e(T,K),e(K,Ce),e(T,Ae),e(T,Z),e(Z,xe),e(v,Pe),e(v,me),e(me,Se),e(v,Te),e(v,W),e(W,Le),e(W,$),e($,je),e(W,ke),e(W,ee),e(ee,Be),e(v,Me),e(v,ge),e(ge,Ne),e(v,Re),e(v,Y),e(Y,Oe),e(Y,te),e(te,Ve),e(Y,qe),e(Y,ae),e(ae,Fe),Ue||(Ye=[le(ct,"drop",vt(yt(h[8]))),le(ct,"paste",h[9]),le(g,"keydown",h[10]),le(g,"input",h[13]),le(k,"click",h[6]),le(q,"change",h[7])],Ue=!0)},p(b,E){E[0]&32&&G!==(G="border-[1.2px] desktop:mt-[34px] "+(b[5]?"":"hidden"))&&n(j,"class",G),E[0]&1&&g.value!==b[0]&&it(g,b[0]),E[0]&2&&Q!==(Q="flex gap-x-2 mt-3 items-center justify-center "+(b[1]?"animate-pulse":""))&&n(S,"class",Q),E[0]&2&&re!==(re="flex flex-col items-center "+(b[1]?"pointer-events-none":""))&&n(l,"class",re)},i:lt,o:lt,d(b){r(R),r(c),r(I),r(D),b&&r(m),b&&r(L),h[11](null),h[12](null),h[14](null),b&&r(oe),b&&r(v),Ue=!1,_t(Ye)}}}const We=500,dt=3e3;function At(){window.createImageBitmap=async function(h){return new Promise((R,c)=>{const A=document.createElement("canvas"),I=A.getContext("2d");A.width=h.width,A.height=h.height,I.putImageData(h,0,0);const J=A.toDataURL(),D=document.createElement("img");D.addEventListener("load",()=>{R(D)}),D.src=J})}}function xt(h,R,c){let A="",I=!1,J=!1,D,x,m,L,j,G,P,l=400,y,U,f,S=!1,g=[];async function ne(){if(!m)return;const t=m.createImageData(x.width,x.height),a=t.data;for(let w=0,V=a.length;w<V;w+=4)a[w]=40*Math.random()*7,a[w+1]=40*Math.random()*7,a[w+2]=40*Math.random()*7,a[w+3]=255;const d=await createImageBitmap(t),_=performance.now()-L;m.globalAlpha=Math.min(_,dt)/dt,m.drawImage(d,0,0,l,l),I&&window.requestAnimationFrame(ne)}function k(t){if(!m)return;const a=performance.now()-j;m.globalAlpha=Math.min(a,We)/We,m.drawImage(t,0,0,l,l),a<We&&window.requestAnimationFrame(()=>k(t))}async function ce(t){const a=t.toDataURL("png"),_=await(await fetch(a)).blob(),w=new File([_],"canvas shot.png",{type:"image/png"}),V=t.getContext("2d").getImageData(0,0,l,l),C=await createImageBitmap(V);return{imgFile:w,imgBitmap:C}}async function Q(){if(!A)return alert("Please add prompt");if(!x||!m)return;c(1,I=!0),c(5,S=!1),he(),L=performance.now(),ne();const{imgFile:t,imgBitmap:a}=await ce(x),d=new FormData;d.append("prompt",A),d.append("strength","0.85"),d.append("image",t);try{const _=await fetch("https://sdb.pcuenca.net/i2i",{method:"POST",body:d}),w=JSON.parse(await _.text()),{images:V}=w;if(!V.length)return alert("All the results were flagged. Please try again with diffeerent sketch + prompt");g=await Promise.all(V.map(async pe=>{const T=new Image;return T.src=`data:image/png;base64, ${pe}`,await new Promise((ue,K)=>{T.onload=()=>ue(T)}),T})),c(1,I=!1),P&&clearInterval(P),c(5,S=!0);let C=0;j=performance.now(),k(g[C%g.length]),G=()=>{P&&clearInterval(P),j=performance.now(),C=C+1,k(g[C%g.length])},P=setInterval(()=>{C=C+1,j=performance.now(),k(g[C%g.length])},2500),!J&&g.length>1&&de()}catch(_){console.error(_),alert("Error happened, queue might be full. Please try again in a bit :)")}}function de(){const t=document.createElement("div");t.className="drawing-board-control";const a=document.createElement("button");a.innerHTML="\u23EF",a.onclick=G,t.append(a);const d=document.querySelector(".drawing-board-controls");d&&(d.appendChild(t),J=!0,c(2,y.onclick=()=>{P&&clearInterval(P)},y))}function H(){const t=document.createElement("div");t.className="drawing-board-control";const a=document.createElement("button");a.innerHTML="\u{1F9F9}",a.onclick=()=>{m==null||m.clearRect(0,0,l,l)},t.append(a);const d=document.querySelector(".drawing-board-controls");d&&d.appendChild(t)}function he(){const t=f.getContext("2d");c(4,f.width=x.width,f),c(4,f.height=x.height,f),t.drawImage(x,0,0)}async function X(t){P&&clearInterval(P);const a=new Image;a.src=URL.createObjectURL(t),await new Promise((w,V)=>{a.onload=()=>w(a)});const{width:d,height:_}=a;m==null||m.drawImage(a,0,0,d,_,0,0,l,l)}function z(){var a;const t=(a=U.files)==null?void 0:a[0];t&&X(t)}function F(t){var _;if(!((_=t.dataTransfer)!=null&&_.files))return;t.preventDefault();const d=Array.from(t.dataTransfer.files)[0];X(d)}function q(t){if(!t.clipboardData)return;const a=Array.from(t.clipboardData.files);if(a.length===0)return;t.preventDefault();const d=a[0];X(d)}function fe(t){t.code==="Enter"&&(t.preventDefault(),Q())}Et(async()=>{typeof createImageBitmap>"u"&&At();const{innerWidth:t}=window;l=Math.min(l,Math.floor(t*.75)),c(2,y.style.width=`${l}px`,y),c(2,y.style.height=`${l}px`,y),c(4,f.style.width=`${l}px`,f),c(4,f.style.height=`${l}px`,f),await It(),D=new window.DrawingBoard.Board("board-container",{size:10,controls:["Color",{Size:{type:"dropdown"}},{DrawingMode:{filler:!1}}],webStorage:!1,enlargeYourContainer:!0}),x=D.canvas,m=x.getContext("2d"),x.ondragover=function(a){return a.preventDefault(),!1},H()});function re(t){Ke[t?"unshift":"push"](()=>{f=t,c(4,f)})}function oe(t){Ke[t?"unshift":"push"](()=>{y=t,c(2,y)})}function v(){A=this.value,c(0,A)}function O(t){Ke[t?"unshift":"push"](()=>{U=t,c(3,U)})}return[A,I,y,U,f,S,Q,z,F,q,fe,re,oe,v,O]}class St extends ut{constructor(R){super(),mt(this,R,xt,Ct,gt,{},null,[-1,-1])}}export{St as default}; |