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