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