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