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