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