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