diff --git a/CHANGELOG.md b/CHANGELOG.md index af03d1682..3de3ea493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # @vladmandic/human - Version: **2.10.0** + Version: **2.10.1** Description: **Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gesture Recognition** Author: **Vladimir Mandic ** @@ -9,7 +9,10 @@ ## Changelog -### **HEAD -> main** 2022/09/06 mandic00@live.com +### **HEAD -> main** 2022/09/07 mandic00@live.com + + +### **origin/main** 2022/09/07 mandic00@live.com - add config flags - test update diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index ec6388890..57302deb6 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -96,7 +96,7 @@ var _2=Object.defineProperty;var No=Object.getOwnPropertyDescriptor;var Oo=Objec c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var t5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},o5=class{constructor(t,o,n){w(this,"uniform",{});w(this,"attribute",{});w(this,"gl");w(this,"id");w(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(g(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(g("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!s)){if(!this.id){g("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){g(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),t5(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);t5(o,"uniform",this.uniform),t5(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function U1(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,c=a0(100,100),x={},d={INTERMEDIATE:1},l=c.getContext("webgl");if(!l){g("filter: cannot get webgl context");return}this.gl=l;function f(P,p){if(!(P===c.width&&p===c.height)){if(c.width=P,c.height=p,!a){let h=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,a),l.bufferData(l.ARRAY_BUFFER,h,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,c.width,c.height),r=[null,null]}}function y(P,p){let h=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,h);let E=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,E);let k=l.createTexture();return l.bindTexture(l.TEXTURE_2D,k),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,P,p,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,k,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:h,texture:k}}function m(P){return r[P]=r[P]||y(c.width,c.height),r[P]}function u(P=0){if(!i)return;let p=null,h=null,E=!1;e===0?p=t:p=m(n).texture||null,e++,o&&!(P&d.INTERMEDIATE)?(h=null,E=e%2===0):(n=(n+1)%2,h=m(n).fbo||null),l.bindTexture(l.TEXTURE_2D,p),l.bindFramebuffer(l.FRAMEBUFFER,h),l.uniform1f(i.uniform.flipY,E?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(P){if(x[P])return i=x[P],l.useProgram((i?i.id:null)||null),i;if(i=new o5(l,H1,P),!i)return g("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,h=4*p;return l.enableVertexAttribArray(i.attribute.pos),l.vertexAttribPointer(i.attribute.pos,2,l.FLOAT,!1,h,0*p),l.enableVertexAttribArray(i.attribute.uv),l.vertexAttribPointer(i.attribute.uv,2,l.FLOAT,!1,h,2*p),x[P]=i,i}let v={colorMatrix:P=>{let p=new Float32Array(P);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let h=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?V1:D1,E=M(h);!E||(l.uniform1fv(E.uniform.m,p),u())},brightness:P=>{let p=(P||0)+1;v.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:P=>{let p=(P||0)*2/3+1,h=(p-1)*-.5;v.colorMatrix([p,h,h,0,0,h,p,h,0,0,h,h,p,0,0,0,0,0,1,0])},desaturate:()=>{v.saturation(-1)},contrast:P=>{let p=(P||0)+1,h=-128*(p-1);v.colorMatrix([p,0,0,0,h,0,p,0,0,h,0,0,p,0,h,0,0,0,1,0])},negative:()=>{v.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let p=Math.cos(P),h=Math.sin(P),E=.213,k=.715,b=.072;v.colorMatrix([E+p*(1-E)+h*-E,k+p*-k+h*-k,b+p*-b+h*(1-b),0,0,E+p*-E+h*.143,k+p*(1-k)+h*.14,b+p*-b+h*-.283,0,0,E+p*-E+h*-(1-E),k+p*-k+h*k,b+p*(1-b)+h*b,0,0,0,0,0,1,0])},desaturateLuminance:()=>{v.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{v.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{v.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{v.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{v.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{v.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{v.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{v.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let p=new Float32Array(P),h=1/c.width,E=1/c.height,k=M(q1);!k||(l.uniform1fv(k.uniform.m,p),l.uniform2f(k.uniform.px,h,E),u())},detectEdges:()=>{v.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{v.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{v.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let p=P||1;v.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:P=>{let p=P||1;v.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:P=>{let p=P/7/c.width,h=P/7/c.height,E=M(X1);!E||(l.uniform2f(E.uniform.px,0,h),u(d.INTERMEDIATE),l.uniform2f(E.uniform.px,p,0),u())},pixelate:P=>{let p=P/c.width,h=P/c.height,E=M(Z1);!E||(l.uniform2f(E.uniform.size,p,h),u())}};this.add=function(P){let p=Array.prototype.slice.call(arguments,1),h=v[P];s.push({func:h,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(P){f(P.width,P.height),e=0,t||(t=l.createTexture()),l.bindTexture(l.TEXTURE_2D,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,P);for(let p=0;py.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[A.sub(o[0],n[0]),A.sub(o[1],n[1]),A.sub(o[2],n[2])],c=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,c[0]),A.div(a,c[1]),A.div(a,c[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],l=A.stack([d[0],d[1],d[2]],2),f=A.reshape(l,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...c,...x,...d,l,t]),f}var x2=3840,e0=null,t0=null,Me=null,D,b0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function n5(){b0.inputSum=0,b0.cacheDiff=1,b0.sumMethod=0,b0.inputTensor=void 0}function a0(e,t){let o;if(T.browser)if(T.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof T.Canvas!="undefined"?o=new T.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function y2(e,t){let o=t||a0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function ve(e,t,o=!0){var f,y;if(!e)return t.debug&&g("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof ge)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof T.Canvas!="undefined"&&e instanceof T.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof ge){let m=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)m=A.expandDims(e,0);else if(e.shape[2]===4){let u=A.slice3d(e,[0,0,0],[-1,-1,3]);m=A.expandDims(u,0),A.dispose(u)}}else e.shape.length===4&&(e.shape[3]===3?m=A.clone(e):e.shape[3]===4&&(m=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(m==null||m.shape.length!==4||m.shape[0]!==1||m.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(m.dtype==="int32"){let u=A.cast(m,"float32");A.dispose(m),m=u}return{tensor:m,canvas:t.filter.return?t0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&g("input stream is not ready"),{tensor:null,canvas:e0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&g("cannot determine input dimensions"),{tensor:null,canvas:e0};let s=n,a=r;if(s>x2&&(s=x2,a=Math.trunc(s*r/n)),a>x2&&(a=x2,s=Math.trunc(a*n/r)),(((f=t.filter)==null?void 0:f.width)||0)>0?s=t.filter.width:(((y=t.filter)==null?void 0:y.height)||0)>0&&(s=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=r*((t.filter.width||0)/n)),!s||!a)throw new Error("input error: cannot determine dimension");(!e0||e0.width!==s||e0.height!==a)&&(e0=a0(s,a));let i=e0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(n,0),i.scale(-1,1),i.drawImage(e,0,0,n,r,0,0,e0.width,e0.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,e0.width,e0.height),(!t0||e0.width!==t0.width||e0.height!==t0.height)&&(t0=a0(e0.width,e0.height)),t.filter.enabled&&T.webgl.supported?(D||(D=T.browser?new U1:null),T.filter=!!D,D!=null&&D.add?(D.reset(),t.filter.brightness!==0&&D.add("brightness",t.filter.brightness),t.filter.contrast!==0&&D.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&D.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&D.add("blur",t.filter.blur),t.filter.saturation!==0&&D.add("saturation",t.filter.saturation),t.filter.hue!==0&&D.add("hue",t.filter.hue),t.filter.negative&&D.add("negative"),t.filter.sepia&&D.add("sepia"),t.filter.vintage&&D.add("brownie"),t.filter.sepia&&D.add("sepia"),t.filter.kodachrome&&D.add("kodachrome"),t.filter.technicolor&&D.add("technicolor"),t.filter.polaroid&&D.add("polaroid"),t.filter.pixelate!==0&&D.add("pixelate",t.filter.pixelate),D.get()>0?t0=D.apply(e0):t0=D.draw(e0)):(t.debug&&g("input process error: cannot initialize filters"),T.webgl.supported=!1,t.filter.enabled=!1,y2(e0,t0))):(y2(e0,t0),D&&(D=null),T.filter=!!D),!o)return{tensor:null,canvas:t0};if(!t0)throw new Error("canvas error: cannot create output");let c,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(T.browser&&A.browser)c=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let m=new Uint8Array(e.data.buffer);c=A.tensor(m,[e.height,e.width,x],"int32")}else if((!Me||t0.width!==Me.width||t0.height!==Me.height)&&(Me=a0(t0.width,t0.height)),A.browser&&T.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?c=A.browser.fromPixels(t0):(Me=y2(t0),c=A.browser.fromPixels(Me));else{let M=y2(t0).getContext("2d").getImageData(0,0,s,a);x=M.data.length/s/a;let v=new Uint8Array(M.data.buffer);c=A.tensor(v,[s,a,x])}if(x===4){let m=A.slice3d(c,[0,0,0],[-1,-1,3]);A.dispose(c),c=m}if(!c)throw new Error("input error: cannot create tensor");let d=A.cast(c,"float32"),l=t.filter.equalization?await c2(d):A.expandDims(d,0);return A.dispose([c,d]),{tensor:l,canvas:t.filter.return?t0:null}}async function Y1(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!b0.inputTensor)b0.inputTensor=A.clone(t);else if(b0.inputTensor.shape[1]!==t.shape[1]||b0.inputTensor.shape[2]!==t.shape[2])A.dispose(b0.inputTensor),b0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,b0.inputTensor),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;A.dispose([b0.inputTensor,n.diff,n.squared,n.sum]),b0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function K1(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||g("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||g("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=A.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?A.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):A.clone(o),n.diff=A.sub(n.input1,n.input2),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return A.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var r5=class{constructor(){w(this,"browser");w(this,"node");w(this,"worker");w(this,"platform","");w(this,"agent","");w(this,"backends",[]);w(this,"initial");w(this,"filter");w(this,"tfjs");w(this,"offscreen");w(this,"perfadd",!1);w(this,"tensorflow",{version:void 0,gpu:void 0});w(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});w(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});w(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});w(this,"cpu",{model:void 0,flags:[]});w(this,"kernels",[]);w(this,"Canvas");w(this,"Image");w(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Ue["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(A.engine().registryFactory),this.tensorflow={version:A.backend().binding?A.backend().binding.TF_Version:void 0,gpu:A.backend().binding?A.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=A.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=A.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=a0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(A.getBackend()==="webgl"||A.getBackend()==="humangl")){let n=A.backend().gpgpu!=="undefined"?await A.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},T=new r5;var A5={};q0(A5,{age:()=>an,"anti-spoofing":()=>Gn,antispoof:()=>Yo,blazeface:()=>Ko,"blazeface-back":()=>ln,"blazeface-front":()=>cn,"blazepose-detect":()=>Fn,"blazepose-detector2d":()=>xn,"blazepose-detector3d":()=>yn,"blazepose-full":()=>dn,"blazepose-heavy":()=>fn,"blazepose-lite":()=>mn,default:()=>_n,efficientpose:()=>pn,"efficientpose-i-lite":()=>Bn,"efficientpose-ii-lite":()=>Hn,"efficientpose-iv":()=>Dn,emotion:()=>Jo,faceboxes:()=>un,facemesh:()=>Qo,"facemesh-attention":()=>bn,"facemesh-attention-alt":()=>hn,"facemesh-detection-full":()=>gn,"facemesh-detection-short":()=>Mn,"facemesh-orig":()=>vn,faceres:()=>_o,"faceres-deep":()=>Rn,gear:()=>Pn,gender:()=>wn,"gender-ssrnet-imdb":()=>Tn,handdetect:()=>kn,"handlandmark-full":()=>$o,"handlandmark-lite":()=>En,"handlandmark-sparse":()=>zn,handskeleton:()=>Sn,handtrack:()=>en,"insightface-efficientnet-b0":()=>Vn,"insightface-ghostnet-strides1":()=>Zn,"insightface-ghostnet-strides2":()=>Xn,"insightface-mobilenet-emore":()=>qn,"insightface-mobilenet-swish":()=>Un,iris:()=>tn,liveness:()=>on,"mb3-centernet":()=>nn,meet:()=>Cn,mobileface:()=>jn,mobilefacenet:()=>In,models:()=>rn,"movenet-lightning":()=>An,"movenet-multipose":()=>Nn,"movenet-thunder":()=>On,nanodet:()=>Ln,"nanodet-e":()=>Yn,"nanodet-g":()=>Kn,"nanodet-m":()=>Jn,"nanodet-t":()=>Qn,posenet:()=>Wn,selfie:()=>sn});var Yo=853098,Ko=538928,Jo=820516,Qo=1477958,_o=6978814,$o=5431368,en=2964837,tn=2599092,on=592976,nn=4030290,rn=0,An=4650216,sn=212886,an=161240,ln=538928,cn=402048,xn=7499400,yn=5928856,dn=6338290,fn=27501554,mn=2725490,pn=5651240,un=2013002,hn=2387598,bn=2382414,gn=1026192,Mn=201268,vn=2955780,Rn=13957620,Pn=1498916,Tn=161236,wn=201808,kn=3515612,En=2023432,zn=5286322,Sn=5502280,Cn=372228,jn=2183192,In=5171976,Nn=9448838,On=12477112,Ln=7574558,Wn=5032780,Fn=5928804,Gn=853098,Bn=2269064,Hn=5651240,Dn=25643252,Vn=13013224,Zn=8093408,Xn=8049584,qn=6938536,Un=12168584,Yn=12319156,Kn=7574558,Jn=1887474,Qn=5294216,_n={antispoof:Yo,blazeface:Ko,emotion:Jo,facemesh:Qo,faceres:_o,"handlandmark-full":$o,handtrack:en,iris:tn,liveness:on,"mb3-centernet":nn,models:rn,"movenet-lightning":An,selfie:sn,age:an,"blazeface-back":ln,"blazeface-front":cn,"blazepose-detector2d":xn,"blazepose-detector3d":yn,"blazepose-full":dn,"blazepose-heavy":fn,"blazepose-lite":mn,efficientpose:pn,faceboxes:un,"facemesh-attention-alt":hn,"facemesh-attention":bn,"facemesh-detection-full":gn,"facemesh-detection-short":Mn,"facemesh-orig":vn,"faceres-deep":Rn,gear:Pn,"gender-ssrnet-imdb":Tn,gender:wn,handdetect:kn,"handlandmark-lite":En,"handlandmark-sparse":zn,handskeleton:Sn,meet:Cn,mobileface:jn,mobilefacenet:In,"movenet-multipose":Nn,"movenet-thunder":On,nanodet:Ln,posenet:Wn,"blazepose-detect":Fn,"anti-spoofing":Gn,"efficientpose-i-lite":Bn,"efficientpose-ii-lite":Hn,"efficientpose-iv":Dn,"insightface-efficientnet-b0":Vn,"insightface-ghostnet-strides1":Zn,"insightface-ghostnet-strides2":Xn,"insightface-mobilenet-emore":qn,"insightface-mobilenet-swish":Un,"nanodet-e":Yn,"nanodet-g":Kn,"nanodet-m":Jn,"nanodet-t":Qn};var t2={};q0(t2,{Models:()=>s2,getModelStats:()=>h1,load:()=>b1,reset:()=>O2,validate:()=>U2,validateModel:()=>Ie});var T0,s5=[],$n=["white","black","asian","indian","other"],er=[15,23,28,35.5,45.5,55.5,65],J1=0,Q1=0,a5=Number.MAX_SAFE_INTEGER;async function _1(e){var t;return T.initial&&(T0=null),T0?e.debug&&g("cached model:",T0.modelUrl):T0=await L((t=e.face.gear)==null?void 0:t.modelPath),T0}async function i5(e,t,o,n){var a,i;if(!T0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=a5<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>R()-Q1;return t.skipAllowed&&s&&r&&J1===n&&s5[o]?(a5++,s5[o]):(a5=0,new Promise(async c=>{var v,P;if(!(T0!=null&&T0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[T0.inputs[0].shape[2],T0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(v=t.face.gear)!=null&&v.enabled&&([x.age,x.gender,x.race]=T0.execute(x.resize,["age_output","gender_output","race_output"]));let f=await x.gender.data();l.gender=f[0]>f[1]?"male":"female",l.genderScore=Math.round(100*(f[0]>f[1]?f[0]:f[1]))/100;let y=await x.race.data();for(let p=0;p(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&l.race.push({score:Math.round(100*y[p])/100,race:$n[p]});l.race.sort((p,h)=>h.score-p.score);let u=Array.from(await x.age.data()).map((p,h)=>[er[h],p]).sort((p,h)=>h[1]-p[1]),M=u[0][0];for(let p=1;pA.dispose(x[p])),s5[o]=l,J1=n,Q1=R(),c(l)}))}var F={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function et(){F.tf255=A.scalar(255,"float32"),F.tf1=A.scalar(1,"float32"),F.tf2=A.scalar(2,"float32"),F.tf05=A.scalar(.5,"float32"),F.tf127=A.scalar(127.5,"float32"),F.rgb=A.tensor1d([.2989,.587,.114],"float32")}var d0,d2=[],tt=0,ot=0,l5=Number.MAX_SAFE_INTEGER;async function nt(e){return T.initial&&(d0=null),d0?e.debug&&g("cached model:",d0.modelUrl):d0=await L(e.face.ssrnet.modelPathAge),d0}async function c5(e,t,o,n){var a,i,c,x;if(!d0)return{age:0};let r=l5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>R()-ot;return t.skipAllowed&&r&&s&&tt===n&&((c=d2[o])==null?void 0:c.age)&&((x=d2[o])==null?void 0:x.age)>0?(l5++,d2[o]):(l5=0,new Promise(async d=>{var y;if(!(d0!=null&&d0.inputs)||!d0.inputs[0]||!d0.inputs[0].shape)return;let l={};l.resize=A.image.resizeBilinear(e,[d0.inputs[0].shape[2],d0.inputs[0].shape[1]],!1),l.enhance=A.mul(l.resize,F.tf255);let f={age:0};if((y=t.face.ssrnet)!=null&&y.enabled&&(l.age=d0.execute(l.enhance)),l.age){let m=await l.age.data();f.age=Math.trunc(10*m[0])/10}Object.keys(l).forEach(m=>A.dispose(l[m])),d2[o]=f,tt=n,ot=R(),d(f)}))}var w0,f2=[],At=0,st=0,x5=Number.MAX_SAFE_INTEGER,y5=[.2989,.587,.114];async function at(e){var t;return T.initial&&(w0=null),w0?e.debug&&g("cached model:",w0.modelUrl):w0=await L((t=e.face.ssrnet)==null?void 0:t.modelPathGender),w0}async function d5(e,t,o,n){var a,i,c,x;if(!w0)return{gender:"unknown",genderScore:0};let r=x5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>R()-st;return t.skipAllowed&&r&&s&&At===n&&((c=f2[o])==null?void 0:c.gender)&&((x=f2[o])==null?void 0:x.genderScore)>0?(x5++,f2[o]):(x5=0,new Promise(async d=>{var m;if(!(w0!=null&&w0.inputs[0].shape))return;let l={};l.resize=A.image.resizeBilinear(e,[w0.inputs[0].shape[2],w0.inputs[0].shape[1]],!1),l.enhance=A.tidy(()=>{let[u,M,v]=A.split(l.resize,3,3),P=A.mul(u,y5[0]),p=A.mul(M,y5[1]),h=A.mul(v,y5[2]),E=A.addN([P,p,h]);return A.mul(A.sub(E,F.tf05),2)});let f={gender:"unknown",genderScore:0};(m=t.face.ssrnet)!=null&&m.enabled&&(l.gender=w0.execute(l.enhance));let y=await l.gender.data();f.gender=y[0]>y[1]?"female":"male",f.genderScore=y[0]>y[1]?Math.trunc(100*y[0])/100:Math.trunc(100*y[1])/100,Object.keys(l).forEach(u=>A.dispose(l[u])),f2[o]=f,At=n,st=R(),d(f)}))}var _,m2=[],f5=Number.MAX_SAFE_INTEGER,lt=0,ct=0;async function xt(e){var t;return T.initial&&(_=null),_?e.debug&&g("cached model:",_.modelUrl):_=await L((t=e.face.antispoof)==null?void 0:t.modelPath),_}async function m5(e,t,o,n){var a,i;if(!_||!(_!=null&&_.executor))return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>R()-ct,s=f5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&<===n&&m2[o]?(f5++,m2[o]):(f5=0,new Promise(async c=>{let x=A.image.resizeBilinear(e,[_!=null&&_.inputs[0].shape?_.inputs[0].shape[2]:0,_!=null&&_.inputs[0].shape?_.inputs[0].shape[1]:0],!1),d=_==null?void 0:_.execute(x),l=(await d.data())[0];m2[o]=Math.round(100*l)/100,lt=n,ct=R(),A.dispose([x,d]),c(m2[o])}))}var k0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},p5={count:468,mouth:13,symmetryLine:[13,k0.midwayBetweenEyes[0]]},ae={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},u5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Ke=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],ie=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var or=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],nr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],rr=[33,133,362,263,1,78,308],R7=or.map(e=>Ke[e]),P7=nr.map(e=>Ke[e]),T7=rr.map(e=>Ke[e]);function U0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Ar=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],sr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],ar=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],ir=[[474,475],[475,476],[476,477],[477,474]],lr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],cr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],xr=[[469,470],[470,471],[471,472],[472,469]],yr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],w7={lips:U0(Ar),leftEye:U0(sr),leftEyebrow:U0(ar),leftIris:U0(ir),rightEye:U0(lr),rightEyebrow:U0(cr),rightIris:U0(xr),faceOval:U0(yr)};var Re=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],p2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],u2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],h2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],mt=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},b5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],a=A.image.cropAndResize(t,[s],[0],o),i=A.div(a,F.tf255);return A.dispose(a),i},b2=(e,t)=>{let o=p2(e),n=Re(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},g2=e=>{let t=p2(e),o=Re(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},pt=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},g5=[[1,0,0],[0,1,0],[0,0,1]],dr=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),fr=(e,t)=>dr(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var dt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],s=dt(t[0],t[1]),a=ft(s,r),i=dt(-t[0],-t[1]);return ft(a,i)},pr=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-le(t[0],o),-le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},ur=(e,t)=>[le(e,t[0]),le(e,t[1])];function ht(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[s[0]/r*(y[0]-r/2),s[1]/r*(y[1]-r/2),y[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,c=i?ut(o,[0,0]):g5,x=i?a.map(y=>[...ur(y,c),y[2]]):a,d=i?pr(n):g5,l=p2(t),f=[le(l,d[0]),le(l,d[1])];return x.map(y=>[Math.trunc(y[0]+f[0]),Math.trunc(y[1]+f[1]),Math.trunc(y[2]||0)])}function gt(e,t,o,n){let r=t.landmarks.length>=p5.count?p5.symmetryLine:ae.symmetryLine,s=0,a=g5,i;if(e&&T.kernels.includes("rotatewithoffset"))if(s=fr(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=p2(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],l=A.image.rotateWithOffset(o,s,0,d);a=ut(-s,x),i=b5(t,l,[n,n]),A.dispose(l)}else i=b5(t,o,[n,n]);else i=b5(t,o,[n,n]);return[s,a,i]}var hr=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},Mt=(e,t)=>{let o=hr(e),n=Re(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var vt=6,br=1.4,C0,Rt=null,Y0=0,Je=null,Pe=()=>Y0;async function Pt(e){var t;return T.initial&&(C0=null),C0?e.debug&&g("cached model:",C0.modelUrl):C0=await L((t=e.face.detector)==null?void 0:t.modelPath),Y0=C0.executor&&C0.inputs[0].shape?C0.inputs[0].shape[2]:256,Je=A.scalar(Y0,"int32"),Rt=A.tensor2d(ht(Y0)),C0}function gr(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,Rt),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,Je),t.centersNormalized=A.div(t.centers,Je),t.halfBoxSize=A.div(t.boxSizesNormalized,F.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,Je),t.endNormalized=A.mul(t.ends,Je);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function Tt(e,t){var i,c,x,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=A.image.resizeBilinear(e,[Y0,Y0]),o.div=A.div(o.resized,F.tf127),o.normalized=A.sub(o.div,F.tf05);let n=C0==null?void 0:C0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((f,y)=>f.size-y.size);o.concat384=A.concat([l[0],l[2]],2),o.concat512=A.concat([l[1],l[3]],2),o.concat=A.concat([o.concat512,o.concat384],1),o.batch=A.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=A.squeeze(n[0]):o.batch=A.squeeze(n);A.dispose(n),o.boxes=gr(o.batch),o.logits=A.slice(o.batch,[0,0],[-1,1]),o.sigmoid=A.sigmoid(o.logits),o.scores=A.squeeze(o.sigmoid),o.nms=await A.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((c=t.face.detector)==null?void 0:c.iouThreshold)||0,((x=t.face.detector)==null?void 0:x.minConfidence)||0);let r=await o.nms.array(),s=[],a=await o.scores.data();for(let l=0;l(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let y={};y.bbox=A.slice(o.boxes,[r[l],0],[1,-1]),y.slice=A.slice(o.batch,[r[l],vt-1],[1,-1]),y.squeeze=A.squeeze(y.slice),y.landmarks=A.reshape(y.squeeze,[vt,-1]);let m=await y.bbox.data(),u={startPoint:[m[0],m[1]],endPoint:[m[2],m[3]],landmarks:await y.landmarks.array(),confidence:f},M=mt(u,[(e.shape[2]||0)/Y0,(e.shape[1]||0)/Y0]),v=b2(M,t.face.scale||br),P=g2(v);s.push(P),Object.keys(y).forEach(p=>A.dispose(y[p]))}}return Object.keys(o).forEach(l=>A.dispose(o[l])),s}var M2={};q0(M2,{connected:()=>R5,kpt:()=>v5});var v5=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],R5={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var kt=224,Mr,vr=5,v2=[8,16,32,32,32];function Et(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function G0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[n[0],n[1],r[0]-n[0],r[1]-n[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function zt(e,t=[1,1]){let o=[e.map(x=>x[0]),e.map(x=>x[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[(n[0]+r[0])/2,(n[1]+r[1])/2],a=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+r[0],-s[1]+r[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],c=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:c}}function R2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var jt={initial:!0},r0={detector:null,landmarks:null},Te={detector:[224,224],landmarks:[256,256]},P5=Number.MAX_SAFE_INTEGER,Pr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},T2=null,Qe,K0=[[0,0],[0,0],[0,0],[0,0]],St=0,Ct=e=>1-1/(1+Math.exp(e));async function It(e){var t;if(jt.initial&&(r0.detector=null),!r0.detector&&e.body.detector&&e.body.detector.modelPath){r0.detector=await L(e.body.detector.modelPath);let o=(t=r0.detector)!=null&&t.executor?Object.values(r0.detector.modelSignature.inputs):void 0;Te.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Te.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&r0.detector&&g("cached model:",r0.detector.modelUrl);return Et(),r0.detector}async function Nt(e){var t;if(jt.initial&&(r0.landmarks=null),r0.landmarks)e.debug&&g("cached model:",r0.landmarks.modelUrl);else{r0.landmarks=await L(e.body.modelPath);let o=(t=r0.landmarks)!=null&&t.executor?Object.values(r0.landmarks.modelSignature.inputs):void 0;Te.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Te.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return r0.landmarks}function Tr(e,t){var r,s;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((s=e==null?void 0:e.shape)!=null&&s[2]))return e;let n;if(Qe&&(o.cropped=A.image.cropAndResize(e,[Qe],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let a=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],i=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];K0=[[0,0],a,i,[0,0]],o.pad=A.pad(o.cropped||e,K0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,F.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,F.tf255)):n=A.div(o.cropped||e,F.tf255);return Object.keys(o).forEach(a=>A.dispose(o[a])),n}function wr(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+K0[2][0]+K0[2][1])/t[0]-K0[2][0]),Math.trunc(o.position[1]*(t[1]+K0[1][0]+K0[1][1])/t[1]-K0[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(Qe)for(let o of e)o.positionRaw=[o.positionRaw[0]+Qe[1],o.positionRaw[1]+Qe[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function kr(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),n=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");r.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function Er(e,t,o){var m,u;if(!((m=r0.landmarks)!=null&&m.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=r0.landmarks)==null?void 0:u.execute(e,Pr.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(M=>A.dispose(n[M]));let i=[],c=5;for(let M=0;MM.position),l=G0(d,[o[0],o[1]]),f={};for(let[M,v]of Object.entries(R5)){let P=[];for(let p=0;pk.part===v[p]),E=x.find(k=>k.part===v[p+1]);h&&E&&P.push([h.position,E.position])}f[M]=P}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:x,annotations:f}}async function T5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>R()-St,r=P5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&T2!==null)P5++;else{let s={};s.landmarks=Tr(e,256),T2=await Er(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),St=R(),P5=0}return T2?[T2]:[]}var we=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var x0,ce=0,w5=[],Lt=0,k5=Number.MAX_SAFE_INTEGER;async function Wt(e){if(T.initial&&(x0=null),x0)e.debug&&g("cached model:",x0.modelUrl);else{x0=await L(e.object.modelPath);let t=x0!=null&&x0.executor?Object.values(x0.modelSignature.inputs):void 0;ce=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return x0}async function zr(e,t,o){if(!e)return[];let n={},r=[],s=await e.array();n.squeeze=A.squeeze(e);let a=A.split(n.squeeze,6,1);n.stack=A.stack([a[1],a[0],a[3],a[2]],1),n.boxes=A.squeeze(n.stack),n.scores=A.squeeze(a[4]),n.classes=A.squeeze(a[5]),A.dispose([e,...a]),n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await n.nms.data(),c=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,l=s[0][x][5];if(Number.isNaN(l))continue;let f=we[l].label,[y,m]=[s[0][x][0]/ce,s[0][x][1]/ce],u=[y,m,s[0][x][2]/ce-y,s[0][x][3]/ce-m],M=[Math.trunc(u[0]*t[0]),Math.trunc(u[1]*t[1]),Math.trunc(u[2]*t[0]),Math.trunc(u[3]*t[1])];r.push({id:c++,score:d,class:l,label:f,box:M,boxRaw:u})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function E5(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.object.skipTime||0)>R()-Lt,n=k5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&w5.length>0?(k5++,w5):(k5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ce,ce]),i=t.object.enabled?x0==null?void 0:x0.execute(a,["tower_0/detections"]):null;Lt=R(),A.dispose(a);let c=await zr(i,s,t);w5=c,r(c)}))}var w2={};q0(w2,{connected:()=>S5,kpt:()=>z5});var z5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],S5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $,Gt=0,i0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},C5=Number.MAX_SAFE_INTEGER;async function Bt(e){return T.initial&&($=null),$?e.debug&&g("cached model:",$.modelUrl):$=await L(e.body.modelPath),$}async function Sr(e,t){let[o,n]=e.shape,r=A.reshape(e,[n*o]),s=A.max(r,0),a=(await s.data())[0];if(a>t){let i=A.argMax(r,0),c=A.mod(i,o),x=(await c.data())[0],d=A.div(i,o),l=(await d.data())[0];return A.dispose([r,s,i,c,d]),[x,l,a]}return A.dispose([r,s]),[0,0,a]}async function j5(e,t){if(!($!=null&&$.executor))return[];let o=(t.body.skipTime||0)>R()-Gt,n=C5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(i0.keypoints).length>0?(C5++,[i0]):(C5=0,new Promise(async r=>{let s=A.tidy(()=>{if(!($!=null&&$.inputs[0].shape))return null;let l=A.image.resizeBilinear(e,[$.inputs[0].shape[2],$.inputs[0].shape[1]],!1),f=A.mul(l,F.tf2);return A.sub(f,F.tf1)}),a;if(t.body.enabled&&(a=$==null?void 0:$.execute(s)),Gt=R(),A.dispose(s),a){i0.keypoints.length=0;let l=A.squeeze(a);A.dispose(a);let f=A.unstack(l,2);A.dispose(l);for(let y=0;y(t.body.minConfidence||0)&&i0.keypoints.push({score:Math.round(100*M)/100,part:z5[y],positionRaw:[m/$.inputs[0].shape[2],u/$.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/$.inputs[0].shape[2]),Math.round(e.shape[1]*u/$.inputs[0].shape[1])]})}f.forEach(y=>A.dispose(y))}i0.score=i0.keypoints.reduce((l,f)=>f.score>l?f.score:l,0);let i=i0.keypoints.map(l=>l.position[0]),c=i0.keypoints.map(l=>l.position[1]);i0.box=[Math.min(...i),Math.min(...c),Math.max(...i)-Math.min(...i),Math.max(...c)-Math.min(...c)];let x=i0.keypoints.map(l=>l.positionRaw[0]),d=i0.keypoints.map(l=>l.positionRaw[1]);i0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[l,f]of Object.entries(S5)){let y=[];for(let m=0;mv.part===f[m]),M=i0.keypoints.find(v=>v.part===f[m+1]);u&&M&&u.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&y.push([u.position,M.position])}i0.annotations[l]=y}r([i0])}))}var Cr=["angry","disgust","fear","happy","sad","surprise","neutral"],g0,k2=[],Dt=0,Vt=0,I5=Number.MAX_SAFE_INTEGER;async function Zt(e){var t;return T.initial&&(g0=null),g0?e.debug&&g("cached model:",g0.modelUrl):g0=await L((t=e.face.emotion)==null?void 0:t.modelPath),g0}async function N5(e,t,o,n){var a,i;if(!g0)return[];let r=I5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>R()-Vt;return t.skipAllowed&&s&&r&&Dt===n&&k2[o]&&k2[o].length>0?(I5++,k2[o]):(I5=0,new Promise(async c=>{var d;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let l={},f=g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0;l.resize=A.image.resizeBilinear(e,[f,f],!1),l.channels=A.mul(l.resize,F.rgb),l.grayscale=A.sum(l.channels,3,!0),l.grayscaleSub=A.sub(l.grayscale,F.tf05),l.grayscaleMul=A.mul(l.grayscaleSub,F.tf2),l.emotion=g0==null?void 0:g0.execute(l.grayscaleMul),Vt=R();let y=await l.emotion.data();for(let m=0;m(t.face.emotion.minConfidence||0)&&x.push({score:Math.min(.99,Math.trunc(100*y[m])/100),emotion:Cr[m]});x.sort((m,u)=>u.score-m.score),Object.keys(l).forEach(m=>A.dispose(l[m]))}k2[o]=x,Dt=n,c(x)}))}var f0,O5=[],qt=0,Ut=0,Yt=Number.MAX_SAFE_INTEGER;async function Kt(e){var t;return T.initial&&(f0=null),f0?e.debug&&g("cached model:",f0.modelUrl):f0=await L((t=e.face.mobilefacenet)==null?void 0:t.modelPath),f0}async function L5(e,t,o,n){var a,i;if(!(f0!=null&&f0.executor))return[];let r=Yt<(((a=t.face.mobilefacenet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.mobilefacenet)==null?void 0:i.skipTime)||0)>R()-Ut;return t.skipAllowed&&s&&r&&qt===n&&O5[o]?(Yt++,O5[o]):new Promise(async c=>{var d;let x=[];if(((d=t.face.mobilefacenet)==null?void 0:d.enabled)&&(f0==null?void 0:f0.inputs[0].shape)){let l={};l.crop=A.image.resizeBilinear(e,[f0.inputs[0].shape[2],f0.inputs[0].shape[1]],!1),l.data=f0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(y=>A.dispose(l[y]))}O5[o]=x,qt=n,Ut=R(),c(x)})}var m0,W5=[],Qt=0,_t=0,$t=Number.MAX_SAFE_INTEGER;async function e3(e){return T.initial&&(m0=null),m0?e.debug&&g("cached model:",m0.modelUrl):m0=await L(e.face.insightface.modelPath),m0}async function F5(e,t,o,n){var a,i;if(!(m0!=null&&m0.executor))return[];let r=$t<(((a=t.face.insightface)==null?void 0:a.skipFrames)||0),s=(((i=t.face.insightface)==null?void 0:i.skipTime)||0)>R()-_t;return t.skipAllowed&&s&&r&&Qt===n&&W5[o]?($t++,W5[o]):new Promise(async c=>{var d;let x=[];if(((d=t.face.insightface)==null?void 0:d.enabled)&&(m0==null?void 0:m0.inputs[0].shape)){let l={};l.crop=A.image.resizeBilinear(e,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),l.data=m0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(y=>A.dispose(l[y]))}W5[o]=x,Qt=n,_t=R(),c(x)})}var p0,J0=0,jr=2.3,G5=k0.leftEyeLower0,B5=k0.rightEyeLower0,ke={leftBounds:[G5[0],G5[G5.length-1]],rightBounds:[B5[0],B5[B5.length-1]]},Ee={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function A3(e){var t,o;return T.initial&&(p0=null),p0?e.debug&&g("cached model:",p0.modelUrl):p0=await L((t=e.face.iris)==null?void 0:t.modelPath),J0=(p0==null?void 0:p0.executor)&&((o=p0.inputs)==null?void 0:o[0].shape)?p0.inputs[0].shape[2]:0,J0===-1&&(J0=64),p0}function E2(e,t,o,n){for(let r=0;r{let t=e[ke.leftBounds[0]][2],o=e[ke.rightBounds[0]][2];return t-o},o3=(e,t,o,n,r,s=!1)=>{let a=g2(b2(pt([e[o],e[n]]),jr)),i=Re(a),c=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[J0,J0]);if(s&&T.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(c);A.dispose(c),c=x}return{box:a,boxSize:i,crop:c}},n3=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[k0[`${o}EyeUpper0`][Ee.upperCenter]][2],r=e[k0[`${o}EyeLower0`][Ee.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let c=s;return i===2?c=n:i===4&&(c=r),[a[0],a[1],c]})};async function s3(e,t,o){if(!(p0!=null&&p0.executor))return e;let{box:n,boxSize:r,crop:s}=o3(e,t,ke.leftBounds[0],ke.leftBounds[1],o,!0),{box:a,boxSize:i,crop:c}=o3(e,t,ke.rightBounds[0],ke.rightBounds[1],o,!0),x=A.concat([s,c]);A.dispose(s),A.dispose(c);let d=p0.execute(x);A.dispose(x);let l=await d.data();A.dispose(d);let f=l.slice(0,Ee.numCoordinates*3),{rawCoords:y,iris:m}=n3(f,n,r,!0),u=l.slice(Ee.numCoordinates*3),{rawCoords:M,iris:v}=n3(u,a,i,!1),P=Ir(e);Math.abs(P)<30?(E2(e,y,"left",null),E2(e,M,"right",null)):P<1?E2(e,y,"left",["EyeUpper0","EyeLower0"]):E2(e,M,"right",["EyeUpper0","EyeLower0"]);let p=r3(e,m,"left"),h=r3(e,v,"right");return e.concat(p).concat(h)}var Nr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Or=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Lr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Wr=[[474,475],[475,476],[476,477],[477,474]],Fr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Gr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Br=[[469,470],[470,471],[471,472],[472,469]],Hr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Q0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Dr={lips:Q0(Nr),leftEye:Q0(Or),leftEyebrow:Q0(Lr),leftIris:Q0(Wr),rightEye:Q0(Fr),rightEyebrow:Q0(Gr),rightIris:Q0(Br),faceOval:Q0(Hr)},Vr=Object.entries(Dr).map(([e,t])=>t.map(o=>[o,e])).flat(),r4=new Map(Vr),_e=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],xe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],ye=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function l3(e,t){var s,a,i,c,x,d,l,f,y,m;let o={lips:await((a=(s=t.filter(u=>u.size===160))==null?void 0:s[0])==null?void 0:a.data()),irisL:await((c=(i=t.filter(u=>u.size===10))==null?void 0:i[0])==null?void 0:c.data()),eyeL:await((d=(x=t.filter(u=>u.size===142))==null?void 0:x[0])==null?void 0:d.data()),irisR:await((f=(l=t.filter(u=>u.size===10))==null?void 0:l[1])==null?void 0:f.data()),eyeR:await((m=(y=t.filter(u=>u.size===142))==null?void 0:y[1])==null?void 0:m.data())};for(let u of Object.values(o))if(!u)return e;let n=xe.reduce((u,M)=>u+=e[M][2],0)/xe.length;for(let u=0;uu+=e[M][2],0)/ye.length;for(let u=0;uR()-L0.timestamp,n=L0.skipped<(((x=t.face.detector)==null?void 0:x.skipFrames)||0);!t.skipAllowed||!o||!n||L0.boxes.length===0?(L0.boxes=await Tt(e,t),L0.timestamp=R(),L0.skipped=0):L0.skipped++;let r=[],s=[],a=0,i=$e;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(k.faceScore=Math.round(100*B[0])/100,k.faceScore<(((m=t.face.detector)==null?void 0:m.minConfidence)||1)){if(p.confidence=k.faceScore,t.face.mesh.keepInvalid){k.box=u2(p,e),k.boxRaw=h2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(I=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*I[0]/Pe(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*I[1]/Pe()]),k.meshRaw=k.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/i]);for(let I of Object.keys(ae))k.annotations[I]=[k.mesh[ae[I]]]}}else{let I=b.find(j=>j.shape[j.shape.length-1]===1404),O=A.reshape(I,[-1,3]),G=await O.array();A.dispose(O),(u=t.face.attention)!=null&&u.enabled?G=await l3(G,b):(M=t.face.iris)!=null&&M.enabled&&(G=await s3(G,k.tensor,$e)),k.mesh=bt(G,p,h,E,$e),k.meshRaw=k.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/i]);for(let j of Object.keys(k0))k.annotations[j]=k0[j].map(n0=>k.mesh[n0]);k.score=k.faceScore;let N={...Mt(k.mesh,p),confidence:p.confidence,landmarks:p.landmarks};k.box=u2(N,e),k.boxRaw=h2(N,e),s.push(N)}A.dispose(b)}else{k.box=u2(p,e),k.boxRaw=h2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(b=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*b[0]/Pe(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*b[1]/Pe()]),k.meshRaw=k.mesh.map(b=>[b[0]/(e.shape[2]||0),b[1]/(e.shape[1]||0),(b[2]||0)/i]);for(let b of Object.keys(ae))k.annotations[b]=[k.mesh[ae[b]]]}k.score>(((v=t.face.detector)==null?void 0:v.minConfidence)||1)?r.push(k):A.dispose(k.tensor)}return L0.boxes=s,r}async function x3(e){var t,o,n,r,s,a;return T.initial&&(X=null),((t=e.face.attention)==null?void 0:t.enabled)&&(X==null?void 0:X.signature)&&Object.keys(((o=X==null?void 0:X.signature)==null?void 0:o.outputs)||{}).length<6&&(X=null),X?e.debug&&g("cached model:",X.modelUrl):(n=e.face.attention)!=null&&n.enabled?X=await L(e.face.attention.modelPath):X=await L((r=e.face.mesh)==null?void 0:r.modelPath),$e=X.executor&&((s=X==null?void 0:X.inputs)==null?void 0:s[0].shape)?(a=X==null?void 0:X.inputs)==null?void 0:a[0].shape[2]:256,X}var y3=ie,d3=Ke;var A0,_0=[],f3=0,m3=0,D5=Number.MAX_SAFE_INTEGER;async function p3(e){var t;return T.initial&&(A0=null),A0?e.debug&&g("cached model:",A0.modelUrl):A0=await L((t=e.face.description)==null?void 0:t.modelPath),A0}function V5(e){let t=e.image||e.tensor||e;if(!(A0!=null&&A0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),n=A.mul(o,F.tf255);return A.dispose(o),n}async function Z5(e,t,o,n){var i,c,x,d;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(A0!=null&&A0.executor))return r;let s=D5<(((i=t.face.description)==null?void 0:i.skipFrames)||0),a=(((c=t.face.description)==null?void 0:c.skipTime)||0)>R()-f3;return t.skipAllowed&&s&&a&&m3===n&&((x=_0==null?void 0:_0[o])==null?void 0:x.age)>0&&((d=_0==null?void 0:_0[o])==null?void 0:d.genderScore)>0?(D5++,_0[o]):(D5=0,new Promise(async l=>{var f;if((f=t.face.description)!=null&&f.enabled){let y=V5(e),m=A0==null?void 0:A0.execute(y);f3=R(),A.dispose(y);let M=await m.find(W=>W.shape[1]===1).data(),v=Math.trunc(200*Math.abs(M[0]-.5))/100;v>(t.face.description.minConfidence||0)&&(r.gender=M[0]<=.5?"female":"male",r.genderScore=Math.min(.99,v));let P=A.argMax(m.find(W=>W.shape[1]===100),1),p=(await P.data())[0];A.dispose(P);let E=await m.find(W=>W.shape[1]===100).data();r.age=Math.round(E[p-1]>E[p+1]?10*p-100*E[p-1]:10*p+100*E[p+1])/10,(Number.isNaN(M[0])||Number.isNaN(E[0]))&&g("faceres error:",{model:A0,result:m});let k=m.find(W=>W.shape[1]===1024),b=k?await k.data():[];r.descriptor=Array.from(b),m.forEach(W=>A.dispose(W))}_0[o]=r,m3=n,l(r)}))}function z2(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function e2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function b3(e,t,o){let n=t.shape[1],r=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return A.image.cropAndResize(t,s,[0],o)}function g3(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function S2(e,t=1.5){let o=e2(e),n=z2(e),r=[t*n[0]/2,t*n[1]/2],s=[o[0]-r[0],o[1]-r[1]],a=[o[0]+r[0],o[1]+r[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function C2(e){let t=e2(e),o=z2(e),r=Math.max(...o)/2,s=[t[0]-r,t[1]-r],a=[t[0]+r,t[1]+r];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function Xr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function M3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Xr(o)}var u3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function $0(e,t){let o=0;for(let n=0;n[a.x,a.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=((s=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:s[2])||0,this.inputSizeTensor=A.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=A.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=A.slice(t,[0,0],[-1,2]),o.boxSizes=A.slice(t,[0,2],[-1,2]),o.div=A.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=A.add(o.div,this.anchorsTensor),o.halfBoxSizes=A.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=A.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=A.mul(o.sub,this.inputSizeTensor),o.add=A.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=A.mul(o.add,this.inputSizeTensor);let n=A.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=A.reshape(t,[-1,7,2]),n.div=A.div(n.reshape,this.inputSizeTensor),n.landmarks=A.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){var i;let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,F.tf127),n.image=A.sub(n.div,F.tf1),n.batched=this.model.execute(n.image),n.predictions=A.squeeze(n.batched),n.slice=A.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=A.sigmoid(n.slice),n.scores=A.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=A.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await A.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((i=o.hand)==null?void 0:i.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let c of s){let x={};x.box=A.slice(n.norm,[c,0],[1,-1]),x.slice=A.slice(n.predictions,[c,5],[1,14]),x.norm=this.normalizeLandmarks(x.slice,c),x.palmLandmarks=A.reshape(x.norm,[-1,2]);let d=await x.box.data(),l=d.slice(0,2),f=d.slice(2,4),y=await x.palmLandmarks.array(),m={startPoint:l,endPoint:f,palmLandmarks:y,confidence:r[c]},u=g3(m,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);a.push(u),Object.keys(x).forEach(M=>A.dispose(x[M]))}return Object.keys(n).forEach(c=>A.dispose(n[c])),a}};var Kr=5,T3=1.65,w3=[0,5,9,13,17,1,2],Jr=0,Qr=2,k3=0,I2=class{constructor(t,o){w(this,"handDetector");w(this,"handPoseModel");w(this,"inputSize");w(this,"storedBoxes");w(this,"skipped");w(this,"detectedHands");var n,r,s;this.handDetector=t,this.handPoseModel=o,this.inputSize=((s=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:s[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(a=>a[0]),n=t.map(a=>a[1]),r=[Math.min(...o),Math.min(...n)],s=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:s}}getBoxForPalmLandmarks(t,o){let n=t.map(s=>U5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return S2(C2(r),Kr)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=S2(C2(o),T3);n.palmLandmarks=[];for(let r=0;r[a[0]*(y[0]-this.inputSize/2),a[1]*(y[1]-this.inputSize/2),a[2]*y[2]]),c=q5(n,[0,0]),x=i.map(y=>[...U5(y,c),y[2]]),d=v3(r),l=[...e2(o),1],f=[$0(l,d[0]),$0(l,d[1])];return x.map(y=>[Math.trunc(y[0]+f[0]),Math.trunc(y[1]+f[1]),Math.trunc(y[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>R()-k3,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let i=[];for(let c=0;c=o.hand.minConfidence/4){let E=A.reshape(p,[-1,3]),k=await E.array();A.dispose(p),A.dispose(E);let b=this.transformRawCoords(k,u,d,m),W=this.getBoxForHandLandmarks(b);this.storedBoxes[c]={...W,confidence:h};let B={landmarks:b,confidence:h,boxConfidence:x.confidence,fingerConfidence:h,box:{topLeft:W.startPoint,bottomRight:W.endPoint}};i.push(B)}else this.storedBoxes[c]=null;A.dispose(p)}else{let d=S2(C2(x),T3),l={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(l)}}return this.storedBoxes=this.storedBoxes.filter(c=>c!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var l0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>l0.nameMapping[e],getPoints:e=>l0.pointsMapping[e]},te={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>te.nameMapping[e]},q={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>q.nameMapping[e]},ee=class{constructor(t){w(this,"name");w(this,"curls");w(this,"directions");w(this,"weights");w(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,s)=>r+s,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let s=t[r],a=this.curls[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,c]of a)if(s===i){n+=c*this.weightsRelative[r];break}}for(let r in o){let s=o[r],a=this.directions[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,c]of a)if(s===i){n+=c*this.weightsRelative[r];break}}return n/10}};var{thumb:j0,index:B0,middle:H0,ring:de,pinky:fe}=l0,{none:I0,half:$r,full:N0}=te,{verticalUp:ze,verticalDown:b4,horizontalLeft:Y5,horizontalRight:eA,diagonalUpRight:tA,diagonalUpLeft:Se,diagonalDownRight:g4,diagonalDownLeft:M4}=q,oe=new ee("thumbs up");oe.curl(j0,I0,1);oe.direction(j0,ze,1);oe.direction(j0,Se,.25);oe.direction(j0,tA,.25);for(let e of[l0.index,l0.middle,l0.ring,l0.pinky])oe.curl(e,N0,1),oe.direction(e,Y5,1),oe.direction(e,eA,1);var J=new ee("victory");J.curl(j0,$r,.5);J.curl(j0,I0,.5);J.direction(j0,ze,1);J.direction(j0,Se,1);J.curl(B0,I0,1);J.direction(B0,ze,.75);J.direction(B0,Se,1);J.curl(H0,I0,1);J.direction(H0,ze,1);J.direction(H0,Se,.75);J.curl(de,N0,1);J.direction(de,ze,.2);J.direction(de,Se,1);J.direction(de,Y5,.2);J.curl(fe,N0,1);J.direction(fe,ze,.2);J.direction(fe,Se,1);J.direction(fe,Y5,.2);J.weight(B0,2);J.weight(H0,2);var ne=new ee("point");ne.curl(j0,N0,1);ne.curl(B0,I0,.5);ne.curl(H0,N0,.5);ne.curl(de,N0,.5);ne.curl(fe,N0,.5);ne.weight(B0,2);ne.weight(H0,2);var re=new ee("middle finger");re.curl(j0,I0,1);re.curl(B0,N0,.5);re.curl(H0,N0,.5);re.curl(de,N0,.5);re.curl(fe,N0,.5);re.weight(B0,2);re.weight(H0,2);var Ce=new ee("open palm");Ce.curl(j0,I0,.75);Ce.curl(B0,I0,.75);Ce.curl(H0,I0,.75);Ce.curl(de,I0,.75);Ce.curl(fe,I0,.75);var E3=[oe,J,ne,re,Ce];var oA=.7,me={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function z3(e,t,o,n){let r=(t-n)/(e-o),s=Math.atan(r)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function C3(e,t){if(!e||!t)return[0,0];let o=z3(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=z3(e[1],e[2],t[1],t[2]);return[o,n]}function S3(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function nA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],c=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],l=t[2]-o[2],f=Math.sqrt(n*n+a*a+x*x),y=Math.sqrt(r*r+i*i+d*d),m=Math.sqrt(s*s+c*c+l*l),u=(m*m+f*f-y*y)/(2*m*f);u>1?u=1:u<-1&&(u=-1);let M=Math.acos(u);M=57.2958*M%180;let v;return M>me.NO_CURL_START_LIMIT?v=te.none:M>me.HALF_CURL_START_LIMIT?v=te.half:v=te.full,v}function j3(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=q.horizontalLeft:r=q.horizontalRight:n===Math.abs(t)?t>0?r=q.horizontalLeft:r=q.horizontalRight:o>0?r=q.horizontalLeft:r=q.horizontalRight,r}function I3(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=q.verticalDown:r=q.verticalUp:n===Math.abs(t)?t<0?r=q.verticalDown:r=q.verticalUp:o<0?r=q.verticalDown:r=q.verticalUp,r}function rA(e,t,o,n,r,s,a,i){let c,x=I3(e,t,o,n),d=j3(r,s,a,i);return x===q.verticalUp?d===q.horizontalLeft?c=q.diagonalUpLeft:c=q.diagonalUpRight:d===q.horizontalLeft?c=q.diagonalDownLeft:c=q.diagonalDownRight,c}function AA(e,t,o,n){let r=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],c=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),l=Math.max(Math.abs(i),Math.abs(c),Math.abs(x)),f=0,y=0,m=0,u=l/(d+1e-5);u>1.5?f+=me.DISTANCE_VOTE_POWER:u>.66?y+=me.DISTANCE_VOTE_POWER:m+=me.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+i*i),v=Math.sqrt(s*s+c*c),P=Math.sqrt(a*a+x*x),p=Math.max(M,v,P),h=e[0],E=e[1],k=o[0],b=o[1];p===M?(k=o[0],b=o[1]):p===P&&(h=t[0],E=t[1]);let I=C3([h,E],[k,b]),O=S3(I,me.TOTAL_ANGLE_VOTE_POWER);f+=O[0],y+=O[1],m+=O[2];for(let N of n){let j=S3(N,me.SINGLE_ANGLE_VOTE_POWER);f+=j[0],y+=j[1],m+=j[2]}let G;return f===Math.max(f,y,m)?G=I3(c,i,x,l):m===Math.max(y,m)?G=j3(s,r,a,d):G=rA(c,i,x,l,s,r,a,d),G}function N3(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of l0.all){let a=l0.getPoints(s),i=[],c=[];for(let x of a){let d=e[x[0]],l=e[x[1]],f=C3(d,l),y=f[0],m=f[1];i.push(y),c.push(m)}t.push(i),o.push(c)}for(let s of l0.all){let a=s===l0.thumb?1:0,i=l0.getPoints(s),c=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],l=nA(c,x,d),f=AA(c,x,d,t[s].slice(a));n[s]=l,r[s]=f}return{curls:n,directions:r}}function N2(e){if(!e||e.length===0)return null;let t=N3(e),o={};for(let n of l0.all)o[l0.getName(n)]={curl:te.getName(t.curls[n]),direction:q.getName(t.directions[n])};return o}function O3(e){let t=[];if(!e||e.length===0)return t;let o=N3(e);for(let n of E3){let r=n.matchAgainst(o.curls,o.directions);r>=oA&&t.push({name:n.name,confidence:r})}return t}var L3={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},pe,ue,W3;async function J5(e,t){let o=await W3.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],c=[0,0,0,0];if(a&&a.length>0){for(let d of a)d[0]i[2]&&(i[2]=d[0]),d[1]>i[3]&&(i[3]=d[1]);i[2]-=i[0],i[3]-=i[1],c=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],c=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let x=N2(a);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:c,keypoints:a,annotations:s,landmarks:x})}return n}async function Q5(e){var o,n;T.initial&&(pe=null,ue=null),!pe||!ue?[pe,ue]=await Promise.all([e.hand.enabled?L((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?L((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&g("cached model:",pe.modelUrl),e.debug&&g("cached model:",ue.modelUrl));let t=pe?new j2(pe):void 0;return t&&ue&&(W3=new I2(t,ue)),[pe,ue]}var V={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function sA(){let e=V.gl;!e||(V.extensions=e.getSupportedExtensions())}function G3(e){var t;if(e.config.backend==="humangl"&&(V.name in A.engine().registry&&!((t=V==null?void 0:V.gl)!=null&&t.getParameter(V.gl.VERSION))&&(g("humangl error: backend invalid context"),O2(e)),!A.findBackend(V.name))){try{V.canvas=a0(100,100)}catch(n){g("humangl error: cannot create canvas:",n);return}try{if(V.gl=V.canvas.getContext("webgl2",V.webGLattr),!V.gl){g("humangl error: cannot get webgl context");return}if(!V.gl.getParameter(V.gl.VERSION).includes("2.0")){g("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}V.canvas&&(V.canvas.addEventListener("webglcontextlost",r=>{throw g("humangl error:",r.type),g("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),V.canvas.addEventListener("webglcontextrestored",r=>{g("humangl error: context restored:",r)}),V.canvas.addEventListener("webglcontextcreationerror",r=>{g("humangl error: context create:",r)}))}catch(n){g("humangl error: cannot get webgl context:",n);return}try{A.setWebGLContext(2,V.gl)}catch(n){g("humangl error: cannot set webgl context:",n);return}try{let n=new A.GPGPUContext(V.gl);A.registerBackend(V.name,()=>new A.MathBackendWebGL(n),V.priority)}catch(n){g("humangl error: cannot register webgl backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:V.name};A.registerKernel(s)})}catch(n){g("humangl error: cannot update webgl backend registration:",n);return}try{A.env().flagRegistry.WEBGL_VERSION&&A.env().set("WEBGL_VERSION",2)}catch(n){g("humangl error: cannot set WebGL backend flags:",n);return}sA();let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;o?e.config.debug&&g("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):g("humangl error: no current gl context:",o,V.gl)}}function aA(e){let t=[];if(!T.kernels.includes("mod")){let o={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>A.sub(n.inputs.a,A.mul(A.div(n.inputs.a,n.inputs.b),n.inputs.b)))};A.registerKernel(o),T.kernels.push("mod"),t.push("mod")}if(!T.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>A.add(A.mul(A.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),A.mod(n.inputs.a,n.inputs.b)))};A.registerKernel(o),T.kernels.push("floormod"),t.push("floormod")}if(!T.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>{let r=A.getBackend();A.setBackend("cpu");let s=A.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return A.setBackend(r),s})};A.registerKernel(o),T.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&g("registered kernels:",t)}var H3={};async function o2(e,t=!1){if(e.state="backend",t||T.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=R();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&g("running inside web worker"),T.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&g("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),T.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&g(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),T.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")g("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&g("enumerated webgpu adapter:",r),!r)g("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let s="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;g("webgpu adapter info:",s)}}let n=Object.keys(A.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(G3(e),n=Object.keys(A.engine().registryFactory)),e.config.debug&&g("available backends:",n),n.includes(e.config.backend)||(g(`error: backend ${e.config.backend} not found in registry`),e.config.backend=T.node?"tensorflow":"webgl",e.config.debug&&g(`override: setting backend ${e.config.backend}`)),e.config.debug&&g("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(A.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&A.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&g("wasm path:",e.config.wasmPath),typeof A.setWasmPaths!="undefined")A.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,s=!1;try{r=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&g(`wasm execution: ${s?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!s&&g("warning: wasm simd support is not enabled")}catch(a){g("wasm detection failed")}}try{await A.setBackend(e.config.backend),await A.ready()}catch(r){return g("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(H3=JSON.parse(JSON.stringify(A.env().flags)))}if((A.getBackend()==="humangl"||A.getBackend()==="webgl")&&(A.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&A.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.env().flagRegistry.WEBGL_EXP_CONV&&A.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),A.getBackend(),e.config.debug){let n=A.env().flags,r={};for(let s of Object.keys(n))H3[s]!==n[s]&&(r[s]=n[s]);e.config.debug&&Object.keys(r).length>0&&g("backend:",A.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&g("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))A.env().set(n,r)}A.enableProdMode(),et(),e.performance.initBackend=Math.trunc(R()-o),e.config.backend=A.getBackend(),await T.updateBackend(),aA(e.config),T.initial=!1}return!0}function L2(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&g("kernelFunc",o,t.backend)}};A.registerKernel(n)}T.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var K=[null,null],iA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ae=[[0,0],[0,0]],lA=["hand","fist","pinch","point","face","tip","pinchtip"],V3=4,Z3=1.6,cA=512,xA=1.4,W2=Number.MAX_SAFE_INTEGER,_5=0,D0=[0,0],Y={boxes:[],hands:[]},X3={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function q3(e){var t;if(T.initial&&(K[0]=null),K[0])e.debug&&g("cached model:",K[0].modelUrl);else{L2(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),K[0]=await L((t=e.hand.detector)==null?void 0:t.modelPath);let o=K[0].executor?Object.values(K[0].modelSignature.inputs):void 0;Ae[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ae[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return K[0]}async function U3(e){var t;if(T.initial&&(K[1]=null),K[1])e.debug&&g("cached model:",K[1].modelUrl);else{K[1]=await L((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=K[1].executor?Object.values(K[1].modelSignature.inputs):void 0;Ae[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ae[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return K[1]}async function yA(e,t){let o=[];if(!e||!K[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,cA),a=Math.round(s*r/8)*8;n.resize=A.image.resizeBilinear(e,[s,a]),n.cast=A.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await K[0].executeAsync(n.cast,iA),n.boxes=A.squeeze(n.rawBoxes,[0,2]),n.scores=A.squeeze(n.rawScores,[0]);let i=A.unstack(n.scores,1);A.dispose(i[V3]),i.splice(V3,1),n.filtered=A.stack(i,1),A.dispose(i),n.max=A.max(n.filtered,1),n.argmax=A.argMax(n.filtered,1);let c=0;n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let x=await n.nms.data(),d=await n.max.data(),l=await n.argmax.data();for(let f of Array.from(x)){let y=A.slice(n.boxes,f,1),m=await y.data();A.dispose(y);let u=[m[1],m[0],m[3]-m[1],m[2]-m[0]],M=R2(u,xA),v=[Math.trunc(u[0]*D0[0]),Math.trunc(u[1]*D0[1]),Math.trunc(u[2]*D0[0]),Math.trunc(u[3]*D0[1])],P=d[f],p=lA[l[f]],h={id:c++,score:P,box:v,boxRaw:M,label:p};o.push(h)}return Object.keys(n).forEach(f=>A.dispose(n[f])),o.sort((f,y)=>y.score-f.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function $5(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&K[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=A.image.cropAndResize(e,[s],[0],[Ae[1][0],Ae[1][1]],"bilinear"),r.div=A.div(r.crop,F.tf255),[r.score,r.keypoints]=K[1].execute(r.div,["Identity_1","Identity"]);let a=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){n.fingerScore=i,r.reshaped=A.reshape(r.keypoints,[-1,3]);let d=(await r.reshaped.array()).map(l=>[l[0]/Ae[1][1],l[1]/Ae[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=d.map(l=>[D0[0]*(l[0]+t.boxRaw[0]),D0[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=N2(n.keypoints);for(let l of Object.keys(X3))n.annotations[l]=X3[l].map(f=>n.landmarks&&n.keypoints[f]?n.keypoints[f]:null)}Object.keys(r).forEach(c=>A.dispose(r[c]))}return n}async function e1(e,t){var r,s;if(!((r=K[0])!=null&&r.executor)||!((s=K[1])!=null&&s.executor)||!K[0].inputs[0].shape||!K[1].inputs[0].shape)return[];D0=[e.shape[2]||0,e.shape[1]||0],W2++;let o=(t.hand.skipTime||0)>R()-_5,n=W2<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Y.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>R()-_5,c=W2<3*(t.hand.skipFrames||0);t.skipAllowed&&Y.hands.length===t.hand.maxDetected?Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))):t.skipAllowed&&i&&c&&Y.hands.length>0?Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))):(Y.boxes=await yA(e,t),_5=R(),Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))),W2=0);let x=[...Y.boxes];if(Y.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&l.box[3]/(e.shape[1]||1)>.05&&Y.hands[d].fingerScore&&Y.hands[d].fingerScore>(t.hand.minConfidence||0)){let f=R2(l.box,Z3),y=R2(l.boxRaw,Z3);Y.boxes.push({...x[d],box:f,boxRaw:y})}}for(let d=0;dR()-J3,s=t1<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&K3===n&&F2[o]?(t1++,F2[o]):(t1=0,new Promise(async c=>{let x=A.image.resizeBilinear(e,[o0!=null&&o0.inputs[0].shape?o0.inputs[0].shape[2]:0,o0!=null&&o0.inputs[0].shape?o0.inputs[0].shape[1]:0],!1),d=o0==null?void 0:o0.execute(x),l=(await d.data())[0];F2[o]=Math.round(100*l)/100,K3=n,J3=R(),A.dispose([x,d]),c(F2[o])}))}var n2={};q0(n2,{connected:()=>B2,horizontal:()=>n1,kpt:()=>G2,relative:()=>A1,vertical:()=>r1});var G2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],r1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],A1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],B2={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $3=.005,u0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function s1(e){for(let t of n1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]x&&x.part===t[0]),r=e.keypoints.findIndex(x=>x&&x.part===t[1]),s=e.keypoints.findIndex(x=>x&&x.part===o[0]),a=e.keypoints.findIndex(x=>x&&x.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0])]:[0,0],c=e.keypoints[r]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||c[0]>c[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function eo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=A.pad(e,u0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(a=>A.dispose(o[a])),n}function oo(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+u0.padding[2][0]+u0.padding[2][1])/t[0]-u0.padding[2][0],n.position[1]*(t[1]+u0.padding[1][0]+u0.padding[1][1])/t[1]-u0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=G0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var Q,H2=0,a1=Number.MAX_SAFE_INTEGER,he={boxes:[],bodies:[],last:0};async function no(e){var t;return T.initial&&(Q=null),Q?e.debug&&g("cached model:",Q.modelUrl):(L2(["size"],e),Q=await L(e.body.modelPath)),H2=(Q==null?void 0:Q.executor)&&((t=Q==null?void 0:Q.inputs)==null?void 0:t[0].shape)?Q.inputs[0].shape[2]:0,H2<64&&(H2=256),Q}function fA(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let l=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:G2[d],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}s=r.reduce((d,l)=>l.score>d?l.score:d,0);let a=[],i=G0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),c={};for(let[d,l]of Object.entries(B2)){let f=[];for(let y=0;yM.part===l[y]),u=r.find(M=>M.part===l[y+1]);m&&u&&m.score>(t.body.minConfidence||0)&&u.score>(t.body.minConfidence||0)&&f.push([m.position,u.position])}c[d]=f}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:c};return s1(x),a.push(x),a}function mA(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let l=0;l<17;l++){let f=s[3*l+2];if(f>t.body.minConfidence){let y=[s[3*l+1],s[3*l+0]];i.push({part:G2[l],score:Math.round(100*f)/100,positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}}let c=G0(i.map(l=>l.position),[o.shape[2],o.shape[1]]),x={};for(let[l,f]of Object.entries(B2)){let y=[];for(let m=0;mv.part===f[m]),M=i.find(v=>v.part===f[m+1]);u&&M&&u.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&y.push([u.position,M.position])}x[l]=y}let d={id:r,score:a,box:c.box,boxRaw:c.boxRaw,keypoints:[...i],annotations:x};s1(d),n.push(d)}}return n.sort((r,s)=>s.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function i1(e,t){var r;if(!(Q!=null&&Q.executor)||!((r=Q==null?void 0:Q.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(he.boxes.length=0),a1++;let o=(t.body.skipTime||0)>R()-he.last,n=a1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?he.bodies:new Promise(async s=>{let a={};a1=0,a.input=to(e,H2),a.res=Q==null?void 0:Q.execute(a.input),he.last=R();let i=await a.res.array();he.bodies=a.res.shape[2]===17?fA(i,t,e):mA(i,t,e);for(let c of he.bodies)oo(c,[e.shape[2]||1,e.shape[1]||1]),eo(c.keypoints);Object.keys(a).forEach(c=>A.dispose(a[c])),s(he.bodies)})}var E0,D2=[],Ao=0,l1=Number.MAX_SAFE_INTEGER,Z2=0,V2=2.5;async function so(e){if(!E0||T.initial){E0=await L(e.object.modelPath);let t=E0!=null&&E0.executor?Object.values(E0.modelSignature.inputs):void 0;Z2=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&g("cached model:",E0.modelUrl);return E0}async function pA(e,t,o){let n=0,r=[],s=Z2;for(let x of[1,2,4]){let d=x*13,l=A.squeeze(e.find(v=>v.shape[1]===d**2&&(v.shape[2]||0)===we.length)),f=await l.array(),y=A.squeeze(e.find(v=>v.shape[1]===d**2&&(v.shape[2]||0)(o.object.minConfidence||0)&&P!==61){let h=(.5+Math.trunc(v%d))/d,E=(.5+Math.trunc(v/d))/d,k=M[v].map(j=>j*(d/x/s)),[b,W]=[h-V2/x*k[0],E-V2/x*k[1]],[B,I]=[h+V2/x*k[2]-b,E+V2/x*k[3]-W],O=[b,W,B,I];O=O.map(j=>Math.max(0,Math.min(j,1)));let G=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],N={id:n++,score:Math.round(100*p)/100,class:P+1,label:we[P].label,box:G.map(j=>Math.trunc(j)),boxRaw:O};r.push(N)}}A.dispose([l,y,m,u])}let a=r.map(x=>[x.boxRaw[1],x.boxRaw[0],x.boxRaw[3],x.boxRaw[2]]),i=r.map(x=>x.score),c=[];if(a&&a.length>0){let x=await A.image.nonMaxSuppressionAsync(a,i,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);c=await x.data(),A.dispose(x)}return r=r.filter((x,d)=>c.includes(d)).sort((x,d)=>d.score-x.score),r}async function c1(e,t){if(!(E0!=null&&E0.executor))return[];let o=(t.object.skipTime||0)>R()-Ao,n=l1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&D2.length>0?(l1++,D2):(l1=0,!T.kernels.includes("mod")||!T.kernels.includes("sparsetodense")?D2:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[Z2,Z2],!1),i=A.div(a,F.tf255),c=A.transpose(i,[0,3,1,2]),x;t.object.enabled&&(x=E0.execute(c)),Ao=R();let d=await pA(x,s,t);D2=d,A.dispose([a,i,c,...x]),r(d)}))}var A2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],uA=A2.length,r2=A2.reduce((e,t,o)=>(e[t]=o,e),{}),hA=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],Y4=hA.map(([e,t])=>[r2[e],r2[t]]),io=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function lo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(n,i),minX:Math.min(r,a),minY:Math.min(s,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function co(e,[t,o],[n,r]){let s=t/n,a=o/r,i=(x,d)=>({id:d,score:x.score,boxRaw:[x.box[0]/r,x.box[1]/n,x.box[2]/r,x.box[3]/n],box:[Math.trunc(x.box[0]*a),Math.trunc(x.box[1]*s),Math.trunc(x.box[2]*a),Math.trunc(x.box[3]*s)],keypoints:x.keypoints.map(({score:l,part:f,position:y})=>({score:l,part:f,position:[Math.trunc(y.x*a),Math.trunc(y.y*s)],positionRaw:[y.x/n,y.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var X2=class{constructor(t,o){w(this,"priorityQueue");w(this,"numberOfElements");w(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function xo(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function f1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var h0,gA=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],q2=1,je=16,MA=50**2;function yo(e,t,o,n,r,s,a=2){let i=v=>({y:s.get(v.y,v.x,e),x:s.get(v.y,v.x,s.shape[2]/2+e)}),c=(v,P,p)=>({y:d1(Math.round(v.y/je),0,P-1),x:d1(Math.round(v.x/je),0,p-1)}),[x,d]=n.shape,l=c(t.position,x,d),f=i(l),m=f1(t.position,f);for(let v=0;v[r2[f],r2[y]]),a=s.map(([,f])=>f),i=s.map(([f])=>f),c=t.shape[2],x=a.length,d=new Array(c),l=y1(e.part,je,o);d[e.part.id]={score:e.score,part:A2[e.part.id],position:l};for(let f=x-1;f>=0;--f){let y=a[f],m=i[f];d[y]&&!d[m]&&(d[m]=yo(f,d[y],m,t,o,r))}for(let f=0;ft){i=!1;break}if(!i)break}return i}function PA(e,t){let[o,n,r]=t.shape,s=new X2(o*n*r,({score:a})=>a);for(let a=0;a{var a;let s=(a=r[n])==null?void 0:a.position;return s?xo(o,t,s.y,s.x)<=MA:!1})}function TA(e,t){return t.reduce((n,{position:r,score:s},a)=>(fo(e,r,a)||(n+=s),n),0)/t.length}function wA(e,t,o,n,r,s){let a=[],i=PA(s,t);for(;a.lengthy.score>s);let l=TA(a,d),f=lo(d);l>s&&a.push({keypoints:d,box:f,score:Math.round(100*l)/100})}return a}async function m1(e,t){if(!(h0!=null&&h0.executor))return[];let o=A.tidy(()=>{if(!h0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=h0.execute(i,gA).map(d=>A.squeeze(d,[0]));return x[1]=A.sigmoid(x[1]),x}),n=await Promise.all(o.map(a=>a.buffer()));for(let a of o)A.dispose(a);let r=wA(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return h0.inputs[0].shape?co(r,[e.shape[1],e.shape[2]],[h0.inputs[0].shape[2],h0.inputs[0].shape[1]]):[]}async function mo(e){return!h0||T.initial?h0=await L(e.body.modelPath):e.debug&&g("cached model:",h0.modelUrl),h0}var W0,p1=!1;async function u1(e){return!W0||T.initial?W0=await L(e.segmentation.modelPath):e.debug&&g("cached model:",W0.modelUrl),W0}async function uo(e,t,o){var u,M;if(p1)return{data:[],canvas:null,alpha:null};p1=!0,W0||await u1(o);let n=await ve(e,o),r=((u=n.tensor)==null?void 0:u.shape[2])||0,s=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[W0.inputs[0].shape?W0.inputs[0].shape[1]:0,W0.inputs[0].shape?W0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,F.tf255),a.res=W0.execute(a.norm),a.squeeze=A.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=A.softmax(a.squeeze),[a.bg,a.fg]=A.unstack(a.softmax,2),a.expand=A.expandDims(a.fg,2),a.pad=A.expandDims(a.expand,0),a.crop=A.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[r,s]),a.data=A.squeeze(a.crop,0)):a.data=A.image.resizeBilinear(a.squeeze,[s,r]);let i=Array.from(await a.data.data());if(T.node&&!T.Canvas&&typeof ImageData=="undefined")return o.debug&&g("canvas support missing"),Object.keys(a).forEach(v=>A.dispose(a[v])),{data:i,canvas:null,alpha:null};let c=a0(r,s);A.browser&&await A.browser.toPixels(a.data,c);let x=c.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),l=a0(r,s),f=l.getContext("2d");n.canvas&&f.drawImage(n.canvas,0,0),f.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(f.filter=`blur(${o.segmentation.blur}px)`),f.drawImage(c,0,0),f.globalCompositeOperation="source-over",f.filter="none";let y=f.getImageData(0,0,r,s);for(let v=0;vA.dispose(a[v])),p1=!1,{data:i,canvas:l,alpha:c}}var s2=class{constructor(){w(this,"ssrnetage",null);w(this,"gear",null);w(this,"blazeposedetect",null);w(this,"blazepose",null);w(this,"centernet",null);w(this,"efficientpose",null);w(this,"mobilefacenet",null);w(this,"insightface",null);w(this,"emotion",null);w(this,"facedetect",null);w(this,"faceiris",null);w(this,"facemesh",null);w(this,"faceres",null);w(this,"ssrnetgender",null);w(this,"handpose",null);w(this,"handskeleton",null);w(this,"handtrack",null);w(this,"liveness",null);w(this,"movenet",null);w(this,"nanodet",null);w(this,"posenet",null);w(this,"segmentation",null);w(this,"antispoof",null)}},h1=e=>{let t=0,o=0,n=0;for(let s of Object.values(O0))t+=s.sizeFromManifest,o+=s.sizeLoadedWeights,n+=s.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(O0).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(O0)}};function O2(e){for(let t of Object.keys(e.models))e.models[t]=null}async function b1(e){var t,o,n,r,s,a,i,c,x,d,l,f,y,m,u,M,v,P,p,h,E,k,b,W,B,I;T.initial&&O2(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Q5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Q5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=e.config.body.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=Nt(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=It(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((a=e.config.body.modelPath)==null?void 0:a.includes("efficientpose"))&&(e.models.efficientpose=Bt(e.config)),e.config.body.enabled&&!e.models.movenet&&((i=e.config.body.modelPath)==null?void 0:i.includes("movenet"))&&(e.models.movenet=no(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=e.config.body.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=mo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=Pt(e.config)),e.config.face.enabled&&((x=e.config.face.antispoof)==null?void 0:x.enabled)&&!e.models.antispoof&&(e.models.antispoof=xt(e.config)),e.config.face.enabled&&((d=e.config.face.liveness)==null?void 0:d.enabled)&&!e.models.liveness&&(e.models.liveness=Q3(e.config)),e.config.face.enabled&&((l=e.config.face.description)==null?void 0:l.enabled)&&!e.models.faceres&&(e.models.faceres=p3(e.config)),e.config.face.enabled&&((f=e.config.face.emotion)==null?void 0:f.enabled)&&!e.models.emotion&&(e.models.emotion=Zt(e.config)),e.config.face.enabled&&((y=e.config.face.iris)==null?void 0:y.enabled)&&!((m=e.config.face.attention)!=null&&m.enabled)&&!e.models.faceiris&&(e.models.faceiris=A3(e.config)),e.config.face.enabled&&((u=e.config.face.mesh)==null?void 0:u.enabled)&&!e.models.facemesh&&(e.models.facemesh=x3(e.config)),e.config.face.enabled&&((M=e.config.face.gear)==null?void 0:M.enabled)&&!e.models.gear&&(e.models.gear=_1(e.config)),e.config.face.enabled&&((v=e.config.face.ssrnet)==null?void 0:v.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=nt(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=at(e.config)),e.config.face.enabled&&((p=e.config.face.mobilefacenet)==null?void 0:p.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=Kt(e.config)),e.config.face.enabled&&((h=e.config.face.insightface)==null?void 0:h.enabled)&&!e.models.insightface&&(e.models.insightface=e3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((k=(E=e.config.hand.detector)==null?void 0:E.modelPath)==null?void 0:k.includes("handtrack"))&&(e.models.handtrack=q3(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((W=(b=e.config.hand.detector)==null?void 0:b.modelPath)==null?void 0:W.includes("handtrack"))&&(e.models.handskeleton=U3(e.config)),e.config.object.enabled&&!e.models.centernet&&((B=e.config.object.modelPath)==null?void 0:B.includes("centernet"))&&(e.models.centernet=Wt(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=so(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=u1(e.config));for await(let O of Object.keys(e.models))e.models[O]&&typeof e.models[O]!="undefined"&&(e.models[O]=await e.models[O])}var M0;function Ie(e,t,o){var x;if(e&&(M0=e),!t||(M0||g("instance not registred"),!M0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],s=[],a=[],i=t.modelUrl,c=t.executor;if((x=c==null?void 0:c.graph)!=null&&x.nodes)for(let d of Object.values(c.graph.nodes)){let l=d.op.toLowerCase();s.includes(l)||s.push(l)}else!c&&M0.config.debug&&g("model not loaded",o);for(let d of s)!n.includes(d)&&!r.includes(d)&&!M0.env.kernels.includes(d)&&!M0.env.kernels.includes(d.replace("_",""))&&!M0.env.kernels.includes(d.replace("native",""))&&!M0.env.kernels.includes(d.replace("v2",""))&&a.push(d);return M0.config.debug&&a.length>0&&g("model validation failed:",o,a),a.length>0?{name:o,missing:a,ops:s,url:i}:null}function U2(e){M0=e;let t=[];for(let o of Object.keys(M0.models)){let n=M0.models[o];if(!n)continue;let r=Ie(M0,n,o);r&&t.push(r)}return t}var y0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},O0={};async function kA(e,t){return y0.debug&&g("load model fetch:",e,t),fetch(e,t)}function bo(e){y0.cacheModels=e.cacheModels,y0.verbose=e.debug,y0.modelBasePath=e.modelBasePath}async function L(e){var x,d,l;let t=B1(y0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;O0[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:A5[n],inCache:!1},y0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let s={};try{s=y0.cacheSupported&&y0.cacheModels?await A.io.listModels():{}}catch(f){y0.cacheSupported=!1}O0[n].inCache=y0.cacheSupported&&y0.cacheModels&&Object.keys(s).includes(r);let a=typeof fetch=="undefined"?{}:{fetchFunc:(f,y)=>kA(f,y)},i=new e5(O0[n].inCache?r:t,a),c=!1;try{i.findIOHandler(),y0.debug&&g("model load handler:",i.handler);let f=await i.handler.load();O0[n].sizeFromManifest=((x=f==null?void 0:f.weightData)==null?void 0:x.byteLength)||0,i.loadSync(f),O0[n].sizeLoadedWeights=((l=(d=i.artifacts)==null?void 0:d.weightData)==null?void 0:l.byteLength)||0,y0.verbose&&g("load:",{model:n,url:i.modelUrl,bytes:O0[n].sizeLoadedWeights}),c=!0}catch(f){g("error loading model:",t,f)}if(c&&y0.cacheModels&&y0.cacheSupported&&!O0[n].inCache)try{let f=await i.save(r);g("model saved:",r,f)}catch(f){g("error saving model:",t,f)}return Ie(null,i,`${e||""}`),i}var g1="2.10.0";var Mo={};q0(Mo,{all:()=>w1,body:()=>Oe,canvas:()=>T1,face:()=>Ne,gesture:()=>Fe,hand:()=>Le,object:()=>We,options:()=>s0,person:()=>P1});var v0=e=>{if(!e)g("draw error: invalid canvas");else if(!e.getContext)g("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)g("draw error: cannot get canvas context");else return t}return null},be=e=>Math.round(e*180/Math.PI),V0=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function Z0(e,t,o,n,r){e.fillStyle=V0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function F0(e,t,o,n,r,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+n)/2,i=(o+o+r)/2;e.ellipse(a,i,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+n-s.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+s.roundRect),e.lineTo(t+n,o+r-s.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-s.roundRect,o+r),e.lineTo(t+s.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function M1(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=V0(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function go(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){M1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let s=e.emotion.map(a=>`${Math.trunc(100*a.score)}% ${a.emotion}`);s.length>3&&(s.length=3),r.push(s.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${be(e.rotation.angle.roll)}\xB0 yaw:${be(e.rotation.angle.yaw)}\xB0 pitch:${be(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${be(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=H.color;for(let s=r.length-1;s>=0;s--){let a=Math.max(e.box[0],0),i=s*H.lineHeight+e.box[1];H.shadowColor&&H.shadowColor!==""&&(t.fillStyle=H.shadowColor,t.fillText(r[s],a+5,i+16)),t.fillStyle=H.labelColor,t.fillText(r[s],a+4,i+15)}}}function CA(e,t){var o,n,r,s;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let a=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,i=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((s=e.annotations)==null?void 0:s.rightEyeIris[0])){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let a=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,i=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}}function jA(e,t){var o;if(H.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*be(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*be(e.rotation.angle.pitch)/90,s=new Path2D(` +`;var t5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},o5=class{constructor(t,o,n){w(this,"uniform",{});w(this,"attribute",{});w(this,"gl");w(this,"id");w(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(g(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(g("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!s)){if(!this.id){g("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){g(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),t5(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);t5(o,"uniform",this.uniform),t5(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function U1(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,c=a0(100,100),x={},d={INTERMEDIATE:1},l=c.getContext("webgl");if(!l){g("filter: cannot get webgl context");return}this.gl=l;function f(P,p){if(!(P===c.width&&p===c.height)){if(c.width=P,c.height=p,!a){let h=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,a),l.bufferData(l.ARRAY_BUFFER,h,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,c.width,c.height),r=[null,null]}}function y(P,p){let h=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,h);let E=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,E);let k=l.createTexture();return l.bindTexture(l.TEXTURE_2D,k),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,P,p,0,l.RGBA,l.UNSIGNED_BYTE,null),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,k,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:h,texture:k}}function m(P){return r[P]=r[P]||y(c.width,c.height),r[P]}function u(P=0){if(!i)return;let p=null,h=null,E=!1;e===0?p=t:p=m(n).texture||null,e++,o&&!(P&d.INTERMEDIATE)?(h=null,E=e%2===0):(n=(n+1)%2,h=m(n).fbo||null),l.bindTexture(l.TEXTURE_2D,p),l.bindFramebuffer(l.FRAMEBUFFER,h),l.uniform1f(i.uniform.flipY,E?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(P){if(x[P])return i=x[P],l.useProgram((i?i.id:null)||null),i;if(i=new o5(l,H1,P),!i)return g("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,h=4*p;return l.enableVertexAttribArray(i.attribute.pos),l.vertexAttribPointer(i.attribute.pos,2,l.FLOAT,!1,h,0*p),l.enableVertexAttribArray(i.attribute.uv),l.vertexAttribPointer(i.attribute.uv,2,l.FLOAT,!1,h,2*p),x[P]=i,i}let v={colorMatrix:P=>{let p=new Float32Array(P);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let h=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?V1:D1,E=M(h);!E||(l.uniform1fv(E.uniform.m,p),u())},brightness:P=>{let p=(P||0)+1;v.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:P=>{let p=(P||0)*2/3+1,h=(p-1)*-.5;v.colorMatrix([p,h,h,0,0,h,p,h,0,0,h,h,p,0,0,0,0,0,1,0])},desaturate:()=>{v.saturation(-1)},contrast:P=>{let p=(P||0)+1,h=-128*(p-1);v.colorMatrix([p,0,0,0,h,0,p,0,0,h,0,0,p,0,h,0,0,0,1,0])},negative:()=>{v.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let p=Math.cos(P),h=Math.sin(P),E=.213,k=.715,b=.072;v.colorMatrix([E+p*(1-E)+h*-E,k+p*-k+h*-k,b+p*-b+h*(1-b),0,0,E+p*-E+h*.143,k+p*(1-k)+h*.14,b+p*-b+h*-.283,0,0,E+p*-E+h*-(1-E),k+p*-k+h*k,b+p*(1-b)+h*b,0,0,0,0,0,1,0])},desaturateLuminance:()=>{v.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{v.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{v.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{v.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{v.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{v.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{v.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{v.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let p=new Float32Array(P),h=1/c.width,E=1/c.height,k=M(q1);!k||(l.uniform1fv(k.uniform.m,p),l.uniform2f(k.uniform.px,h,E),u())},detectEdges:()=>{v.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{v.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{v.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let p=P||1;v.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:P=>{let p=P||1;v.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:P=>{let p=P/7/c.width,h=P/7/c.height,E=M(X1);!E||(l.uniform2f(E.uniform.px,0,h),u(d.INTERMEDIATE),l.uniform2f(E.uniform.px,p,0),u())},pixelate:P=>{let p=P/c.width,h=P/c.height,E=M(Z1);!E||(l.uniform2f(E.uniform.size,p,h),u())}};this.add=function(P){let p=Array.prototype.slice.call(arguments,1),h=v[P];s.push({func:h,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(P){f(P.width,P.height),e=0,t||(t=l.createTexture()),l.bindTexture(l.TEXTURE_2D,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,P);for(let p=0;py.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[A.sub(o[0],n[0]),A.sub(o[1],n[1]),A.sub(o[2],n[2])],c=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,c[0]),A.div(a,c[1]),A.div(a,c[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],l=A.stack([d[0],d[1],d[2]],2),f=A.reshape(l,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...c,...x,...d,l,t]),f}var x2=3840,e0=null,t0=null,Me=null,D,b0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function n5(){b0.inputSum=0,b0.cacheDiff=1,b0.sumMethod=0,b0.inputTensor=void 0}function a0(e,t){let o;if(T.browser)if(T.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof T.Canvas!="undefined"?o=new T.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function y2(e,t){let o=t||a0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function ve(e,t,o=!0){var f,y;if(!e)return t.debug&&g("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof ge)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof T.Canvas!="undefined"&&e instanceof T.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof ge){let m=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)m=A.expandDims(e,0);else if(e.shape[2]===4){let u=A.slice3d(e,[0,0,0],[-1,-1,3]);m=A.expandDims(u,0),A.dispose(u)}}else e.shape.length===4&&(e.shape[3]===3?m=A.clone(e):e.shape[3]===4&&(m=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(m==null||m.shape.length!==4||m.shape[0]!==1||m.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(m.dtype==="int32"){let u=A.cast(m,"float32");A.dispose(m),m=u}return{tensor:m,canvas:t.filter.return?t0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&g("input stream is not ready"),{tensor:null,canvas:e0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&g("cannot determine input dimensions"),{tensor:null,canvas:e0};let s=n,a=r;if(s>x2&&(s=x2,a=Math.trunc(s*r/n)),a>x2&&(a=x2,s=Math.trunc(a*n/r)),(((f=t.filter)==null?void 0:f.width)||0)>0?s=t.filter.width:(((y=t.filter)==null?void 0:y.height)||0)>0&&(s=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=r*((t.filter.width||0)/n)),!s||!a)throw new Error("input error: cannot determine dimension");(!e0||e0.width!==s||e0.height!==a)&&(e0=a0(s,a));let i=e0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(n,0),i.scale(-1,1),i.drawImage(e,0,0,n,r,0,0,e0.width,e0.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,e0.width,e0.height),(!t0||e0.width!==t0.width||e0.height!==t0.height)&&(t0=a0(e0.width,e0.height)),t.filter.enabled&&T.webgl.supported?(D||(D=T.browser?new U1:null),T.filter=!!D,D!=null&&D.add?(D.reset(),t.filter.brightness!==0&&D.add("brightness",t.filter.brightness),t.filter.contrast!==0&&D.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&D.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&D.add("blur",t.filter.blur),t.filter.saturation!==0&&D.add("saturation",t.filter.saturation),t.filter.hue!==0&&D.add("hue",t.filter.hue),t.filter.negative&&D.add("negative"),t.filter.sepia&&D.add("sepia"),t.filter.vintage&&D.add("brownie"),t.filter.sepia&&D.add("sepia"),t.filter.kodachrome&&D.add("kodachrome"),t.filter.technicolor&&D.add("technicolor"),t.filter.polaroid&&D.add("polaroid"),t.filter.pixelate!==0&&D.add("pixelate",t.filter.pixelate),D.get()>0?t0=D.apply(e0):t0=D.draw(e0)):(t.debug&&g("input process error: cannot initialize filters"),T.webgl.supported=!1,t.filter.enabled=!1,y2(e0,t0))):(y2(e0,t0),D&&(D=null),T.filter=!!D),!o)return{tensor:null,canvas:t0};if(!t0)throw new Error("canvas error: cannot create output");let c,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(T.browser&&A.browser)c=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let m=new Uint8Array(e.data.buffer);c=A.tensor(m,[e.height,e.width,x],"int32")}else if((!Me||t0.width!==Me.width||t0.height!==Me.height)&&(Me=a0(t0.width,t0.height)),A.browser&&T.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?c=A.browser.fromPixels(t0):(Me=y2(t0),c=A.browser.fromPixels(Me));else{let M=y2(t0).getContext("2d").getImageData(0,0,s,a);x=M.data.length/s/a;let v=new Uint8Array(M.data.buffer);c=A.tensor(v,[s,a,x])}if(x===4){let m=A.slice3d(c,[0,0,0],[-1,-1,3]);A.dispose(c),c=m}if(!c)throw new Error("input error: cannot create tensor");let d=A.cast(c,"float32"),l=t.filter.equalization?await c2(d):A.expandDims(d,0);return A.dispose([c,d]),{tensor:l,canvas:t.filter.return?t0:null}}async function Y1(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!b0.inputTensor)b0.inputTensor=A.clone(t);else if(b0.inputTensor.shape[1]!==t.shape[1]||b0.inputTensor.shape[2]!==t.shape[2])A.dispose(b0.inputTensor),b0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,b0.inputTensor),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;A.dispose([b0.inputTensor,n.diff,n.squared,n.sum]),b0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function K1(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||g("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||g("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=A.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?A.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):A.clone(o),n.diff=A.sub(n.input1,n.input2),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return A.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var r5=class{constructor(){w(this,"browser");w(this,"node");w(this,"worker");w(this,"platform","");w(this,"agent","");w(this,"backends",[]);w(this,"initial");w(this,"filter");w(this,"tfjs");w(this,"offscreen");w(this,"perfadd",!1);w(this,"tensorflow",{version:void 0,gpu:void 0});w(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});w(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});w(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});w(this,"cpu",{model:void 0,flags:[]});w(this,"kernels",[]);w(this,"Canvas");w(this,"Image");w(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Ue["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(A.engine().registryFactory),this.tensorflow={version:A.backend().binding?A.backend().binding.TF_Version:void 0,gpu:A.backend().binding?A.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=A.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=A.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=a0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(A.getBackend()==="webgl"||A.getBackend()==="humangl")){let n=A.backend().gpgpu!=="undefined"?await A.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},T=new r5;var A5={};q0(A5,{age:()=>an,"anti-spoofing":()=>Gn,antispoof:()=>Yo,blazeface:()=>Ko,"blazeface-back":()=>ln,"blazeface-front":()=>cn,"blazepose-detect":()=>Fn,"blazepose-detector2d":()=>xn,"blazepose-detector3d":()=>yn,"blazepose-full":()=>dn,"blazepose-heavy":()=>fn,"blazepose-lite":()=>mn,default:()=>_n,efficientpose:()=>pn,"efficientpose-i-lite":()=>Bn,"efficientpose-ii-lite":()=>Hn,"efficientpose-iv":()=>Dn,emotion:()=>Jo,faceboxes:()=>un,facemesh:()=>Qo,"facemesh-attention":()=>bn,"facemesh-attention-alt":()=>hn,"facemesh-detection-full":()=>gn,"facemesh-detection-short":()=>Mn,"facemesh-orig":()=>vn,faceres:()=>_o,"faceres-deep":()=>Rn,gear:()=>Pn,gender:()=>wn,"gender-ssrnet-imdb":()=>Tn,handdetect:()=>kn,"handlandmark-full":()=>$o,"handlandmark-lite":()=>En,"handlandmark-sparse":()=>zn,handskeleton:()=>Sn,handtrack:()=>en,"insightface-efficientnet-b0":()=>Vn,"insightface-ghostnet-strides1":()=>Zn,"insightface-ghostnet-strides2":()=>Xn,"insightface-mobilenet-emore":()=>qn,"insightface-mobilenet-swish":()=>Un,iris:()=>tn,liveness:()=>on,"mb3-centernet":()=>nn,meet:()=>Cn,mobileface:()=>jn,mobilefacenet:()=>In,models:()=>rn,"movenet-lightning":()=>An,"movenet-multipose":()=>Nn,"movenet-thunder":()=>On,nanodet:()=>Ln,"nanodet-e":()=>Yn,"nanodet-g":()=>Kn,"nanodet-m":()=>Jn,"nanodet-t":()=>Qn,posenet:()=>Wn,selfie:()=>sn});var Yo=853098,Ko=538928,Jo=820516,Qo=1477958,_o=6978814,$o=5431368,en=2964837,tn=2599092,on=592976,nn=4030290,rn=0,An=4650216,sn=212886,an=161240,ln=538928,cn=402048,xn=7499400,yn=5928856,dn=6338290,fn=27501554,mn=2725490,pn=5651240,un=2013002,hn=2387598,bn=2382414,gn=1026192,Mn=201268,vn=2955780,Rn=13957620,Pn=1498916,Tn=161236,wn=201808,kn=3515612,En=2023432,zn=5286322,Sn=5502280,Cn=372228,jn=2183192,In=5171976,Nn=9448838,On=12477112,Ln=7574558,Wn=5032780,Fn=5928804,Gn=853098,Bn=2269064,Hn=5651240,Dn=25643252,Vn=13013224,Zn=8093408,Xn=8049584,qn=6938536,Un=12168584,Yn=12319156,Kn=7574558,Jn=1887474,Qn=5294216,_n={antispoof:Yo,blazeface:Ko,emotion:Jo,facemesh:Qo,faceres:_o,"handlandmark-full":$o,handtrack:en,iris:tn,liveness:on,"mb3-centernet":nn,models:rn,"movenet-lightning":An,selfie:sn,age:an,"blazeface-back":ln,"blazeface-front":cn,"blazepose-detector2d":xn,"blazepose-detector3d":yn,"blazepose-full":dn,"blazepose-heavy":fn,"blazepose-lite":mn,efficientpose:pn,faceboxes:un,"facemesh-attention-alt":hn,"facemesh-attention":bn,"facemesh-detection-full":gn,"facemesh-detection-short":Mn,"facemesh-orig":vn,"faceres-deep":Rn,gear:Pn,"gender-ssrnet-imdb":Tn,gender:wn,handdetect:kn,"handlandmark-lite":En,"handlandmark-sparse":zn,handskeleton:Sn,meet:Cn,mobileface:jn,mobilefacenet:In,"movenet-multipose":Nn,"movenet-thunder":On,nanodet:Ln,posenet:Wn,"blazepose-detect":Fn,"anti-spoofing":Gn,"efficientpose-i-lite":Bn,"efficientpose-ii-lite":Hn,"efficientpose-iv":Dn,"insightface-efficientnet-b0":Vn,"insightface-ghostnet-strides1":Zn,"insightface-ghostnet-strides2":Xn,"insightface-mobilenet-emore":qn,"insightface-mobilenet-swish":Un,"nanodet-e":Yn,"nanodet-g":Kn,"nanodet-m":Jn,"nanodet-t":Qn};var t2={};q0(t2,{Models:()=>s2,getModelStats:()=>h1,load:()=>b1,reset:()=>O2,validate:()=>U2,validateModel:()=>Ie});var T0,s5=[],$n=["white","black","asian","indian","other"],er=[15,23,28,35.5,45.5,55.5,65],J1=0,Q1=0,a5=Number.MAX_SAFE_INTEGER;async function _1(e){var t;return T.initial&&(T0=null),T0?e.debug&&g("cached model:",T0.modelUrl):T0=await L((t=e.face.gear)==null?void 0:t.modelPath),T0}async function i5(e,t,o,n){var a,i;if(!T0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=a5<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>R()-Q1;return t.skipAllowed&&s&&r&&J1===n&&s5[o]?(a5++,s5[o]):(a5=0,new Promise(async c=>{var v,P;if(!(T0!=null&&T0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[T0.inputs[0].shape[2],T0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(v=t.face.gear)!=null&&v.enabled&&([x.age,x.gender,x.race]=T0.execute(x.resize,["age_output","gender_output","race_output"]));let f=await x.gender.data();l.gender=f[0]>f[1]?"male":"female",l.genderScore=Math.round(100*(f[0]>f[1]?f[0]:f[1]))/100;let y=await x.race.data();for(let p=0;p(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&l.race.push({score:Math.round(100*y[p])/100,race:$n[p]});l.race.sort((p,h)=>h.score-p.score);let u=Array.from(await x.age.data()).map((p,h)=>[er[h],p]).sort((p,h)=>h[1]-p[1]),M=u[0][0];for(let p=1;pA.dispose(x[p])),s5[o]=l,J1=n,Q1=R(),c(l)}))}var F={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function et(){F.tf255=A.scalar(255,"float32"),F.tf1=A.scalar(1,"float32"),F.tf2=A.scalar(2,"float32"),F.tf05=A.scalar(.5,"float32"),F.tf127=A.scalar(127.5,"float32"),F.rgb=A.tensor1d([.2989,.587,.114],"float32")}var d0,d2=[],tt=0,ot=0,l5=Number.MAX_SAFE_INTEGER;async function nt(e){return T.initial&&(d0=null),d0?e.debug&&g("cached model:",d0.modelUrl):d0=await L(e.face.ssrnet.modelPathAge),d0}async function c5(e,t,o,n){var a,i,c,x;if(!d0)return{age:0};let r=l5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>R()-ot;return t.skipAllowed&&r&&s&&tt===n&&((c=d2[o])==null?void 0:c.age)&&((x=d2[o])==null?void 0:x.age)>0?(l5++,d2[o]):(l5=0,new Promise(async d=>{var y;if(!(d0!=null&&d0.inputs)||!d0.inputs[0]||!d0.inputs[0].shape)return;let l={};l.resize=A.image.resizeBilinear(e,[d0.inputs[0].shape[2],d0.inputs[0].shape[1]],!1),l.enhance=A.mul(l.resize,F.tf255);let f={age:0};if((y=t.face.ssrnet)!=null&&y.enabled&&(l.age=d0.execute(l.enhance)),l.age){let m=await l.age.data();f.age=Math.trunc(10*m[0])/10}Object.keys(l).forEach(m=>A.dispose(l[m])),d2[o]=f,tt=n,ot=R(),d(f)}))}var w0,f2=[],At=0,st=0,x5=Number.MAX_SAFE_INTEGER,y5=[.2989,.587,.114];async function at(e){var t;return T.initial&&(w0=null),w0?e.debug&&g("cached model:",w0.modelUrl):w0=await L((t=e.face.ssrnet)==null?void 0:t.modelPathGender),w0}async function d5(e,t,o,n){var a,i,c,x;if(!w0)return{gender:"unknown",genderScore:0};let r=x5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>R()-st;return t.skipAllowed&&r&&s&&At===n&&((c=f2[o])==null?void 0:c.gender)&&((x=f2[o])==null?void 0:x.genderScore)>0?(x5++,f2[o]):(x5=0,new Promise(async d=>{var m;if(!(w0!=null&&w0.inputs[0].shape))return;let l={};l.resize=A.image.resizeBilinear(e,[w0.inputs[0].shape[2],w0.inputs[0].shape[1]],!1),l.enhance=A.tidy(()=>{let[u,M,v]=A.split(l.resize,3,3),P=A.mul(u,y5[0]),p=A.mul(M,y5[1]),h=A.mul(v,y5[2]),E=A.addN([P,p,h]);return A.mul(A.sub(E,F.tf05),2)});let f={gender:"unknown",genderScore:0};(m=t.face.ssrnet)!=null&&m.enabled&&(l.gender=w0.execute(l.enhance));let y=await l.gender.data();f.gender=y[0]>y[1]?"female":"male",f.genderScore=y[0]>y[1]?Math.trunc(100*y[0])/100:Math.trunc(100*y[1])/100,Object.keys(l).forEach(u=>A.dispose(l[u])),f2[o]=f,At=n,st=R(),d(f)}))}var _,m2=[],f5=Number.MAX_SAFE_INTEGER,lt=0,ct=0;async function xt(e){var t;return T.initial&&(_=null),_?e.debug&&g("cached model:",_.modelUrl):_=await L((t=e.face.antispoof)==null?void 0:t.modelPath),_}async function m5(e,t,o,n){var a,i;if(!_||!(_!=null&&_.executor))return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>R()-ct,s=f5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&<===n&&m2[o]?(f5++,m2[o]):(f5=0,new Promise(async c=>{let x=A.image.resizeBilinear(e,[_!=null&&_.inputs[0].shape?_.inputs[0].shape[2]:0,_!=null&&_.inputs[0].shape?_.inputs[0].shape[1]:0],!1),d=_==null?void 0:_.execute(x),l=(await d.data())[0];m2[o]=Math.round(100*l)/100,lt=n,ct=R(),A.dispose([x,d]),c(m2[o])}))}var k0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},p5={count:468,mouth:13,symmetryLine:[13,k0.midwayBetweenEyes[0]]},ae={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},u5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Ke=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],ie=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var or=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],nr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],rr=[33,133,362,263,1,78,308],R7=or.map(e=>Ke[e]),P7=nr.map(e=>Ke[e]),T7=rr.map(e=>Ke[e]);function U0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Ar=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],sr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],ar=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],ir=[[474,475],[475,476],[476,477],[477,474]],lr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],cr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],xr=[[469,470],[470,471],[471,472],[472,469]],yr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],w7={lips:U0(Ar),leftEye:U0(sr),leftEyebrow:U0(ar),leftIris:U0(ir),rightEye:U0(lr),rightEyebrow:U0(cr),rightIris:U0(xr),faceOval:U0(yr)};var Re=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],p2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],u2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],h2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],mt=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},b5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],a=A.image.cropAndResize(t,[s],[0],o),i=A.div(a,F.tf255);return A.dispose(a),i},b2=(e,t)=>{let o=p2(e),n=Re(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},g2=e=>{let t=p2(e),o=Re(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},pt=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},g5=[[1,0,0],[0,1,0],[0,0,1]],dr=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),fr=(e,t)=>dr(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var dt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],s=dt(t[0],t[1]),a=ft(s,r),i=dt(-t[0],-t[1]);return ft(a,i)},pr=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-le(t[0],o),-le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},ur=(e,t)=>[le(e,t[0]),le(e,t[1])];function ht(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[s[0]/r*(y[0]-r/2),s[1]/r*(y[1]-r/2),y[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,c=i?ut(o,[0,0]):g5,x=i?a.map(y=>[...ur(y,c),y[2]]):a,d=i?pr(n):g5,l=p2(t),f=[le(l,d[0]),le(l,d[1])];return x.map(y=>[Math.trunc(y[0]+f[0]),Math.trunc(y[1]+f[1]),Math.trunc(y[2]||0)])}function gt(e,t,o,n){let r=t.landmarks.length>=p5.count?p5.symmetryLine:ae.symmetryLine,s=0,a=g5,i;if(e&&T.kernels.includes("rotatewithoffset"))if(s=fr(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=p2(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],l=A.image.rotateWithOffset(o,s,0,d);a=ut(-s,x),i=b5(t,l,[n,n]),A.dispose(l)}else i=b5(t,o,[n,n]);else i=b5(t,o,[n,n]);return[s,a,i]}var hr=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},Mt=(e,t)=>{let o=hr(e),n=Re(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var vt=6,br=1.4,C0,Rt=null,Y0=0,Je=null,Pe=()=>Y0;async function Pt(e){var t;return T.initial&&(C0=null),C0?e.debug&&g("cached model:",C0.modelUrl):C0=await L((t=e.face.detector)==null?void 0:t.modelPath),Y0=C0.executor&&C0.inputs[0].shape?C0.inputs[0].shape[2]:256,Je=A.scalar(Y0,"int32"),Rt=A.tensor2d(ht(Y0)),C0}function gr(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,Rt),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,Je),t.centersNormalized=A.div(t.centers,Je),t.halfBoxSize=A.div(t.boxSizesNormalized,F.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,Je),t.endNormalized=A.mul(t.ends,Je);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function Tt(e,t){var i,c,x,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=A.image.resizeBilinear(e,[Y0,Y0]),o.div=A.div(o.resized,F.tf127),o.normalized=A.sub(o.div,F.tf05);let n=C0==null?void 0:C0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((f,y)=>f.size-y.size);o.concat384=A.concat([l[0],l[2]],2),o.concat512=A.concat([l[1],l[3]],2),o.concat=A.concat([o.concat512,o.concat384],1),o.batch=A.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=A.squeeze(n[0]):o.batch=A.squeeze(n);A.dispose(n),o.boxes=gr(o.batch),o.logits=A.slice(o.batch,[0,0],[-1,1]),o.sigmoid=A.sigmoid(o.logits),o.scores=A.squeeze(o.sigmoid),o.nms=await A.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((c=t.face.detector)==null?void 0:c.iouThreshold)||0,((x=t.face.detector)==null?void 0:x.minConfidence)||0);let r=await o.nms.array(),s=[],a=await o.scores.data();for(let l=0;l(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let y={};y.bbox=A.slice(o.boxes,[r[l],0],[1,-1]),y.slice=A.slice(o.batch,[r[l],vt-1],[1,-1]),y.squeeze=A.squeeze(y.slice),y.landmarks=A.reshape(y.squeeze,[vt,-1]);let m=await y.bbox.data(),u={startPoint:[m[0],m[1]],endPoint:[m[2],m[3]],landmarks:await y.landmarks.array(),confidence:f},M=mt(u,[(e.shape[2]||0)/Y0,(e.shape[1]||0)/Y0]),v=b2(M,t.face.scale||br),P=g2(v);s.push(P),Object.keys(y).forEach(p=>A.dispose(y[p]))}}return Object.keys(o).forEach(l=>A.dispose(o[l])),s}var M2={};q0(M2,{connected:()=>R5,kpt:()=>v5});var v5=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],R5={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var kt=224,Mr,vr=5,v2=[8,16,32,32,32];function Et(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function G0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[n[0],n[1],r[0]-n[0],r[1]-n[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function zt(e,t=[1,1]){let o=[e.map(x=>x[0]),e.map(x=>x[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[(n[0]+r[0])/2,(n[1]+r[1])/2],a=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+r[0],-s[1]+r[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],c=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:c}}function R2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var jt={initial:!0},r0={detector:null,landmarks:null},Te={detector:[224,224],landmarks:[256,256]},P5=Number.MAX_SAFE_INTEGER,Pr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},T2=null,Qe,K0=[[0,0],[0,0],[0,0],[0,0]],St=0,Ct=e=>1-1/(1+Math.exp(e));async function It(e){var t;if(jt.initial&&(r0.detector=null),!r0.detector&&e.body.detector&&e.body.detector.modelPath){r0.detector=await L(e.body.detector.modelPath);let o=(t=r0.detector)!=null&&t.executor?Object.values(r0.detector.modelSignature.inputs):void 0;Te.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Te.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&r0.detector&&g("cached model:",r0.detector.modelUrl);return Et(),r0.detector}async function Nt(e){var t;if(jt.initial&&(r0.landmarks=null),r0.landmarks)e.debug&&g("cached model:",r0.landmarks.modelUrl);else{r0.landmarks=await L(e.body.modelPath);let o=(t=r0.landmarks)!=null&&t.executor?Object.values(r0.landmarks.modelSignature.inputs):void 0;Te.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Te.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return r0.landmarks}function Tr(e,t){var r,s;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((s=e==null?void 0:e.shape)!=null&&s[2]))return e;let n;if(Qe&&(o.cropped=A.image.cropAndResize(e,[Qe],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let a=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],i=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];K0=[[0,0],a,i,[0,0]],o.pad=A.pad(o.cropped||e,K0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,F.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,F.tf255)):n=A.div(o.cropped||e,F.tf255);return Object.keys(o).forEach(a=>A.dispose(o[a])),n}function wr(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+K0[2][0]+K0[2][1])/t[0]-K0[2][0]),Math.trunc(o.position[1]*(t[1]+K0[1][0]+K0[1][1])/t[1]-K0[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(Qe)for(let o of e)o.positionRaw=[o.positionRaw[0]+Qe[1],o.positionRaw[1]+Qe[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function kr(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),n=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");r.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function Er(e,t,o){var m,u;if(!((m=r0.landmarks)!=null&&m.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=r0.landmarks)==null?void 0:u.execute(e,Pr.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(M=>A.dispose(n[M]));let i=[],c=5;for(let M=0;MM.position),l=G0(d,[o[0],o[1]]),f={};for(let[M,v]of Object.entries(R5)){let P=[];for(let p=0;pk.part===v[p]),E=x.find(k=>k.part===v[p+1]);h&&E&&P.push([h.position,E.position])}f[M]=P}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:x,annotations:f}}async function T5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>R()-St,r=P5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&T2!==null)P5++;else{let s={};s.landmarks=Tr(e,256),T2=await Er(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),St=R(),P5=0}return T2?[T2]:[]}var we=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var x0,ce=0,w5=[],Lt=0,k5=Number.MAX_SAFE_INTEGER;async function Wt(e){if(T.initial&&(x0=null),x0)e.debug&&g("cached model:",x0.modelUrl);else{x0=await L(e.object.modelPath);let t=x0!=null&&x0.executor?Object.values(x0.modelSignature.inputs):void 0;ce=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return x0}async function zr(e,t,o){if(!e)return[];let n={},r=[],s=await e.array();n.squeeze=A.squeeze(e);let a=A.split(n.squeeze,6,1);n.stack=A.stack([a[1],a[0],a[3],a[2]],1),n.boxes=A.squeeze(n.stack),n.scores=A.squeeze(a[4]),n.classes=A.squeeze(a[5]),A.dispose([e,...a]),n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await n.nms.data(),c=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,l=s[0][x][5];if(Number.isNaN(l))continue;let f=we[l].label,[y,m]=[s[0][x][0]/ce,s[0][x][1]/ce],u=[y,m,s[0][x][2]/ce-y,s[0][x][3]/ce-m],M=[Math.trunc(u[0]*t[0]),Math.trunc(u[1]*t[1]),Math.trunc(u[2]*t[0]),Math.trunc(u[3]*t[1])];r.push({id:c++,score:d,class:l,label:f,box:M,boxRaw:u})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function E5(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.object.skipTime||0)>R()-Lt,n=k5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&w5.length>0?(k5++,w5):(k5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ce,ce]),i=t.object.enabled?x0==null?void 0:x0.execute(a,["tower_0/detections"]):null;Lt=R(),A.dispose(a);let c=await zr(i,s,t);w5=c,r(c)}))}var w2={};q0(w2,{connected:()=>S5,kpt:()=>z5});var z5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],S5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $,Gt=0,i0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},C5=Number.MAX_SAFE_INTEGER;async function Bt(e){return T.initial&&($=null),$?e.debug&&g("cached model:",$.modelUrl):$=await L(e.body.modelPath),$}async function Sr(e,t){let[o,n]=e.shape,r=A.reshape(e,[n*o]),s=A.max(r,0),a=(await s.data())[0];if(a>t){let i=A.argMax(r,0),c=A.mod(i,o),x=(await c.data())[0],d=A.div(i,o),l=(await d.data())[0];return A.dispose([r,s,i,c,d]),[x,l,a]}return A.dispose([r,s]),[0,0,a]}async function j5(e,t){if(!($!=null&&$.executor))return[];let o=(t.body.skipTime||0)>R()-Gt,n=C5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(i0.keypoints).length>0?(C5++,[i0]):(C5=0,new Promise(async r=>{let s=A.tidy(()=>{if(!($!=null&&$.inputs[0].shape))return null;let l=A.image.resizeBilinear(e,[$.inputs[0].shape[2],$.inputs[0].shape[1]],!1),f=A.mul(l,F.tf2);return A.sub(f,F.tf1)}),a;if(t.body.enabled&&(a=$==null?void 0:$.execute(s)),Gt=R(),A.dispose(s),a){i0.keypoints.length=0;let l=A.squeeze(a);A.dispose(a);let f=A.unstack(l,2);A.dispose(l);for(let y=0;y(t.body.minConfidence||0)&&i0.keypoints.push({score:Math.round(100*M)/100,part:z5[y],positionRaw:[m/$.inputs[0].shape[2],u/$.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/$.inputs[0].shape[2]),Math.round(e.shape[1]*u/$.inputs[0].shape[1])]})}f.forEach(y=>A.dispose(y))}i0.score=i0.keypoints.reduce((l,f)=>f.score>l?f.score:l,0);let i=i0.keypoints.map(l=>l.position[0]),c=i0.keypoints.map(l=>l.position[1]);i0.box=[Math.min(...i),Math.min(...c),Math.max(...i)-Math.min(...i),Math.max(...c)-Math.min(...c)];let x=i0.keypoints.map(l=>l.positionRaw[0]),d=i0.keypoints.map(l=>l.positionRaw[1]);i0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[l,f]of Object.entries(S5)){let y=[];for(let m=0;mv.part===f[m]),M=i0.keypoints.find(v=>v.part===f[m+1]);u&&M&&u.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&y.push([u.position,M.position])}i0.annotations[l]=y}r([i0])}))}var Cr=["angry","disgust","fear","happy","sad","surprise","neutral"],g0,k2=[],Dt=0,Vt=0,I5=Number.MAX_SAFE_INTEGER;async function Zt(e){var t;return T.initial&&(g0=null),g0?e.debug&&g("cached model:",g0.modelUrl):g0=await L((t=e.face.emotion)==null?void 0:t.modelPath),g0}async function N5(e,t,o,n){var a,i;if(!g0)return[];let r=I5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>R()-Vt;return t.skipAllowed&&s&&r&&Dt===n&&k2[o]&&k2[o].length>0?(I5++,k2[o]):(I5=0,new Promise(async c=>{var d;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let l={},f=g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0;l.resize=A.image.resizeBilinear(e,[f,f],!1),l.channels=A.mul(l.resize,F.rgb),l.grayscale=A.sum(l.channels,3,!0),l.grayscaleSub=A.sub(l.grayscale,F.tf05),l.grayscaleMul=A.mul(l.grayscaleSub,F.tf2),l.emotion=g0==null?void 0:g0.execute(l.grayscaleMul),Vt=R();let y=await l.emotion.data();for(let m=0;m(t.face.emotion.minConfidence||0)&&x.push({score:Math.min(.99,Math.trunc(100*y[m])/100),emotion:Cr[m]});x.sort((m,u)=>u.score-m.score),Object.keys(l).forEach(m=>A.dispose(l[m]))}k2[o]=x,Dt=n,c(x)}))}var f0,O5=[],qt=0,Ut=0,Yt=Number.MAX_SAFE_INTEGER;async function Kt(e){var t;return T.initial&&(f0=null),f0?e.debug&&g("cached model:",f0.modelUrl):f0=await L((t=e.face.mobilefacenet)==null?void 0:t.modelPath),f0}async function L5(e,t,o,n){var a,i;if(!(f0!=null&&f0.executor))return[];let r=Yt<(((a=t.face.mobilefacenet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.mobilefacenet)==null?void 0:i.skipTime)||0)>R()-Ut;return t.skipAllowed&&s&&r&&qt===n&&O5[o]?(Yt++,O5[o]):new Promise(async c=>{var d;let x=[];if(((d=t.face.mobilefacenet)==null?void 0:d.enabled)&&(f0==null?void 0:f0.inputs[0].shape)){let l={};l.crop=A.image.resizeBilinear(e,[f0.inputs[0].shape[2],f0.inputs[0].shape[1]],!1),l.data=f0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(y=>A.dispose(l[y]))}O5[o]=x,qt=n,Ut=R(),c(x)})}var m0,W5=[],Qt=0,_t=0,$t=Number.MAX_SAFE_INTEGER;async function e3(e){return T.initial&&(m0=null),m0?e.debug&&g("cached model:",m0.modelUrl):m0=await L(e.face.insightface.modelPath),m0}async function F5(e,t,o,n){var a,i;if(!(m0!=null&&m0.executor))return[];let r=$t<(((a=t.face.insightface)==null?void 0:a.skipFrames)||0),s=(((i=t.face.insightface)==null?void 0:i.skipTime)||0)>R()-_t;return t.skipAllowed&&s&&r&&Qt===n&&W5[o]?($t++,W5[o]):new Promise(async c=>{var d;let x=[];if(((d=t.face.insightface)==null?void 0:d.enabled)&&(m0==null?void 0:m0.inputs[0].shape)){let l={};l.crop=A.image.resizeBilinear(e,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),l.data=m0.execute(l.crop);let f=await l.data.data();x=Array.from(f),Object.keys(l).forEach(y=>A.dispose(l[y]))}W5[o]=x,Qt=n,_t=R(),c(x)})}var p0,J0=0,jr=2.3,G5=k0.leftEyeLower0,B5=k0.rightEyeLower0,ke={leftBounds:[G5[0],G5[G5.length-1]],rightBounds:[B5[0],B5[B5.length-1]]},Ee={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function A3(e){var t,o;return T.initial&&(p0=null),p0?e.debug&&g("cached model:",p0.modelUrl):p0=await L((t=e.face.iris)==null?void 0:t.modelPath),J0=(p0==null?void 0:p0.executor)&&((o=p0.inputs)==null?void 0:o[0].shape)?p0.inputs[0].shape[2]:0,J0===-1&&(J0=64),p0}function E2(e,t,o,n){for(let r=0;r{let t=e[ke.leftBounds[0]][2],o=e[ke.rightBounds[0]][2];return t-o},o3=(e,t,o,n,r,s=!1)=>{let a=g2(b2(pt([e[o],e[n]]),jr)),i=Re(a),c=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[J0,J0]);if(s&&T.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(c);A.dispose(c),c=x}return{box:a,boxSize:i,crop:c}},n3=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[k0[`${o}EyeUpper0`][Ee.upperCenter]][2],r=e[k0[`${o}EyeLower0`][Ee.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let c=s;return i===2?c=n:i===4&&(c=r),[a[0],a[1],c]})};async function s3(e,t,o){if(!(p0!=null&&p0.executor))return e;let{box:n,boxSize:r,crop:s}=o3(e,t,ke.leftBounds[0],ke.leftBounds[1],o,!0),{box:a,boxSize:i,crop:c}=o3(e,t,ke.rightBounds[0],ke.rightBounds[1],o,!0),x=A.concat([s,c]);A.dispose(s),A.dispose(c);let d=p0.execute(x);A.dispose(x);let l=await d.data();A.dispose(d);let f=l.slice(0,Ee.numCoordinates*3),{rawCoords:y,iris:m}=n3(f,n,r,!0),u=l.slice(Ee.numCoordinates*3),{rawCoords:M,iris:v}=n3(u,a,i,!1),P=Ir(e);Math.abs(P)<30?(E2(e,y,"left",null),E2(e,M,"right",null)):P<1?E2(e,y,"left",["EyeUpper0","EyeLower0"]):E2(e,M,"right",["EyeUpper0","EyeLower0"]);let p=r3(e,m,"left"),h=r3(e,v,"right");return e.concat(p).concat(h)}var Nr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Or=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Lr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Wr=[[474,475],[475,476],[476,477],[477,474]],Fr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Gr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Br=[[469,470],[470,471],[471,472],[472,469]],Hr=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Q0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Dr={lips:Q0(Nr),leftEye:Q0(Or),leftEyebrow:Q0(Lr),leftIris:Q0(Wr),rightEye:Q0(Fr),rightEyebrow:Q0(Gr),rightIris:Q0(Br),faceOval:Q0(Hr)},Vr=Object.entries(Dr).map(([e,t])=>t.map(o=>[o,e])).flat(),r4=new Map(Vr),_e=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],xe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],ye=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function l3(e,t){var s,a,i,c,x,d,l,f,y,m;let o={lips:await((a=(s=t.filter(u=>u.size===160))==null?void 0:s[0])==null?void 0:a.data()),irisL:await((c=(i=t.filter(u=>u.size===10))==null?void 0:i[0])==null?void 0:c.data()),eyeL:await((d=(x=t.filter(u=>u.size===142))==null?void 0:x[0])==null?void 0:d.data()),irisR:await((f=(l=t.filter(u=>u.size===10))==null?void 0:l[1])==null?void 0:f.data()),eyeR:await((m=(y=t.filter(u=>u.size===142))==null?void 0:y[1])==null?void 0:m.data())};for(let u of Object.values(o))if(!u)return e;let n=xe.reduce((u,M)=>u+=e[M][2],0)/xe.length;for(let u=0;uu+=e[M][2],0)/ye.length;for(let u=0;uR()-L0.timestamp,n=L0.skipped<(((x=t.face.detector)==null?void 0:x.skipFrames)||0);!t.skipAllowed||!o||!n||L0.boxes.length===0?(L0.boxes=await Tt(e,t),L0.timestamp=R(),L0.skipped=0):L0.skipped++;let r=[],s=[],a=0,i=$e;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(k.faceScore=Math.round(100*B[0])/100,k.faceScore<(((m=t.face.detector)==null?void 0:m.minConfidence)||1)){if(p.confidence=k.faceScore,t.face.mesh.keepInvalid){k.box=u2(p,e),k.boxRaw=h2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(I=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*I[0]/Pe(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*I[1]/Pe()]),k.meshRaw=k.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/i]);for(let I of Object.keys(ae))k.annotations[I]=[k.mesh[ae[I]]]}}else{let I=b.find(j=>j.shape[j.shape.length-1]===1404),O=A.reshape(I,[-1,3]),G=await O.array();A.dispose(O),(u=t.face.attention)!=null&&u.enabled?G=await l3(G,b):(M=t.face.iris)!=null&&M.enabled&&(G=await s3(G,k.tensor,$e)),k.mesh=bt(G,p,h,E,$e),k.meshRaw=k.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/i]);for(let j of Object.keys(k0))k.annotations[j]=k0[j].map(n0=>k.mesh[n0]);k.score=k.faceScore;let N={...Mt(k.mesh,p),confidence:p.confidence,landmarks:p.landmarks};k.box=u2(N,e),k.boxRaw=h2(N,e),s.push(N)}A.dispose(b)}else{k.box=u2(p,e),k.boxRaw=h2(p,e),k.score=k.boxScore,k.mesh=p.landmarks.map(b=>[(p.startPoint[0]+p.endPoint[0])/2+(p.endPoint[0]+p.startPoint[0])*b[0]/Pe(),(p.startPoint[1]+p.endPoint[1])/2+(p.endPoint[1]+p.startPoint[1])*b[1]/Pe()]),k.meshRaw=k.mesh.map(b=>[b[0]/(e.shape[2]||0),b[1]/(e.shape[1]||0),(b[2]||0)/i]);for(let b of Object.keys(ae))k.annotations[b]=[k.mesh[ae[b]]]}k.score>(((v=t.face.detector)==null?void 0:v.minConfidence)||1)?r.push(k):A.dispose(k.tensor)}return L0.boxes=s,r}async function x3(e){var t,o,n,r,s,a;return T.initial&&(X=null),((t=e.face.attention)==null?void 0:t.enabled)&&(X==null?void 0:X.signature)&&Object.keys(((o=X==null?void 0:X.signature)==null?void 0:o.outputs)||{}).length<6&&(X=null),X?e.debug&&g("cached model:",X.modelUrl):(n=e.face.attention)!=null&&n.enabled?X=await L(e.face.attention.modelPath):X=await L((r=e.face.mesh)==null?void 0:r.modelPath),$e=X.executor&&((s=X==null?void 0:X.inputs)==null?void 0:s[0].shape)?(a=X==null?void 0:X.inputs)==null?void 0:a[0].shape[2]:256,X}var y3=ie,d3=Ke;var A0,_0=[],f3=0,m3=0,D5=Number.MAX_SAFE_INTEGER;async function p3(e){var t;return T.initial&&(A0=null),A0?e.debug&&g("cached model:",A0.modelUrl):A0=await L((t=e.face.description)==null?void 0:t.modelPath),A0}function V5(e){let t=e.image||e.tensor||e;if(!(A0!=null&&A0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),n=A.mul(o,F.tf255);return A.dispose(o),n}async function Z5(e,t,o,n){var i,c,x,d;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(A0!=null&&A0.executor))return r;let s=D5<(((i=t.face.description)==null?void 0:i.skipFrames)||0),a=(((c=t.face.description)==null?void 0:c.skipTime)||0)>R()-f3;return t.skipAllowed&&s&&a&&m3===n&&((x=_0==null?void 0:_0[o])==null?void 0:x.age)>0&&((d=_0==null?void 0:_0[o])==null?void 0:d.genderScore)>0?(D5++,_0[o]):(D5=0,new Promise(async l=>{var f;if((f=t.face.description)!=null&&f.enabled){let y=V5(e),m=A0==null?void 0:A0.execute(y);f3=R(),A.dispose(y);let M=await m.find(W=>W.shape[1]===1).data(),v=Math.trunc(200*Math.abs(M[0]-.5))/100;v>(t.face.description.minConfidence||0)&&(r.gender=M[0]<=.5?"female":"male",r.genderScore=Math.min(.99,v));let P=A.argMax(m.find(W=>W.shape[1]===100),1),p=(await P.data())[0];A.dispose(P);let E=await m.find(W=>W.shape[1]===100).data();r.age=Math.round(E[p-1]>E[p+1]?10*p-100*E[p-1]:10*p+100*E[p+1])/10,(Number.isNaN(M[0])||Number.isNaN(E[0]))&&g("faceres error:",{model:A0,result:m});let k=m.find(W=>W.shape[1]===1024),b=k?await k.data():[];r.descriptor=Array.from(b),m.forEach(W=>A.dispose(W))}_0[o]=r,m3=n,l(r)}))}function z2(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function e2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function b3(e,t,o){let n=t.shape[1],r=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return A.image.cropAndResize(t,s,[0],o)}function g3(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function S2(e,t=1.5){let o=e2(e),n=z2(e),r=[t*n[0]/2,t*n[1]/2],s=[o[0]-r[0],o[1]-r[1]],a=[o[0]+r[0],o[1]+r[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function C2(e){let t=e2(e),o=z2(e),r=Math.max(...o)/2,s=[t[0]-r,t[1]-r],a=[t[0]+r,t[1]+r];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function Xr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function M3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Xr(o)}var u3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function $0(e,t){let o=0;for(let n=0;n[a.x,a.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=((s=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:s[2])||0,this.inputSizeTensor=A.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=A.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=A.slice(t,[0,0],[-1,2]),o.boxSizes=A.slice(t,[0,2],[-1,2]),o.div=A.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=A.add(o.div,this.anchorsTensor),o.halfBoxSizes=A.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=A.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=A.mul(o.sub,this.inputSizeTensor),o.add=A.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=A.mul(o.add,this.inputSizeTensor);let n=A.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=A.reshape(t,[-1,7,2]),n.div=A.div(n.reshape,this.inputSizeTensor),n.landmarks=A.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){var i;let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,F.tf127),n.image=A.sub(n.div,F.tf1),n.batched=this.model.execute(n.image),n.predictions=A.squeeze(n.batched),n.slice=A.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=A.sigmoid(n.slice),n.scores=A.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=A.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await A.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((i=o.hand)==null?void 0:i.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let c of s){let x={};x.box=A.slice(n.norm,[c,0],[1,-1]),x.slice=A.slice(n.predictions,[c,5],[1,14]),x.norm=this.normalizeLandmarks(x.slice,c),x.palmLandmarks=A.reshape(x.norm,[-1,2]);let d=await x.box.data(),l=d.slice(0,2),f=d.slice(2,4),y=await x.palmLandmarks.array(),m={startPoint:l,endPoint:f,palmLandmarks:y,confidence:r[c]},u=g3(m,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);a.push(u),Object.keys(x).forEach(M=>A.dispose(x[M]))}return Object.keys(n).forEach(c=>A.dispose(n[c])),a}};var Kr=5,T3=1.65,w3=[0,5,9,13,17,1,2],Jr=0,Qr=2,k3=0,I2=class{constructor(t,o){w(this,"handDetector");w(this,"handPoseModel");w(this,"inputSize");w(this,"storedBoxes");w(this,"skipped");w(this,"detectedHands");var n,r,s;this.handDetector=t,this.handPoseModel=o,this.inputSize=((s=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:s[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(a=>a[0]),n=t.map(a=>a[1]),r=[Math.min(...o),Math.min(...n)],s=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:s}}getBoxForPalmLandmarks(t,o){let n=t.map(s=>U5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return S2(C2(r),Kr)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=S2(C2(o),T3);n.palmLandmarks=[];for(let r=0;r[a[0]*(y[0]-this.inputSize/2),a[1]*(y[1]-this.inputSize/2),a[2]*y[2]]),c=q5(n,[0,0]),x=i.map(y=>[...U5(y,c),y[2]]),d=v3(r),l=[...e2(o),1],f=[$0(l,d[0]),$0(l,d[1])];return x.map(y=>[Math.trunc(y[0]+f[0]),Math.trunc(y[1]+f[1]),Math.trunc(y[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>R()-k3,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let i=[];for(let c=0;c=o.hand.minConfidence/4){let E=A.reshape(p,[-1,3]),k=await E.array();A.dispose(p),A.dispose(E);let b=this.transformRawCoords(k,u,d,m),W=this.getBoxForHandLandmarks(b);this.storedBoxes[c]={...W,confidence:h};let B={landmarks:b,confidence:h,boxConfidence:x.confidence,fingerConfidence:h,box:{topLeft:W.startPoint,bottomRight:W.endPoint}};i.push(B)}else this.storedBoxes[c]=null;A.dispose(p)}else{let d=S2(C2(x),T3),l={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(l)}}return this.storedBoxes=this.storedBoxes.filter(c=>c!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var l0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>l0.nameMapping[e],getPoints:e=>l0.pointsMapping[e]},te={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>te.nameMapping[e]},q={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>q.nameMapping[e]},ee=class{constructor(t){w(this,"name");w(this,"curls");w(this,"directions");w(this,"weights");w(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,s)=>r+s,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let s=t[r],a=this.curls[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,c]of a)if(s===i){n+=c*this.weightsRelative[r];break}}for(let r in o){let s=o[r],a=this.directions[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,c]of a)if(s===i){n+=c*this.weightsRelative[r];break}}return n/10}};var{thumb:j0,index:B0,middle:H0,ring:de,pinky:fe}=l0,{none:I0,half:$r,full:N0}=te,{verticalUp:ze,verticalDown:b4,horizontalLeft:Y5,horizontalRight:eA,diagonalUpRight:tA,diagonalUpLeft:Se,diagonalDownRight:g4,diagonalDownLeft:M4}=q,oe=new ee("thumbs up");oe.curl(j0,I0,1);oe.direction(j0,ze,1);oe.direction(j0,Se,.25);oe.direction(j0,tA,.25);for(let e of[l0.index,l0.middle,l0.ring,l0.pinky])oe.curl(e,N0,1),oe.direction(e,Y5,1),oe.direction(e,eA,1);var J=new ee("victory");J.curl(j0,$r,.5);J.curl(j0,I0,.5);J.direction(j0,ze,1);J.direction(j0,Se,1);J.curl(B0,I0,1);J.direction(B0,ze,.75);J.direction(B0,Se,1);J.curl(H0,I0,1);J.direction(H0,ze,1);J.direction(H0,Se,.75);J.curl(de,N0,1);J.direction(de,ze,.2);J.direction(de,Se,1);J.direction(de,Y5,.2);J.curl(fe,N0,1);J.direction(fe,ze,.2);J.direction(fe,Se,1);J.direction(fe,Y5,.2);J.weight(B0,2);J.weight(H0,2);var ne=new ee("point");ne.curl(j0,N0,1);ne.curl(B0,I0,.5);ne.curl(H0,N0,.5);ne.curl(de,N0,.5);ne.curl(fe,N0,.5);ne.weight(B0,2);ne.weight(H0,2);var re=new ee("middle finger");re.curl(j0,I0,1);re.curl(B0,N0,.5);re.curl(H0,N0,.5);re.curl(de,N0,.5);re.curl(fe,N0,.5);re.weight(B0,2);re.weight(H0,2);var Ce=new ee("open palm");Ce.curl(j0,I0,.75);Ce.curl(B0,I0,.75);Ce.curl(H0,I0,.75);Ce.curl(de,I0,.75);Ce.curl(fe,I0,.75);var E3=[oe,J,ne,re,Ce];var oA=.7,me={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function z3(e,t,o,n){let r=(t-n)/(e-o),s=Math.atan(r)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function C3(e,t){if(!e||!t)return[0,0];let o=z3(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=z3(e[1],e[2],t[1],t[2]);return[o,n]}function S3(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function nA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],c=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],l=t[2]-o[2],f=Math.sqrt(n*n+a*a+x*x),y=Math.sqrt(r*r+i*i+d*d),m=Math.sqrt(s*s+c*c+l*l),u=(m*m+f*f-y*y)/(2*m*f);u>1?u=1:u<-1&&(u=-1);let M=Math.acos(u);M=57.2958*M%180;let v;return M>me.NO_CURL_START_LIMIT?v=te.none:M>me.HALF_CURL_START_LIMIT?v=te.half:v=te.full,v}function j3(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=q.horizontalLeft:r=q.horizontalRight:n===Math.abs(t)?t>0?r=q.horizontalLeft:r=q.horizontalRight:o>0?r=q.horizontalLeft:r=q.horizontalRight,r}function I3(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=q.verticalDown:r=q.verticalUp:n===Math.abs(t)?t<0?r=q.verticalDown:r=q.verticalUp:o<0?r=q.verticalDown:r=q.verticalUp,r}function rA(e,t,o,n,r,s,a,i){let c,x=I3(e,t,o,n),d=j3(r,s,a,i);return x===q.verticalUp?d===q.horizontalLeft?c=q.diagonalUpLeft:c=q.diagonalUpRight:d===q.horizontalLeft?c=q.diagonalDownLeft:c=q.diagonalDownRight,c}function AA(e,t,o,n){let r=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],c=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),l=Math.max(Math.abs(i),Math.abs(c),Math.abs(x)),f=0,y=0,m=0,u=l/(d+1e-5);u>1.5?f+=me.DISTANCE_VOTE_POWER:u>.66?y+=me.DISTANCE_VOTE_POWER:m+=me.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+i*i),v=Math.sqrt(s*s+c*c),P=Math.sqrt(a*a+x*x),p=Math.max(M,v,P),h=e[0],E=e[1],k=o[0],b=o[1];p===M?(k=o[0],b=o[1]):p===P&&(h=t[0],E=t[1]);let I=C3([h,E],[k,b]),O=S3(I,me.TOTAL_ANGLE_VOTE_POWER);f+=O[0],y+=O[1],m+=O[2];for(let N of n){let j=S3(N,me.SINGLE_ANGLE_VOTE_POWER);f+=j[0],y+=j[1],m+=j[2]}let G;return f===Math.max(f,y,m)?G=I3(c,i,x,l):m===Math.max(y,m)?G=j3(s,r,a,d):G=rA(c,i,x,l,s,r,a,d),G}function N3(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of l0.all){let a=l0.getPoints(s),i=[],c=[];for(let x of a){let d=e[x[0]],l=e[x[1]],f=C3(d,l),y=f[0],m=f[1];i.push(y),c.push(m)}t.push(i),o.push(c)}for(let s of l0.all){let a=s===l0.thumb?1:0,i=l0.getPoints(s),c=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],l=nA(c,x,d),f=AA(c,x,d,t[s].slice(a));n[s]=l,r[s]=f}return{curls:n,directions:r}}function N2(e){if(!e||e.length===0)return null;let t=N3(e),o={};for(let n of l0.all)o[l0.getName(n)]={curl:te.getName(t.curls[n]),direction:q.getName(t.directions[n])};return o}function O3(e){let t=[];if(!e||e.length===0)return t;let o=N3(e);for(let n of E3){let r=n.matchAgainst(o.curls,o.directions);r>=oA&&t.push({name:n.name,confidence:r})}return t}var L3={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},pe,ue,W3;async function J5(e,t){let o=await W3.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],c=[0,0,0,0];if(a&&a.length>0){for(let d of a)d[0]i[2]&&(i[2]=d[0]),d[1]>i[3]&&(i[3]=d[1]);i[2]-=i[0],i[3]-=i[1],c=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],c=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let x=N2(a);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:c,keypoints:a,annotations:s,landmarks:x})}return n}async function Q5(e){var o,n;T.initial&&(pe=null,ue=null),!pe||!ue?[pe,ue]=await Promise.all([e.hand.enabled?L((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?L((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&g("cached model:",pe.modelUrl),e.debug&&g("cached model:",ue.modelUrl));let t=pe?new j2(pe):void 0;return t&&ue&&(W3=new I2(t,ue)),[pe,ue]}var V={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function sA(){let e=V.gl;!e||(V.extensions=e.getSupportedExtensions())}function G3(e){var t;if(e.config.backend==="humangl"&&(V.name in A.engine().registry&&!((t=V==null?void 0:V.gl)!=null&&t.getParameter(V.gl.VERSION))&&(g("humangl error: backend invalid context"),O2(e)),!A.findBackend(V.name))){try{V.canvas=a0(100,100)}catch(n){g("humangl error: cannot create canvas:",n);return}try{if(V.gl=V.canvas.getContext("webgl2",V.webGLattr),!V.gl){g("humangl error: cannot get webgl context");return}if(!V.gl.getParameter(V.gl.VERSION).includes("2.0")){g("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}V.canvas&&(V.canvas.addEventListener("webglcontextlost",r=>{throw g("humangl error:",r.type),g("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),V.canvas.addEventListener("webglcontextrestored",r=>{g("humangl error: context restored:",r)}),V.canvas.addEventListener("webglcontextcreationerror",r=>{g("humangl error: context create:",r)}))}catch(n){g("humangl error: cannot get webgl context:",n);return}try{A.setWebGLContext(2,V.gl)}catch(n){g("humangl error: cannot set webgl context:",n);return}try{let n=new A.GPGPUContext(V.gl);A.registerBackend(V.name,()=>new A.MathBackendWebGL(n),V.priority)}catch(n){g("humangl error: cannot register webgl backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:V.name};A.registerKernel(s)})}catch(n){g("humangl error: cannot update webgl backend registration:",n);return}try{A.env().flagRegistry.WEBGL_VERSION&&A.env().set("WEBGL_VERSION",2)}catch(n){g("humangl error: cannot set WebGL backend flags:",n);return}sA();let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;o?e.config.debug&&g("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):g("humangl error: no current gl context:",o,V.gl)}}function aA(e){let t=[];if(!T.kernels.includes("mod")){let o={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>A.sub(n.inputs.a,A.mul(A.div(n.inputs.a,n.inputs.b),n.inputs.b)))};A.registerKernel(o),T.kernels.push("mod"),t.push("mod")}if(!T.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>A.add(A.mul(A.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),A.mod(n.inputs.a,n.inputs.b)))};A.registerKernel(o),T.kernels.push("floormod"),t.push("floormod")}if(!T.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:A.getBackend(),kernelFunc:n=>A.tidy(()=>{let r=A.getBackend();A.setBackend("cpu");let s=A.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return A.setBackend(r),s})};A.registerKernel(o),T.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&g("registered kernels:",t)}var H3={};async function o2(e,t=!1){if(e.state="backend",t||T.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=R();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&g("running inside web worker"),T.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&g("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),T.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&g(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),T.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")g("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&g("enumerated webgpu adapter:",r),!r)g("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let s="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;g("webgpu adapter info:",s)}}let n=Object.keys(A.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(G3(e),n=Object.keys(A.engine().registryFactory)),e.config.debug&&g("available backends:",n),n.includes(e.config.backend)||(g(`error: backend ${e.config.backend} not found in registry`),e.config.backend=T.node?"tensorflow":"webgl",e.config.debug&&g(`override: setting backend ${e.config.backend}`)),e.config.debug&&g("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(A.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&A.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&g("wasm path:",e.config.wasmPath),typeof A.setWasmPaths!="undefined")A.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,s=!1;try{r=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&g(`wasm execution: ${s?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!s&&g("warning: wasm simd support is not enabled")}catch(a){g("wasm detection failed")}}try{await A.setBackend(e.config.backend),await A.ready()}catch(r){return g("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(H3=JSON.parse(JSON.stringify(A.env().flags)))}if((A.getBackend()==="humangl"||A.getBackend()==="webgl")&&(A.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&A.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.env().flagRegistry.WEBGL_EXP_CONV&&A.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),A.getBackend(),e.config.debug){let n=A.env().flags,r={};for(let s of Object.keys(n))H3[s]!==n[s]&&(r[s]=n[s]);e.config.debug&&Object.keys(r).length>0&&g("backend:",A.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&g("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))A.env().set(n,r)}A.enableProdMode(),et(),e.performance.initBackend=Math.trunc(R()-o),e.config.backend=A.getBackend(),await T.updateBackend(),aA(e.config),T.initial=!1}return!0}function L2(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&g("kernelFunc",o,t.backend)}};A.registerKernel(n)}T.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var K=[null,null],iA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ae=[[0,0],[0,0]],lA=["hand","fist","pinch","point","face","tip","pinchtip"],V3=4,Z3=1.6,cA=512,xA=1.4,W2=Number.MAX_SAFE_INTEGER,_5=0,D0=[0,0],Y={boxes:[],hands:[]},X3={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function q3(e){var t;if(T.initial&&(K[0]=null),K[0])e.debug&&g("cached model:",K[0].modelUrl);else{L2(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),K[0]=await L((t=e.hand.detector)==null?void 0:t.modelPath);let o=K[0].executor?Object.values(K[0].modelSignature.inputs):void 0;Ae[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ae[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return K[0]}async function U3(e){var t;if(T.initial&&(K[1]=null),K[1])e.debug&&g("cached model:",K[1].modelUrl);else{K[1]=await L((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=K[1].executor?Object.values(K[1].modelSignature.inputs):void 0;Ae[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ae[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return K[1]}async function yA(e,t){let o=[];if(!e||!K[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,cA),a=Math.round(s*r/8)*8;n.resize=A.image.resizeBilinear(e,[s,a]),n.cast=A.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await K[0].executeAsync(n.cast,iA),n.boxes=A.squeeze(n.rawBoxes,[0,2]),n.scores=A.squeeze(n.rawScores,[0]);let i=A.unstack(n.scores,1);A.dispose(i[V3]),i.splice(V3,1),n.filtered=A.stack(i,1),A.dispose(i),n.max=A.max(n.filtered,1),n.argmax=A.argMax(n.filtered,1);let c=0;n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let x=await n.nms.data(),d=await n.max.data(),l=await n.argmax.data();for(let f of Array.from(x)){let y=A.slice(n.boxes,f,1),m=await y.data();A.dispose(y);let u=[m[1],m[0],m[3]-m[1],m[2]-m[0]],M=R2(u,xA),v=[Math.trunc(u[0]*D0[0]),Math.trunc(u[1]*D0[1]),Math.trunc(u[2]*D0[0]),Math.trunc(u[3]*D0[1])],P=d[f],p=lA[l[f]],h={id:c++,score:P,box:v,boxRaw:M,label:p};o.push(h)}return Object.keys(n).forEach(f=>A.dispose(n[f])),o.sort((f,y)=>y.score-f.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function $5(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&K[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=A.image.cropAndResize(e,[s],[0],[Ae[1][0],Ae[1][1]],"bilinear"),r.div=A.div(r.crop,F.tf255),[r.score,r.keypoints]=K[1].execute(r.div,["Identity_1","Identity"]);let a=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){n.fingerScore=i,r.reshaped=A.reshape(r.keypoints,[-1,3]);let d=(await r.reshaped.array()).map(l=>[l[0]/Ae[1][1],l[1]/Ae[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=d.map(l=>[D0[0]*(l[0]+t.boxRaw[0]),D0[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=N2(n.keypoints);for(let l of Object.keys(X3))n.annotations[l]=X3[l].map(f=>n.landmarks&&n.keypoints[f]?n.keypoints[f]:null)}Object.keys(r).forEach(c=>A.dispose(r[c]))}return n}async function e1(e,t){var r,s;if(!((r=K[0])!=null&&r.executor)||!((s=K[1])!=null&&s.executor)||!K[0].inputs[0].shape||!K[1].inputs[0].shape)return[];D0=[e.shape[2]||0,e.shape[1]||0],W2++;let o=(t.hand.skipTime||0)>R()-_5,n=W2<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Y.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>R()-_5,c=W2<3*(t.hand.skipFrames||0);t.skipAllowed&&Y.hands.length===t.hand.maxDetected?Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))):t.skipAllowed&&i&&c&&Y.hands.length>0?Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))):(Y.boxes=await yA(e,t),_5=R(),Y.hands=await Promise.all(Y.boxes.map(d=>$5(e,d,t))),W2=0);let x=[...Y.boxes];if(Y.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&l.box[3]/(e.shape[1]||1)>.05&&Y.hands[d].fingerScore&&Y.hands[d].fingerScore>(t.hand.minConfidence||0)){let f=R2(l.box,Z3),y=R2(l.boxRaw,Z3);Y.boxes.push({...x[d],box:f,boxRaw:y})}}for(let d=0;dR()-J3,s=t1<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&K3===n&&F2[o]?(t1++,F2[o]):(t1=0,new Promise(async c=>{let x=A.image.resizeBilinear(e,[o0!=null&&o0.inputs[0].shape?o0.inputs[0].shape[2]:0,o0!=null&&o0.inputs[0].shape?o0.inputs[0].shape[1]:0],!1),d=o0==null?void 0:o0.execute(x),l=(await d.data())[0];F2[o]=Math.round(100*l)/100,K3=n,J3=R(),A.dispose([x,d]),c(F2[o])}))}var n2={};q0(n2,{connected:()=>B2,horizontal:()=>n1,kpt:()=>G2,relative:()=>A1,vertical:()=>r1});var G2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],r1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],A1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],B2={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $3=.005,u0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function s1(e){for(let t of n1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]x&&x.part===t[0]),r=e.keypoints.findIndex(x=>x&&x.part===t[1]),s=e.keypoints.findIndex(x=>x&&x.part===o[0]),a=e.keypoints.findIndex(x=>x&&x.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0])]:[0,0],c=e.keypoints[r]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||c[0]>c[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function eo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=A.pad(e,u0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(a=>A.dispose(o[a])),n}function oo(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+u0.padding[2][0]+u0.padding[2][1])/t[0]-u0.padding[2][0],n.position[1]*(t[1]+u0.padding[1][0]+u0.padding[1][1])/t[1]-u0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=G0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var Q,H2=0,a1=Number.MAX_SAFE_INTEGER,he={boxes:[],bodies:[],last:0};async function no(e){var t;return T.initial&&(Q=null),Q?e.debug&&g("cached model:",Q.modelUrl):(L2(["size"],e),Q=await L(e.body.modelPath)),H2=(Q==null?void 0:Q.executor)&&((t=Q==null?void 0:Q.inputs)==null?void 0:t[0].shape)?Q.inputs[0].shape[2]:0,H2<64&&(H2=256),Q}function fA(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let l=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:G2[d],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}s=r.reduce((d,l)=>l.score>d?l.score:d,0);let a=[],i=G0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),c={};for(let[d,l]of Object.entries(B2)){let f=[];for(let y=0;yM.part===l[y]),u=r.find(M=>M.part===l[y+1]);m&&u&&m.score>(t.body.minConfidence||0)&&u.score>(t.body.minConfidence||0)&&f.push([m.position,u.position])}c[d]=f}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:c};return s1(x),a.push(x),a}function mA(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let l=0;l<17;l++){let f=s[3*l+2];if(f>t.body.minConfidence){let y=[s[3*l+1],s[3*l+0]];i.push({part:G2[l],score:Math.round(100*f)/100,positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}}let c=G0(i.map(l=>l.position),[o.shape[2],o.shape[1]]),x={};for(let[l,f]of Object.entries(B2)){let y=[];for(let m=0;mv.part===f[m]),M=i.find(v=>v.part===f[m+1]);u&&M&&u.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&y.push([u.position,M.position])}x[l]=y}let d={id:r,score:a,box:c.box,boxRaw:c.boxRaw,keypoints:[...i],annotations:x};s1(d),n.push(d)}}return n.sort((r,s)=>s.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function i1(e,t){var r;if(!(Q!=null&&Q.executor)||!((r=Q==null?void 0:Q.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(he.boxes.length=0),a1++;let o=(t.body.skipTime||0)>R()-he.last,n=a1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?he.bodies:new Promise(async s=>{let a={};a1=0,a.input=to(e,H2),a.res=Q==null?void 0:Q.execute(a.input),he.last=R();let i=await a.res.array();he.bodies=a.res.shape[2]===17?fA(i,t,e):mA(i,t,e);for(let c of he.bodies)oo(c,[e.shape[2]||1,e.shape[1]||1]),eo(c.keypoints);Object.keys(a).forEach(c=>A.dispose(a[c])),s(he.bodies)})}var E0,D2=[],Ao=0,l1=Number.MAX_SAFE_INTEGER,Z2=0,V2=2.5;async function so(e){if(!E0||T.initial){E0=await L(e.object.modelPath);let t=E0!=null&&E0.executor?Object.values(E0.modelSignature.inputs):void 0;Z2=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&g("cached model:",E0.modelUrl);return E0}async function pA(e,t,o){let n=0,r=[],s=Z2;for(let x of[1,2,4]){let d=x*13,l=A.squeeze(e.find(v=>v.shape[1]===d**2&&(v.shape[2]||0)===we.length)),f=await l.array(),y=A.squeeze(e.find(v=>v.shape[1]===d**2&&(v.shape[2]||0)(o.object.minConfidence||0)&&P!==61){let h=(.5+Math.trunc(v%d))/d,E=(.5+Math.trunc(v/d))/d,k=M[v].map(j=>j*(d/x/s)),[b,W]=[h-V2/x*k[0],E-V2/x*k[1]],[B,I]=[h+V2/x*k[2]-b,E+V2/x*k[3]-W],O=[b,W,B,I];O=O.map(j=>Math.max(0,Math.min(j,1)));let G=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],N={id:n++,score:Math.round(100*p)/100,class:P+1,label:we[P].label,box:G.map(j=>Math.trunc(j)),boxRaw:O};r.push(N)}}A.dispose([l,y,m,u])}let a=r.map(x=>[x.boxRaw[1],x.boxRaw[0],x.boxRaw[3],x.boxRaw[2]]),i=r.map(x=>x.score),c=[];if(a&&a.length>0){let x=await A.image.nonMaxSuppressionAsync(a,i,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);c=await x.data(),A.dispose(x)}return r=r.filter((x,d)=>c.includes(d)).sort((x,d)=>d.score-x.score),r}async function c1(e,t){if(!(E0!=null&&E0.executor))return[];let o=(t.object.skipTime||0)>R()-Ao,n=l1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&D2.length>0?(l1++,D2):(l1=0,!T.kernels.includes("mod")||!T.kernels.includes("sparsetodense")?D2:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[Z2,Z2],!1),i=A.div(a,F.tf255),c=A.transpose(i,[0,3,1,2]),x;t.object.enabled&&(x=E0.execute(c)),Ao=R();let d=await pA(x,s,t);D2=d,A.dispose([a,i,c,...x]),r(d)}))}var A2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],uA=A2.length,r2=A2.reduce((e,t,o)=>(e[t]=o,e),{}),hA=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],Y4=hA.map(([e,t])=>[r2[e],r2[t]]),io=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function lo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(n,i),minX:Math.min(r,a),minY:Math.min(s,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function co(e,[t,o],[n,r]){let s=t/n,a=o/r,i=(x,d)=>({id:d,score:x.score,boxRaw:[x.box[0]/r,x.box[1]/n,x.box[2]/r,x.box[3]/n],box:[Math.trunc(x.box[0]*a),Math.trunc(x.box[1]*s),Math.trunc(x.box[2]*a),Math.trunc(x.box[3]*s)],keypoints:x.keypoints.map(({score:l,part:f,position:y})=>({score:l,part:f,position:[Math.trunc(y.x*a),Math.trunc(y.y*s)],positionRaw:[y.x/n,y.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var X2=class{constructor(t,o){w(this,"priorityQueue");w(this,"numberOfElements");w(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function xo(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function f1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var h0,gA=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],q2=1,je=16,MA=50**2;function yo(e,t,o,n,r,s,a=2){let i=v=>({y:s.get(v.y,v.x,e),x:s.get(v.y,v.x,s.shape[2]/2+e)}),c=(v,P,p)=>({y:d1(Math.round(v.y/je),0,P-1),x:d1(Math.round(v.x/je),0,p-1)}),[x,d]=n.shape,l=c(t.position,x,d),f=i(l),m=f1(t.position,f);for(let v=0;v[r2[f],r2[y]]),a=s.map(([,f])=>f),i=s.map(([f])=>f),c=t.shape[2],x=a.length,d=new Array(c),l=y1(e.part,je,o);d[e.part.id]={score:e.score,part:A2[e.part.id],position:l};for(let f=x-1;f>=0;--f){let y=a[f],m=i[f];d[y]&&!d[m]&&(d[m]=yo(f,d[y],m,t,o,r))}for(let f=0;ft){i=!1;break}if(!i)break}return i}function PA(e,t){let[o,n,r]=t.shape,s=new X2(o*n*r,({score:a})=>a);for(let a=0;a{var a;let s=(a=r[n])==null?void 0:a.position;return s?xo(o,t,s.y,s.x)<=MA:!1})}function TA(e,t){return t.reduce((n,{position:r,score:s},a)=>(fo(e,r,a)||(n+=s),n),0)/t.length}function wA(e,t,o,n,r,s){let a=[],i=PA(s,t);for(;a.lengthy.score>s);let l=TA(a,d),f=lo(d);l>s&&a.push({keypoints:d,box:f,score:Math.round(100*l)/100})}return a}async function m1(e,t){if(!(h0!=null&&h0.executor))return[];let o=A.tidy(()=>{if(!h0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=h0.execute(i,gA).map(d=>A.squeeze(d,[0]));return x[1]=A.sigmoid(x[1]),x}),n=await Promise.all(o.map(a=>a.buffer()));for(let a of o)A.dispose(a);let r=wA(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return h0.inputs[0].shape?co(r,[e.shape[1],e.shape[2]],[h0.inputs[0].shape[2],h0.inputs[0].shape[1]]):[]}async function mo(e){return!h0||T.initial?h0=await L(e.body.modelPath):e.debug&&g("cached model:",h0.modelUrl),h0}var W0,p1=!1;async function u1(e){return!W0||T.initial?W0=await L(e.segmentation.modelPath):e.debug&&g("cached model:",W0.modelUrl),W0}async function uo(e,t,o){var u,M;if(p1)return{data:[],canvas:null,alpha:null};p1=!0,W0||await u1(o);let n=await ve(e,o),r=((u=n.tensor)==null?void 0:u.shape[2])||0,s=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[W0.inputs[0].shape?W0.inputs[0].shape[1]:0,W0.inputs[0].shape?W0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,F.tf255),a.res=W0.execute(a.norm),a.squeeze=A.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=A.softmax(a.squeeze),[a.bg,a.fg]=A.unstack(a.softmax,2),a.expand=A.expandDims(a.fg,2),a.pad=A.expandDims(a.expand,0),a.crop=A.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[r,s]),a.data=A.squeeze(a.crop,0)):a.data=A.image.resizeBilinear(a.squeeze,[s,r]);let i=Array.from(await a.data.data());if(T.node&&!T.Canvas&&typeof ImageData=="undefined")return o.debug&&g("canvas support missing"),Object.keys(a).forEach(v=>A.dispose(a[v])),{data:i,canvas:null,alpha:null};let c=a0(r,s);A.browser&&await A.browser.toPixels(a.data,c);let x=c.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),l=a0(r,s),f=l.getContext("2d");n.canvas&&f.drawImage(n.canvas,0,0),f.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(f.filter=`blur(${o.segmentation.blur}px)`),f.drawImage(c,0,0),f.globalCompositeOperation="source-over",f.filter="none";let y=f.getImageData(0,0,r,s);for(let v=0;vA.dispose(a[v])),p1=!1,{data:i,canvas:l,alpha:c}}var s2=class{constructor(){w(this,"ssrnetage",null);w(this,"gear",null);w(this,"blazeposedetect",null);w(this,"blazepose",null);w(this,"centernet",null);w(this,"efficientpose",null);w(this,"mobilefacenet",null);w(this,"insightface",null);w(this,"emotion",null);w(this,"facedetect",null);w(this,"faceiris",null);w(this,"facemesh",null);w(this,"faceres",null);w(this,"ssrnetgender",null);w(this,"handpose",null);w(this,"handskeleton",null);w(this,"handtrack",null);w(this,"liveness",null);w(this,"movenet",null);w(this,"nanodet",null);w(this,"posenet",null);w(this,"segmentation",null);w(this,"antispoof",null)}},h1=e=>{let t=0,o=0,n=0;for(let s of Object.values(O0))t+=s.sizeFromManifest,o+=s.sizeLoadedWeights,n+=s.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(O0).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(O0)}};function O2(e){for(let t of Object.keys(e.models))e.models[t]=null}async function b1(e){var t,o,n,r,s,a,i,c,x,d,l,f,y,m,u,M,v,P,p,h,E,k,b,W,B,I;T.initial&&O2(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Q5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Q5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=e.config.body.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=Nt(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=It(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((a=e.config.body.modelPath)==null?void 0:a.includes("efficientpose"))&&(e.models.efficientpose=Bt(e.config)),e.config.body.enabled&&!e.models.movenet&&((i=e.config.body.modelPath)==null?void 0:i.includes("movenet"))&&(e.models.movenet=no(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=e.config.body.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=mo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=Pt(e.config)),e.config.face.enabled&&((x=e.config.face.antispoof)==null?void 0:x.enabled)&&!e.models.antispoof&&(e.models.antispoof=xt(e.config)),e.config.face.enabled&&((d=e.config.face.liveness)==null?void 0:d.enabled)&&!e.models.liveness&&(e.models.liveness=Q3(e.config)),e.config.face.enabled&&((l=e.config.face.description)==null?void 0:l.enabled)&&!e.models.faceres&&(e.models.faceres=p3(e.config)),e.config.face.enabled&&((f=e.config.face.emotion)==null?void 0:f.enabled)&&!e.models.emotion&&(e.models.emotion=Zt(e.config)),e.config.face.enabled&&((y=e.config.face.iris)==null?void 0:y.enabled)&&!((m=e.config.face.attention)!=null&&m.enabled)&&!e.models.faceiris&&(e.models.faceiris=A3(e.config)),e.config.face.enabled&&((u=e.config.face.mesh)==null?void 0:u.enabled)&&!e.models.facemesh&&(e.models.facemesh=x3(e.config)),e.config.face.enabled&&((M=e.config.face.gear)==null?void 0:M.enabled)&&!e.models.gear&&(e.models.gear=_1(e.config)),e.config.face.enabled&&((v=e.config.face.ssrnet)==null?void 0:v.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=nt(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=at(e.config)),e.config.face.enabled&&((p=e.config.face.mobilefacenet)==null?void 0:p.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=Kt(e.config)),e.config.face.enabled&&((h=e.config.face.insightface)==null?void 0:h.enabled)&&!e.models.insightface&&(e.models.insightface=e3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((k=(E=e.config.hand.detector)==null?void 0:E.modelPath)==null?void 0:k.includes("handtrack"))&&(e.models.handtrack=q3(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((W=(b=e.config.hand.detector)==null?void 0:b.modelPath)==null?void 0:W.includes("handtrack"))&&(e.models.handskeleton=U3(e.config)),e.config.object.enabled&&!e.models.centernet&&((B=e.config.object.modelPath)==null?void 0:B.includes("centernet"))&&(e.models.centernet=Wt(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=so(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=u1(e.config));for await(let O of Object.keys(e.models))e.models[O]&&typeof e.models[O]!="undefined"&&(e.models[O]=await e.models[O])}var M0;function Ie(e,t,o){var x;if(e&&(M0=e),!t||(M0||g("instance not registred"),!M0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],s=[],a=[],i=t.modelUrl,c=t.executor;if((x=c==null?void 0:c.graph)!=null&&x.nodes)for(let d of Object.values(c.graph.nodes)){let l=d.op.toLowerCase();s.includes(l)||s.push(l)}else!c&&M0.config.debug&&g("model not loaded",o);for(let d of s)!n.includes(d)&&!r.includes(d)&&!M0.env.kernels.includes(d)&&!M0.env.kernels.includes(d.replace("_",""))&&!M0.env.kernels.includes(d.replace("native",""))&&!M0.env.kernels.includes(d.replace("v2",""))&&a.push(d);return M0.config.debug&&a.length>0&&g("model validation failed:",o,a),a.length>0?{name:o,missing:a,ops:s,url:i}:null}function U2(e){M0=e;let t=[];for(let o of Object.keys(M0.models)){let n=M0.models[o];if(!n)continue;let r=Ie(M0,n,o);r&&t.push(r)}return t}var y0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},O0={};async function kA(e,t){return y0.debug&&g("load model fetch:",e,t),fetch(e,t)}function bo(e){y0.cacheModels=e.cacheModels,y0.verbose=e.debug,y0.modelBasePath=e.modelBasePath}async function L(e){var x,d,l;let t=B1(y0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;O0[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:A5[n],inCache:!1},y0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let s={};try{s=y0.cacheSupported&&y0.cacheModels?await A.io.listModels():{}}catch(f){y0.cacheSupported=!1}O0[n].inCache=y0.cacheSupported&&y0.cacheModels&&Object.keys(s).includes(r);let a=typeof fetch=="undefined"?{}:{fetchFunc:(f,y)=>kA(f,y)},i=new e5(O0[n].inCache?r:t,a),c=!1;try{i.findIOHandler(),y0.debug&&g("model load handler:",i.handler);let f=await i.handler.load();O0[n].sizeFromManifest=((x=f==null?void 0:f.weightData)==null?void 0:x.byteLength)||0,i.loadSync(f),O0[n].sizeLoadedWeights=((l=(d=i.artifacts)==null?void 0:d.weightData)==null?void 0:l.byteLength)||0,y0.verbose&&g("load:",{model:n,url:i.modelUrl,bytes:O0[n].sizeLoadedWeights}),c=!0}catch(f){g("error loading model:",t,f)}if(c&&y0.cacheModels&&y0.cacheSupported&&!O0[n].inCache)try{let f=await i.save(r);g("model saved:",r,f)}catch(f){g("error saving model:",t,f)}return Ie(null,i,`${e||""}`),i}var g1="2.10.1";var Mo={};q0(Mo,{all:()=>w1,body:()=>Oe,canvas:()=>T1,face:()=>Ne,gesture:()=>Fe,hand:()=>Le,object:()=>We,options:()=>s0,person:()=>P1});var v0=e=>{if(!e)g("draw error: invalid canvas");else if(!e.getContext)g("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)g("draw error: cannot get canvas context");else return t}return null},be=e=>Math.round(e*180/Math.PI),V0=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function Z0(e,t,o,n,r){e.fillStyle=V0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function F0(e,t,o,n,r,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+n)/2,i=(o+o+r)/2;e.ellipse(a,i,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+n-s.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+s.roundRect),e.lineTo(t+n,o+r-s.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-s.roundRect,o+r),e.lineTo(t+s.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function M1(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=V0(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function go(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){M1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let s=e.emotion.map(a=>`${Math.trunc(100*a.score)}% ${a.emotion}`);s.length>3&&(s.length=3),r.push(s.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${be(e.rotation.angle.roll)}\xB0 yaw:${be(e.rotation.angle.yaw)}\xB0 pitch:${be(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${be(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=H.color;for(let s=r.length-1;s>=0;s--){let a=Math.max(e.box[0],0),i=s*H.lineHeight+e.box[1];H.shadowColor&&H.shadowColor!==""&&(t.fillStyle=H.shadowColor,t.fillText(r[s],a+5,i+16)),t.fillStyle=H.labelColor,t.fillText(r[s],a+4,i+15)}}}function CA(e,t){var o,n,r,s;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let a=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,i=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((s=e.annotations)==null?void 0:s.rightEyeIris[0])){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let a=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,i=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],a,i,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}}function jA(e,t){var o;if(H.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*be(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*be(e.rotation.angle.pitch)/90,s=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${n} ${e.box[1]}, diff --git a/dist/human.esm.js b/dist/human.esm.js index 2b031eca3..13274ff30 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -85244,7 +85244,7 @@ async function loadModel(modelPath) { } // package.json -var version5 = "2.10.0"; +var version5 = "2.10.1"; // src/draw/draw.ts var draw_exports = {}; diff --git a/dist/human.js b/dist/human.js index 6eaa5f248..6aa50776d 100644 --- a/dist/human.js +++ b/dist/human.js @@ -7097,7 +7097,7 @@ return a / b;`,Cle=` c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var bb=(e,t,n)=>{let s=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(s,(r,a)=>(n[a]=0,r))},vb=class{constructor(t,n,s){ge(this,"uniform",{});ge(this,"attribute",{});ge(this,"gl");ge(this,"id");ge(this,"compile",(t,n)=>{let s=this.gl.createShader(n);return s?(this.gl.shaderSource(s,t),this.gl.compileShader(s),this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)?s:(ae(`filter: gl compile failed: ${this.gl.getShaderInfoLog(s)||"unknown"}`),null)):(ae("filter: could not create shader"),null)});this.gl=t;let r=this.compile(n,this.gl.VERTEX_SHADER),a=this.compile(s,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!a)){if(!this.id){ae("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,a),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){ae(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),bb(n,"attribute",this.attribute);for(let o in this.attribute)this.attribute[o]=this.gl.getAttribLocation(this.id,o);bb(n,"uniform",this.uniform),bb(s,"uniform",this.uniform);for(let o in this.uniform)this.uniform[o]=this.gl.getUniformLocation(this.id,o)}}};function LT(){let e=0,t=null,n=!1,s=-1,r=[null,null],a=[],o=null,i=null,l=ds(100,100),u={},c={INTERMEDIATE:1},p=l.getContext("webgl");if(!p){ae("filter: cannot get webgl context");return}this.gl=p;function d(x,A){if(!(x===l.width&&A===l.height)){if(l.width=x,l.height=A,!o){let b=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);o=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,o),p.bufferData(p.ARRAY_BUFFER,b,p.STATIC_DRAW),p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}p.viewport(0,0,l.width,l.height),r=[null,null]}}function h(x,A){let b=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,b);let w=p.createRenderbuffer();p.bindRenderbuffer(p.RENDERBUFFER,w);let S=p.createTexture();return p.bindTexture(p.TEXTURE_2D,S),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,x,A,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,S,0),p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),{fbo:b,texture:S}}function f(x){return r[x]=r[x]||h(l.width,l.height),r[x]}function m(x=0){if(!i)return;let A=null,b=null,w=!1;e===0?A=t:A=f(s).texture||null,e++,n&&!(x&c.INTERMEDIATE)?(b=null,w=e%2===0):(s=(s+1)%2,b=f(s).fbo||null),p.bindTexture(p.TEXTURE_2D,A),p.bindFramebuffer(p.FRAMEBUFFER,b),p.uniform1f(i.uniform.flipY,w?-1:1),p.drawArrays(p.TRIANGLES,0,6)}function g(x){if(u[x])return i=u[x],p.useProgram((i?i.id:null)||null),i;if(i=new vb(p,$T,x),!i)return ae("filter: could not get webgl program"),null;let A=Float32Array.BYTES_PER_ELEMENT,b=4*A;return p.enableVertexAttribArray(i.attribute.pos),p.vertexAttribPointer(i.attribute.pos,2,p.FLOAT,!1,b,0*A),p.enableVertexAttribArray(i.attribute.uv),p.vertexAttribPointer(i.attribute.uv,2,p.FLOAT,!1,b,2*A),u[x]=i,i}let y={colorMatrix:x=>{let A=new Float32Array(x);A[4]/=255,A[9]/=255,A[14]/=255,A[19]/=255;let b=A[18]===1&&A[3]===0&&A[8]===0&&A[13]===0&&A[15]===0&&A[16]===0&&A[17]===0&&A[19]===0?PT:FT,w=g(b);!w||(p.uniform1fv(w.uniform.m,A),m())},brightness:x=>{let A=(x||0)+1;y.colorMatrix([A,0,0,0,0,0,A,0,0,0,0,0,A,0,0,0,0,0,1,0])},saturation:x=>{let A=(x||0)*2/3+1,b=(A-1)*-.5;y.colorMatrix([A,b,b,0,0,b,A,b,0,0,b,b,A,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:x=>{let A=(x||0)+1,b=-128*(A-1);y.colorMatrix([A,0,0,0,b,0,A,0,0,b,0,0,A,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:x=>{x=(x||0)/180*Math.PI;let A=Math.cos(x),b=Math.sin(x),w=.213,S=.715,k=.072;y.colorMatrix([w+A*(1-w)+b*-w,S+A*-S+b*-S,k+A*-k+b*(1-k),0,0,w+A*-w+b*.143,S+A*(1-S)+b*.14,k+A*-k+b*-.283,0,0,w+A*-w+b*-(1-w),S+A*-S+b*S,k+A*(1-k)+b*k,0,0,0,0,0,1,0])},desaturateLuminance:()=>{y.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{y.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{y.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{y.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{y.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{y.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{y.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{y.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:x=>{let A=new Float32Array(x),b=1/l.width,w=1/l.height,S=g(zT);!S||(p.uniform1fv(S.uniform.m,A),p.uniform2f(S.uniform.px,b,w),m())},detectEdges:()=>{y.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{y.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{y.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:x=>{let A=x||1;y.convolution.call(this,[0,-1*A,0,-1*A,1+4*A,-1*A,0,-1*A,0])},emboss:x=>{let A=x||1;y.convolution.call(this,[-2*A,-1*A,0,-1*A,1,1*A,0,1*A,2*A])},blur:x=>{let A=x/7/l.width,b=x/7/l.height,w=g(MT);!w||(p.uniform2f(w.uniform.px,0,b),m(c.INTERMEDIATE),p.uniform2f(w.uniform.px,A,0),m())},pixelate:x=>{let A=x/l.width,b=x/l.height,w=g(OT);!w||(p.uniform2f(w.uniform.size,A,b),m())}};this.add=function(x){let A=Array.prototype.slice.call(arguments,1),b=y[x];a.push({func:b,args:A})},this.reset=function(){a=[]},this.get=function(){return a},this.apply=function(x){d(x.width,x.height),e=0,t||(t=p.createTexture()),p.bindTexture(p.TEXTURE_2D,t),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,x);for(let A=0;Ah.data())),o=.99*Math.max(a[0][0],a[1][0],a[2][0]),i=[me(n[0],s[0]),me(n[1],s[1]),me(n[2],s[2])],l=[me(r[0],s[0]),me(r[1],s[1]),me(r[2],s[2])],u=[fe(o,l[0]),fe(o,l[1]),fe(o,l[2])],c=[z(i[0],u[0]),z(i[1],u[1]),z(i[2],u[2])],p=ln([c[0],c[1],c[2]],2),d=V(p,[1,t.shape[0],t.shape[1],3]);return J([...n,...s,...r,...i,...l,...u,...c,p,t]),d}var U2=3840,En=null,Rn=null,xd=null,Rt,ar={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function wb(){ar.inputSum=0,ar.cacheDiff=1,ar.sumMethod=0,ar.inputTensor=void 0}function ds(e,t){let n;if(he.browser)if(he.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");n=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");n=document.createElement("canvas"),n.width=e,n.height=t}else typeof he.Canvas!="undefined"?n=new he.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(n=new globalThis.Canvas(e,t));return n}function G2(e,t){let n=t||ds(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),n}async function bd(e,t,n=!0){var d,h;if(!e)return t.debug&&ae("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof st)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof he.Canvas!="undefined"&&e instanceof he.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof st){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=Bt(e,0);else if(e.shape[2]===4){let m=pi(e,[0,0,0],[-1,-1,3]);f=Bt(m,0),J(m)}}else e.shape.length===4&&(e.shape[3]===3?f=Vn(e):e.shape[3]===4&&(f=ro(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let m=ye(f,"float32");J(f),f=m}return{tensor:f,canvas:t.filter.return?Rn:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&ae("input stream is not ready"),{tensor:null,canvas:En};let s=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!s||!r)return t.debug&&ae("cannot determine input dimensions"),{tensor:null,canvas:En};let a=s,o=r;if(a>U2&&(a=U2,o=Math.trunc(a*r/s)),o>U2&&(o=U2,a=Math.trunc(o*s/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?a=t.filter.width:(((h=t.filter)==null?void 0:h.height)||0)>0&&(a=s*((t.filter.height||0)/r)),(t.filter.height||0)>0?o=t.filter.height:(t.filter.width||0)>0&&(o=r*((t.filter.width||0)/s)),!a||!o)throw new Error("input error: cannot determine dimension");(!En||En.width!==a||En.height!==o)&&(En=ds(a,o));let i=En.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(s,0),i.scale(-1,1),i.drawImage(e,0,0,s,r,0,0,En.width,En.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,s,r,0,0,En.width,En.height),(!Rn||En.width!==Rn.width||En.height!==Rn.height)&&(Rn=ds(En.width,En.height)),t.filter.enabled&&he.webgl.supported?(Rt||(Rt=he.browser?new LT:null),he.filter=!!Rt,Rt!=null&&Rt.add?(Rt.reset(),t.filter.brightness!==0&&Rt.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Rt.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Rt.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Rt.add("blur",t.filter.blur),t.filter.saturation!==0&&Rt.add("saturation",t.filter.saturation),t.filter.hue!==0&&Rt.add("hue",t.filter.hue),t.filter.negative&&Rt.add("negative"),t.filter.sepia&&Rt.add("sepia"),t.filter.vintage&&Rt.add("brownie"),t.filter.sepia&&Rt.add("sepia"),t.filter.kodachrome&&Rt.add("kodachrome"),t.filter.technicolor&&Rt.add("technicolor"),t.filter.polaroid&&Rt.add("polaroid"),t.filter.pixelate!==0&&Rt.add("pixelate",t.filter.pixelate),Rt.get()>0?Rn=Rt.apply(En):Rn=Rt.draw(En)):(t.debug&&ae("input process error: cannot initialize filters"),he.webgl.supported=!1,t.filter.enabled=!1,G2(En,Rn))):(G2(En,Rn),Rt&&(Rt=null),he.filter=!!Rt),!n)return{tensor:null,canvas:Rn};if(!Rn)throw new Error("canvas error: cannot create output");let l,u=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(he.browser&&nr)l=nr?nr.fromPixels(e):null;else{u=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=ct(f,[e.height,e.width,u],"int32")}else if((!xd||Rn.width!==xd.width||Rn.height!==xd.height)&&(xd=ds(Rn.width,Rn.height)),nr&&he.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=nr.fromPixels(Rn):(xd=G2(Rn),l=nr.fromPixels(xd));else{let g=G2(Rn).getContext("2d").getImageData(0,0,a,o);u=g.data.length/a/o;let y=new Uint8Array(g.data.buffer);l=ct(y,[a,o,u])}if(u===4){let f=pi(l,[0,0,0],[-1,-1,3]);J(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let c=ye(l,"float32"),p=t.filter.equalization?await V2(c):Bt(c,0);return J([l,c]),{tensor:p,canvas:t.filter.return?Rn:null}}async function BT(e,t){let n=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return n;if(!ar.inputTensor)ar.inputTensor=Vn(t);else if(ar.inputTensor.shape[1]!==t.shape[1]||ar.inputTensor.shape[2]!==t.shape[2])J(ar.inputTensor),ar.inputTensor=Vn(t);else{let s={};s.diff=me(t,ar.inputTensor),s.squared=z(s.diff,s.diff),s.sum=ke(s.squared);let a=(await s.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;J([ar.inputTensor,s.diff,s.squared,s.sum]),ar.inputTensor=Vn(t),n=a<=(e.cacheSensitivity||0)}return n}async function WT(e,t,n){let s={};if(!t||!n||t.shape.length!==4||t.shape.length!==n.shape.length)return e.debug||ae("invalid input tensor or tensor shapes do not match:",t.shape,n.shape),0;if(t.shape[0]!==1||n.shape[0]!==1||t.shape[3]!==3||n.shape[3]!==3)return e.debug||ae("input tensors must be of shape [1, height, width, 3]:",t.shape,n.shape),0;s.input1=Vn(t),s.input2=t.shape[1]!==n.shape[1]||t.shape[2]!==n.shape[2]?Ie.resizeBilinear(n,[t.shape[1],t.shape[2]]):Vn(n),s.diff=me(s.input1,s.input2),s.squared=z(s.diff,s.diff),s.sum=ke(s.squared);let a=(await s.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return J([s.input1,s.input2,s.diff,s.squared,s.sum]),a}var kb=class{constructor(){ge(this,"browser");ge(this,"node");ge(this,"worker");ge(this,"platform","");ge(this,"agent","");ge(this,"backends",[]);ge(this,"initial");ge(this,"filter");ge(this,"tfjs");ge(this,"offscreen");ge(this,"perfadd",!1);ge(this,"tensorflow",{version:void 0,gpu:void 0});ge(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});ge(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});ge(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});ge(this,"cpu",{model:void 0,flags:[]});ge(this,"kernels",[]);ge(this,"Canvas");ge(this,"Image");ge(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Zh["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let n=t[0].match(/\(([^()]+)\)/g);this.platform=n!=null&&n[0]?n[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(Yt().registryFactory),this.tensorflow={version:Ls().binding?Ls().binding.TF_Version:void 0,gpu:Ls().binding?Ls().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&cn()==="wasm"&&(this.wasm.simd=H().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=H().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=ds(100,100),n=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof n!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(cn()==="webgl"||cn()==="humangl")){let s=Ls().gpgpu!=="undefined"?await Ls().getGPGPUContext().gl:null;s&&(this.webgl.version=s.getParameter(s.VERSION),this.webgl.renderer=s.getParameter(s.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let s=await navigator.gpu.requestAdapter();this.webgpu.adapter=s?s.name:void 0}}catch(s){this.webgpu.supported=!1}try{this.kernels=ta(cn()).map(s=>s.kernelName.toLowerCase())}catch(s){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},he=new kb;var Sb={};fa(Sb,{age:()=>qAe,"anti-spoofing":()=>S5e,antispoof:()=>FAe,blazeface:()=>PAe,"blazeface-back":()=>XAe,"blazeface-front":()=>KAe,"blazepose-detect":()=>k5e,"blazepose-detector2d":()=>ZAe,"blazepose-detector3d":()=>YAe,"blazepose-full":()=>JAe,"blazepose-heavy":()=>QAe,"blazepose-lite":()=>e5e,default:()=>M5e,efficientpose:()=>t5e,"efficientpose-i-lite":()=>I5e,"efficientpose-ii-lite":()=>C5e,"efficientpose-iv":()=>T5e,emotion:()=>OAe,faceboxes:()=>n5e,facemesh:()=>MAe,"facemesh-attention":()=>r5e,"facemesh-attention-alt":()=>s5e,"facemesh-detection-full":()=>a5e,"facemesh-detection-short":()=>o5e,"facemesh-orig":()=>i5e,faceres:()=>zAe,"faceres-deep":()=>l5e,gear:()=>u5e,gender:()=>d5e,"gender-ssrnet-imdb":()=>c5e,handdetect:()=>p5e,"handlandmark-full":()=>LAe,"handlandmark-lite":()=>h5e,"handlandmark-sparse":()=>f5e,handskeleton:()=>m5e,handtrack:()=>BAe,"insightface-efficientnet-b0":()=>N5e,"insightface-ghostnet-strides1":()=>E5e,"insightface-ghostnet-strides2":()=>R5e,"insightface-mobilenet-emore":()=>_5e,"insightface-mobilenet-swish":()=>D5e,iris:()=>WAe,liveness:()=>VAe,"mb3-centernet":()=>UAe,meet:()=>g5e,mobileface:()=>y5e,mobilefacenet:()=>A5e,models:()=>GAe,"movenet-lightning":()=>HAe,"movenet-multipose":()=>x5e,"movenet-thunder":()=>b5e,nanodet:()=>v5e,"nanodet-e":()=>$5e,"nanodet-g":()=>F5e,"nanodet-m":()=>P5e,"nanodet-t":()=>O5e,posenet:()=>w5e,selfie:()=>jAe});var FAe=853098,PAe=538928,OAe=820516,MAe=1477958,zAe=6978814,LAe=5431368,BAe=2964837,WAe=2599092,VAe=592976,UAe=4030290,GAe=0,HAe=4650216,jAe=212886,qAe=161240,XAe=538928,KAe=402048,ZAe=7499400,YAe=5928856,JAe=6338290,QAe=27501554,e5e=2725490,t5e=5651240,n5e=2013002,s5e=2387598,r5e=2382414,a5e=1026192,o5e=201268,i5e=2955780,l5e=13957620,u5e=1498916,c5e=161236,d5e=201808,p5e=3515612,h5e=2023432,f5e=5286322,m5e=5502280,g5e=372228,y5e=2183192,A5e=5171976,x5e=9448838,b5e=12477112,v5e=7574558,w5e=5032780,k5e=5928804,S5e=853098,I5e=2269064,C5e=5651240,T5e=25643252,N5e=13013224,E5e=8093408,R5e=8049584,_5e=6938536,D5e=12168584,$5e=12319156,F5e=7574558,P5e=1887474,O5e=5294216,M5e={antispoof:FAe,blazeface:PAe,emotion:OAe,facemesh:MAe,faceres:zAe,"handlandmark-full":LAe,handtrack:BAe,iris:WAe,liveness:VAe,"mb3-centernet":UAe,models:GAe,"movenet-lightning":HAe,selfie:jAe,age:qAe,"blazeface-back":XAe,"blazeface-front":KAe,"blazepose-detector2d":ZAe,"blazepose-detector3d":YAe,"blazepose-full":JAe,"blazepose-heavy":QAe,"blazepose-lite":e5e,efficientpose:t5e,faceboxes:n5e,"facemesh-attention-alt":s5e,"facemesh-attention":r5e,"facemesh-detection-full":a5e,"facemesh-detection-short":o5e,"facemesh-orig":i5e,"faceres-deep":l5e,gear:u5e,"gender-ssrnet-imdb":c5e,gender:d5e,handdetect:p5e,"handlandmark-lite":h5e,"handlandmark-sparse":f5e,handskeleton:m5e,meet:g5e,mobileface:y5e,mobilefacenet:A5e,"movenet-multipose":x5e,"movenet-thunder":b5e,nanodet:v5e,posenet:w5e,"blazepose-detect":k5e,"anti-spoofing":S5e,"efficientpose-i-lite":I5e,"efficientpose-ii-lite":C5e,"efficientpose-iv":T5e,"insightface-efficientnet-b0":N5e,"insightface-ghostnet-strides1":E5e,"insightface-ghostnet-strides2":R5e,"insightface-mobilenet-emore":_5e,"insightface-mobilenet-swish":D5e,"nanodet-e":$5e,"nanodet-g":F5e,"nanodet-m":P5e,"nanodet-t":O5e};var Rd={};fa(Rd,{Models:()=>uf,getModelStats:()=>M4,load:()=>z4,reset:()=>h1,validate:()=>I1,validateModel:()=>Dd});var br,Ib=[],z5e=["white","black","asian","indian","other"],L5e=[15,23,28,35.5,45.5,55.5,65],VT=0,UT=0,Cb=Number.MAX_SAFE_INTEGER;async function GT(e){var t;return he.initial&&(br=null),br?e.debug&&ae("cached model:",br.modelUrl):br=await je((t=e.face.gear)==null?void 0:t.modelPath),br}async function Tb(e,t,n,s){var o,i;if(!br)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=Cb<(((o=t.face.gear)==null?void 0:o.skipFrames)||0),a=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>le()-UT;return t.skipAllowed&&a&&r&&VT===s&&Ib[n]?(Cb++,Ib[n]):(Cb=0,new Promise(async l=>{var y,x;if(!(br!=null&&br.inputs[0].shape))return;let u={},c=[[0,.1,.9,.9]];u.resize=Ie.cropAndResize(e,c,[0],[br.inputs[0].shape[2],br.inputs[0].shape[1]]);let p={age:0,gender:"unknown",genderScore:0,race:[]};(y=t.face.gear)!=null&&y.enabled&&([u.age,u.gender,u.race]=br.execute(u.resize,["age_output","gender_output","race_output"]));let d=await u.gender.data();p.gender=d[0]>d[1]?"male":"female",p.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let h=await u.race.data();for(let A=0;A(((x=t.face.gear)==null?void 0:x.minConfidence)||.2)&&p.race.push({score:Math.round(100*h[A])/100,race:z5e[A]});p.race.sort((A,b)=>b.score-A.score);let m=Array.from(await u.age.data()).map((A,b)=>[L5e[b],A]).sort((A,b)=>b[1]-A[1]),g=m[0][0];for(let A=1;AJ(u[A])),Ib[n]=p,VT=s,UT=le(),l(p)}))}var at={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function jT(){at.tf255=Ce(255,"float32"),at.tf1=Ce(1,"float32"),at.tf2=Ce(2,"float32"),at.tf05=Ce(.5,"float32"),at.tf127=Ce(127.5,"float32"),at.rgb=Ft([.2989,.587,.114],"float32")}var Bs,H2=[],qT=0,XT=0,Nb=Number.MAX_SAFE_INTEGER;async function KT(e){return he.initial&&(Bs=null),Bs?e.debug&&ae("cached model:",Bs.modelUrl):Bs=await je(e.face.ssrnet.modelPathAge),Bs}async function Eb(e,t,n,s){var o,i,l,u;if(!Bs)return{age:0};let r=Nb<(((o=t.face.ssrnet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>le()-XT;return t.skipAllowed&&r&&a&&qT===s&&((l=H2[n])==null?void 0:l.age)&&((u=H2[n])==null?void 0:u.age)>0?(Nb++,H2[n]):(Nb=0,new Promise(async c=>{var h;if(!(Bs!=null&&Bs.inputs)||!Bs.inputs[0]||!Bs.inputs[0].shape)return;let p={};p.resize=Ie.resizeBilinear(e,[Bs.inputs[0].shape[2],Bs.inputs[0].shape[1]],!1),p.enhance=z(p.resize,at.tf255);let d={age:0};if((h=t.face.ssrnet)!=null&&h.enabled&&(p.age=Bs.execute(p.enhance)),p.age){let f=await p.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(p).forEach(f=>J(p[f])),H2[n]=d,qT=s,XT=le(),c(d)}))}var vr,j2=[],YT=0,JT=0,Rb=Number.MAX_SAFE_INTEGER,_b=[.2989,.587,.114];async function QT(e){var t;return he.initial&&(vr=null),vr?e.debug&&ae("cached model:",vr.modelUrl):vr=await je((t=e.face.ssrnet)==null?void 0:t.modelPathGender),vr}async function Db(e,t,n,s){var o,i,l,u;if(!vr)return{gender:"unknown",genderScore:0};let r=Rb<(((o=t.face.ssrnet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>le()-JT;return t.skipAllowed&&r&&a&&YT===s&&((l=j2[n])==null?void 0:l.gender)&&((u=j2[n])==null?void 0:u.genderScore)>0?(Rb++,j2[n]):(Rb=0,new Promise(async c=>{var f;if(!(vr!=null&&vr.inputs[0].shape))return;let p={};p.resize=Ie.resizeBilinear(e,[vr.inputs[0].shape[2],vr.inputs[0].shape[1]],!1),p.enhance=Z(()=>{let[m,g,y]=Jt(p.resize,3,3),x=z(m,_b[0]),A=z(g,_b[1]),b=z(y,_b[2]),w=C0([x,A,b]);return z(me(w,at.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(p.gender=vr.execute(p.enhance));let h=await p.gender.data();d.gender=h[0]>h[1]?"female":"male",d.genderScore=h[0]>h[1]?Math.trunc(100*h[0])/100:Math.trunc(100*h[1])/100,Object.keys(p).forEach(m=>J(p[m])),j2[n]=d,YT=s,JT=le(),c(d)}))}var vn,q2=[],$b=Number.MAX_SAFE_INTEGER,tN=0,nN=0;async function sN(e){var t;return he.initial&&(vn=null),vn?e.debug&&ae("cached model:",vn.modelUrl):vn=await je((t=e.face.antispoof)==null?void 0:t.modelPath),vn}async function Fb(e,t,n,s){var o,i;if(!vn||!(vn!=null&&vn.executor))return 0;let r=(((o=t.face.antispoof)==null?void 0:o.skipTime)||0)>le()-nN,a=$b<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&a&&tN===s&&q2[n]?($b++,q2[n]):($b=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[vn!=null&&vn.inputs[0].shape?vn.inputs[0].shape[2]:0,vn!=null&&vn.inputs[0].shape?vn.inputs[0].shape[1]:0],!1),c=vn==null?void 0:vn.execute(u),p=(await c.data())[0];q2[n]=Math.round(100*p)/100,tN=s,nN=le(),J([u,c]),l(q2[n])}))}var wr={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},Pb={count:468,mouth:13,symmetryLine:[13,wr.midwayBetweenEyes[0]]},gu={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Ob=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Jh=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],yu=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var W5e=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],V5e=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],U5e=[33,133,362,263,1,78,308],jke=W5e.map(e=>Jh[e]),qke=V5e.map(e=>Jh[e]),Xke=U5e.map(e=>Jh[e]);function Ai(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var G5e=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],H5e=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],j5e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],q5e=[[474,475],[475,476],[476,477],[477,474]],X5e=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],K5e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Z5e=[[469,470],[470,471],[471,472],[472,469]],Y5e=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],Kke={lips:Ai(G5e),leftEye:Ai(H5e),leftEyebrow:Ai(j5e),leftIris:Ai(q5e),rightEye:Ai(X5e),rightEyebrow:Ai(K5e),rightIris:Ai(Z5e),faceOval:Ai(Y5e)};var vd=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],K2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],Z2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],iN=(e,t)=>{let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:s,landmarks:e.landmarks,confidence:e.confidence}},zb=(e,t,n)=>{let s=t.shape[1],r=t.shape[2],a=[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r],o=Ie.cropAndResize(t,[a],[0],n),i=fe(o,at.tf255);return J(o),i},Y2=(e,t)=>{let n=X2(e),s=vd(e),r=[t*s[0]/2,t*s[1]/2];return{startPoint:[n[0]-r[0],n[1]-r[1]],endPoint:[n[0]+r[0],n[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},J2=e=>{let t=X2(e),n=vd(e),s=Math.max(...n)/2;return{startPoint:[Math.round(t[0]-s),Math.round(t[1]-s)],endPoint:[Math.round(t[0]+s),Math.round(t[1]+s)],landmarks:e.landmarks,confidence:e.confidence}},lN=e=>{let t=e.map(s=>s[0]),n=e.map(s=>s[1]);return{startPoint:[Math.min(...t),Math.min(...n)],endPoint:[Math.max(...t),Math.max(...n)],landmarks:e}},Lb=[[1,0,0],[0,1,0],[0,0,1]],J5e=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Q5e=(e,t)=>J5e(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var aN=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Au=(e,t)=>{let n=0;for(let s=0;s{let n=[];for(let s=0;s{let n=[],s=e.length;for(let r=0;r{let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=aN(t[0],t[1]),o=oN(a,r),i=aN(-t[0],-t[1]);return oN(o,i)},txe=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-Au(t[0],n),-Au(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]},nxe=(e,t)=>[Au(e,t[0]),Au(e,t[1])];function cN(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},n=[];for(let s=0;s[a[0]/r*(h[0]-r/2),a[1]/r*(h[1]-r/2),h[2]||0]),i=n&&n!==0&&Math.abs(n)>.2,l=i?uN(n,[0,0]):Lb,u=i?o.map(h=>[...nxe(h,l),h[2]]):o,c=i?txe(s):Lb,p=X2(t),d=[Au(p,c[0]),Au(p,c[1])];return u.map(h=>[Math.trunc(h[0]+d[0]),Math.trunc(h[1]+d[1]),Math.trunc(h[2]||0)])}function pN(e,t,n,s){let r=t.landmarks.length>=Pb.count?Pb.symmetryLine:gu.symmetryLine,a=0,o=Lb,i;if(e&&he.kernels.includes("rotatewithoffset"))if(a=Q5e(t.landmarks[r[0]],t.landmarks[r[1]]),a&&a!==0&&Math.abs(a)>.2){let u=X2(t),c=[u[0]/n.shape[2],u[1]/n.shape[1]],p=Ie.rotateWithOffset(n,a,0,c);o=uN(-a,u),i=zb(t,p,[s,s]),J(p)}else i=zb(t,n,[s,s]);else i=zb(t,n,[s,s]);return[a,o,i]}var sxe=e=>{let t=e.map(s=>s[0]),n=e.map(s=>s[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...n)+(Math.max(...n)-Math.min(...n))/2]},hN=(e,t)=>{let n=sxe(e),s=vd(t);return{startPoint:[n[0]-s[0]/2,n[1]-s[1]/2],endPoint:[n[0]+s[0]/2,n[1]+s[1]/2]}};var fN=6,rxe=1.4,Ur,mN=null,xi=0,Qh=null,wd=()=>xi;async function gN(e){var t;return he.initial&&(Ur=null),Ur?e.debug&&ae("cached model:",Ur.modelUrl):Ur=await je((t=e.face.detector)==null?void 0:t.modelPath),xi=Ur.executor&&Ur.inputs[0].shape?Ur.inputs[0].shape[2]:256,Qh=Ce(xi,"int32"),mN=fr(cN(xi)),Ur}function axe(e){let t={};t.boxStarts=ze(e,[0,1],[-1,2]),t.centers=ue(t.boxStarts,mN),t.boxSizes=ze(e,[0,3],[-1,2]),t.boxSizesNormalized=fe(t.boxSizes,Qh),t.centersNormalized=fe(t.centers,Qh),t.halfBoxSize=fe(t.boxSizesNormalized,at.tf2),t.starts=me(t.centersNormalized,t.halfBoxSize),t.ends=ue(t.centersNormalized,t.halfBoxSize),t.startNormalized=z(t.starts,Qh),t.endNormalized=z(t.ends,Qh);let n=ru([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(s=>J(t[s])),n}async function yN(e,t){var i,l,u,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let n={};n.resized=Ie.resizeBilinear(e,[xi,xi]),n.div=fe(n.resized,at.tf127),n.normalized=me(n.div,at.tf05);let s=Ur==null?void 0:Ur.execute(n.normalized);if(Array.isArray(s)&&s.length>2){let p=s.sort((d,h)=>d.size-h.size);n.concat384=It([p[0],p[2]],2),n.concat512=It([p[1],p[3]],2),n.concat=It([n.concat512,n.concat384],1),n.batch=rt(n.concat,0)}else Array.isArray(s)?n.batch=rt(s[0]):n.batch=rt(s);J(s),n.boxes=axe(n.batch),n.logits=ze(n.batch,[0,0],[-1,1]),n.sigmoid=$n(n.logits),n.scores=rt(n.sigmoid),n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((u=t.face.detector)==null?void 0:u.minConfidence)||0);let r=await n.nms.array(),a=[],o=await n.scores.data();for(let p=0;p(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let h={};h.bbox=ze(n.boxes,[r[p],0],[1,-1]),h.slice=ze(n.batch,[r[p],fN-1],[1,-1]),h.squeeze=rt(h.slice),h.landmarks=V(h.squeeze,[fN,-1]);let f=await h.bbox.data(),m={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await h.landmarks.array(),confidence:d},g=iN(m,[(e.shape[2]||0)/xi,(e.shape[1]||0)/xi]),y=Y2(g,t.face.scale||rxe),x=J2(y);a.push(x),Object.keys(h).forEach(A=>J(h[A]))}}return Object.keys(n).forEach(p=>J(n[p])),a}var Q2={};fa(Q2,{connected:()=>Vb,kpt:()=>Wb});var Wb=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],Vb={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var xN=224,oxe,ixe=5,e1=[8,16,32,32,32];function bN(){let e=[],t=0;for(;tn.x)),y:Ft(e.map(n=>n.y))}}function $a(e,t=[1,1]){let n=[e.map(i=>i[0]),e.map(i=>i[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[s[0],s[1],r[0]-s[0],r[1]-s[1]],o=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:o}}function vN(e,t=[1,1]){let n=[e.map(u=>u[0]),e.map(u=>u[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[(s[0]+r[0])/2,(s[1]+r[1])/2],o=Math.max(a[0]-s[0],a[1]-s[1],-a[0]+r[0],-a[1]+r[1]),i=[Math.trunc(a[0]-o),Math.trunc(a[1]-o),Math.trunc(2*o),Math.trunc(2*o)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function t1(e,t){let n=[e[2]*t,e[3]*t];return[e[0]-(n[0]-e[2])/2,e[1]-(n[1]-e[3])/2,n[0],n[1]]}var SN={initial:!0},jn={detector:null,landmarks:null},kd={detector:[224,224],landmarks:[256,256]},Ub=Number.MAX_SAFE_INTEGER,uxe={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},s1=null,ef,bi=[[0,0],[0,0],[0,0],[0,0]],wN=0,kN=e=>1-1/(1+Math.exp(e));async function IN(e){var t;if(SN.initial&&(jn.detector=null),!jn.detector&&e.body.detector&&e.body.detector.modelPath){jn.detector=await je(e.body.detector.modelPath);let n=(t=jn.detector)!=null&&t.executor?Object.values(jn.detector.modelSignature.inputs):void 0;kd.detector[0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,kd.detector[1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}else e.debug&&jn.detector&&ae("cached model:",jn.detector.modelUrl);return bN(),jn.detector}async function CN(e){var t;if(SN.initial&&(jn.landmarks=null),jn.landmarks)e.debug&&ae("cached model:",jn.landmarks.modelUrl);else{jn.landmarks=await je(e.body.modelPath);let n=(t=jn.landmarks)!=null&&t.executor?Object.values(jn.landmarks.modelSignature.inputs):void 0;kd.landmarks[0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,kd.landmarks[1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return jn.landmarks}function cxe(e,t){var r,a;let n={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((a=e==null?void 0:e.shape)!=null&&a[2]))return e;let s;if(ef&&(n.cropped=Ie.cropAndResize(e,[ef],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let o=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],i=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];bi=[[0,0],o,i,[0,0]],n.pad=sr(n.cropped||e,bi),n.resize=Ie.resizeBilinear(n.pad,[t,t]),s=fe(n.resize,at.tf255)}else e.shape[1]!==t?(n.resize=Ie.resizeBilinear(n.cropped||e,[t,t]),s=fe(n.resize,at.tf255)):s=fe(n.cropped||e,at.tf255);return Object.keys(n).forEach(o=>J(n[o])),s}function dxe(e,t){for(let n of e)n.position=[Math.trunc(n.position[0]*(t[0]+bi[2][0]+bi[2][1])/t[0]-bi[2][0]),Math.trunc(n.position[1]*(t[1]+bi[1][0]+bi[1][1])/t[1]-bi[1][0]),n.position[2]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1],2*n.position[2]/(t[0]+t[1])];if(ef)for(let n of e)n.positionRaw=[n.positionRaw[0]+ef[1],n.positionRaw[1]+ef[0],n.positionRaw[2]],n.position=[Math.trunc(n.positionRaw[0]*t[0]),Math.trunc(n.positionRaw[1]*t[1]),n.positionRaw[2]];return e}function pxe(e){let t=e.find(i=>i.part==="leftPalm"),n=e.find(i=>i.part==="leftWrist"),s=e.find(i=>i.part==="leftIndex");t.position[2]=((n.position[2]||0)+(s.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),a=e.find(i=>i.part==="rightWrist"),o=e.find(i=>i.part==="rightIndex");r.position[2]=((a.position[2]||0)+(o.position[2]||0))/2}async function hxe(e,t,n){var f,m;if(!((f=jn.landmarks)!=null&&f.executor))return null;let s={};[s.ld,s.segmentation,s.heatmap,s.world,s.poseflag]=(m=jn.landmarks)==null?void 0:m.execute(e,uxe.landmarks);let r=(await s.poseflag.data())[0],a=await s.ld.data(),o=await s.world.data();Object.keys(s).forEach(g=>J(s[g]));let i=[],l=5;for(let g=0;gg.position),p=$a(c,[n[0],n[1]]),d={};for(let[g,y]of Object.entries(Vb)){let x=[];for(let A=0;AS.part===y[A]),w=u.find(S=>S.part===y[A+1]);b&&w&&x.push([b.position,w.position])}d[g]=x}return{id:0,score:Math.trunc(100*r)/100,box:p.box,boxRaw:p.boxRaw,keypoints:u,annotations:d}}async function Gb(e,t){let n=[e.shape[2]||0,e.shape[1]||0],s=(t.body.skipTime||0)>le()-wN,r=Ub<(t.body.skipFrames||0);if(t.skipAllowed&&s&&r&&s1!==null)Ub++;else{let a={};a.landmarks=cxe(e,256),s1=await hxe(a.landmarks,t,n),Object.keys(a).forEach(o=>J(a[o])),wN=le(),Ub=0}return s1?[s1]:[]}var Sd=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var ws,xu=0,Hb=[],NN=0,jb=Number.MAX_SAFE_INTEGER;async function EN(e){if(he.initial&&(ws=null),ws)e.debug&&ae("cached model:",ws.modelUrl);else{ws=await je(e.object.modelPath);let t=ws!=null&&ws.executor?Object.values(ws.modelSignature.inputs):void 0;xu=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ws}async function fxe(e,t,n){if(!e)return[];let s={},r=[],a=await e.array();s.squeeze=rt(e);let o=Jt(s.squeeze,6,1);s.stack=ln([o[1],o[0],o[3],o[2]],1),s.boxes=rt(s.stack),s.scores=rt(o[4]),s.classes=rt(o[5]),J([e,...o]),s.nms=await Ie.nonMaxSuppressionAsync(s.boxes,s.scores,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence||0);let i=await s.nms.data(),l=0;for(let u of Array.from(i)){let c=Math.trunc(100*a[0][u][4])/100,p=a[0][u][5];if(Number.isNaN(p))continue;let d=Sd[p].label,[h,f]=[a[0][u][0]/xu,a[0][u][1]/xu],m=[h,f,a[0][u][2]/xu-h,a[0][u][3]/xu-f],g=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];r.push({id:l++,score:c,class:p,label:d,box:g,boxRaw:m})}return Object.keys(s).forEach(u=>J(s[u])),r}async function qb(e,t){if(!(ws!=null&&ws.executor))return[];let n=(t.object.skipTime||0)>le()-NN,s=jb<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&Hb.length>0?(jb++,Hb):(jb=0,new Promise(async r=>{let a=[e.shape[2]||0,e.shape[1]||0],o=Ie.resizeBilinear(e,[xu,xu]),i=t.object.enabled?ws==null?void 0:ws.execute(o,["tower_0/detections"]):null;NN=le(),J(o);let l=await fxe(i,a,t);Hb=l,r(l)}))}var r1={};fa(r1,{connected:()=>Kb,kpt:()=>Xb});var Xb=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],Kb={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var wn,_N=0,ps={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},Zb=Number.MAX_SAFE_INTEGER;async function DN(e){return he.initial&&(wn=null),wn?e.debug&&ae("cached model:",wn.modelUrl):wn=await je(e.body.modelPath),wn}async function mxe(e,t){let[n,s]=e.shape,r=V(e,[s*n]),a=yn(r,0),o=(await a.data())[0];if(o>t){let i=$s(r,0),l=ou(i,n),u=(await l.data())[0],c=fe(i,n),p=(await c.data())[0];return J([r,a,i,l,c]),[u,p,o]}return J([r,a]),[0,0,o]}async function Yb(e,t){if(!(wn!=null&&wn.executor))return[];let n=(t.body.skipTime||0)>le()-_N,s=Zb<(t.body.skipFrames||0);return t.skipAllowed&&n&&s&&Object.keys(ps.keypoints).length>0?(Zb++,[ps]):(Zb=0,new Promise(async r=>{let a=Z(()=>{if(!(wn!=null&&wn.inputs[0].shape))return null;let p=Ie.resizeBilinear(e,[wn.inputs[0].shape[2],wn.inputs[0].shape[1]],!1),d=z(p,at.tf2);return me(d,at.tf1)}),o;if(t.body.enabled&&(o=wn==null?void 0:wn.execute(a)),_N=le(),J(a),o){ps.keypoints.length=0;let p=rt(o);J(o);let d=On(p,2);J(p);for(let h=0;h(t.body.minConfidence||0)&&ps.keypoints.push({score:Math.round(100*g)/100,part:Xb[h],positionRaw:[f/wn.inputs[0].shape[2],m/wn.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/wn.inputs[0].shape[2]),Math.round(e.shape[1]*m/wn.inputs[0].shape[1])]})}d.forEach(h=>J(h))}ps.score=ps.keypoints.reduce((p,d)=>d.score>p?d.score:p,0);let i=ps.keypoints.map(p=>p.position[0]),l=ps.keypoints.map(p=>p.position[1]);ps.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let u=ps.keypoints.map(p=>p.positionRaw[0]),c=ps.keypoints.map(p=>p.positionRaw[1]);ps.boxRaw=[Math.min(...u),Math.min(...c),Math.max(...u)-Math.min(...u),Math.max(...c)-Math.min(...c)];for(let[p,d]of Object.entries(Kb)){let h=[];for(let f=0;fy.part===d[f]),g=ps.keypoints.find(y=>y.part===d[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}ps.annotations[p]=h}r([ps])}))}var gxe=["angry","disgust","fear","happy","sad","surprise","neutral"],or,a1=[],FN=0,PN=0,Jb=Number.MAX_SAFE_INTEGER;async function ON(e){var t;return he.initial&&(or=null),or?e.debug&&ae("cached model:",or.modelUrl):or=await je((t=e.face.emotion)==null?void 0:t.modelPath),or}async function Qb(e,t,n,s){var o,i;if(!or)return[];let r=Jb<(((o=t.face.emotion)==null?void 0:o.skipFrames)||0),a=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>le()-PN;return t.skipAllowed&&a&&r&&FN===s&&a1[n]&&a1[n].length>0?(Jb++,a1[n]):(Jb=0,new Promise(async l=>{var c;let u=[];if((c=t.face.emotion)!=null&&c.enabled){let p={},d=or!=null&&or.inputs[0].shape?or.inputs[0].shape[2]:0;p.resize=Ie.resizeBilinear(e,[d,d],!1),p.channels=z(p.resize,at.rgb),p.grayscale=ke(p.channels,3,!0),p.grayscaleSub=me(p.grayscale,at.tf05),p.grayscaleMul=z(p.grayscaleSub,at.tf2),p.emotion=or==null?void 0:or.execute(p.grayscaleMul),PN=le();let h=await p.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&u.push({score:Math.min(.99,Math.trunc(100*h[f])/100),emotion:gxe[f]});u.sort((f,m)=>m.score-f.score),Object.keys(p).forEach(f=>J(p[f]))}a1[n]=u,FN=s,l(u)}))}var Ws,e4=[],zN=0,LN=0,BN=Number.MAX_SAFE_INTEGER;async function WN(e){var t;return he.initial&&(Ws=null),Ws?e.debug&&ae("cached model:",Ws.modelUrl):Ws=await je((t=e.face.mobilefacenet)==null?void 0:t.modelPath),Ws}async function t4(e,t,n,s){var o,i;if(!(Ws!=null&&Ws.executor))return[];let r=BN<(((o=t.face.mobilefacenet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.mobilefacenet)==null?void 0:i.skipTime)||0)>le()-LN;return t.skipAllowed&&a&&r&&zN===s&&e4[n]?(BN++,e4[n]):new Promise(async l=>{var c;let u=[];if(((c=t.face.mobilefacenet)==null?void 0:c.enabled)&&(Ws==null?void 0:Ws.inputs[0].shape)){let p={};p.crop=Ie.resizeBilinear(e,[Ws.inputs[0].shape[2],Ws.inputs[0].shape[1]],!1),p.data=Ws.execute(p.crop);let d=await p.data.data();u=Array.from(d),Object.keys(p).forEach(h=>J(p[h]))}e4[n]=u,zN=s,LN=le(),l(u)})}var Vs,n4=[],UN=0,GN=0,HN=Number.MAX_SAFE_INTEGER;async function jN(e){return he.initial&&(Vs=null),Vs?e.debug&&ae("cached model:",Vs.modelUrl):Vs=await je(e.face.insightface.modelPath),Vs}async function s4(e,t,n,s){var o,i;if(!(Vs!=null&&Vs.executor))return[];let r=HN<(((o=t.face.insightface)==null?void 0:o.skipFrames)||0),a=(((i=t.face.insightface)==null?void 0:i.skipTime)||0)>le()-GN;return t.skipAllowed&&a&&r&&UN===s&&n4[n]?(HN++,n4[n]):new Promise(async l=>{var c;let u=[];if(((c=t.face.insightface)==null?void 0:c.enabled)&&(Vs==null?void 0:Vs.inputs[0].shape)){let p={};p.crop=Ie.resizeBilinear(e,[Vs.inputs[0].shape[2],Vs.inputs[0].shape[1]],!1),p.data=Vs.execute(p.crop);let d=await p.data.data();u=Array.from(d),Object.keys(p).forEach(h=>J(p[h]))}n4[n]=u,UN=s,GN=le(),l(u)})}var Us,vi=0,yxe=2.3,r4=wr.leftEyeLower0,a4=wr.rightEyeLower0,Id={leftBounds:[r4[0],r4[r4.length-1]],rightBounds:[a4[0],a4[a4.length-1]]},Cd={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function YN(e){var t,n;return he.initial&&(Us=null),Us?e.debug&&ae("cached model:",Us.modelUrl):Us=await je((t=e.face.iris)==null?void 0:t.modelPath),vi=(Us==null?void 0:Us.executor)&&((n=Us.inputs)==null?void 0:n[0].shape)?Us.inputs[0].shape[2]:0,vi===-1&&(vi=64),Us}function o1(e,t,n,s){for(let r=0;r{let t=e[Id.leftBounds[0]][2],n=e[Id.rightBounds[0]][2];return t-n},XN=(e,t,n,s,r,a=!1)=>{let o=J2(Y2(lN([e[n],e[s]]),yxe)),i=vd(o),l=Ie.cropAndResize(t,[[o.startPoint[1]/r,o.startPoint[0]/r,o.endPoint[1]/r,o.endPoint[0]/r]],[0],[vi,vi]);if(a&&he.kernels.includes("flipleftright")){let u=Ie.flipLeftRight(l);J(l),l=u}return{box:o,boxSize:i,crop:l}},KN=(e,t,n,s=!1)=>{let r=[];for(let a=0;a{let s=e[wr[`${n}EyeUpper0`][Cd.upperCenter]][2],r=e[wr[`${n}EyeLower0`][Cd.lowerCenter]][2],a=(s+r)/2;return t.map((o,i)=>{let l=a;return i===2?l=s:i===4&&(l=r),[o[0],o[1],l]})};async function JN(e,t,n){if(!(Us!=null&&Us.executor))return e;let{box:s,boxSize:r,crop:a}=XN(e,t,Id.leftBounds[0],Id.leftBounds[1],n,!0),{box:o,boxSize:i,crop:l}=XN(e,t,Id.rightBounds[0],Id.rightBounds[1],n,!0),u=It([a,l]);J(a),J(l);let c=Us.execute(u);J(u);let p=await c.data();J(c);let d=p.slice(0,Cd.numCoordinates*3),{rawCoords:h,iris:f}=KN(d,s,r,!0),m=p.slice(Cd.numCoordinates*3),{rawCoords:g,iris:y}=KN(m,o,i,!1),x=Axe(e);Math.abs(x)<30?(o1(e,h,"left",null),o1(e,g,"right",null)):x<1?o1(e,h,"left",["EyeUpper0","EyeLower0"]):o1(e,g,"right",["EyeUpper0","EyeLower0"]);let A=ZN(e,f,"left"),b=ZN(e,y,"right");return e.concat(A).concat(b)}var xxe=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],bxe=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vxe=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],wxe=[[474,475],[475,476],[476,477],[477,474]],kxe=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Sxe=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Ixe=[[469,470],[470,471],[471,472],[472,469]],Cxe=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function wi(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var Txe={lips:wi(xxe),leftEye:wi(bxe),leftEyebrow:wi(vxe),leftIris:wi(wxe),rightEye:wi(kxe),rightEyebrow:wi(Sxe),rightIris:wi(Ixe),faceOval:wi(Cxe)},Nxe=Object.entries(Txe).map(([e,t])=>t.map(n=>[n,e])).flat(),TSe=new Map(Nxe),tf=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],bu=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],vu=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function tE(e,t){var a,o,i,l,u,c,p,d,h,f;let n={lips:await((o=(a=t.filter(m=>m.size===160))==null?void 0:a[0])==null?void 0:o.data()),irisL:await((l=(i=t.filter(m=>m.size===10))==null?void 0:i[0])==null?void 0:l.data()),eyeL:await((c=(u=t.filter(m=>m.size===142))==null?void 0:u[0])==null?void 0:c.data()),irisR:await((d=(p=t.filter(m=>m.size===10))==null?void 0:p[1])==null?void 0:d.data()),eyeR:await((f=(h=t.filter(m=>m.size===142))==null?void 0:h[1])==null?void 0:f.data())};for(let m of Object.values(n))if(!m)return e;let s=bu.reduce((m,g)=>m+=e[g][2],0)/bu.length;for(let m=0;mm+=e[g][2],0)/vu.length;for(let m=0;mle()-la.timestamp,s=la.skipped<(((u=t.face.detector)==null?void 0:u.skipFrames)||0);!t.skipAllowed||!n||!s||la.boxes.length===0?(la.boxes=await yN(e,t),la.timestamp=le(),la.skipped=0):la.skipped++;let r=[],a=[],o=0,i=nf;for(let x=0;xD.shape[D.shape.length-1]===1).data();if(S.faceScore=Math.round(100*_[0])/100,S.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(A.confidence=S.faceScore,t.face.mesh.keepInvalid){S.box=K2(A,e),S.boxRaw=Z2(A,e),S.score=S.boxScore,S.mesh=A.landmarks.map(D=>[(A.startPoint[0]+A.endPoint[0])/2+(A.endPoint[0]+A.startPoint[0])*D[0]/wd(),(A.startPoint[1]+A.endPoint[1])/2+(A.endPoint[1]+A.startPoint[1])*D[1]/wd()]),S.meshRaw=S.mesh.map(D=>[D[0]/(e.shape[2]||1),D[1]/(e.shape[1]||1),(D[2]||0)/i]);for(let D of Object.keys(gu))S.annotations[D]=[S.mesh[gu[D]]]}}else{let D=k.find(M=>M.shape[M.shape.length-1]===1404),R=V(D,[-1,3]),F=await R.array();J(R),(m=t.face.attention)!=null&&m.enabled?F=await tE(F,k):(g=t.face.iris)!=null&&g.enabled&&(F=await JN(F,S.tensor,nf)),S.mesh=dN(F,A,b,w,nf),S.meshRaw=S.mesh.map(M=>[M[0]/(e.shape[2]||0),M[1]/(e.shape[1]||0),(M[2]||0)/i]);for(let M of Object.keys(wr))S.annotations[M]=wr[M].map(L=>S.mesh[L]);S.score=S.faceScore;let C={...hN(S.mesh,A),confidence:A.confidence,landmarks:A.landmarks};S.box=K2(C,e),S.boxRaw=Z2(C,e),a.push(C)}J(k)}else{S.box=K2(A,e),S.boxRaw=Z2(A,e),S.score=S.boxScore,S.mesh=A.landmarks.map(k=>[(A.startPoint[0]+A.endPoint[0])/2+(A.endPoint[0]+A.startPoint[0])*k[0]/wd(),(A.startPoint[1]+A.endPoint[1])/2+(A.endPoint[1]+A.startPoint[1])*k[1]/wd()]),S.meshRaw=S.mesh.map(k=>[k[0]/(e.shape[2]||0),k[1]/(e.shape[1]||0),(k[2]||0)/i]);for(let k of Object.keys(gu))S.annotations[k]=[S.mesh[gu[k]]]}S.score>(((y=t.face.detector)==null?void 0:y.minConfidence)||1)?r.push(S):J(S.tensor)}return la.boxes=a,r}async function sE(e){var t,n,s,r,a,o;return he.initial&&(Mt=null),((t=e.face.attention)==null?void 0:t.enabled)&&(Mt==null?void 0:Mt.signature)&&Object.keys(((n=Mt==null?void 0:Mt.signature)==null?void 0:n.outputs)||{}).length<6&&(Mt=null),Mt?e.debug&&ae("cached model:",Mt.modelUrl):(s=e.face.attention)!=null&&s.enabled?Mt=await je(e.face.attention.modelPath):Mt=await je((r=e.face.mesh)==null?void 0:r.modelPath),nf=Mt.executor&&((a=Mt==null?void 0:Mt.inputs)==null?void 0:a[0].shape)?(o=Mt==null?void 0:Mt.inputs)==null?void 0:o[0].shape[2]:256,Mt}var rE=yu,aE=Jh;var qn,ki=[],oE=0,iE=0,i4=Number.MAX_SAFE_INTEGER;async function lE(e){var t;return he.initial&&(qn=null),qn?e.debug&&ae("cached model:",qn.modelUrl):qn=await je((t=e.face.description)==null?void 0:t.modelPath),qn}function l4(e){let t=e.image||e.tensor||e;if(!(qn!=null&&qn.inputs[0].shape))return t;let n=Ie.resizeBilinear(t,[qn.inputs[0].shape[2],qn.inputs[0].shape[1]],!1),s=z(n,at.tf255);return J(n),s}async function u4(e,t,n,s){var i,l,u,c;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(qn!=null&&qn.executor))return r;let a=i4<(((i=t.face.description)==null?void 0:i.skipFrames)||0),o=(((l=t.face.description)==null?void 0:l.skipTime)||0)>le()-oE;return t.skipAllowed&&a&&o&&iE===s&&((u=ki==null?void 0:ki[n])==null?void 0:u.age)>0&&((c=ki==null?void 0:ki[n])==null?void 0:c.genderScore)>0?(i4++,ki[n]):(i4=0,new Promise(async p=>{var d;if((d=t.face.description)!=null&&d.enabled){let h=l4(e),f=qn==null?void 0:qn.execute(h);oE=le(),J(h);let g=await f.find(E=>E.shape[1]===1).data(),y=Math.trunc(200*Math.abs(g[0]-.5))/100;y>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,y));let x=$s(f.find(E=>E.shape[1]===100),1),A=(await x.data())[0];J(x);let w=await f.find(E=>E.shape[1]===100).data();r.age=Math.round(w[A-1]>w[A+1]?10*A-100*w[A-1]:10*A+100*w[A+1])/10,(Number.isNaN(g[0])||Number.isNaN(w[0]))&&ae("faceres error:",{model:qn,result:f});let S=f.find(E=>E.shape[1]===1024),k=S?await S.data():[];r.descriptor=Array.from(k),f.forEach(E=>J(E))}ki[n]=r,iE=s,p(r)}))}function i1(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function sf(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function dE(e,t,n){let s=t.shape[1],r=t.shape[2],a=[[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r]];return Ie.cropAndResize(t,a,[0],n)}function pE(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(a=>[a[0]*t[0],a[1]*t[1]]);return{startPoint:n,endPoint:s,palmLandmarks:r,confidence:e.confidence}}function l1(e,t=1.5){let n=sf(e),s=i1(e),r=[t*s[0]/2,t*s[1]/2],a=[n[0]-r[0],n[1]-r[1]],o=[n[0]+r[0],n[1]+r[1]];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function u1(e){let t=sf(e),n=i1(e),r=Math.max(...n)/2,a=[t[0]-r,t[1]-r],o=[t[0]+r,t[1]+r];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function Rxe(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function hE(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Rxe(n)}var uE=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Si(e,t){let n=0;for(let s=0;s[o.x,o.y]),this.anchorsTensor=fr(this.anchors),this.inputSize=((a=(r=(s=(n=this==null?void 0:this.model)==null?void 0:n.inputs)==null?void 0:s[0])==null?void 0:r.shape)==null?void 0:a[2])||0,this.inputSizeTensor=Ft([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Ft([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let n={};n.boxOffsets=ze(t,[0,0],[-1,2]),n.boxSizes=ze(t,[0,2],[-1,2]),n.div=fe(n.boxOffsets,this.inputSizeTensor),n.boxCenterPoints=ue(n.div,this.anchorsTensor),n.halfBoxSizes=fe(n.boxSizes,this.doubleInputSizeTensor),n.sub=me(n.boxCenterPoints,n.halfBoxSizes),n.startPoints=z(n.sub,this.inputSizeTensor),n.add=ue(n.boxCenterPoints,n.halfBoxSizes),n.endPoints=z(n.add,this.inputSizeTensor);let s=ru([n.startPoints,n.endPoints],1);return Object.keys(n).forEach(r=>J(n[r])),s}normalizeLandmarks(t,n){let s={};s.reshape=V(t,[-1,7,2]),s.div=fe(s.reshape,this.inputSizeTensor),s.landmarks=ue(s.div,this.anchors[n]?this.anchors[n]:0);let r=z(s.landmarks,this.inputSizeTensor);return Object.keys(s).forEach(a=>J(s[a])),r}async predict(t,n){var i;let s={};s.resize=Ie.resizeBilinear(t,[this.inputSize,this.inputSize]),s.div=fe(s.resize,at.tf127),s.image=me(s.div,at.tf1),s.batched=this.model.execute(s.image),s.predictions=rt(s.batched),s.slice=ze(s.predictions,[0,0],[-1,1]),s.sigmoid=$n(s.slice),s.scores=rt(s.sigmoid);let r=await s.scores.data();s.boxes=ze(s.predictions,[0,1],[-1,4]),s.norm=this.normalizeBoxes(s.boxes),s.nms=await Ie.nonMaxSuppressionAsync(s.norm,s.scores,3*(((i=n.hand)==null?void 0:i.maxDetected)||1),n.hand.iouThreshold,n.hand.minConfidence);let a=await s.nms.array(),o=[];for(let l of a){let u={};u.box=ze(s.norm,[l,0],[1,-1]),u.slice=ze(s.predictions,[l,5],[1,14]),u.norm=this.normalizeLandmarks(u.slice,l),u.palmLandmarks=V(u.norm,[-1,2]);let c=await u.box.data(),p=c.slice(0,2),d=c.slice(2,4),h=await u.palmLandmarks.array(),f={startPoint:p,endPoint:d,palmLandmarks:h,confidence:r[l]},m=pE(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);o.push(m),Object.keys(u).forEach(g=>J(u[g]))}return Object.keys(s).forEach(l=>J(s[l])),o}};var Fxe=5,yE=1.65,AE=[0,5,9,13,17,1,2],Pxe=0,Oxe=2,xE=0,d1=class{constructor(t,n){ge(this,"handDetector");ge(this,"handPoseModel");ge(this,"inputSize");ge(this,"storedBoxes");ge(this,"skipped");ge(this,"detectedHands");var s,r,a;this.handDetector=t,this.handPoseModel=n,this.inputSize=((a=(r=(s=this.handPoseModel)==null?void 0:s.inputs)==null?void 0:r[0].shape)==null?void 0:a[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(o=>o[0]),s=t.map(o=>o[1]),r=[Math.min(...n),Math.min(...s)],a=[Math.max(...n),Math.max(...s)];return{startPoint:r,endPoint:a}}getBoxForPalmLandmarks(t,n){let s=t.map(a=>p4([...a,1],n)),r=this.calculateLandmarksBoundingBox(s);return l1(u1(r),Fxe)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),s=l1(u1(n),yE);s.palmLandmarks=[];for(let r=0;r[o[0]*(h[0]-this.inputSize/2),o[1]*(h[1]-this.inputSize/2),o[2]*h[2]]),l=d4(s,[0,0]),u=i.map(h=>[...p4(h,l),h[2]]),c=fE(r),p=[...sf(n),1],d=[Si(p,c[0]),Si(p,c[1])];return u.map(h=>[Math.trunc(h[0]+d[0]),Math.trunc(h[1]+d[1]),Math.trunc(h[2])])}async estimateHands(t,n){let s=!1,r,a=(n.hand.skipTime||0)>le()-xE,o=this.skipped<(n.hand.skipFrames||0);n.skipAllowed&&a&&o&&(r=await this.handDetector.predict(t,n),this.skipped=0),n.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(s=!0));let i=[];for(let l=0;l=n.hand.minConfidence/4){let w=V(A,[-1,3]),S=await w.array();J(A),J(w);let k=this.transformRawCoords(S,m,c,f),E=this.getBoxForHandLandmarks(k);this.storedBoxes[l]={...E,confidence:b};let _={landmarks:k,confidence:b,boxConfidence:u.confidence,fingerConfidence:b,box:{topLeft:E.startPoint,bottomRight:E.endPoint}};i.push(_)}else this.storedBoxes[l]=null;J(A)}else{let c=l1(u1(u),yE),p={confidence:u.confidence,boxConfidence:u.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};i.push(p)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>n.hand.maxDetected&&(i.length=n.hand.maxDetected),i}};var hs={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>hs.nameMapping[e],getPoints:e=>hs.pointsMapping[e]},Ci={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ci.nameMapping[e]},qt={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>qt.nameMapping[e]},Ii=class{constructor(t){ge(this,"name");ge(this,"curls");ge(this,"directions");ge(this,"weights");ge(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,n,s){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([n,s])}direction(t,n,s){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([n,s])}weight(t,n){this.weights[t]=n;let s=this.weights.reduce((r,a)=>r+a,0);this.weightsRelative=this.weights.map(r=>r*5/s)}matchAgainst(t,n){let s=0;for(let r in t){let a=t[r],o=this.curls[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}for(let r in n){let a=n[r],o=this.directions[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}return s/10}};var{thumb:Gr,index:Fa,middle:Pa,ring:wu,pinky:ku}=hs,{none:Hr,half:zxe,full:jr}=Ci,{verticalUp:Td,verticalDown:VSe,horizontalLeft:h4,horizontalRight:Lxe,diagonalUpRight:Bxe,diagonalUpLeft:Nd,diagonalDownRight:USe,diagonalDownLeft:GSe}=qt,Ti=new Ii("thumbs up");Ti.curl(Gr,Hr,1);Ti.direction(Gr,Td,1);Ti.direction(Gr,Nd,.25);Ti.direction(Gr,Bxe,.25);for(let e of[hs.index,hs.middle,hs.ring,hs.pinky])Ti.curl(e,jr,1),Ti.direction(e,h4,1),Ti.direction(e,Lxe,1);var pn=new Ii("victory");pn.curl(Gr,zxe,.5);pn.curl(Gr,Hr,.5);pn.direction(Gr,Td,1);pn.direction(Gr,Nd,1);pn.curl(Fa,Hr,1);pn.direction(Fa,Td,.75);pn.direction(Fa,Nd,1);pn.curl(Pa,Hr,1);pn.direction(Pa,Td,1);pn.direction(Pa,Nd,.75);pn.curl(wu,jr,1);pn.direction(wu,Td,.2);pn.direction(wu,Nd,1);pn.direction(wu,h4,.2);pn.curl(ku,jr,1);pn.direction(ku,Td,.2);pn.direction(ku,Nd,1);pn.direction(ku,h4,.2);pn.weight(Fa,2);pn.weight(Pa,2);var Ni=new Ii("point");Ni.curl(Gr,jr,1);Ni.curl(Fa,Hr,.5);Ni.curl(Pa,jr,.5);Ni.curl(wu,jr,.5);Ni.curl(ku,jr,.5);Ni.weight(Fa,2);Ni.weight(Pa,2);var Ei=new Ii("middle finger");Ei.curl(Gr,Hr,1);Ei.curl(Fa,jr,.5);Ei.curl(Pa,jr,.5);Ei.curl(wu,jr,.5);Ei.curl(ku,jr,.5);Ei.weight(Fa,2);Ei.weight(Pa,2);var Ed=new Ii("open palm");Ed.curl(Gr,Hr,.75);Ed.curl(Fa,Hr,.75);Ed.curl(Pa,Hr,.75);Ed.curl(wu,Hr,.75);Ed.curl(ku,Hr,.75);var bE=[Ti,pn,Ni,Ei,Ed];var Wxe=.7,Su={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function vE(e,t,n,s){let r=(t-s)/(e-n),a=Math.atan(r)*180/Math.PI;return a<=0?a=-a:a>0&&(a=180-a),a}function kE(e,t){if(!e||!t)return[0,0];let n=vE(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let s=vE(e[1],e[2],t[1],t[2]);return[n,s]}function wE(e,t=1){let n=0,s=0,r=0;return e>=75&&e<=105?n=1*t:e>=25&&e<=155?s=1*t:r=1*t,[n,s,r]}function Vxe(e,t,n){let s=e[0]-t[0],r=e[0]-n[0],a=t[0]-n[0],o=e[1]-t[1],i=e[1]-n[1],l=t[1]-n[1],u=e[2]-t[2],c=e[2]-n[2],p=t[2]-n[2],d=Math.sqrt(s*s+o*o+u*u),h=Math.sqrt(r*r+i*i+c*c),f=Math.sqrt(a*a+l*l+p*p),m=(f*f+d*d-h*h)/(2*f*d);m>1?m=1:m<-1&&(m=-1);let g=Math.acos(m);g=57.2958*g%180;let y;return g>Su.NO_CURL_START_LIMIT?y=Ci.none:g>Su.HALF_CURL_START_LIMIT?y=Ci.half:y=Ci.full,y}function SE(e,t,n,s){let r;return s===Math.abs(e)?e>0?r=qt.horizontalLeft:r=qt.horizontalRight:s===Math.abs(t)?t>0?r=qt.horizontalLeft:r=qt.horizontalRight:n>0?r=qt.horizontalLeft:r=qt.horizontalRight,r}function IE(e,t,n,s){let r;return s===Math.abs(e)?e<0?r=qt.verticalDown:r=qt.verticalUp:s===Math.abs(t)?t<0?r=qt.verticalDown:r=qt.verticalUp:n<0?r=qt.verticalDown:r=qt.verticalUp,r}function Uxe(e,t,n,s,r,a,o,i){let l,u=IE(e,t,n,s),c=SE(r,a,o,i);return u===qt.verticalUp?c===qt.horizontalLeft?l=qt.diagonalUpLeft:l=qt.diagonalUpRight:c===qt.horizontalLeft?l=qt.diagonalDownLeft:l=qt.diagonalDownRight,l}function Gxe(e,t,n,s){let r=e[0]-t[0],a=e[0]-n[0],o=t[0]-n[0],i=e[1]-t[1],l=e[1]-n[1],u=t[1]-n[1],c=Math.max(Math.abs(r),Math.abs(a),Math.abs(o)),p=Math.max(Math.abs(i),Math.abs(l),Math.abs(u)),d=0,h=0,f=0,m=p/(c+1e-5);m>1.5?d+=Su.DISTANCE_VOTE_POWER:m>.66?h+=Su.DISTANCE_VOTE_POWER:f+=Su.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+i*i),y=Math.sqrt(a*a+l*l),x=Math.sqrt(o*o+u*u),A=Math.max(g,y,x),b=e[0],w=e[1],S=n[0],k=n[1];A===g?(S=n[0],k=n[1]):A===x&&(b=t[0],w=t[1]);let D=kE([b,w],[S,k]),R=wE(D,Su.TOTAL_ANGLE_VOTE_POWER);d+=R[0],h+=R[1],f+=R[2];for(let C of s){let M=wE(C,Su.SINGLE_ANGLE_VOTE_POWER);d+=M[0],h+=M[1],f+=M[2]}let F;return d===Math.max(d,h,f)?F=IE(l,i,u,p):f===Math.max(h,f)?F=SE(a,r,o,c):F=Uxe(l,i,u,p,a,r,o,c),F}function CE(e){let t=[],n=[],s=[],r=[];if(!e)return{curls:s,directions:r};for(let a of hs.all){let o=hs.getPoints(a),i=[],l=[];for(let u of o){let c=e[u[0]],p=e[u[1]],d=kE(c,p),h=d[0],f=d[1];i.push(h),l.push(f)}t.push(i),n.push(l)}for(let a of hs.all){let o=a===hs.thumb?1:0,i=hs.getPoints(a),l=e[i[o][0]],u=e[i[o+1][1]],c=e[i[3][1]],p=Vxe(l,u,c),d=Gxe(l,u,c,t[a].slice(o));s[a]=p,r[a]=d}return{curls:s,directions:r}}function p1(e){if(!e||e.length===0)return null;let t=CE(e),n={};for(let s of hs.all)n[hs.getName(s)]={curl:Ci.getName(t.curls[s]),direction:qt.getName(t.directions[s])};return n}function TE(e){let t=[];if(!e||e.length===0)return t;let n=CE(e);for(let s of bE){let r=s.matchAgainst(n.curls,n.directions);r>=Wxe&&t.push({name:s.name,confidence:r})}return t}var NE={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Iu,Cu,EE;async function m4(e,t){let n=await EE.estimateHands(e,t);if(!n)return[];let s=[];for(let r=0;rn[r].landmarks[p]);let o=n[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(o&&o.length>0){for(let c of o)c[0]i[2]&&(i[2]=c[0]),c[1]>i[3]&&(i[3]=c[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=n[r].box?[Math.trunc(Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.max(0,n[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,n[r].box.bottomRight[0])-Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,n[r].box.bottomRight[1])-Math.max(0,n[r].box.topLeft[1]))]:[0,0,0,0],l=[n[r].box.topLeft[0]/(e.shape[2]||0),n[r].box.topLeft[1]/(e.shape[1]||0),(n[r].box.bottomRight[0]-n[r].box.topLeft[0])/(e.shape[2]||0),(n[r].box.bottomRight[1]-n[r].box.topLeft[1])/(e.shape[1]||0)];let u=p1(o);s.push({id:r,score:Math.round(100*n[r].confidence)/100,boxScore:Math.round(100*n[r].boxConfidence)/100,fingerScore:Math.round(100*n[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:l,keypoints:o,annotations:a,landmarks:u})}return s}async function g4(e){var n,s;he.initial&&(Iu=null,Cu=null),!Iu||!Cu?[Iu,Cu]=await Promise.all([e.hand.enabled?je((n=e.hand.detector)==null?void 0:n.modelPath):null,e.hand.landmarks?je((s=e.hand.skeleton)==null?void 0:s.modelPath):null]):(e.debug&&ae("cached model:",Iu.modelUrl),e.debug&&ae("cached model:",Cu.modelUrl));let t=Iu?new c1(Iu):void 0;return t&&Cu&&(EE=new d1(t,Cu)),[Iu,Cu]}var _t={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function Hxe(){let e=_t.gl;!e||(_t.extensions=e.getSupportedExtensions())}function _E(e){var t;if(e.config.backend==="humangl"&&(_t.name in Yt().registry&&!((t=_t==null?void 0:_t.gl)!=null&&t.getParameter(_t.gl.VERSION))&&(ae("humangl error: backend invalid context"),h1(e)),!Xy(_t.name))){try{_t.canvas=ds(100,100)}catch(s){ae("humangl error: cannot create canvas:",s);return}try{if(_t.gl=_t.canvas.getContext("webgl2",_t.webGLattr),!_t.gl){ae("humangl error: cannot get webgl context");return}if(!_t.gl.getParameter(_t.gl.VERSION).includes("2.0")){ae("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}_t.canvas&&(_t.canvas.addEventListener("webglcontextlost",r=>{throw ae("humangl error:",r.type),ae("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),_t.canvas.addEventListener("webglcontextrestored",r=>{ae("humangl error: context restored:",r)}),_t.canvas.addEventListener("webglcontextcreationerror",r=>{ae("humangl error: context create:",r)}))}catch(s){ae("humangl error: cannot get webgl context:",s);return}try{R2(2,_t.gl)}catch(s){ae("humangl error: cannot set webgl context:",s);return}try{let s=new tc(_t.gl);nu(_t.name,()=>new pd(s),_t.priority)}catch(s){ae("humangl error: cannot register webgl backend:",s);return}try{ta("webgl").forEach(r=>{let a={...r,backendName:_t.name};tr(a)})}catch(s){ae("humangl error: cannot update webgl backend registration:",s);return}try{H().flagRegistry.WEBGL_VERSION&&H().set("WEBGL_VERSION",2)}catch(s){ae("humangl error: cannot set WebGL backend flags:",s);return}Hxe();let n=Ls().getGPGPUContext?Ls().getGPGPUContext().gl:null;n?e.config.debug&&ae("humangl backend registered:",{webgl:n.getParameter(n.VERSION),renderer:n.getParameter(n.RENDERER)}):ae("humangl error: no current gl context:",n,_t.gl)}}function jxe(e){let t=[];if(!he.kernels.includes("mod")){let n={kernelName:"Mod",backendName:cn(),kernelFunc:s=>Z(()=>me(s.inputs.a,z(fe(s.inputs.a,s.inputs.b),s.inputs.b)))};tr(n),he.kernels.push("mod"),t.push("mod")}if(!he.kernels.includes("floormod")){let n={kernelName:"FloorMod",backendName:cn(),kernelFunc:s=>Z(()=>ue(z(Hc(s.inputs.a/s.inputs.b),s.inputs.b),ou(s.inputs.a,s.inputs.b)))};tr(n),he.kernels.push("floormod"),t.push("floormod")}if(!he.kernels.includes("rotatewithoffset")&&e.softwareKernels){let n={kernelName:"RotateWithOffset",backendName:cn(),kernelFunc:s=>Z(()=>{let r=cn();dh("cpu");let a=Ie.rotateWithOffset(s.inputs.image,s.attrs.radians,s.attrs.fillValue,s.attrs.center);return dh(r),a})};tr(n),he.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&ae("registered kernels:",t)}var $E={};async function rf(e,t=!1){if(e.state="backend",t||he.initial||e.config.backend&&e.config.backend.length>0&&cn()!==e.config.backend){let n=le();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&ae("running inside web worker"),he.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&ae("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),he.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&ae(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),he.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")ae("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&ae("enumerated webgpu adapter:",r),!r)ae("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let a="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;ae("webgpu adapter info:",a)}}let s=Object.keys(Yt().registryFactory);if(e.config.backend==="humangl"&&!s.includes("humangl")&&(_E(e),s=Object.keys(Yt().registryFactory)),e.config.debug&&ae("available backends:",s),s.includes(e.config.backend)||(ae(`error: backend ${e.config.backend} not found in registry`),e.config.backend=he.node?"tensorflow":"webgl",e.config.debug&&ae(`override: setting backend ${e.config.backend}`)),e.config.debug&&ae("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(H().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&H().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&ae("wasm path:",e.config.wasmPath),typeof M2!="undefined")M2(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,a=!1;try{r=await H().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),a=await H().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&ae(`wasm execution: ${a?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!a&&ae("warning: wasm simd support is not enabled")}catch(o){ae("wasm detection failed")}}try{await dh(e.config.backend),await ph()}catch(r){return ae("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&($E=JSON.parse(JSON.stringify(H().flags)))}if((cn()==="humangl"||cn()==="webgl")&&(H().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&H().set("WEBGL_USE_SHAPES_UNIFORMS",!0),H().flagRegistry.WEBGL_EXP_CONV&&H().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(ae("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),H().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),cn(),e.config.debug){let s=H().flags,r={};for(let a of Object.keys(s))$E[a]!==s[a]&&(r[a]=s[a]);e.config.debug&&Object.keys(r).length>0&&ae("backend:",cn(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&ae("flags:",e.config.flags);for(let[s,r]of Object.entries(e.config.flags))H().set(s,r)}jy(),jT(),e.performance.initBackend=Math.trunc(le()-n),e.config.backend=cn(),await he.updateBackend(),jxe(e.config),he.initial=!1}return!0}function f1(e,t){for(let n of e){let s={kernelName:n,backendName:t.backend,kernelFunc:()=>{t.debug&&ae("kernelFunc",n,t.backend)}};tr(s)}he.kernels=ta(cn()).map(n=>n.kernelName.toLowerCase())}var tn=[null,null],qxe=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ri=[[0,0],[0,0]],Xxe=["hand","fist","pinch","point","face","tip","pinchtip"],PE=4,OE=1.6,Kxe=512,Zxe=1.4,m1=Number.MAX_SAFE_INTEGER,y4=0,Oa=[0,0],en={boxes:[],hands:[]},ME={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function zE(e){var t;if(he.initial&&(tn[0]=null),tn[0])e.debug&&ae("cached model:",tn[0].modelUrl);else{f1(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),tn[0]=await je((t=e.hand.detector)==null?void 0:t.modelPath);let n=tn[0].executor?Object.values(tn[0].modelSignature.inputs):void 0;Ri[0][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,Ri[0][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return tn[0]}async function LE(e){var t;if(he.initial&&(tn[1]=null),tn[1])e.debug&&ae("cached model:",tn[1].modelUrl);else{tn[1]=await je((t=e.hand.skeleton)==null?void 0:t.modelPath);let n=tn[1].executor?Object.values(tn[1].modelSignature.inputs):void 0;Ri[1][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,Ri[1][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return tn[1]}async function Yxe(e,t){let n=[];if(!e||!tn[0])return n;let s={},r=(e.shape[2]||1)/(e.shape[1]||1),a=Math.min(Math.round((e.shape[1]||0)/8)*8,Kxe),o=Math.round(a*r/8)*8;s.resize=Ie.resizeBilinear(e,[a,o]),s.cast=ye(s.resize,"int32"),[s.rawScores,s.rawBoxes]=await tn[0].executeAsync(s.cast,qxe),s.boxes=rt(s.rawBoxes,[0,2]),s.scores=rt(s.rawScores,[0]);let i=On(s.scores,1);J(i[PE]),i.splice(PE,1),s.filtered=ln(i,1),J(i),s.max=yn(s.filtered,1),s.argmax=$s(s.filtered,1);let l=0;s.nms=await Ie.nonMaxSuppressionAsync(s.boxes,s.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let u=await s.nms.data(),c=await s.max.data(),p=await s.argmax.data();for(let d of Array.from(u)){let h=ze(s.boxes,d,1),f=await h.data();J(h);let m=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=t1(m,Zxe),y=[Math.trunc(m[0]*Oa[0]),Math.trunc(m[1]*Oa[1]),Math.trunc(m[2]*Oa[0]),Math.trunc(m[3]*Oa[1])],x=c[d],A=Xxe[p[d]],b={id:l++,score:x,box:y,boxRaw:g,label:A};n.push(b)}return Object.keys(s).forEach(d=>J(s[d])),n.sort((d,h)=>h.score-d.score),n.length>(t.hand.maxDetected||1)&&(n.length=t.hand.maxDetected||1),n}async function A4(e,t,n){let s={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&tn[1]&&n.hand.landmarks&&t.score>(n.hand.minConfidence||0)){let r={},a=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=Ie.cropAndResize(e,[a],[0],[Ri[1][0],Ri[1][1]],"bilinear"),r.div=fe(r.crop,at.tf255),[r.score,r.keypoints]=tn[1].execute(r.div,["Identity_1","Identity"]);let o=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(o))))/100;if(i>=(n.hand.minConfidence||0)){s.fingerScore=i,r.reshaped=V(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(p=>[p[0]/Ri[1][1],p[1]/Ri[1][0],p[2]||0]).map(p=>[p[0]*t.boxRaw[2],p[1]*t.boxRaw[3],p[2]||0]);s.keypoints=c.map(p=>[Oa[0]*(p[0]+t.boxRaw[0]),Oa[1]*(p[1]+t.boxRaw[1]),p[2]||0]),s.landmarks=p1(s.keypoints);for(let p of Object.keys(ME))s.annotations[p]=ME[p].map(d=>s.landmarks&&s.keypoints[d]?s.keypoints[d]:null)}Object.keys(r).forEach(l=>J(r[l]))}return s}async function x4(e,t){var r,a;if(!((r=tn[0])!=null&&r.executor)||!((a=tn[1])!=null&&a.executor)||!tn[0].inputs[0].shape||!tn[1].inputs[0].shape)return[];Oa=[e.shape[2]||0,e.shape[1]||0],m1++;let n=(t.hand.skipTime||0)>le()-y4,s=m1<(t.hand.skipFrames||0);return t.skipAllowed&&n&&s?en.hands:new Promise(async o=>{let i=3*(t.hand.skipTime||0)>le()-y4,l=m1<3*(t.hand.skipFrames||0);t.skipAllowed&&en.hands.length===t.hand.maxDetected?en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))):t.skipAllowed&&i&&l&&en.hands.length>0?en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))):(en.boxes=await Yxe(e,t),y4=le(),en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))),m1=0);let u=[...en.boxes];if(en.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&p.box[3]/(e.shape[1]||1)>.05&&en.hands[c].fingerScore&&en.hands[c].fingerScore>(t.hand.minConfidence||0)){let d=t1(p.box,OE),h=t1(p.boxRaw,OE);en.boxes.push({...u[c],box:d,boxRaw:h})}}for(let c=0;cle()-VE,a=b4<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&a&&WE===s&&g1[n]?(b4++,g1[n]):(b4=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[_n!=null&&_n.inputs[0].shape?_n.inputs[0].shape[2]:0,_n!=null&&_n.inputs[0].shape?_n.inputs[0].shape[1]:0],!1),c=_n==null?void 0:_n.execute(u),p=(await c.data())[0];g1[n]=Math.round(100*p)/100,WE=s,VE=le(),J([u,c]),l(g1[n])}))}var af={};fa(af,{connected:()=>A1,horizontal:()=>w4,kpt:()=>y1,relative:()=>S4,vertical:()=>k4});var y1=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],w4=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],k4=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S4=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],A1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var HE=.005,Gs={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function I4(e){for(let t of w4){let n=e.keypoints.findIndex(r=>r.part===t[0]),s=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[0]r&&r.part===t[0]),s=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[1]u&&u.part===t[0]),r=e.keypoints.findIndex(u=>u&&u.part===t[1]),a=e.keypoints.findIndex(u=>u&&u.part===n[0]),o=e.keypoints.findIndex(u=>u&&u.part===n[1]);if(!e.keypoints[a]||!e.keypoints[o])continue;let i=e.keypoints[s]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[s].position[0]),Math.abs(e.keypoints[o].position[0]-e.keypoints[s].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[o].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||l[0]>l[1]){let u=e.keypoints[s];e.keypoints[s]=e.keypoints[r],e.keypoints[r]=u}}}function jE(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],n.pad=sr(e,Gs.padding),n.resize=Ie.resizeBilinear(n.pad,[t,t]);let s=ye(n.resize,"int32");return Object.keys(n).forEach(o=>J(n[o])),s}function XE(e,t){e.keypoints=e.keypoints.filter(s=>s==null?void 0:s.position);for(let s of e.keypoints)s.position=[s.position[0]*(t[0]+Gs.padding[2][0]+Gs.padding[2][1])/t[0]-Gs.padding[2][0],s.position[1]*(t[1]+Gs.padding[1][0]+Gs.padding[1][1])/t[1]-Gs.padding[1][0]],s.positionRaw=[s.position[0]/t[0],s.position[1]/t[1]];let n=$a(e.keypoints.map(s=>s.position),t);return e.box=n.box,e.boxRaw=n.boxRaw,e}var hn,x1=0,C4=Number.MAX_SAFE_INTEGER,Tu={boxes:[],bodies:[],last:0};async function KE(e){var t;return he.initial&&(hn=null),hn?e.debug&&ae("cached model:",hn.modelUrl):(f1(["size"],e),hn=await je(e.body.modelPath)),x1=(hn==null?void 0:hn.executor)&&((t=hn==null?void 0:hn.inputs)==null?void 0:t[0].shape)?hn.inputs[0].shape[2]:0,x1<64&&(x1=256),hn}function Qxe(e,t,n){let s=e[0][0],r=[],a=0;for(let c=0;ct.body.minConfidence){let p=[s[c][1],s[c][0]];r.push({score:Math.round(100*a)/100,part:y1[c],positionRaw:p,position:[Math.round((n.shape[2]||0)*p[0]),Math.round((n.shape[1]||0)*p[1])]})}a=r.reduce((c,p)=>p.score>c?p.score:c,0);let o=[],i=$a(r.map(c=>c.position),[n.shape[2],n.shape[1]]),l={};for(let[c,p]of Object.entries(A1)){let d=[];for(let h=0;hg.part===p[h]),m=r.find(g=>g.part===p[h+1]);f&&m&&f.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&d.push([f.position,m.position])}l[c]=d}let u={id:0,score:a,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return I4(u),o.push(u),o}function ebe(e,t,n){let s=[];for(let r=0;rt.body.minConfidence){let i=[];for(let p=0;p<17;p++){let d=a[3*p+2];if(d>t.body.minConfidence){let h=[a[3*p+1],a[3*p+0]];i.push({part:y1[p],score:Math.round(100*d)/100,positionRaw:h,position:[Math.round((n.shape[2]||0)*h[0]),Math.round((n.shape[1]||0)*h[1])]})}}let l=$a(i.map(p=>p.position),[n.shape[2],n.shape[1]]),u={};for(let[p,d]of Object.entries(A1)){let h=[];for(let f=0;fy.part===d[f]),g=i.find(y=>y.part===d[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}u[p]=h}let c={id:r,score:o,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:u};I4(c),s.push(c)}}return s.sort((r,a)=>a.score-r.score),s.length>t.body.maxDetected&&(s.length=t.body.maxDetected),s}async function T4(e,t){var r;if(!(hn!=null&&hn.executor)||!((r=hn==null?void 0:hn.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Tu.boxes.length=0),C4++;let n=(t.body.skipTime||0)>le()-Tu.last,s=C4<(t.body.skipFrames||0);return t.skipAllowed&&n&&s?Tu.bodies:new Promise(async a=>{let o={};C4=0,o.input=qE(e,x1),o.res=hn==null?void 0:hn.execute(o.input),Tu.last=le();let i=await o.res.array();Tu.bodies=o.res.shape[2]===17?Qxe(i,t,e):ebe(i,t,e);for(let l of Tu.bodies)XE(l,[e.shape[2]||1,e.shape[1]||1]),jE(l.keypoints);Object.keys(o).forEach(l=>J(o[l])),a(Tu.bodies)})}var kr,b1=[],YE=0,N4=Number.MAX_SAFE_INTEGER,w1=0,v1=2.5;async function JE(e){if(!kr||he.initial){kr=await je(e.object.modelPath);let t=kr!=null&&kr.executor?Object.values(kr.modelSignature.inputs):void 0;w1=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&ae("cached model:",kr.modelUrl);return kr}async function tbe(e,t,n){let s=0,r=[],a=w1;for(let u of[1,2,4]){let c=u*13,p=rt(e.find(y=>y.shape[1]===c**2&&(y.shape[2]||0)===Sd.length)),d=await p.array(),h=rt(e.find(y=>y.shape[1]===c**2&&(y.shape[2]||0)(n.object.minConfidence||0)&&x!==61){let b=(.5+Math.trunc(y%c))/c,w=(.5+Math.trunc(y/c))/c,S=g[y].map(M=>M*(c/u/a)),[k,E]=[b-v1/u*S[0],w-v1/u*S[1]],[_,D]=[b+v1/u*S[2]-k,w+v1/u*S[3]-E],R=[k,E,_,D];R=R.map(M=>Math.max(0,Math.min(M,1)));let F=[R[0]*t[0],R[1]*t[1],R[2]*t[0],R[3]*t[1]],C={id:s++,score:Math.round(100*A)/100,class:x+1,label:Sd[x].label,box:F.map(M=>Math.trunc(M)),boxRaw:R};r.push(C)}}J([p,h,f,m])}let o=r.map(u=>[u.boxRaw[1],u.boxRaw[0],u.boxRaw[3],u.boxRaw[2]]),i=r.map(u=>u.score),l=[];if(o&&o.length>0){let u=await Ie.nonMaxSuppressionAsync(o,i,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence);l=await u.data(),J(u)}return r=r.filter((u,c)=>l.includes(c)).sort((u,c)=>c.score-u.score),r}async function E4(e,t){if(!(kr!=null&&kr.executor))return[];let n=(t.object.skipTime||0)>le()-YE,s=N4<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&b1.length>0?(N4++,b1):(N4=0,!he.kernels.includes("mod")||!he.kernels.includes("sparsetodense")?b1:new Promise(async r=>{let a=[e.shape[2]||0,e.shape[1]||0],o=Ie.resizeBilinear(e,[w1,w1],!1),i=fe(o,at.tf255),l=tt(i,[0,3,1,2]),u;t.object.enabled&&(u=kr.execute(l)),YE=le();let c=await tbe(u,a,t);b1=c,J([o,i,l,...u]),r(c)}))}var lf=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],nbe=lf.length,of=lf.reduce((e,t,n)=>(e[t]=n,e),{}),sbe=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],yIe=sbe.map(([e,t])=>[of[e],of[t]]),eR=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function tR(e){let t=e.reduce(({maxX:n,maxY:s,minX:r,minY:a},{position:{x:o,y:i}})=>({maxX:Math.max(n,o),maxY:Math.max(s,i),minX:Math.min(r,o),minY:Math.min(a,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function nR(e,[t,n],[s,r]){let a=t/s,o=n/r,i=(u,c)=>({id:c,score:u.score,boxRaw:[u.box[0]/r,u.box[1]/s,u.box[2]/r,u.box[3]/s],box:[Math.trunc(u.box[0]*o),Math.trunc(u.box[1]*a),Math.trunc(u.box[2]*o),Math.trunc(u.box[3]*a)],keypoints:u.keypoints.map(({score:p,part:d,position:h})=>({score:p,part:d,position:[Math.trunc(h.x*o),Math.trunc(h.y*a)],positionRaw:[h.x/s,h.y/s]})),annotations:{}});return e.map((u,c)=>i(u,c))}var k1=class{constructor(t,n){ge(this,"priorityQueue");ge(this,"numberOfElements");ge(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=n}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let n=2*t;if(nn?n:e}function sR(e,t,n,s){let r=n-e,a=s-t;return r*r+a*a}function $4(e,t){return{x:e.x+t.x,y:e.y+t.y}}var Hs,abe=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],S1=1,_d=16,obe=50**2;function rR(e,t,n,s,r,a,o=2){let i=y=>({y:a.get(y.y,y.x,e),x:a.get(y.y,y.x,a.shape[2]/2+e)}),l=(y,x,A)=>({y:D4(Math.round(y.y/_d),0,x-1),x:D4(Math.round(y.x/_d),0,A-1)}),[u,c]=s.shape,p=l(t.position,u,c),d=i(p),f=$4(t.position,d);for(let y=0;y[of[d],of[h]]),o=a.map(([,d])=>d),i=a.map(([d])=>d),l=t.shape[2],u=o.length,c=new Array(l),p=_4(e.part,_d,n);c[e.part.id]={score:e.score,part:lf[e.part.id],position:p};for(let d=u-1;d>=0;--d){let h=o[d],f=i[d];c[h]&&!c[f]&&(c[f]=rR(d,c[h],f,t,n,r))}for(let d=0;dt){i=!1;break}if(!i)break}return i}function ube(e,t){let[n,s,r]=t.shape,a=new k1(n*s*r,({score:o})=>o);for(let o=0;o{var o;let a=(o=r[s])==null?void 0:o.position;return a?sR(n,t,a.y,a.x)<=obe:!1})}function cbe(e,t){return t.reduce((s,{position:r,score:a},o)=>(aR(e,r,o)||(s+=a),s),0)/t.length}function dbe(e,t,n,s,r,a){let o=[],i=ube(a,t);for(;o.lengthh.score>a);let p=cbe(o,c),d=tR(c);p>a&&o.push({keypoints:c,box:d,score:Math.round(100*p)/100})}return o}async function F4(e,t){if(!(Hs!=null&&Hs.executor))return[];let n=Z(()=>{if(!Hs.inputs[0].shape)return[];let o=Ie.resizeBilinear(e,[Hs.inputs[0].shape[2],Hs.inputs[0].shape[1]]),i=me(fe(ye(o,"float32"),127.5),1),u=Hs.execute(i,abe).map(c=>rt(c,[0]));return u[1]=$n(u[1]),u}),s=await Promise.all(n.map(o=>o.buffer()));for(let o of n)J(o);let r=dbe(s[0],s[1],s[2],s[3],t.body.maxDetected,t.body.minConfidence);return Hs.inputs[0].shape?nR(r,[e.shape[1],e.shape[2]],[Hs.inputs[0].shape[2],Hs.inputs[0].shape[1]]):[]}async function oR(e){return!Hs||he.initial?Hs=await je(e.body.modelPath):e.debug&&ae("cached model:",Hs.modelUrl),Hs}var ua,P4=!1;async function O4(e){return!ua||he.initial?ua=await je(e.segmentation.modelPath):e.debug&&ae("cached model:",ua.modelUrl),ua}async function lR(e,t,n){var m,g;if(P4)return{data:[],canvas:null,alpha:null};P4=!0,ua||await O4(n);let s=await bd(e,n),r=((m=s.tensor)==null?void 0:m.shape[2])||0,a=((g=s.tensor)==null?void 0:g.shape[1])||0;if(!s.tensor)return{data:[],canvas:null,alpha:null};let o={};o.resize=Ie.resizeBilinear(s.tensor,[ua.inputs[0].shape?ua.inputs[0].shape[1]:0,ua.inputs[0].shape?ua.inputs[0].shape[2]:0],!1),J(s.tensor),o.norm=fe(o.resize,at.tf255),o.res=ua.execute(o.norm),o.squeeze=rt(o.res,0),o.squeeze.shape[2]===2?(o.softmax=iu(o.squeeze),[o.bg,o.fg]=On(o.softmax,2),o.expand=Bt(o.fg,2),o.pad=Bt(o.expand,0),o.crop=Ie.cropAndResize(o.pad,[[0,0,.5,.5]],[0],[r,a]),o.data=rt(o.crop,0)):o.data=Ie.resizeBilinear(o.squeeze,[a,r]);let i=Array.from(await o.data.data());if(he.node&&!he.Canvas&&typeof ImageData=="undefined")return n.debug&&ae("canvas support missing"),Object.keys(o).forEach(y=>J(o[y])),{data:i,canvas:null,alpha:null};let l=ds(r,a);nr&&await nr.toPixels(o.data,l);let u=l.getContext("2d");n.segmentation.blur&&n.segmentation.blur>0&&(u.filter=`blur(${n.segmentation.blur}px)`);let c=u.getImageData(0,0,r,a),p=ds(r,a),d=p.getContext("2d");s.canvas&&d.drawImage(s.canvas,0,0),d.globalCompositeOperation="darken",n.segmentation.blur&&n.segmentation.blur>0&&(d.filter=`blur(${n.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let h=d.getImageData(0,0,r,a);for(let y=0;yJ(o[y])),P4=!1,{data:i,canvas:p,alpha:l}}var uf=class{constructor(){ge(this,"ssrnetage",null);ge(this,"gear",null);ge(this,"blazeposedetect",null);ge(this,"blazepose",null);ge(this,"centernet",null);ge(this,"efficientpose",null);ge(this,"mobilefacenet",null);ge(this,"insightface",null);ge(this,"emotion",null);ge(this,"facedetect",null);ge(this,"faceiris",null);ge(this,"facemesh",null);ge(this,"faceres",null);ge(this,"ssrnetgender",null);ge(this,"handpose",null);ge(this,"handskeleton",null);ge(this,"handtrack",null);ge(this,"liveness",null);ge(this,"movenet",null);ge(this,"nanodet",null);ge(this,"posenet",null);ge(this,"segmentation",null);ge(this,"antispoof",null)}},M4=e=>{let t=0,n=0,s=0;for(let a of Object.values(qr))t+=a.sizeFromManifest,n+=a.sizeLoadedWeights,s+=a.sizeDesired;let r=s>0?n/s:0;return{numLoadedModels:Object.values(qr).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:n,totalSizeLoading:s,totalSizeEnabled:void 0,modelStats:Object.values(qr)}};function h1(e){for(let t of Object.keys(e.models))e.models[t]=null}async function z4(e){var t,n,s,r,a,o,i,l,u,c,p,d,h,f,m,g,y,x,A,b,w,S,k,E,_,D;he.initial&&h1(e),e.config.hand.enabled&&(!e.models.handpose&&((n=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:n.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await g4(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(s=e.config.hand.detector)==null?void 0:s.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await g4(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=e.config.body.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=CN(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=IN(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((o=e.config.body.modelPath)==null?void 0:o.includes("efficientpose"))&&(e.models.efficientpose=DN(e.config)),e.config.body.enabled&&!e.models.movenet&&((i=e.config.body.modelPath)==null?void 0:i.includes("movenet"))&&(e.models.movenet=KE(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=oR(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=gN(e.config)),e.config.face.enabled&&((u=e.config.face.antispoof)==null?void 0:u.enabled)&&!e.models.antispoof&&(e.models.antispoof=sN(e.config)),e.config.face.enabled&&((c=e.config.face.liveness)==null?void 0:c.enabled)&&!e.models.liveness&&(e.models.liveness=UE(e.config)),e.config.face.enabled&&((p=e.config.face.description)==null?void 0:p.enabled)&&!e.models.faceres&&(e.models.faceres=lE(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=ON(e.config)),e.config.face.enabled&&((h=e.config.face.iris)==null?void 0:h.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=YN(e.config)),e.config.face.enabled&&((m=e.config.face.mesh)==null?void 0:m.enabled)&&!e.models.facemesh&&(e.models.facemesh=sE(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=GT(e.config)),e.config.face.enabled&&((y=e.config.face.ssrnet)==null?void 0:y.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=KT(e.config)),e.config.face.enabled&&((x=e.config.face.ssrnet)==null?void 0:x.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=QT(e.config)),e.config.face.enabled&&((A=e.config.face.mobilefacenet)==null?void 0:A.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=WN(e.config)),e.config.face.enabled&&((b=e.config.face.insightface)==null?void 0:b.enabled)&&!e.models.insightface&&(e.models.insightface=jN(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((S=(w=e.config.hand.detector)==null?void 0:w.modelPath)==null?void 0:S.includes("handtrack"))&&(e.models.handtrack=zE(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((E=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:E.includes("handtrack"))&&(e.models.handskeleton=LE(e.config)),e.config.object.enabled&&!e.models.centernet&&((_=e.config.object.modelPath)==null?void 0:_.includes("centernet"))&&(e.models.centernet=EN(e.config)),e.config.object.enabled&&!e.models.nanodet&&((D=e.config.object.modelPath)==null?void 0:D.includes("nanodet"))&&(e.models.nanodet=JE(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=O4(e.config));for await(let R of Object.keys(e.models))e.models[R]&&typeof e.models[R]!="undefined"&&(e.models[R]=await e.models[R])}var ir;function Dd(e,t,n){var u;if(e&&(ir=e),!t||(ir||ae("instance not registred"),!ir.config.validateModels))return null;let s=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],a=[],o=[],i=t.modelUrl,l=t.executor;if((u=l==null?void 0:l.graph)!=null&&u.nodes)for(let c of Object.values(l.graph.nodes)){let p=c.op.toLowerCase();a.includes(p)||a.push(p)}else!l&&ir.config.debug&&ae("model not loaded",n);for(let c of a)!s.includes(c)&&!r.includes(c)&&!ir.env.kernels.includes(c)&&!ir.env.kernels.includes(c.replace("_",""))&&!ir.env.kernels.includes(c.replace("native",""))&&!ir.env.kernels.includes(c.replace("v2",""))&&o.push(c);return ir.config.debug&&o.length>0&&ae("model validation failed:",n,o),o.length>0?{name:n,missing:o,ops:a,url:i}:null}function I1(e){ir=e;let t=[];for(let n of Object.keys(ir.models)){let s=ir.models[n];if(!s)continue;let r=Dd(ir,s,n);r&&t.push(r)}return t}var ks={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},qr={};async function pbe(e,t){return ks.debug&&ae("load model fetch:",e,t),fetch(e,t)}function cR(e){ks.cacheModels=e.cacheModels,ks.verbose=e.debug,ks.modelBasePath=e.modelBasePath}async function je(e){var u,c,p;let t=wv(ks.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let n=t.includes("/")?t.split("/"):t.split("\\"),s=n[n.length-1].replace(".json",""),r="indexeddb://"+s;qr[s]={name:s,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:Sb[s],inCache:!1},ks.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let a={};try{a=ks.cacheSupported&&ks.cacheModels?await _s.listModels():{}}catch(d){ks.cacheSupported=!1}qr[s].inCache=ks.cacheSupported&&ks.cacheModels&&Object.keys(a).includes(r);let o=typeof fetch=="undefined"?{}:{fetchFunc:(d,h)=>pbe(d,h)},i=new Bh(qr[s].inCache?r:t,o),l=!1;try{i.findIOHandler(),ks.debug&&ae("model load handler:",i.handler);let d=await i.handler.load();qr[s].sizeFromManifest=((u=d==null?void 0:d.weightData)==null?void 0:u.byteLength)||0,i.loadSync(d),qr[s].sizeLoadedWeights=((p=(c=i.artifacts)==null?void 0:c.weightData)==null?void 0:p.byteLength)||0,ks.verbose&&ae("load:",{model:s,url:i.modelUrl,bytes:qr[s].sizeLoadedWeights}),l=!0}catch(d){ae("error loading model:",t,d)}if(l&&ks.cacheModels&&ks.cacheSupported&&!qr[s].inCache)try{let d=await i.save(r);ae("model saved:",r,d)}catch(d){ae("error saving model:",t,d)}return Dd(null,i,`${e||""}`),i}var L4="2.10.0";var j4={};fa(j4,{all:()=>H4,body:()=>Fd,canvas:()=>G4,face:()=>$d,gesture:()=>Md,hand:()=>Pd,object:()=>Od,options:()=>Xn,person:()=>U4});var lr=e=>{if(!e)ae("draw error: invalid canvas");else if(!e.getContext)ae("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)ae("draw error: cannot get canvas context");else return t}return null},Nu=e=>Math.round(e*180/Math.PI),Ma=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let n=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t.alpha})`};function za(e,t,n,s,r){e.fillStyle=Ma(s,r),e.beginPath(),e.arc(t,n,r.pointSize,0,2*Math.PI),e.fill()}function ca(e,t,n,s,r,a){if(e.beginPath(),e.lineWidth=a.lineWidth,a.useCurves){let o=(t+t+s)/2,i=(n+n+r)/2;e.ellipse(o,i,s/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+a.roundRect,n),e.lineTo(t+s-a.roundRect,n),e.quadraticCurveTo(t+s,n,t+s,n+a.roundRect),e.lineTo(t+s,n+r-a.roundRect),e.quadraticCurveTo(t+s,n+r,t+s-a.roundRect,n+r),e.lineTo(t+a.roundRect,n+r),e.quadraticCurveTo(t,n+r,t,n+r-a.roundRect),e.lineTo(t,n+a.roundRect),e.quadraticCurveTo(t,n,t+a.roundRect,n),e.closePath();e.stroke()}function B4(e,t,n){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let s of t)e.strokeStyle=Ma(s[2]||0,n),e.lineTo(Math.trunc(s[0]),Math.trunc(s[1]));e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function dR(e,t,n){if(!(t.length<2)){if(e.lineWidth=n.lineWidth,!n.useCurves||t.length<=2){B4(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let s=0;s0){let a=e.emotion.map(o=>`${Math.trunc(100*o.score)}% ${o.emotion}`);a.length>3&&(a.length=3),r.push(a.join(" "))}((n=e.rotation)==null?void 0:n.angle)&&((s=e.rotation)==null?void 0:s.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${Nu(e.rotation.angle.roll)}\xB0 yaw:${Nu(e.rotation.angle.yaw)}\xB0 pitch:${Nu(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${Nu(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=ft.color;for(let a=r.length-1;a>=0;a--){let o=Math.max(e.box[0],0),i=a*ft.lineHeight+e.box[1];ft.shadowColor&&ft.shadowColor!==""&&(t.fillStyle=ft.shadowColor,t.fillText(r[a],o+5,i+16)),t.fillStyle=ft.labelColor,t.fillText(r[a],o+4,i+15)}}}function gbe(e,t){var n,s,r,a;if(((n=e.annotations)==null?void 0:n.leftEyeIris)&&((s=e.annotations)==null?void 0:s.leftEyeIris[0])){t.strokeStyle=ft.useDepth?"rgba(255, 200, 255, 0.3)":ft.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,i=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],o,i,0,0,2*Math.PI),t.stroke(),ft.fillPolygons&&(t.fillStyle=ft.useDepth?"rgba(255, 255, 200, 0.3)":ft.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((a=e.annotations)==null?void 0:a.rightEyeIris[0])){t.strokeStyle=ft.useDepth?"rgba(255, 200, 255, 0.3)":ft.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,i=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],o,i,0,0,2*Math.PI),t.stroke(),ft.fillPolygons&&(t.fillStyle=ft.useDepth?"rgba(255, 255, 200, 0.3)":ft.color,t.fill())}}function ybe(e,t){var n;if(ft.drawGaze&&((n=e.rotation)==null?void 0:n.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let s=e.box[0]+e.box[2]/2-e.box[3]*Nu(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Nu(e.rotation.angle.pitch)/90,a=new Path2D(` +`;var bb=(e,t,n)=>{let s=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(s,(r,a)=>(n[a]=0,r))},vb=class{constructor(t,n,s){ge(this,"uniform",{});ge(this,"attribute",{});ge(this,"gl");ge(this,"id");ge(this,"compile",(t,n)=>{let s=this.gl.createShader(n);return s?(this.gl.shaderSource(s,t),this.gl.compileShader(s),this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)?s:(ae(`filter: gl compile failed: ${this.gl.getShaderInfoLog(s)||"unknown"}`),null)):(ae("filter: could not create shader"),null)});this.gl=t;let r=this.compile(n,this.gl.VERTEX_SHADER),a=this.compile(s,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!a)){if(!this.id){ae("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,a),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){ae(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),bb(n,"attribute",this.attribute);for(let o in this.attribute)this.attribute[o]=this.gl.getAttribLocation(this.id,o);bb(n,"uniform",this.uniform),bb(s,"uniform",this.uniform);for(let o in this.uniform)this.uniform[o]=this.gl.getUniformLocation(this.id,o)}}};function LT(){let e=0,t=null,n=!1,s=-1,r=[null,null],a=[],o=null,i=null,l=ds(100,100),u={},c={INTERMEDIATE:1},p=l.getContext("webgl");if(!p){ae("filter: cannot get webgl context");return}this.gl=p;function d(x,A){if(!(x===l.width&&A===l.height)){if(l.width=x,l.height=A,!o){let b=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);o=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,o),p.bufferData(p.ARRAY_BUFFER,b,p.STATIC_DRAW),p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}p.viewport(0,0,l.width,l.height),r=[null,null]}}function h(x,A){let b=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,b);let w=p.createRenderbuffer();p.bindRenderbuffer(p.RENDERBUFFER,w);let S=p.createTexture();return p.bindTexture(p.TEXTURE_2D,S),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,x,A,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,S,0),p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),{fbo:b,texture:S}}function f(x){return r[x]=r[x]||h(l.width,l.height),r[x]}function m(x=0){if(!i)return;let A=null,b=null,w=!1;e===0?A=t:A=f(s).texture||null,e++,n&&!(x&c.INTERMEDIATE)?(b=null,w=e%2===0):(s=(s+1)%2,b=f(s).fbo||null),p.bindTexture(p.TEXTURE_2D,A),p.bindFramebuffer(p.FRAMEBUFFER,b),p.uniform1f(i.uniform.flipY,w?-1:1),p.drawArrays(p.TRIANGLES,0,6)}function g(x){if(u[x])return i=u[x],p.useProgram((i?i.id:null)||null),i;if(i=new vb(p,$T,x),!i)return ae("filter: could not get webgl program"),null;let A=Float32Array.BYTES_PER_ELEMENT,b=4*A;return p.enableVertexAttribArray(i.attribute.pos),p.vertexAttribPointer(i.attribute.pos,2,p.FLOAT,!1,b,0*A),p.enableVertexAttribArray(i.attribute.uv),p.vertexAttribPointer(i.attribute.uv,2,p.FLOAT,!1,b,2*A),u[x]=i,i}let y={colorMatrix:x=>{let A=new Float32Array(x);A[4]/=255,A[9]/=255,A[14]/=255,A[19]/=255;let b=A[18]===1&&A[3]===0&&A[8]===0&&A[13]===0&&A[15]===0&&A[16]===0&&A[17]===0&&A[19]===0?PT:FT,w=g(b);!w||(p.uniform1fv(w.uniform.m,A),m())},brightness:x=>{let A=(x||0)+1;y.colorMatrix([A,0,0,0,0,0,A,0,0,0,0,0,A,0,0,0,0,0,1,0])},saturation:x=>{let A=(x||0)*2/3+1,b=(A-1)*-.5;y.colorMatrix([A,b,b,0,0,b,A,b,0,0,b,b,A,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:x=>{let A=(x||0)+1,b=-128*(A-1);y.colorMatrix([A,0,0,0,b,0,A,0,0,b,0,0,A,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:x=>{x=(x||0)/180*Math.PI;let A=Math.cos(x),b=Math.sin(x),w=.213,S=.715,k=.072;y.colorMatrix([w+A*(1-w)+b*-w,S+A*-S+b*-S,k+A*-k+b*(1-k),0,0,w+A*-w+b*.143,S+A*(1-S)+b*.14,k+A*-k+b*-.283,0,0,w+A*-w+b*-(1-w),S+A*-S+b*S,k+A*(1-k)+b*k,0,0,0,0,0,1,0])},desaturateLuminance:()=>{y.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{y.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{y.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{y.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{y.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{y.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{y.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{y.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:x=>{let A=new Float32Array(x),b=1/l.width,w=1/l.height,S=g(zT);!S||(p.uniform1fv(S.uniform.m,A),p.uniform2f(S.uniform.px,b,w),m())},detectEdges:()=>{y.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{y.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{y.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:x=>{let A=x||1;y.convolution.call(this,[0,-1*A,0,-1*A,1+4*A,-1*A,0,-1*A,0])},emboss:x=>{let A=x||1;y.convolution.call(this,[-2*A,-1*A,0,-1*A,1,1*A,0,1*A,2*A])},blur:x=>{let A=x/7/l.width,b=x/7/l.height,w=g(MT);!w||(p.uniform2f(w.uniform.px,0,b),m(c.INTERMEDIATE),p.uniform2f(w.uniform.px,A,0),m())},pixelate:x=>{let A=x/l.width,b=x/l.height,w=g(OT);!w||(p.uniform2f(w.uniform.size,A,b),m())}};this.add=function(x){let A=Array.prototype.slice.call(arguments,1),b=y[x];a.push({func:b,args:A})},this.reset=function(){a=[]},this.get=function(){return a},this.apply=function(x){d(x.width,x.height),e=0,t||(t=p.createTexture()),p.bindTexture(p.TEXTURE_2D,t),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,x);for(let A=0;Ah.data())),o=.99*Math.max(a[0][0],a[1][0],a[2][0]),i=[me(n[0],s[0]),me(n[1],s[1]),me(n[2],s[2])],l=[me(r[0],s[0]),me(r[1],s[1]),me(r[2],s[2])],u=[fe(o,l[0]),fe(o,l[1]),fe(o,l[2])],c=[z(i[0],u[0]),z(i[1],u[1]),z(i[2],u[2])],p=ln([c[0],c[1],c[2]],2),d=V(p,[1,t.shape[0],t.shape[1],3]);return J([...n,...s,...r,...i,...l,...u,...c,p,t]),d}var U2=3840,En=null,Rn=null,xd=null,Rt,ar={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function wb(){ar.inputSum=0,ar.cacheDiff=1,ar.sumMethod=0,ar.inputTensor=void 0}function ds(e,t){let n;if(he.browser)if(he.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");n=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");n=document.createElement("canvas"),n.width=e,n.height=t}else typeof he.Canvas!="undefined"?n=new he.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(n=new globalThis.Canvas(e,t));return n}function G2(e,t){let n=t||ds(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),n}async function bd(e,t,n=!0){var d,h;if(!e)return t.debug&&ae("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof st)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof he.Canvas!="undefined"&&e instanceof he.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof st){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=Bt(e,0);else if(e.shape[2]===4){let m=pi(e,[0,0,0],[-1,-1,3]);f=Bt(m,0),J(m)}}else e.shape.length===4&&(e.shape[3]===3?f=Vn(e):e.shape[3]===4&&(f=ro(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let m=ye(f,"float32");J(f),f=m}return{tensor:f,canvas:t.filter.return?Rn:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&ae("input stream is not ready"),{tensor:null,canvas:En};let s=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!s||!r)return t.debug&&ae("cannot determine input dimensions"),{tensor:null,canvas:En};let a=s,o=r;if(a>U2&&(a=U2,o=Math.trunc(a*r/s)),o>U2&&(o=U2,a=Math.trunc(o*s/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?a=t.filter.width:(((h=t.filter)==null?void 0:h.height)||0)>0&&(a=s*((t.filter.height||0)/r)),(t.filter.height||0)>0?o=t.filter.height:(t.filter.width||0)>0&&(o=r*((t.filter.width||0)/s)),!a||!o)throw new Error("input error: cannot determine dimension");(!En||En.width!==a||En.height!==o)&&(En=ds(a,o));let i=En.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(s,0),i.scale(-1,1),i.drawImage(e,0,0,s,r,0,0,En.width,En.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,s,r,0,0,En.width,En.height),(!Rn||En.width!==Rn.width||En.height!==Rn.height)&&(Rn=ds(En.width,En.height)),t.filter.enabled&&he.webgl.supported?(Rt||(Rt=he.browser?new LT:null),he.filter=!!Rt,Rt!=null&&Rt.add?(Rt.reset(),t.filter.brightness!==0&&Rt.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Rt.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Rt.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Rt.add("blur",t.filter.blur),t.filter.saturation!==0&&Rt.add("saturation",t.filter.saturation),t.filter.hue!==0&&Rt.add("hue",t.filter.hue),t.filter.negative&&Rt.add("negative"),t.filter.sepia&&Rt.add("sepia"),t.filter.vintage&&Rt.add("brownie"),t.filter.sepia&&Rt.add("sepia"),t.filter.kodachrome&&Rt.add("kodachrome"),t.filter.technicolor&&Rt.add("technicolor"),t.filter.polaroid&&Rt.add("polaroid"),t.filter.pixelate!==0&&Rt.add("pixelate",t.filter.pixelate),Rt.get()>0?Rn=Rt.apply(En):Rn=Rt.draw(En)):(t.debug&&ae("input process error: cannot initialize filters"),he.webgl.supported=!1,t.filter.enabled=!1,G2(En,Rn))):(G2(En,Rn),Rt&&(Rt=null),he.filter=!!Rt),!n)return{tensor:null,canvas:Rn};if(!Rn)throw new Error("canvas error: cannot create output");let l,u=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(he.browser&&nr)l=nr?nr.fromPixels(e):null;else{u=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=ct(f,[e.height,e.width,u],"int32")}else if((!xd||Rn.width!==xd.width||Rn.height!==xd.height)&&(xd=ds(Rn.width,Rn.height)),nr&&he.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=nr.fromPixels(Rn):(xd=G2(Rn),l=nr.fromPixels(xd));else{let g=G2(Rn).getContext("2d").getImageData(0,0,a,o);u=g.data.length/a/o;let y=new Uint8Array(g.data.buffer);l=ct(y,[a,o,u])}if(u===4){let f=pi(l,[0,0,0],[-1,-1,3]);J(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let c=ye(l,"float32"),p=t.filter.equalization?await V2(c):Bt(c,0);return J([l,c]),{tensor:p,canvas:t.filter.return?Rn:null}}async function BT(e,t){let n=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return n;if(!ar.inputTensor)ar.inputTensor=Vn(t);else if(ar.inputTensor.shape[1]!==t.shape[1]||ar.inputTensor.shape[2]!==t.shape[2])J(ar.inputTensor),ar.inputTensor=Vn(t);else{let s={};s.diff=me(t,ar.inputTensor),s.squared=z(s.diff,s.diff),s.sum=ke(s.squared);let a=(await s.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;J([ar.inputTensor,s.diff,s.squared,s.sum]),ar.inputTensor=Vn(t),n=a<=(e.cacheSensitivity||0)}return n}async function WT(e,t,n){let s={};if(!t||!n||t.shape.length!==4||t.shape.length!==n.shape.length)return e.debug||ae("invalid input tensor or tensor shapes do not match:",t.shape,n.shape),0;if(t.shape[0]!==1||n.shape[0]!==1||t.shape[3]!==3||n.shape[3]!==3)return e.debug||ae("input tensors must be of shape [1, height, width, 3]:",t.shape,n.shape),0;s.input1=Vn(t),s.input2=t.shape[1]!==n.shape[1]||t.shape[2]!==n.shape[2]?Ie.resizeBilinear(n,[t.shape[1],t.shape[2]]):Vn(n),s.diff=me(s.input1,s.input2),s.squared=z(s.diff,s.diff),s.sum=ke(s.squared);let a=(await s.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return J([s.input1,s.input2,s.diff,s.squared,s.sum]),a}var kb=class{constructor(){ge(this,"browser");ge(this,"node");ge(this,"worker");ge(this,"platform","");ge(this,"agent","");ge(this,"backends",[]);ge(this,"initial");ge(this,"filter");ge(this,"tfjs");ge(this,"offscreen");ge(this,"perfadd",!1);ge(this,"tensorflow",{version:void 0,gpu:void 0});ge(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});ge(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});ge(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});ge(this,"cpu",{model:void 0,flags:[]});ge(this,"kernels",[]);ge(this,"Canvas");ge(this,"Image");ge(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Zh["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let n=t[0].match(/\(([^()]+)\)/g);this.platform=n!=null&&n[0]?n[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(Yt().registryFactory),this.tensorflow={version:Ls().binding?Ls().binding.TF_Version:void 0,gpu:Ls().binding?Ls().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&cn()==="wasm"&&(this.wasm.simd=H().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=H().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=ds(100,100),n=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof n!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(cn()==="webgl"||cn()==="humangl")){let s=Ls().gpgpu!=="undefined"?await Ls().getGPGPUContext().gl:null;s&&(this.webgl.version=s.getParameter(s.VERSION),this.webgl.renderer=s.getParameter(s.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let s=await navigator.gpu.requestAdapter();this.webgpu.adapter=s?s.name:void 0}}catch(s){this.webgpu.supported=!1}try{this.kernels=ta(cn()).map(s=>s.kernelName.toLowerCase())}catch(s){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},he=new kb;var Sb={};fa(Sb,{age:()=>qAe,"anti-spoofing":()=>S5e,antispoof:()=>FAe,blazeface:()=>PAe,"blazeface-back":()=>XAe,"blazeface-front":()=>KAe,"blazepose-detect":()=>k5e,"blazepose-detector2d":()=>ZAe,"blazepose-detector3d":()=>YAe,"blazepose-full":()=>JAe,"blazepose-heavy":()=>QAe,"blazepose-lite":()=>e5e,default:()=>M5e,efficientpose:()=>t5e,"efficientpose-i-lite":()=>I5e,"efficientpose-ii-lite":()=>C5e,"efficientpose-iv":()=>T5e,emotion:()=>OAe,faceboxes:()=>n5e,facemesh:()=>MAe,"facemesh-attention":()=>r5e,"facemesh-attention-alt":()=>s5e,"facemesh-detection-full":()=>a5e,"facemesh-detection-short":()=>o5e,"facemesh-orig":()=>i5e,faceres:()=>zAe,"faceres-deep":()=>l5e,gear:()=>u5e,gender:()=>d5e,"gender-ssrnet-imdb":()=>c5e,handdetect:()=>p5e,"handlandmark-full":()=>LAe,"handlandmark-lite":()=>h5e,"handlandmark-sparse":()=>f5e,handskeleton:()=>m5e,handtrack:()=>BAe,"insightface-efficientnet-b0":()=>N5e,"insightface-ghostnet-strides1":()=>E5e,"insightface-ghostnet-strides2":()=>R5e,"insightface-mobilenet-emore":()=>_5e,"insightface-mobilenet-swish":()=>D5e,iris:()=>WAe,liveness:()=>VAe,"mb3-centernet":()=>UAe,meet:()=>g5e,mobileface:()=>y5e,mobilefacenet:()=>A5e,models:()=>GAe,"movenet-lightning":()=>HAe,"movenet-multipose":()=>x5e,"movenet-thunder":()=>b5e,nanodet:()=>v5e,"nanodet-e":()=>$5e,"nanodet-g":()=>F5e,"nanodet-m":()=>P5e,"nanodet-t":()=>O5e,posenet:()=>w5e,selfie:()=>jAe});var FAe=853098,PAe=538928,OAe=820516,MAe=1477958,zAe=6978814,LAe=5431368,BAe=2964837,WAe=2599092,VAe=592976,UAe=4030290,GAe=0,HAe=4650216,jAe=212886,qAe=161240,XAe=538928,KAe=402048,ZAe=7499400,YAe=5928856,JAe=6338290,QAe=27501554,e5e=2725490,t5e=5651240,n5e=2013002,s5e=2387598,r5e=2382414,a5e=1026192,o5e=201268,i5e=2955780,l5e=13957620,u5e=1498916,c5e=161236,d5e=201808,p5e=3515612,h5e=2023432,f5e=5286322,m5e=5502280,g5e=372228,y5e=2183192,A5e=5171976,x5e=9448838,b5e=12477112,v5e=7574558,w5e=5032780,k5e=5928804,S5e=853098,I5e=2269064,C5e=5651240,T5e=25643252,N5e=13013224,E5e=8093408,R5e=8049584,_5e=6938536,D5e=12168584,$5e=12319156,F5e=7574558,P5e=1887474,O5e=5294216,M5e={antispoof:FAe,blazeface:PAe,emotion:OAe,facemesh:MAe,faceres:zAe,"handlandmark-full":LAe,handtrack:BAe,iris:WAe,liveness:VAe,"mb3-centernet":UAe,models:GAe,"movenet-lightning":HAe,selfie:jAe,age:qAe,"blazeface-back":XAe,"blazeface-front":KAe,"blazepose-detector2d":ZAe,"blazepose-detector3d":YAe,"blazepose-full":JAe,"blazepose-heavy":QAe,"blazepose-lite":e5e,efficientpose:t5e,faceboxes:n5e,"facemesh-attention-alt":s5e,"facemesh-attention":r5e,"facemesh-detection-full":a5e,"facemesh-detection-short":o5e,"facemesh-orig":i5e,"faceres-deep":l5e,gear:u5e,"gender-ssrnet-imdb":c5e,gender:d5e,handdetect:p5e,"handlandmark-lite":h5e,"handlandmark-sparse":f5e,handskeleton:m5e,meet:g5e,mobileface:y5e,mobilefacenet:A5e,"movenet-multipose":x5e,"movenet-thunder":b5e,nanodet:v5e,posenet:w5e,"blazepose-detect":k5e,"anti-spoofing":S5e,"efficientpose-i-lite":I5e,"efficientpose-ii-lite":C5e,"efficientpose-iv":T5e,"insightface-efficientnet-b0":N5e,"insightface-ghostnet-strides1":E5e,"insightface-ghostnet-strides2":R5e,"insightface-mobilenet-emore":_5e,"insightface-mobilenet-swish":D5e,"nanodet-e":$5e,"nanodet-g":F5e,"nanodet-m":P5e,"nanodet-t":O5e};var Rd={};fa(Rd,{Models:()=>uf,getModelStats:()=>M4,load:()=>z4,reset:()=>h1,validate:()=>I1,validateModel:()=>Dd});var br,Ib=[],z5e=["white","black","asian","indian","other"],L5e=[15,23,28,35.5,45.5,55.5,65],VT=0,UT=0,Cb=Number.MAX_SAFE_INTEGER;async function GT(e){var t;return he.initial&&(br=null),br?e.debug&&ae("cached model:",br.modelUrl):br=await je((t=e.face.gear)==null?void 0:t.modelPath),br}async function Tb(e,t,n,s){var o,i;if(!br)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=Cb<(((o=t.face.gear)==null?void 0:o.skipFrames)||0),a=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>le()-UT;return t.skipAllowed&&a&&r&&VT===s&&Ib[n]?(Cb++,Ib[n]):(Cb=0,new Promise(async l=>{var y,x;if(!(br!=null&&br.inputs[0].shape))return;let u={},c=[[0,.1,.9,.9]];u.resize=Ie.cropAndResize(e,c,[0],[br.inputs[0].shape[2],br.inputs[0].shape[1]]);let p={age:0,gender:"unknown",genderScore:0,race:[]};(y=t.face.gear)!=null&&y.enabled&&([u.age,u.gender,u.race]=br.execute(u.resize,["age_output","gender_output","race_output"]));let d=await u.gender.data();p.gender=d[0]>d[1]?"male":"female",p.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let h=await u.race.data();for(let A=0;A(((x=t.face.gear)==null?void 0:x.minConfidence)||.2)&&p.race.push({score:Math.round(100*h[A])/100,race:z5e[A]});p.race.sort((A,b)=>b.score-A.score);let m=Array.from(await u.age.data()).map((A,b)=>[L5e[b],A]).sort((A,b)=>b[1]-A[1]),g=m[0][0];for(let A=1;AJ(u[A])),Ib[n]=p,VT=s,UT=le(),l(p)}))}var at={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function jT(){at.tf255=Ce(255,"float32"),at.tf1=Ce(1,"float32"),at.tf2=Ce(2,"float32"),at.tf05=Ce(.5,"float32"),at.tf127=Ce(127.5,"float32"),at.rgb=Ft([.2989,.587,.114],"float32")}var Bs,H2=[],qT=0,XT=0,Nb=Number.MAX_SAFE_INTEGER;async function KT(e){return he.initial&&(Bs=null),Bs?e.debug&&ae("cached model:",Bs.modelUrl):Bs=await je(e.face.ssrnet.modelPathAge),Bs}async function Eb(e,t,n,s){var o,i,l,u;if(!Bs)return{age:0};let r=Nb<(((o=t.face.ssrnet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>le()-XT;return t.skipAllowed&&r&&a&&qT===s&&((l=H2[n])==null?void 0:l.age)&&((u=H2[n])==null?void 0:u.age)>0?(Nb++,H2[n]):(Nb=0,new Promise(async c=>{var h;if(!(Bs!=null&&Bs.inputs)||!Bs.inputs[0]||!Bs.inputs[0].shape)return;let p={};p.resize=Ie.resizeBilinear(e,[Bs.inputs[0].shape[2],Bs.inputs[0].shape[1]],!1),p.enhance=z(p.resize,at.tf255);let d={age:0};if((h=t.face.ssrnet)!=null&&h.enabled&&(p.age=Bs.execute(p.enhance)),p.age){let f=await p.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(p).forEach(f=>J(p[f])),H2[n]=d,qT=s,XT=le(),c(d)}))}var vr,j2=[],YT=0,JT=0,Rb=Number.MAX_SAFE_INTEGER,_b=[.2989,.587,.114];async function QT(e){var t;return he.initial&&(vr=null),vr?e.debug&&ae("cached model:",vr.modelUrl):vr=await je((t=e.face.ssrnet)==null?void 0:t.modelPathGender),vr}async function Db(e,t,n,s){var o,i,l,u;if(!vr)return{gender:"unknown",genderScore:0};let r=Rb<(((o=t.face.ssrnet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>le()-JT;return t.skipAllowed&&r&&a&&YT===s&&((l=j2[n])==null?void 0:l.gender)&&((u=j2[n])==null?void 0:u.genderScore)>0?(Rb++,j2[n]):(Rb=0,new Promise(async c=>{var f;if(!(vr!=null&&vr.inputs[0].shape))return;let p={};p.resize=Ie.resizeBilinear(e,[vr.inputs[0].shape[2],vr.inputs[0].shape[1]],!1),p.enhance=Z(()=>{let[m,g,y]=Jt(p.resize,3,3),x=z(m,_b[0]),A=z(g,_b[1]),b=z(y,_b[2]),w=C0([x,A,b]);return z(me(w,at.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(p.gender=vr.execute(p.enhance));let h=await p.gender.data();d.gender=h[0]>h[1]?"female":"male",d.genderScore=h[0]>h[1]?Math.trunc(100*h[0])/100:Math.trunc(100*h[1])/100,Object.keys(p).forEach(m=>J(p[m])),j2[n]=d,YT=s,JT=le(),c(d)}))}var vn,q2=[],$b=Number.MAX_SAFE_INTEGER,tN=0,nN=0;async function sN(e){var t;return he.initial&&(vn=null),vn?e.debug&&ae("cached model:",vn.modelUrl):vn=await je((t=e.face.antispoof)==null?void 0:t.modelPath),vn}async function Fb(e,t,n,s){var o,i;if(!vn||!(vn!=null&&vn.executor))return 0;let r=(((o=t.face.antispoof)==null?void 0:o.skipTime)||0)>le()-nN,a=$b<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&a&&tN===s&&q2[n]?($b++,q2[n]):($b=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[vn!=null&&vn.inputs[0].shape?vn.inputs[0].shape[2]:0,vn!=null&&vn.inputs[0].shape?vn.inputs[0].shape[1]:0],!1),c=vn==null?void 0:vn.execute(u),p=(await c.data())[0];q2[n]=Math.round(100*p)/100,tN=s,nN=le(),J([u,c]),l(q2[n])}))}var wr={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},Pb={count:468,mouth:13,symmetryLine:[13,wr.midwayBetweenEyes[0]]},gu={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Ob=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Jh=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],yu=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var W5e=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],V5e=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],U5e=[33,133,362,263,1,78,308],jke=W5e.map(e=>Jh[e]),qke=V5e.map(e=>Jh[e]),Xke=U5e.map(e=>Jh[e]);function Ai(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var G5e=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],H5e=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],j5e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],q5e=[[474,475],[475,476],[476,477],[477,474]],X5e=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],K5e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Z5e=[[469,470],[470,471],[471,472],[472,469]],Y5e=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],Kke={lips:Ai(G5e),leftEye:Ai(H5e),leftEyebrow:Ai(j5e),leftIris:Ai(q5e),rightEye:Ai(X5e),rightEyebrow:Ai(K5e),rightIris:Ai(Z5e),faceOval:Ai(Y5e)};var vd=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],K2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],Z2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],iN=(e,t)=>{let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:s,landmarks:e.landmarks,confidence:e.confidence}},zb=(e,t,n)=>{let s=t.shape[1],r=t.shape[2],a=[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r],o=Ie.cropAndResize(t,[a],[0],n),i=fe(o,at.tf255);return J(o),i},Y2=(e,t)=>{let n=X2(e),s=vd(e),r=[t*s[0]/2,t*s[1]/2];return{startPoint:[n[0]-r[0],n[1]-r[1]],endPoint:[n[0]+r[0],n[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},J2=e=>{let t=X2(e),n=vd(e),s=Math.max(...n)/2;return{startPoint:[Math.round(t[0]-s),Math.round(t[1]-s)],endPoint:[Math.round(t[0]+s),Math.round(t[1]+s)],landmarks:e.landmarks,confidence:e.confidence}},lN=e=>{let t=e.map(s=>s[0]),n=e.map(s=>s[1]);return{startPoint:[Math.min(...t),Math.min(...n)],endPoint:[Math.max(...t),Math.max(...n)],landmarks:e}},Lb=[[1,0,0],[0,1,0],[0,0,1]],J5e=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Q5e=(e,t)=>J5e(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var aN=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Au=(e,t)=>{let n=0;for(let s=0;s{let n=[];for(let s=0;s{let n=[],s=e.length;for(let r=0;r{let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=aN(t[0],t[1]),o=oN(a,r),i=aN(-t[0],-t[1]);return oN(o,i)},txe=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-Au(t[0],n),-Au(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]},nxe=(e,t)=>[Au(e,t[0]),Au(e,t[1])];function cN(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},n=[];for(let s=0;s[a[0]/r*(h[0]-r/2),a[1]/r*(h[1]-r/2),h[2]||0]),i=n&&n!==0&&Math.abs(n)>.2,l=i?uN(n,[0,0]):Lb,u=i?o.map(h=>[...nxe(h,l),h[2]]):o,c=i?txe(s):Lb,p=X2(t),d=[Au(p,c[0]),Au(p,c[1])];return u.map(h=>[Math.trunc(h[0]+d[0]),Math.trunc(h[1]+d[1]),Math.trunc(h[2]||0)])}function pN(e,t,n,s){let r=t.landmarks.length>=Pb.count?Pb.symmetryLine:gu.symmetryLine,a=0,o=Lb,i;if(e&&he.kernels.includes("rotatewithoffset"))if(a=Q5e(t.landmarks[r[0]],t.landmarks[r[1]]),a&&a!==0&&Math.abs(a)>.2){let u=X2(t),c=[u[0]/n.shape[2],u[1]/n.shape[1]],p=Ie.rotateWithOffset(n,a,0,c);o=uN(-a,u),i=zb(t,p,[s,s]),J(p)}else i=zb(t,n,[s,s]);else i=zb(t,n,[s,s]);return[a,o,i]}var sxe=e=>{let t=e.map(s=>s[0]),n=e.map(s=>s[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...n)+(Math.max(...n)-Math.min(...n))/2]},hN=(e,t)=>{let n=sxe(e),s=vd(t);return{startPoint:[n[0]-s[0]/2,n[1]-s[1]/2],endPoint:[n[0]+s[0]/2,n[1]+s[1]/2]}};var fN=6,rxe=1.4,Ur,mN=null,xi=0,Qh=null,wd=()=>xi;async function gN(e){var t;return he.initial&&(Ur=null),Ur?e.debug&&ae("cached model:",Ur.modelUrl):Ur=await je((t=e.face.detector)==null?void 0:t.modelPath),xi=Ur.executor&&Ur.inputs[0].shape?Ur.inputs[0].shape[2]:256,Qh=Ce(xi,"int32"),mN=fr(cN(xi)),Ur}function axe(e){let t={};t.boxStarts=ze(e,[0,1],[-1,2]),t.centers=ue(t.boxStarts,mN),t.boxSizes=ze(e,[0,3],[-1,2]),t.boxSizesNormalized=fe(t.boxSizes,Qh),t.centersNormalized=fe(t.centers,Qh),t.halfBoxSize=fe(t.boxSizesNormalized,at.tf2),t.starts=me(t.centersNormalized,t.halfBoxSize),t.ends=ue(t.centersNormalized,t.halfBoxSize),t.startNormalized=z(t.starts,Qh),t.endNormalized=z(t.ends,Qh);let n=ru([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(s=>J(t[s])),n}async function yN(e,t){var i,l,u,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let n={};n.resized=Ie.resizeBilinear(e,[xi,xi]),n.div=fe(n.resized,at.tf127),n.normalized=me(n.div,at.tf05);let s=Ur==null?void 0:Ur.execute(n.normalized);if(Array.isArray(s)&&s.length>2){let p=s.sort((d,h)=>d.size-h.size);n.concat384=It([p[0],p[2]],2),n.concat512=It([p[1],p[3]],2),n.concat=It([n.concat512,n.concat384],1),n.batch=rt(n.concat,0)}else Array.isArray(s)?n.batch=rt(s[0]):n.batch=rt(s);J(s),n.boxes=axe(n.batch),n.logits=ze(n.batch,[0,0],[-1,1]),n.sigmoid=$n(n.logits),n.scores=rt(n.sigmoid),n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((u=t.face.detector)==null?void 0:u.minConfidence)||0);let r=await n.nms.array(),a=[],o=await n.scores.data();for(let p=0;p(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let h={};h.bbox=ze(n.boxes,[r[p],0],[1,-1]),h.slice=ze(n.batch,[r[p],fN-1],[1,-1]),h.squeeze=rt(h.slice),h.landmarks=V(h.squeeze,[fN,-1]);let f=await h.bbox.data(),m={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await h.landmarks.array(),confidence:d},g=iN(m,[(e.shape[2]||0)/xi,(e.shape[1]||0)/xi]),y=Y2(g,t.face.scale||rxe),x=J2(y);a.push(x),Object.keys(h).forEach(A=>J(h[A]))}}return Object.keys(n).forEach(p=>J(n[p])),a}var Q2={};fa(Q2,{connected:()=>Vb,kpt:()=>Wb});var Wb=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],Vb={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var xN=224,oxe,ixe=5,e1=[8,16,32,32,32];function bN(){let e=[],t=0;for(;tn.x)),y:Ft(e.map(n=>n.y))}}function $a(e,t=[1,1]){let n=[e.map(i=>i[0]),e.map(i=>i[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[s[0],s[1],r[0]-s[0],r[1]-s[1]],o=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:o}}function vN(e,t=[1,1]){let n=[e.map(u=>u[0]),e.map(u=>u[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[(s[0]+r[0])/2,(s[1]+r[1])/2],o=Math.max(a[0]-s[0],a[1]-s[1],-a[0]+r[0],-a[1]+r[1]),i=[Math.trunc(a[0]-o),Math.trunc(a[1]-o),Math.trunc(2*o),Math.trunc(2*o)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function t1(e,t){let n=[e[2]*t,e[3]*t];return[e[0]-(n[0]-e[2])/2,e[1]-(n[1]-e[3])/2,n[0],n[1]]}var SN={initial:!0},jn={detector:null,landmarks:null},kd={detector:[224,224],landmarks:[256,256]},Ub=Number.MAX_SAFE_INTEGER,uxe={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},s1=null,ef,bi=[[0,0],[0,0],[0,0],[0,0]],wN=0,kN=e=>1-1/(1+Math.exp(e));async function IN(e){var t;if(SN.initial&&(jn.detector=null),!jn.detector&&e.body.detector&&e.body.detector.modelPath){jn.detector=await je(e.body.detector.modelPath);let n=(t=jn.detector)!=null&&t.executor?Object.values(jn.detector.modelSignature.inputs):void 0;kd.detector[0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,kd.detector[1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}else e.debug&&jn.detector&&ae("cached model:",jn.detector.modelUrl);return bN(),jn.detector}async function CN(e){var t;if(SN.initial&&(jn.landmarks=null),jn.landmarks)e.debug&&ae("cached model:",jn.landmarks.modelUrl);else{jn.landmarks=await je(e.body.modelPath);let n=(t=jn.landmarks)!=null&&t.executor?Object.values(jn.landmarks.modelSignature.inputs):void 0;kd.landmarks[0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,kd.landmarks[1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return jn.landmarks}function cxe(e,t){var r,a;let n={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((a=e==null?void 0:e.shape)!=null&&a[2]))return e;let s;if(ef&&(n.cropped=Ie.cropAndResize(e,[ef],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let o=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],i=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];bi=[[0,0],o,i,[0,0]],n.pad=sr(n.cropped||e,bi),n.resize=Ie.resizeBilinear(n.pad,[t,t]),s=fe(n.resize,at.tf255)}else e.shape[1]!==t?(n.resize=Ie.resizeBilinear(n.cropped||e,[t,t]),s=fe(n.resize,at.tf255)):s=fe(n.cropped||e,at.tf255);return Object.keys(n).forEach(o=>J(n[o])),s}function dxe(e,t){for(let n of e)n.position=[Math.trunc(n.position[0]*(t[0]+bi[2][0]+bi[2][1])/t[0]-bi[2][0]),Math.trunc(n.position[1]*(t[1]+bi[1][0]+bi[1][1])/t[1]-bi[1][0]),n.position[2]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1],2*n.position[2]/(t[0]+t[1])];if(ef)for(let n of e)n.positionRaw=[n.positionRaw[0]+ef[1],n.positionRaw[1]+ef[0],n.positionRaw[2]],n.position=[Math.trunc(n.positionRaw[0]*t[0]),Math.trunc(n.positionRaw[1]*t[1]),n.positionRaw[2]];return e}function pxe(e){let t=e.find(i=>i.part==="leftPalm"),n=e.find(i=>i.part==="leftWrist"),s=e.find(i=>i.part==="leftIndex");t.position[2]=((n.position[2]||0)+(s.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),a=e.find(i=>i.part==="rightWrist"),o=e.find(i=>i.part==="rightIndex");r.position[2]=((a.position[2]||0)+(o.position[2]||0))/2}async function hxe(e,t,n){var f,m;if(!((f=jn.landmarks)!=null&&f.executor))return null;let s={};[s.ld,s.segmentation,s.heatmap,s.world,s.poseflag]=(m=jn.landmarks)==null?void 0:m.execute(e,uxe.landmarks);let r=(await s.poseflag.data())[0],a=await s.ld.data(),o=await s.world.data();Object.keys(s).forEach(g=>J(s[g]));let i=[],l=5;for(let g=0;gg.position),p=$a(c,[n[0],n[1]]),d={};for(let[g,y]of Object.entries(Vb)){let x=[];for(let A=0;AS.part===y[A]),w=u.find(S=>S.part===y[A+1]);b&&w&&x.push([b.position,w.position])}d[g]=x}return{id:0,score:Math.trunc(100*r)/100,box:p.box,boxRaw:p.boxRaw,keypoints:u,annotations:d}}async function Gb(e,t){let n=[e.shape[2]||0,e.shape[1]||0],s=(t.body.skipTime||0)>le()-wN,r=Ub<(t.body.skipFrames||0);if(t.skipAllowed&&s&&r&&s1!==null)Ub++;else{let a={};a.landmarks=cxe(e,256),s1=await hxe(a.landmarks,t,n),Object.keys(a).forEach(o=>J(a[o])),wN=le(),Ub=0}return s1?[s1]:[]}var Sd=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var ws,xu=0,Hb=[],NN=0,jb=Number.MAX_SAFE_INTEGER;async function EN(e){if(he.initial&&(ws=null),ws)e.debug&&ae("cached model:",ws.modelUrl);else{ws=await je(e.object.modelPath);let t=ws!=null&&ws.executor?Object.values(ws.modelSignature.inputs):void 0;xu=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ws}async function fxe(e,t,n){if(!e)return[];let s={},r=[],a=await e.array();s.squeeze=rt(e);let o=Jt(s.squeeze,6,1);s.stack=ln([o[1],o[0],o[3],o[2]],1),s.boxes=rt(s.stack),s.scores=rt(o[4]),s.classes=rt(o[5]),J([e,...o]),s.nms=await Ie.nonMaxSuppressionAsync(s.boxes,s.scores,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence||0);let i=await s.nms.data(),l=0;for(let u of Array.from(i)){let c=Math.trunc(100*a[0][u][4])/100,p=a[0][u][5];if(Number.isNaN(p))continue;let d=Sd[p].label,[h,f]=[a[0][u][0]/xu,a[0][u][1]/xu],m=[h,f,a[0][u][2]/xu-h,a[0][u][3]/xu-f],g=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];r.push({id:l++,score:c,class:p,label:d,box:g,boxRaw:m})}return Object.keys(s).forEach(u=>J(s[u])),r}async function qb(e,t){if(!(ws!=null&&ws.executor))return[];let n=(t.object.skipTime||0)>le()-NN,s=jb<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&Hb.length>0?(jb++,Hb):(jb=0,new Promise(async r=>{let a=[e.shape[2]||0,e.shape[1]||0],o=Ie.resizeBilinear(e,[xu,xu]),i=t.object.enabled?ws==null?void 0:ws.execute(o,["tower_0/detections"]):null;NN=le(),J(o);let l=await fxe(i,a,t);Hb=l,r(l)}))}var r1={};fa(r1,{connected:()=>Kb,kpt:()=>Xb});var Xb=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],Kb={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var wn,_N=0,ps={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},Zb=Number.MAX_SAFE_INTEGER;async function DN(e){return he.initial&&(wn=null),wn?e.debug&&ae("cached model:",wn.modelUrl):wn=await je(e.body.modelPath),wn}async function mxe(e,t){let[n,s]=e.shape,r=V(e,[s*n]),a=yn(r,0),o=(await a.data())[0];if(o>t){let i=$s(r,0),l=ou(i,n),u=(await l.data())[0],c=fe(i,n),p=(await c.data())[0];return J([r,a,i,l,c]),[u,p,o]}return J([r,a]),[0,0,o]}async function Yb(e,t){if(!(wn!=null&&wn.executor))return[];let n=(t.body.skipTime||0)>le()-_N,s=Zb<(t.body.skipFrames||0);return t.skipAllowed&&n&&s&&Object.keys(ps.keypoints).length>0?(Zb++,[ps]):(Zb=0,new Promise(async r=>{let a=Z(()=>{if(!(wn!=null&&wn.inputs[0].shape))return null;let p=Ie.resizeBilinear(e,[wn.inputs[0].shape[2],wn.inputs[0].shape[1]],!1),d=z(p,at.tf2);return me(d,at.tf1)}),o;if(t.body.enabled&&(o=wn==null?void 0:wn.execute(a)),_N=le(),J(a),o){ps.keypoints.length=0;let p=rt(o);J(o);let d=On(p,2);J(p);for(let h=0;h(t.body.minConfidence||0)&&ps.keypoints.push({score:Math.round(100*g)/100,part:Xb[h],positionRaw:[f/wn.inputs[0].shape[2],m/wn.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/wn.inputs[0].shape[2]),Math.round(e.shape[1]*m/wn.inputs[0].shape[1])]})}d.forEach(h=>J(h))}ps.score=ps.keypoints.reduce((p,d)=>d.score>p?d.score:p,0);let i=ps.keypoints.map(p=>p.position[0]),l=ps.keypoints.map(p=>p.position[1]);ps.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let u=ps.keypoints.map(p=>p.positionRaw[0]),c=ps.keypoints.map(p=>p.positionRaw[1]);ps.boxRaw=[Math.min(...u),Math.min(...c),Math.max(...u)-Math.min(...u),Math.max(...c)-Math.min(...c)];for(let[p,d]of Object.entries(Kb)){let h=[];for(let f=0;fy.part===d[f]),g=ps.keypoints.find(y=>y.part===d[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}ps.annotations[p]=h}r([ps])}))}var gxe=["angry","disgust","fear","happy","sad","surprise","neutral"],or,a1=[],FN=0,PN=0,Jb=Number.MAX_SAFE_INTEGER;async function ON(e){var t;return he.initial&&(or=null),or?e.debug&&ae("cached model:",or.modelUrl):or=await je((t=e.face.emotion)==null?void 0:t.modelPath),or}async function Qb(e,t,n,s){var o,i;if(!or)return[];let r=Jb<(((o=t.face.emotion)==null?void 0:o.skipFrames)||0),a=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>le()-PN;return t.skipAllowed&&a&&r&&FN===s&&a1[n]&&a1[n].length>0?(Jb++,a1[n]):(Jb=0,new Promise(async l=>{var c;let u=[];if((c=t.face.emotion)!=null&&c.enabled){let p={},d=or!=null&&or.inputs[0].shape?or.inputs[0].shape[2]:0;p.resize=Ie.resizeBilinear(e,[d,d],!1),p.channels=z(p.resize,at.rgb),p.grayscale=ke(p.channels,3,!0),p.grayscaleSub=me(p.grayscale,at.tf05),p.grayscaleMul=z(p.grayscaleSub,at.tf2),p.emotion=or==null?void 0:or.execute(p.grayscaleMul),PN=le();let h=await p.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&u.push({score:Math.min(.99,Math.trunc(100*h[f])/100),emotion:gxe[f]});u.sort((f,m)=>m.score-f.score),Object.keys(p).forEach(f=>J(p[f]))}a1[n]=u,FN=s,l(u)}))}var Ws,e4=[],zN=0,LN=0,BN=Number.MAX_SAFE_INTEGER;async function WN(e){var t;return he.initial&&(Ws=null),Ws?e.debug&&ae("cached model:",Ws.modelUrl):Ws=await je((t=e.face.mobilefacenet)==null?void 0:t.modelPath),Ws}async function t4(e,t,n,s){var o,i;if(!(Ws!=null&&Ws.executor))return[];let r=BN<(((o=t.face.mobilefacenet)==null?void 0:o.skipFrames)||0),a=(((i=t.face.mobilefacenet)==null?void 0:i.skipTime)||0)>le()-LN;return t.skipAllowed&&a&&r&&zN===s&&e4[n]?(BN++,e4[n]):new Promise(async l=>{var c;let u=[];if(((c=t.face.mobilefacenet)==null?void 0:c.enabled)&&(Ws==null?void 0:Ws.inputs[0].shape)){let p={};p.crop=Ie.resizeBilinear(e,[Ws.inputs[0].shape[2],Ws.inputs[0].shape[1]],!1),p.data=Ws.execute(p.crop);let d=await p.data.data();u=Array.from(d),Object.keys(p).forEach(h=>J(p[h]))}e4[n]=u,zN=s,LN=le(),l(u)})}var Vs,n4=[],UN=0,GN=0,HN=Number.MAX_SAFE_INTEGER;async function jN(e){return he.initial&&(Vs=null),Vs?e.debug&&ae("cached model:",Vs.modelUrl):Vs=await je(e.face.insightface.modelPath),Vs}async function s4(e,t,n,s){var o,i;if(!(Vs!=null&&Vs.executor))return[];let r=HN<(((o=t.face.insightface)==null?void 0:o.skipFrames)||0),a=(((i=t.face.insightface)==null?void 0:i.skipTime)||0)>le()-GN;return t.skipAllowed&&a&&r&&UN===s&&n4[n]?(HN++,n4[n]):new Promise(async l=>{var c;let u=[];if(((c=t.face.insightface)==null?void 0:c.enabled)&&(Vs==null?void 0:Vs.inputs[0].shape)){let p={};p.crop=Ie.resizeBilinear(e,[Vs.inputs[0].shape[2],Vs.inputs[0].shape[1]],!1),p.data=Vs.execute(p.crop);let d=await p.data.data();u=Array.from(d),Object.keys(p).forEach(h=>J(p[h]))}n4[n]=u,UN=s,GN=le(),l(u)})}var Us,vi=0,yxe=2.3,r4=wr.leftEyeLower0,a4=wr.rightEyeLower0,Id={leftBounds:[r4[0],r4[r4.length-1]],rightBounds:[a4[0],a4[a4.length-1]]},Cd={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function YN(e){var t,n;return he.initial&&(Us=null),Us?e.debug&&ae("cached model:",Us.modelUrl):Us=await je((t=e.face.iris)==null?void 0:t.modelPath),vi=(Us==null?void 0:Us.executor)&&((n=Us.inputs)==null?void 0:n[0].shape)?Us.inputs[0].shape[2]:0,vi===-1&&(vi=64),Us}function o1(e,t,n,s){for(let r=0;r{let t=e[Id.leftBounds[0]][2],n=e[Id.rightBounds[0]][2];return t-n},XN=(e,t,n,s,r,a=!1)=>{let o=J2(Y2(lN([e[n],e[s]]),yxe)),i=vd(o),l=Ie.cropAndResize(t,[[o.startPoint[1]/r,o.startPoint[0]/r,o.endPoint[1]/r,o.endPoint[0]/r]],[0],[vi,vi]);if(a&&he.kernels.includes("flipleftright")){let u=Ie.flipLeftRight(l);J(l),l=u}return{box:o,boxSize:i,crop:l}},KN=(e,t,n,s=!1)=>{let r=[];for(let a=0;a{let s=e[wr[`${n}EyeUpper0`][Cd.upperCenter]][2],r=e[wr[`${n}EyeLower0`][Cd.lowerCenter]][2],a=(s+r)/2;return t.map((o,i)=>{let l=a;return i===2?l=s:i===4&&(l=r),[o[0],o[1],l]})};async function JN(e,t,n){if(!(Us!=null&&Us.executor))return e;let{box:s,boxSize:r,crop:a}=XN(e,t,Id.leftBounds[0],Id.leftBounds[1],n,!0),{box:o,boxSize:i,crop:l}=XN(e,t,Id.rightBounds[0],Id.rightBounds[1],n,!0),u=It([a,l]);J(a),J(l);let c=Us.execute(u);J(u);let p=await c.data();J(c);let d=p.slice(0,Cd.numCoordinates*3),{rawCoords:h,iris:f}=KN(d,s,r,!0),m=p.slice(Cd.numCoordinates*3),{rawCoords:g,iris:y}=KN(m,o,i,!1),x=Axe(e);Math.abs(x)<30?(o1(e,h,"left",null),o1(e,g,"right",null)):x<1?o1(e,h,"left",["EyeUpper0","EyeLower0"]):o1(e,g,"right",["EyeUpper0","EyeLower0"]);let A=ZN(e,f,"left"),b=ZN(e,y,"right");return e.concat(A).concat(b)}var xxe=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],bxe=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vxe=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],wxe=[[474,475],[475,476],[476,477],[477,474]],kxe=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Sxe=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Ixe=[[469,470],[470,471],[471,472],[472,469]],Cxe=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function wi(e){let t=e.map(n=>n[0]);return t.push(e[e.length-1][1]),t}var Txe={lips:wi(xxe),leftEye:wi(bxe),leftEyebrow:wi(vxe),leftIris:wi(wxe),rightEye:wi(kxe),rightEyebrow:wi(Sxe),rightIris:wi(Ixe),faceOval:wi(Cxe)},Nxe=Object.entries(Txe).map(([e,t])=>t.map(n=>[n,e])).flat(),TSe=new Map(Nxe),tf=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],bu=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],vu=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function tE(e,t){var a,o,i,l,u,c,p,d,h,f;let n={lips:await((o=(a=t.filter(m=>m.size===160))==null?void 0:a[0])==null?void 0:o.data()),irisL:await((l=(i=t.filter(m=>m.size===10))==null?void 0:i[0])==null?void 0:l.data()),eyeL:await((c=(u=t.filter(m=>m.size===142))==null?void 0:u[0])==null?void 0:c.data()),irisR:await((d=(p=t.filter(m=>m.size===10))==null?void 0:p[1])==null?void 0:d.data()),eyeR:await((f=(h=t.filter(m=>m.size===142))==null?void 0:h[1])==null?void 0:f.data())};for(let m of Object.values(n))if(!m)return e;let s=bu.reduce((m,g)=>m+=e[g][2],0)/bu.length;for(let m=0;mm+=e[g][2],0)/vu.length;for(let m=0;mle()-la.timestamp,s=la.skipped<(((u=t.face.detector)==null?void 0:u.skipFrames)||0);!t.skipAllowed||!n||!s||la.boxes.length===0?(la.boxes=await yN(e,t),la.timestamp=le(),la.skipped=0):la.skipped++;let r=[],a=[],o=0,i=nf;for(let x=0;xD.shape[D.shape.length-1]===1).data();if(S.faceScore=Math.round(100*_[0])/100,S.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(A.confidence=S.faceScore,t.face.mesh.keepInvalid){S.box=K2(A,e),S.boxRaw=Z2(A,e),S.score=S.boxScore,S.mesh=A.landmarks.map(D=>[(A.startPoint[0]+A.endPoint[0])/2+(A.endPoint[0]+A.startPoint[0])*D[0]/wd(),(A.startPoint[1]+A.endPoint[1])/2+(A.endPoint[1]+A.startPoint[1])*D[1]/wd()]),S.meshRaw=S.mesh.map(D=>[D[0]/(e.shape[2]||1),D[1]/(e.shape[1]||1),(D[2]||0)/i]);for(let D of Object.keys(gu))S.annotations[D]=[S.mesh[gu[D]]]}}else{let D=k.find(M=>M.shape[M.shape.length-1]===1404),R=V(D,[-1,3]),F=await R.array();J(R),(m=t.face.attention)!=null&&m.enabled?F=await tE(F,k):(g=t.face.iris)!=null&&g.enabled&&(F=await JN(F,S.tensor,nf)),S.mesh=dN(F,A,b,w,nf),S.meshRaw=S.mesh.map(M=>[M[0]/(e.shape[2]||0),M[1]/(e.shape[1]||0),(M[2]||0)/i]);for(let M of Object.keys(wr))S.annotations[M]=wr[M].map(L=>S.mesh[L]);S.score=S.faceScore;let C={...hN(S.mesh,A),confidence:A.confidence,landmarks:A.landmarks};S.box=K2(C,e),S.boxRaw=Z2(C,e),a.push(C)}J(k)}else{S.box=K2(A,e),S.boxRaw=Z2(A,e),S.score=S.boxScore,S.mesh=A.landmarks.map(k=>[(A.startPoint[0]+A.endPoint[0])/2+(A.endPoint[0]+A.startPoint[0])*k[0]/wd(),(A.startPoint[1]+A.endPoint[1])/2+(A.endPoint[1]+A.startPoint[1])*k[1]/wd()]),S.meshRaw=S.mesh.map(k=>[k[0]/(e.shape[2]||0),k[1]/(e.shape[1]||0),(k[2]||0)/i]);for(let k of Object.keys(gu))S.annotations[k]=[S.mesh[gu[k]]]}S.score>(((y=t.face.detector)==null?void 0:y.minConfidence)||1)?r.push(S):J(S.tensor)}return la.boxes=a,r}async function sE(e){var t,n,s,r,a,o;return he.initial&&(Mt=null),((t=e.face.attention)==null?void 0:t.enabled)&&(Mt==null?void 0:Mt.signature)&&Object.keys(((n=Mt==null?void 0:Mt.signature)==null?void 0:n.outputs)||{}).length<6&&(Mt=null),Mt?e.debug&&ae("cached model:",Mt.modelUrl):(s=e.face.attention)!=null&&s.enabled?Mt=await je(e.face.attention.modelPath):Mt=await je((r=e.face.mesh)==null?void 0:r.modelPath),nf=Mt.executor&&((a=Mt==null?void 0:Mt.inputs)==null?void 0:a[0].shape)?(o=Mt==null?void 0:Mt.inputs)==null?void 0:o[0].shape[2]:256,Mt}var rE=yu,aE=Jh;var qn,ki=[],oE=0,iE=0,i4=Number.MAX_SAFE_INTEGER;async function lE(e){var t;return he.initial&&(qn=null),qn?e.debug&&ae("cached model:",qn.modelUrl):qn=await je((t=e.face.description)==null?void 0:t.modelPath),qn}function l4(e){let t=e.image||e.tensor||e;if(!(qn!=null&&qn.inputs[0].shape))return t;let n=Ie.resizeBilinear(t,[qn.inputs[0].shape[2],qn.inputs[0].shape[1]],!1),s=z(n,at.tf255);return J(n),s}async function u4(e,t,n,s){var i,l,u,c;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(qn!=null&&qn.executor))return r;let a=i4<(((i=t.face.description)==null?void 0:i.skipFrames)||0),o=(((l=t.face.description)==null?void 0:l.skipTime)||0)>le()-oE;return t.skipAllowed&&a&&o&&iE===s&&((u=ki==null?void 0:ki[n])==null?void 0:u.age)>0&&((c=ki==null?void 0:ki[n])==null?void 0:c.genderScore)>0?(i4++,ki[n]):(i4=0,new Promise(async p=>{var d;if((d=t.face.description)!=null&&d.enabled){let h=l4(e),f=qn==null?void 0:qn.execute(h);oE=le(),J(h);let g=await f.find(E=>E.shape[1]===1).data(),y=Math.trunc(200*Math.abs(g[0]-.5))/100;y>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,y));let x=$s(f.find(E=>E.shape[1]===100),1),A=(await x.data())[0];J(x);let w=await f.find(E=>E.shape[1]===100).data();r.age=Math.round(w[A-1]>w[A+1]?10*A-100*w[A-1]:10*A+100*w[A+1])/10,(Number.isNaN(g[0])||Number.isNaN(w[0]))&&ae("faceres error:",{model:qn,result:f});let S=f.find(E=>E.shape[1]===1024),k=S?await S.data():[];r.descriptor=Array.from(k),f.forEach(E=>J(E))}ki[n]=r,iE=s,p(r)}))}function i1(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function sf(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function dE(e,t,n){let s=t.shape[1],r=t.shape[2],a=[[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r]];return Ie.cropAndResize(t,a,[0],n)}function pE(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(a=>[a[0]*t[0],a[1]*t[1]]);return{startPoint:n,endPoint:s,palmLandmarks:r,confidence:e.confidence}}function l1(e,t=1.5){let n=sf(e),s=i1(e),r=[t*s[0]/2,t*s[1]/2],a=[n[0]-r[0],n[1]-r[1]],o=[n[0]+r[0],n[1]+r[1]];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function u1(e){let t=sf(e),n=i1(e),r=Math.max(...n)/2,a=[t[0]-r,t[1]-r],o=[t[0]+r,t[1]+r];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function Rxe(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function hE(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Rxe(n)}var uE=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Si(e,t){let n=0;for(let s=0;s[o.x,o.y]),this.anchorsTensor=fr(this.anchors),this.inputSize=((a=(r=(s=(n=this==null?void 0:this.model)==null?void 0:n.inputs)==null?void 0:s[0])==null?void 0:r.shape)==null?void 0:a[2])||0,this.inputSizeTensor=Ft([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Ft([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let n={};n.boxOffsets=ze(t,[0,0],[-1,2]),n.boxSizes=ze(t,[0,2],[-1,2]),n.div=fe(n.boxOffsets,this.inputSizeTensor),n.boxCenterPoints=ue(n.div,this.anchorsTensor),n.halfBoxSizes=fe(n.boxSizes,this.doubleInputSizeTensor),n.sub=me(n.boxCenterPoints,n.halfBoxSizes),n.startPoints=z(n.sub,this.inputSizeTensor),n.add=ue(n.boxCenterPoints,n.halfBoxSizes),n.endPoints=z(n.add,this.inputSizeTensor);let s=ru([n.startPoints,n.endPoints],1);return Object.keys(n).forEach(r=>J(n[r])),s}normalizeLandmarks(t,n){let s={};s.reshape=V(t,[-1,7,2]),s.div=fe(s.reshape,this.inputSizeTensor),s.landmarks=ue(s.div,this.anchors[n]?this.anchors[n]:0);let r=z(s.landmarks,this.inputSizeTensor);return Object.keys(s).forEach(a=>J(s[a])),r}async predict(t,n){var i;let s={};s.resize=Ie.resizeBilinear(t,[this.inputSize,this.inputSize]),s.div=fe(s.resize,at.tf127),s.image=me(s.div,at.tf1),s.batched=this.model.execute(s.image),s.predictions=rt(s.batched),s.slice=ze(s.predictions,[0,0],[-1,1]),s.sigmoid=$n(s.slice),s.scores=rt(s.sigmoid);let r=await s.scores.data();s.boxes=ze(s.predictions,[0,1],[-1,4]),s.norm=this.normalizeBoxes(s.boxes),s.nms=await Ie.nonMaxSuppressionAsync(s.norm,s.scores,3*(((i=n.hand)==null?void 0:i.maxDetected)||1),n.hand.iouThreshold,n.hand.minConfidence);let a=await s.nms.array(),o=[];for(let l of a){let u={};u.box=ze(s.norm,[l,0],[1,-1]),u.slice=ze(s.predictions,[l,5],[1,14]),u.norm=this.normalizeLandmarks(u.slice,l),u.palmLandmarks=V(u.norm,[-1,2]);let c=await u.box.data(),p=c.slice(0,2),d=c.slice(2,4),h=await u.palmLandmarks.array(),f={startPoint:p,endPoint:d,palmLandmarks:h,confidence:r[l]},m=pE(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);o.push(m),Object.keys(u).forEach(g=>J(u[g]))}return Object.keys(s).forEach(l=>J(s[l])),o}};var Fxe=5,yE=1.65,AE=[0,5,9,13,17,1,2],Pxe=0,Oxe=2,xE=0,d1=class{constructor(t,n){ge(this,"handDetector");ge(this,"handPoseModel");ge(this,"inputSize");ge(this,"storedBoxes");ge(this,"skipped");ge(this,"detectedHands");var s,r,a;this.handDetector=t,this.handPoseModel=n,this.inputSize=((a=(r=(s=this.handPoseModel)==null?void 0:s.inputs)==null?void 0:r[0].shape)==null?void 0:a[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(o=>o[0]),s=t.map(o=>o[1]),r=[Math.min(...n),Math.min(...s)],a=[Math.max(...n),Math.max(...s)];return{startPoint:r,endPoint:a}}getBoxForPalmLandmarks(t,n){let s=t.map(a=>p4([...a,1],n)),r=this.calculateLandmarksBoundingBox(s);return l1(u1(r),Fxe)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),s=l1(u1(n),yE);s.palmLandmarks=[];for(let r=0;r[o[0]*(h[0]-this.inputSize/2),o[1]*(h[1]-this.inputSize/2),o[2]*h[2]]),l=d4(s,[0,0]),u=i.map(h=>[...p4(h,l),h[2]]),c=fE(r),p=[...sf(n),1],d=[Si(p,c[0]),Si(p,c[1])];return u.map(h=>[Math.trunc(h[0]+d[0]),Math.trunc(h[1]+d[1]),Math.trunc(h[2])])}async estimateHands(t,n){let s=!1,r,a=(n.hand.skipTime||0)>le()-xE,o=this.skipped<(n.hand.skipFrames||0);n.skipAllowed&&a&&o&&(r=await this.handDetector.predict(t,n),this.skipped=0),n.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(s=!0));let i=[];for(let l=0;l=n.hand.minConfidence/4){let w=V(A,[-1,3]),S=await w.array();J(A),J(w);let k=this.transformRawCoords(S,m,c,f),E=this.getBoxForHandLandmarks(k);this.storedBoxes[l]={...E,confidence:b};let _={landmarks:k,confidence:b,boxConfidence:u.confidence,fingerConfidence:b,box:{topLeft:E.startPoint,bottomRight:E.endPoint}};i.push(_)}else this.storedBoxes[l]=null;J(A)}else{let c=l1(u1(u),yE),p={confidence:u.confidence,boxConfidence:u.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};i.push(p)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>n.hand.maxDetected&&(i.length=n.hand.maxDetected),i}};var hs={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>hs.nameMapping[e],getPoints:e=>hs.pointsMapping[e]},Ci={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ci.nameMapping[e]},qt={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>qt.nameMapping[e]},Ii=class{constructor(t){ge(this,"name");ge(this,"curls");ge(this,"directions");ge(this,"weights");ge(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,n,s){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([n,s])}direction(t,n,s){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([n,s])}weight(t,n){this.weights[t]=n;let s=this.weights.reduce((r,a)=>r+a,0);this.weightsRelative=this.weights.map(r=>r*5/s)}matchAgainst(t,n){let s=0;for(let r in t){let a=t[r],o=this.curls[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}for(let r in n){let a=n[r],o=this.directions[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}return s/10}};var{thumb:Gr,index:Fa,middle:Pa,ring:wu,pinky:ku}=hs,{none:Hr,half:zxe,full:jr}=Ci,{verticalUp:Td,verticalDown:VSe,horizontalLeft:h4,horizontalRight:Lxe,diagonalUpRight:Bxe,diagonalUpLeft:Nd,diagonalDownRight:USe,diagonalDownLeft:GSe}=qt,Ti=new Ii("thumbs up");Ti.curl(Gr,Hr,1);Ti.direction(Gr,Td,1);Ti.direction(Gr,Nd,.25);Ti.direction(Gr,Bxe,.25);for(let e of[hs.index,hs.middle,hs.ring,hs.pinky])Ti.curl(e,jr,1),Ti.direction(e,h4,1),Ti.direction(e,Lxe,1);var pn=new Ii("victory");pn.curl(Gr,zxe,.5);pn.curl(Gr,Hr,.5);pn.direction(Gr,Td,1);pn.direction(Gr,Nd,1);pn.curl(Fa,Hr,1);pn.direction(Fa,Td,.75);pn.direction(Fa,Nd,1);pn.curl(Pa,Hr,1);pn.direction(Pa,Td,1);pn.direction(Pa,Nd,.75);pn.curl(wu,jr,1);pn.direction(wu,Td,.2);pn.direction(wu,Nd,1);pn.direction(wu,h4,.2);pn.curl(ku,jr,1);pn.direction(ku,Td,.2);pn.direction(ku,Nd,1);pn.direction(ku,h4,.2);pn.weight(Fa,2);pn.weight(Pa,2);var Ni=new Ii("point");Ni.curl(Gr,jr,1);Ni.curl(Fa,Hr,.5);Ni.curl(Pa,jr,.5);Ni.curl(wu,jr,.5);Ni.curl(ku,jr,.5);Ni.weight(Fa,2);Ni.weight(Pa,2);var Ei=new Ii("middle finger");Ei.curl(Gr,Hr,1);Ei.curl(Fa,jr,.5);Ei.curl(Pa,jr,.5);Ei.curl(wu,jr,.5);Ei.curl(ku,jr,.5);Ei.weight(Fa,2);Ei.weight(Pa,2);var Ed=new Ii("open palm");Ed.curl(Gr,Hr,.75);Ed.curl(Fa,Hr,.75);Ed.curl(Pa,Hr,.75);Ed.curl(wu,Hr,.75);Ed.curl(ku,Hr,.75);var bE=[Ti,pn,Ni,Ei,Ed];var Wxe=.7,Su={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function vE(e,t,n,s){let r=(t-s)/(e-n),a=Math.atan(r)*180/Math.PI;return a<=0?a=-a:a>0&&(a=180-a),a}function kE(e,t){if(!e||!t)return[0,0];let n=vE(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let s=vE(e[1],e[2],t[1],t[2]);return[n,s]}function wE(e,t=1){let n=0,s=0,r=0;return e>=75&&e<=105?n=1*t:e>=25&&e<=155?s=1*t:r=1*t,[n,s,r]}function Vxe(e,t,n){let s=e[0]-t[0],r=e[0]-n[0],a=t[0]-n[0],o=e[1]-t[1],i=e[1]-n[1],l=t[1]-n[1],u=e[2]-t[2],c=e[2]-n[2],p=t[2]-n[2],d=Math.sqrt(s*s+o*o+u*u),h=Math.sqrt(r*r+i*i+c*c),f=Math.sqrt(a*a+l*l+p*p),m=(f*f+d*d-h*h)/(2*f*d);m>1?m=1:m<-1&&(m=-1);let g=Math.acos(m);g=57.2958*g%180;let y;return g>Su.NO_CURL_START_LIMIT?y=Ci.none:g>Su.HALF_CURL_START_LIMIT?y=Ci.half:y=Ci.full,y}function SE(e,t,n,s){let r;return s===Math.abs(e)?e>0?r=qt.horizontalLeft:r=qt.horizontalRight:s===Math.abs(t)?t>0?r=qt.horizontalLeft:r=qt.horizontalRight:n>0?r=qt.horizontalLeft:r=qt.horizontalRight,r}function IE(e,t,n,s){let r;return s===Math.abs(e)?e<0?r=qt.verticalDown:r=qt.verticalUp:s===Math.abs(t)?t<0?r=qt.verticalDown:r=qt.verticalUp:n<0?r=qt.verticalDown:r=qt.verticalUp,r}function Uxe(e,t,n,s,r,a,o,i){let l,u=IE(e,t,n,s),c=SE(r,a,o,i);return u===qt.verticalUp?c===qt.horizontalLeft?l=qt.diagonalUpLeft:l=qt.diagonalUpRight:c===qt.horizontalLeft?l=qt.diagonalDownLeft:l=qt.diagonalDownRight,l}function Gxe(e,t,n,s){let r=e[0]-t[0],a=e[0]-n[0],o=t[0]-n[0],i=e[1]-t[1],l=e[1]-n[1],u=t[1]-n[1],c=Math.max(Math.abs(r),Math.abs(a),Math.abs(o)),p=Math.max(Math.abs(i),Math.abs(l),Math.abs(u)),d=0,h=0,f=0,m=p/(c+1e-5);m>1.5?d+=Su.DISTANCE_VOTE_POWER:m>.66?h+=Su.DISTANCE_VOTE_POWER:f+=Su.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+i*i),y=Math.sqrt(a*a+l*l),x=Math.sqrt(o*o+u*u),A=Math.max(g,y,x),b=e[0],w=e[1],S=n[0],k=n[1];A===g?(S=n[0],k=n[1]):A===x&&(b=t[0],w=t[1]);let D=kE([b,w],[S,k]),R=wE(D,Su.TOTAL_ANGLE_VOTE_POWER);d+=R[0],h+=R[1],f+=R[2];for(let C of s){let M=wE(C,Su.SINGLE_ANGLE_VOTE_POWER);d+=M[0],h+=M[1],f+=M[2]}let F;return d===Math.max(d,h,f)?F=IE(l,i,u,p):f===Math.max(h,f)?F=SE(a,r,o,c):F=Uxe(l,i,u,p,a,r,o,c),F}function CE(e){let t=[],n=[],s=[],r=[];if(!e)return{curls:s,directions:r};for(let a of hs.all){let o=hs.getPoints(a),i=[],l=[];for(let u of o){let c=e[u[0]],p=e[u[1]],d=kE(c,p),h=d[0],f=d[1];i.push(h),l.push(f)}t.push(i),n.push(l)}for(let a of hs.all){let o=a===hs.thumb?1:0,i=hs.getPoints(a),l=e[i[o][0]],u=e[i[o+1][1]],c=e[i[3][1]],p=Vxe(l,u,c),d=Gxe(l,u,c,t[a].slice(o));s[a]=p,r[a]=d}return{curls:s,directions:r}}function p1(e){if(!e||e.length===0)return null;let t=CE(e),n={};for(let s of hs.all)n[hs.getName(s)]={curl:Ci.getName(t.curls[s]),direction:qt.getName(t.directions[s])};return n}function TE(e){let t=[];if(!e||e.length===0)return t;let n=CE(e);for(let s of bE){let r=s.matchAgainst(n.curls,n.directions);r>=Wxe&&t.push({name:s.name,confidence:r})}return t}var NE={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Iu,Cu,EE;async function m4(e,t){let n=await EE.estimateHands(e,t);if(!n)return[];let s=[];for(let r=0;rn[r].landmarks[p]);let o=n[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(o&&o.length>0){for(let c of o)c[0]i[2]&&(i[2]=c[0]),c[1]>i[3]&&(i[3]=c[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=n[r].box?[Math.trunc(Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.max(0,n[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,n[r].box.bottomRight[0])-Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,n[r].box.bottomRight[1])-Math.max(0,n[r].box.topLeft[1]))]:[0,0,0,0],l=[n[r].box.topLeft[0]/(e.shape[2]||0),n[r].box.topLeft[1]/(e.shape[1]||0),(n[r].box.bottomRight[0]-n[r].box.topLeft[0])/(e.shape[2]||0),(n[r].box.bottomRight[1]-n[r].box.topLeft[1])/(e.shape[1]||0)];let u=p1(o);s.push({id:r,score:Math.round(100*n[r].confidence)/100,boxScore:Math.round(100*n[r].boxConfidence)/100,fingerScore:Math.round(100*n[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:l,keypoints:o,annotations:a,landmarks:u})}return s}async function g4(e){var n,s;he.initial&&(Iu=null,Cu=null),!Iu||!Cu?[Iu,Cu]=await Promise.all([e.hand.enabled?je((n=e.hand.detector)==null?void 0:n.modelPath):null,e.hand.landmarks?je((s=e.hand.skeleton)==null?void 0:s.modelPath):null]):(e.debug&&ae("cached model:",Iu.modelUrl),e.debug&&ae("cached model:",Cu.modelUrl));let t=Iu?new c1(Iu):void 0;return t&&Cu&&(EE=new d1(t,Cu)),[Iu,Cu]}var _t={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function Hxe(){let e=_t.gl;!e||(_t.extensions=e.getSupportedExtensions())}function _E(e){var t;if(e.config.backend==="humangl"&&(_t.name in Yt().registry&&!((t=_t==null?void 0:_t.gl)!=null&&t.getParameter(_t.gl.VERSION))&&(ae("humangl error: backend invalid context"),h1(e)),!Xy(_t.name))){try{_t.canvas=ds(100,100)}catch(s){ae("humangl error: cannot create canvas:",s);return}try{if(_t.gl=_t.canvas.getContext("webgl2",_t.webGLattr),!_t.gl){ae("humangl error: cannot get webgl context");return}if(!_t.gl.getParameter(_t.gl.VERSION).includes("2.0")){ae("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}_t.canvas&&(_t.canvas.addEventListener("webglcontextlost",r=>{throw ae("humangl error:",r.type),ae("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),_t.canvas.addEventListener("webglcontextrestored",r=>{ae("humangl error: context restored:",r)}),_t.canvas.addEventListener("webglcontextcreationerror",r=>{ae("humangl error: context create:",r)}))}catch(s){ae("humangl error: cannot get webgl context:",s);return}try{R2(2,_t.gl)}catch(s){ae("humangl error: cannot set webgl context:",s);return}try{let s=new tc(_t.gl);nu(_t.name,()=>new pd(s),_t.priority)}catch(s){ae("humangl error: cannot register webgl backend:",s);return}try{ta("webgl").forEach(r=>{let a={...r,backendName:_t.name};tr(a)})}catch(s){ae("humangl error: cannot update webgl backend registration:",s);return}try{H().flagRegistry.WEBGL_VERSION&&H().set("WEBGL_VERSION",2)}catch(s){ae("humangl error: cannot set WebGL backend flags:",s);return}Hxe();let n=Ls().getGPGPUContext?Ls().getGPGPUContext().gl:null;n?e.config.debug&&ae("humangl backend registered:",{webgl:n.getParameter(n.VERSION),renderer:n.getParameter(n.RENDERER)}):ae("humangl error: no current gl context:",n,_t.gl)}}function jxe(e){let t=[];if(!he.kernels.includes("mod")){let n={kernelName:"Mod",backendName:cn(),kernelFunc:s=>Z(()=>me(s.inputs.a,z(fe(s.inputs.a,s.inputs.b),s.inputs.b)))};tr(n),he.kernels.push("mod"),t.push("mod")}if(!he.kernels.includes("floormod")){let n={kernelName:"FloorMod",backendName:cn(),kernelFunc:s=>Z(()=>ue(z(Hc(s.inputs.a/s.inputs.b),s.inputs.b),ou(s.inputs.a,s.inputs.b)))};tr(n),he.kernels.push("floormod"),t.push("floormod")}if(!he.kernels.includes("rotatewithoffset")&&e.softwareKernels){let n={kernelName:"RotateWithOffset",backendName:cn(),kernelFunc:s=>Z(()=>{let r=cn();dh("cpu");let a=Ie.rotateWithOffset(s.inputs.image,s.attrs.radians,s.attrs.fillValue,s.attrs.center);return dh(r),a})};tr(n),he.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&ae("registered kernels:",t)}var $E={};async function rf(e,t=!1){if(e.state="backend",t||he.initial||e.config.backend&&e.config.backend.length>0&&cn()!==e.config.backend){let n=le();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&ae("running inside web worker"),he.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&ae("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),he.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&ae(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),he.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")ae("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&ae("enumerated webgpu adapter:",r),!r)ae("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let a="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;ae("webgpu adapter info:",a)}}let s=Object.keys(Yt().registryFactory);if(e.config.backend==="humangl"&&!s.includes("humangl")&&(_E(e),s=Object.keys(Yt().registryFactory)),e.config.debug&&ae("available backends:",s),s.includes(e.config.backend)||(ae(`error: backend ${e.config.backend} not found in registry`),e.config.backend=he.node?"tensorflow":"webgl",e.config.debug&&ae(`override: setting backend ${e.config.backend}`)),e.config.debug&&ae("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(H().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&H().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&ae("wasm path:",e.config.wasmPath),typeof M2!="undefined")M2(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,a=!1;try{r=await H().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),a=await H().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&ae(`wasm execution: ${a?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!a&&ae("warning: wasm simd support is not enabled")}catch(o){ae("wasm detection failed")}}try{await dh(e.config.backend),await ph()}catch(r){return ae("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&($E=JSON.parse(JSON.stringify(H().flags)))}if((cn()==="humangl"||cn()==="webgl")&&(H().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&H().set("WEBGL_USE_SHAPES_UNIFORMS",!0),H().flagRegistry.WEBGL_EXP_CONV&&H().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(ae("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),H().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),cn(),e.config.debug){let s=H().flags,r={};for(let a of Object.keys(s))$E[a]!==s[a]&&(r[a]=s[a]);e.config.debug&&Object.keys(r).length>0&&ae("backend:",cn(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&ae("flags:",e.config.flags);for(let[s,r]of Object.entries(e.config.flags))H().set(s,r)}jy(),jT(),e.performance.initBackend=Math.trunc(le()-n),e.config.backend=cn(),await he.updateBackend(),jxe(e.config),he.initial=!1}return!0}function f1(e,t){for(let n of e){let s={kernelName:n,backendName:t.backend,kernelFunc:()=>{t.debug&&ae("kernelFunc",n,t.backend)}};tr(s)}he.kernels=ta(cn()).map(n=>n.kernelName.toLowerCase())}var tn=[null,null],qxe=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ri=[[0,0],[0,0]],Xxe=["hand","fist","pinch","point","face","tip","pinchtip"],PE=4,OE=1.6,Kxe=512,Zxe=1.4,m1=Number.MAX_SAFE_INTEGER,y4=0,Oa=[0,0],en={boxes:[],hands:[]},ME={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function zE(e){var t;if(he.initial&&(tn[0]=null),tn[0])e.debug&&ae("cached model:",tn[0].modelUrl);else{f1(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),tn[0]=await je((t=e.hand.detector)==null?void 0:t.modelPath);let n=tn[0].executor?Object.values(tn[0].modelSignature.inputs):void 0;Ri[0][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,Ri[0][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return tn[0]}async function LE(e){var t;if(he.initial&&(tn[1]=null),tn[1])e.debug&&ae("cached model:",tn[1].modelUrl);else{tn[1]=await je((t=e.hand.skeleton)==null?void 0:t.modelPath);let n=tn[1].executor?Object.values(tn[1].modelSignature.inputs):void 0;Ri[1][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,Ri[1][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0}return tn[1]}async function Yxe(e,t){let n=[];if(!e||!tn[0])return n;let s={},r=(e.shape[2]||1)/(e.shape[1]||1),a=Math.min(Math.round((e.shape[1]||0)/8)*8,Kxe),o=Math.round(a*r/8)*8;s.resize=Ie.resizeBilinear(e,[a,o]),s.cast=ye(s.resize,"int32"),[s.rawScores,s.rawBoxes]=await tn[0].executeAsync(s.cast,qxe),s.boxes=rt(s.rawBoxes,[0,2]),s.scores=rt(s.rawScores,[0]);let i=On(s.scores,1);J(i[PE]),i.splice(PE,1),s.filtered=ln(i,1),J(i),s.max=yn(s.filtered,1),s.argmax=$s(s.filtered,1);let l=0;s.nms=await Ie.nonMaxSuppressionAsync(s.boxes,s.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let u=await s.nms.data(),c=await s.max.data(),p=await s.argmax.data();for(let d of Array.from(u)){let h=ze(s.boxes,d,1),f=await h.data();J(h);let m=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=t1(m,Zxe),y=[Math.trunc(m[0]*Oa[0]),Math.trunc(m[1]*Oa[1]),Math.trunc(m[2]*Oa[0]),Math.trunc(m[3]*Oa[1])],x=c[d],A=Xxe[p[d]],b={id:l++,score:x,box:y,boxRaw:g,label:A};n.push(b)}return Object.keys(s).forEach(d=>J(s[d])),n.sort((d,h)=>h.score-d.score),n.length>(t.hand.maxDetected||1)&&(n.length=t.hand.maxDetected||1),n}async function A4(e,t,n){let s={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&tn[1]&&n.hand.landmarks&&t.score>(n.hand.minConfidence||0)){let r={},a=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=Ie.cropAndResize(e,[a],[0],[Ri[1][0],Ri[1][1]],"bilinear"),r.div=fe(r.crop,at.tf255),[r.score,r.keypoints]=tn[1].execute(r.div,["Identity_1","Identity"]);let o=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(o))))/100;if(i>=(n.hand.minConfidence||0)){s.fingerScore=i,r.reshaped=V(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(p=>[p[0]/Ri[1][1],p[1]/Ri[1][0],p[2]||0]).map(p=>[p[0]*t.boxRaw[2],p[1]*t.boxRaw[3],p[2]||0]);s.keypoints=c.map(p=>[Oa[0]*(p[0]+t.boxRaw[0]),Oa[1]*(p[1]+t.boxRaw[1]),p[2]||0]),s.landmarks=p1(s.keypoints);for(let p of Object.keys(ME))s.annotations[p]=ME[p].map(d=>s.landmarks&&s.keypoints[d]?s.keypoints[d]:null)}Object.keys(r).forEach(l=>J(r[l]))}return s}async function x4(e,t){var r,a;if(!((r=tn[0])!=null&&r.executor)||!((a=tn[1])!=null&&a.executor)||!tn[0].inputs[0].shape||!tn[1].inputs[0].shape)return[];Oa=[e.shape[2]||0,e.shape[1]||0],m1++;let n=(t.hand.skipTime||0)>le()-y4,s=m1<(t.hand.skipFrames||0);return t.skipAllowed&&n&&s?en.hands:new Promise(async o=>{let i=3*(t.hand.skipTime||0)>le()-y4,l=m1<3*(t.hand.skipFrames||0);t.skipAllowed&&en.hands.length===t.hand.maxDetected?en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))):t.skipAllowed&&i&&l&&en.hands.length>0?en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))):(en.boxes=await Yxe(e,t),y4=le(),en.hands=await Promise.all(en.boxes.map(c=>A4(e,c,t))),m1=0);let u=[...en.boxes];if(en.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&p.box[3]/(e.shape[1]||1)>.05&&en.hands[c].fingerScore&&en.hands[c].fingerScore>(t.hand.minConfidence||0)){let d=t1(p.box,OE),h=t1(p.boxRaw,OE);en.boxes.push({...u[c],box:d,boxRaw:h})}}for(let c=0;cle()-VE,a=b4<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&a&&WE===s&&g1[n]?(b4++,g1[n]):(b4=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[_n!=null&&_n.inputs[0].shape?_n.inputs[0].shape[2]:0,_n!=null&&_n.inputs[0].shape?_n.inputs[0].shape[1]:0],!1),c=_n==null?void 0:_n.execute(u),p=(await c.data())[0];g1[n]=Math.round(100*p)/100,WE=s,VE=le(),J([u,c]),l(g1[n])}))}var af={};fa(af,{connected:()=>A1,horizontal:()=>w4,kpt:()=>y1,relative:()=>S4,vertical:()=>k4});var y1=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],w4=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],k4=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S4=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],A1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var HE=.005,Gs={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function I4(e){for(let t of w4){let n=e.keypoints.findIndex(r=>r.part===t[0]),s=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[0]r&&r.part===t[0]),s=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[1]u&&u.part===t[0]),r=e.keypoints.findIndex(u=>u&&u.part===t[1]),a=e.keypoints.findIndex(u=>u&&u.part===n[0]),o=e.keypoints.findIndex(u=>u&&u.part===n[1]);if(!e.keypoints[a]||!e.keypoints[o])continue;let i=e.keypoints[s]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[s].position[0]),Math.abs(e.keypoints[o].position[0]-e.keypoints[s].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[o].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||l[0]>l[1]){let u=e.keypoints[s];e.keypoints[s]=e.keypoints[r],e.keypoints[r]=u}}}function jE(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],n.pad=sr(e,Gs.padding),n.resize=Ie.resizeBilinear(n.pad,[t,t]);let s=ye(n.resize,"int32");return Object.keys(n).forEach(o=>J(n[o])),s}function XE(e,t){e.keypoints=e.keypoints.filter(s=>s==null?void 0:s.position);for(let s of e.keypoints)s.position=[s.position[0]*(t[0]+Gs.padding[2][0]+Gs.padding[2][1])/t[0]-Gs.padding[2][0],s.position[1]*(t[1]+Gs.padding[1][0]+Gs.padding[1][1])/t[1]-Gs.padding[1][0]],s.positionRaw=[s.position[0]/t[0],s.position[1]/t[1]];let n=$a(e.keypoints.map(s=>s.position),t);return e.box=n.box,e.boxRaw=n.boxRaw,e}var hn,x1=0,C4=Number.MAX_SAFE_INTEGER,Tu={boxes:[],bodies:[],last:0};async function KE(e){var t;return he.initial&&(hn=null),hn?e.debug&&ae("cached model:",hn.modelUrl):(f1(["size"],e),hn=await je(e.body.modelPath)),x1=(hn==null?void 0:hn.executor)&&((t=hn==null?void 0:hn.inputs)==null?void 0:t[0].shape)?hn.inputs[0].shape[2]:0,x1<64&&(x1=256),hn}function Qxe(e,t,n){let s=e[0][0],r=[],a=0;for(let c=0;ct.body.minConfidence){let p=[s[c][1],s[c][0]];r.push({score:Math.round(100*a)/100,part:y1[c],positionRaw:p,position:[Math.round((n.shape[2]||0)*p[0]),Math.round((n.shape[1]||0)*p[1])]})}a=r.reduce((c,p)=>p.score>c?p.score:c,0);let o=[],i=$a(r.map(c=>c.position),[n.shape[2],n.shape[1]]),l={};for(let[c,p]of Object.entries(A1)){let d=[];for(let h=0;hg.part===p[h]),m=r.find(g=>g.part===p[h+1]);f&&m&&f.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&d.push([f.position,m.position])}l[c]=d}let u={id:0,score:a,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return I4(u),o.push(u),o}function ebe(e,t,n){let s=[];for(let r=0;rt.body.minConfidence){let i=[];for(let p=0;p<17;p++){let d=a[3*p+2];if(d>t.body.minConfidence){let h=[a[3*p+1],a[3*p+0]];i.push({part:y1[p],score:Math.round(100*d)/100,positionRaw:h,position:[Math.round((n.shape[2]||0)*h[0]),Math.round((n.shape[1]||0)*h[1])]})}}let l=$a(i.map(p=>p.position),[n.shape[2],n.shape[1]]),u={};for(let[p,d]of Object.entries(A1)){let h=[];for(let f=0;fy.part===d[f]),g=i.find(y=>y.part===d[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}u[p]=h}let c={id:r,score:o,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:u};I4(c),s.push(c)}}return s.sort((r,a)=>a.score-r.score),s.length>t.body.maxDetected&&(s.length=t.body.maxDetected),s}async function T4(e,t){var r;if(!(hn!=null&&hn.executor)||!((r=hn==null?void 0:hn.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Tu.boxes.length=0),C4++;let n=(t.body.skipTime||0)>le()-Tu.last,s=C4<(t.body.skipFrames||0);return t.skipAllowed&&n&&s?Tu.bodies:new Promise(async a=>{let o={};C4=0,o.input=qE(e,x1),o.res=hn==null?void 0:hn.execute(o.input),Tu.last=le();let i=await o.res.array();Tu.bodies=o.res.shape[2]===17?Qxe(i,t,e):ebe(i,t,e);for(let l of Tu.bodies)XE(l,[e.shape[2]||1,e.shape[1]||1]),jE(l.keypoints);Object.keys(o).forEach(l=>J(o[l])),a(Tu.bodies)})}var kr,b1=[],YE=0,N4=Number.MAX_SAFE_INTEGER,w1=0,v1=2.5;async function JE(e){if(!kr||he.initial){kr=await je(e.object.modelPath);let t=kr!=null&&kr.executor?Object.values(kr.modelSignature.inputs):void 0;w1=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&ae("cached model:",kr.modelUrl);return kr}async function tbe(e,t,n){let s=0,r=[],a=w1;for(let u of[1,2,4]){let c=u*13,p=rt(e.find(y=>y.shape[1]===c**2&&(y.shape[2]||0)===Sd.length)),d=await p.array(),h=rt(e.find(y=>y.shape[1]===c**2&&(y.shape[2]||0)(n.object.minConfidence||0)&&x!==61){let b=(.5+Math.trunc(y%c))/c,w=(.5+Math.trunc(y/c))/c,S=g[y].map(M=>M*(c/u/a)),[k,E]=[b-v1/u*S[0],w-v1/u*S[1]],[_,D]=[b+v1/u*S[2]-k,w+v1/u*S[3]-E],R=[k,E,_,D];R=R.map(M=>Math.max(0,Math.min(M,1)));let F=[R[0]*t[0],R[1]*t[1],R[2]*t[0],R[3]*t[1]],C={id:s++,score:Math.round(100*A)/100,class:x+1,label:Sd[x].label,box:F.map(M=>Math.trunc(M)),boxRaw:R};r.push(C)}}J([p,h,f,m])}let o=r.map(u=>[u.boxRaw[1],u.boxRaw[0],u.boxRaw[3],u.boxRaw[2]]),i=r.map(u=>u.score),l=[];if(o&&o.length>0){let u=await Ie.nonMaxSuppressionAsync(o,i,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence);l=await u.data(),J(u)}return r=r.filter((u,c)=>l.includes(c)).sort((u,c)=>c.score-u.score),r}async function E4(e,t){if(!(kr!=null&&kr.executor))return[];let n=(t.object.skipTime||0)>le()-YE,s=N4<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&b1.length>0?(N4++,b1):(N4=0,!he.kernels.includes("mod")||!he.kernels.includes("sparsetodense")?b1:new Promise(async r=>{let a=[e.shape[2]||0,e.shape[1]||0],o=Ie.resizeBilinear(e,[w1,w1],!1),i=fe(o,at.tf255),l=tt(i,[0,3,1,2]),u;t.object.enabled&&(u=kr.execute(l)),YE=le();let c=await tbe(u,a,t);b1=c,J([o,i,l,...u]),r(c)}))}var lf=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],nbe=lf.length,of=lf.reduce((e,t,n)=>(e[t]=n,e),{}),sbe=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],yIe=sbe.map(([e,t])=>[of[e],of[t]]),eR=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function tR(e){let t=e.reduce(({maxX:n,maxY:s,minX:r,minY:a},{position:{x:o,y:i}})=>({maxX:Math.max(n,o),maxY:Math.max(s,i),minX:Math.min(r,o),minY:Math.min(a,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function nR(e,[t,n],[s,r]){let a=t/s,o=n/r,i=(u,c)=>({id:c,score:u.score,boxRaw:[u.box[0]/r,u.box[1]/s,u.box[2]/r,u.box[3]/s],box:[Math.trunc(u.box[0]*o),Math.trunc(u.box[1]*a),Math.trunc(u.box[2]*o),Math.trunc(u.box[3]*a)],keypoints:u.keypoints.map(({score:p,part:d,position:h})=>({score:p,part:d,position:[Math.trunc(h.x*o),Math.trunc(h.y*a)],positionRaw:[h.x/s,h.y/s]})),annotations:{}});return e.map((u,c)=>i(u,c))}var k1=class{constructor(t,n){ge(this,"priorityQueue");ge(this,"numberOfElements");ge(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=n}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let n=2*t;if(nn?n:e}function sR(e,t,n,s){let r=n-e,a=s-t;return r*r+a*a}function $4(e,t){return{x:e.x+t.x,y:e.y+t.y}}var Hs,abe=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],S1=1,_d=16,obe=50**2;function rR(e,t,n,s,r,a,o=2){let i=y=>({y:a.get(y.y,y.x,e),x:a.get(y.y,y.x,a.shape[2]/2+e)}),l=(y,x,A)=>({y:D4(Math.round(y.y/_d),0,x-1),x:D4(Math.round(y.x/_d),0,A-1)}),[u,c]=s.shape,p=l(t.position,u,c),d=i(p),f=$4(t.position,d);for(let y=0;y[of[d],of[h]]),o=a.map(([,d])=>d),i=a.map(([d])=>d),l=t.shape[2],u=o.length,c=new Array(l),p=_4(e.part,_d,n);c[e.part.id]={score:e.score,part:lf[e.part.id],position:p};for(let d=u-1;d>=0;--d){let h=o[d],f=i[d];c[h]&&!c[f]&&(c[f]=rR(d,c[h],f,t,n,r))}for(let d=0;dt){i=!1;break}if(!i)break}return i}function ube(e,t){let[n,s,r]=t.shape,a=new k1(n*s*r,({score:o})=>o);for(let o=0;o{var o;let a=(o=r[s])==null?void 0:o.position;return a?sR(n,t,a.y,a.x)<=obe:!1})}function cbe(e,t){return t.reduce((s,{position:r,score:a},o)=>(aR(e,r,o)||(s+=a),s),0)/t.length}function dbe(e,t,n,s,r,a){let o=[],i=ube(a,t);for(;o.lengthh.score>a);let p=cbe(o,c),d=tR(c);p>a&&o.push({keypoints:c,box:d,score:Math.round(100*p)/100})}return o}async function F4(e,t){if(!(Hs!=null&&Hs.executor))return[];let n=Z(()=>{if(!Hs.inputs[0].shape)return[];let o=Ie.resizeBilinear(e,[Hs.inputs[0].shape[2],Hs.inputs[0].shape[1]]),i=me(fe(ye(o,"float32"),127.5),1),u=Hs.execute(i,abe).map(c=>rt(c,[0]));return u[1]=$n(u[1]),u}),s=await Promise.all(n.map(o=>o.buffer()));for(let o of n)J(o);let r=dbe(s[0],s[1],s[2],s[3],t.body.maxDetected,t.body.minConfidence);return Hs.inputs[0].shape?nR(r,[e.shape[1],e.shape[2]],[Hs.inputs[0].shape[2],Hs.inputs[0].shape[1]]):[]}async function oR(e){return!Hs||he.initial?Hs=await je(e.body.modelPath):e.debug&&ae("cached model:",Hs.modelUrl),Hs}var ua,P4=!1;async function O4(e){return!ua||he.initial?ua=await je(e.segmentation.modelPath):e.debug&&ae("cached model:",ua.modelUrl),ua}async function lR(e,t,n){var m,g;if(P4)return{data:[],canvas:null,alpha:null};P4=!0,ua||await O4(n);let s=await bd(e,n),r=((m=s.tensor)==null?void 0:m.shape[2])||0,a=((g=s.tensor)==null?void 0:g.shape[1])||0;if(!s.tensor)return{data:[],canvas:null,alpha:null};let o={};o.resize=Ie.resizeBilinear(s.tensor,[ua.inputs[0].shape?ua.inputs[0].shape[1]:0,ua.inputs[0].shape?ua.inputs[0].shape[2]:0],!1),J(s.tensor),o.norm=fe(o.resize,at.tf255),o.res=ua.execute(o.norm),o.squeeze=rt(o.res,0),o.squeeze.shape[2]===2?(o.softmax=iu(o.squeeze),[o.bg,o.fg]=On(o.softmax,2),o.expand=Bt(o.fg,2),o.pad=Bt(o.expand,0),o.crop=Ie.cropAndResize(o.pad,[[0,0,.5,.5]],[0],[r,a]),o.data=rt(o.crop,0)):o.data=Ie.resizeBilinear(o.squeeze,[a,r]);let i=Array.from(await o.data.data());if(he.node&&!he.Canvas&&typeof ImageData=="undefined")return n.debug&&ae("canvas support missing"),Object.keys(o).forEach(y=>J(o[y])),{data:i,canvas:null,alpha:null};let l=ds(r,a);nr&&await nr.toPixels(o.data,l);let u=l.getContext("2d");n.segmentation.blur&&n.segmentation.blur>0&&(u.filter=`blur(${n.segmentation.blur}px)`);let c=u.getImageData(0,0,r,a),p=ds(r,a),d=p.getContext("2d");s.canvas&&d.drawImage(s.canvas,0,0),d.globalCompositeOperation="darken",n.segmentation.blur&&n.segmentation.blur>0&&(d.filter=`blur(${n.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let h=d.getImageData(0,0,r,a);for(let y=0;yJ(o[y])),P4=!1,{data:i,canvas:p,alpha:l}}var uf=class{constructor(){ge(this,"ssrnetage",null);ge(this,"gear",null);ge(this,"blazeposedetect",null);ge(this,"blazepose",null);ge(this,"centernet",null);ge(this,"efficientpose",null);ge(this,"mobilefacenet",null);ge(this,"insightface",null);ge(this,"emotion",null);ge(this,"facedetect",null);ge(this,"faceiris",null);ge(this,"facemesh",null);ge(this,"faceres",null);ge(this,"ssrnetgender",null);ge(this,"handpose",null);ge(this,"handskeleton",null);ge(this,"handtrack",null);ge(this,"liveness",null);ge(this,"movenet",null);ge(this,"nanodet",null);ge(this,"posenet",null);ge(this,"segmentation",null);ge(this,"antispoof",null)}},M4=e=>{let t=0,n=0,s=0;for(let a of Object.values(qr))t+=a.sizeFromManifest,n+=a.sizeLoadedWeights,s+=a.sizeDesired;let r=s>0?n/s:0;return{numLoadedModels:Object.values(qr).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:n,totalSizeLoading:s,totalSizeEnabled:void 0,modelStats:Object.values(qr)}};function h1(e){for(let t of Object.keys(e.models))e.models[t]=null}async function z4(e){var t,n,s,r,a,o,i,l,u,c,p,d,h,f,m,g,y,x,A,b,w,S,k,E,_,D;he.initial&&h1(e),e.config.hand.enabled&&(!e.models.handpose&&((n=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:n.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await g4(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(s=e.config.hand.detector)==null?void 0:s.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await g4(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=e.config.body.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=CN(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=IN(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((o=e.config.body.modelPath)==null?void 0:o.includes("efficientpose"))&&(e.models.efficientpose=DN(e.config)),e.config.body.enabled&&!e.models.movenet&&((i=e.config.body.modelPath)==null?void 0:i.includes("movenet"))&&(e.models.movenet=KE(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=oR(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=gN(e.config)),e.config.face.enabled&&((u=e.config.face.antispoof)==null?void 0:u.enabled)&&!e.models.antispoof&&(e.models.antispoof=sN(e.config)),e.config.face.enabled&&((c=e.config.face.liveness)==null?void 0:c.enabled)&&!e.models.liveness&&(e.models.liveness=UE(e.config)),e.config.face.enabled&&((p=e.config.face.description)==null?void 0:p.enabled)&&!e.models.faceres&&(e.models.faceres=lE(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=ON(e.config)),e.config.face.enabled&&((h=e.config.face.iris)==null?void 0:h.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=YN(e.config)),e.config.face.enabled&&((m=e.config.face.mesh)==null?void 0:m.enabled)&&!e.models.facemesh&&(e.models.facemesh=sE(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=GT(e.config)),e.config.face.enabled&&((y=e.config.face.ssrnet)==null?void 0:y.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=KT(e.config)),e.config.face.enabled&&((x=e.config.face.ssrnet)==null?void 0:x.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=QT(e.config)),e.config.face.enabled&&((A=e.config.face.mobilefacenet)==null?void 0:A.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=WN(e.config)),e.config.face.enabled&&((b=e.config.face.insightface)==null?void 0:b.enabled)&&!e.models.insightface&&(e.models.insightface=jN(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((S=(w=e.config.hand.detector)==null?void 0:w.modelPath)==null?void 0:S.includes("handtrack"))&&(e.models.handtrack=zE(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((E=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:E.includes("handtrack"))&&(e.models.handskeleton=LE(e.config)),e.config.object.enabled&&!e.models.centernet&&((_=e.config.object.modelPath)==null?void 0:_.includes("centernet"))&&(e.models.centernet=EN(e.config)),e.config.object.enabled&&!e.models.nanodet&&((D=e.config.object.modelPath)==null?void 0:D.includes("nanodet"))&&(e.models.nanodet=JE(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=O4(e.config));for await(let R of Object.keys(e.models))e.models[R]&&typeof e.models[R]!="undefined"&&(e.models[R]=await e.models[R])}var ir;function Dd(e,t,n){var u;if(e&&(ir=e),!t||(ir||ae("instance not registred"),!ir.config.validateModels))return null;let s=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],a=[],o=[],i=t.modelUrl,l=t.executor;if((u=l==null?void 0:l.graph)!=null&&u.nodes)for(let c of Object.values(l.graph.nodes)){let p=c.op.toLowerCase();a.includes(p)||a.push(p)}else!l&&ir.config.debug&&ae("model not loaded",n);for(let c of a)!s.includes(c)&&!r.includes(c)&&!ir.env.kernels.includes(c)&&!ir.env.kernels.includes(c.replace("_",""))&&!ir.env.kernels.includes(c.replace("native",""))&&!ir.env.kernels.includes(c.replace("v2",""))&&o.push(c);return ir.config.debug&&o.length>0&&ae("model validation failed:",n,o),o.length>0?{name:n,missing:o,ops:a,url:i}:null}function I1(e){ir=e;let t=[];for(let n of Object.keys(ir.models)){let s=ir.models[n];if(!s)continue;let r=Dd(ir,s,n);r&&t.push(r)}return t}var ks={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},qr={};async function pbe(e,t){return ks.debug&&ae("load model fetch:",e,t),fetch(e,t)}function cR(e){ks.cacheModels=e.cacheModels,ks.verbose=e.debug,ks.modelBasePath=e.modelBasePath}async function je(e){var u,c,p;let t=wv(ks.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let n=t.includes("/")?t.split("/"):t.split("\\"),s=n[n.length-1].replace(".json",""),r="indexeddb://"+s;qr[s]={name:s,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:Sb[s],inCache:!1},ks.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let a={};try{a=ks.cacheSupported&&ks.cacheModels?await _s.listModels():{}}catch(d){ks.cacheSupported=!1}qr[s].inCache=ks.cacheSupported&&ks.cacheModels&&Object.keys(a).includes(r);let o=typeof fetch=="undefined"?{}:{fetchFunc:(d,h)=>pbe(d,h)},i=new Bh(qr[s].inCache?r:t,o),l=!1;try{i.findIOHandler(),ks.debug&&ae("model load handler:",i.handler);let d=await i.handler.load();qr[s].sizeFromManifest=((u=d==null?void 0:d.weightData)==null?void 0:u.byteLength)||0,i.loadSync(d),qr[s].sizeLoadedWeights=((p=(c=i.artifacts)==null?void 0:c.weightData)==null?void 0:p.byteLength)||0,ks.verbose&&ae("load:",{model:s,url:i.modelUrl,bytes:qr[s].sizeLoadedWeights}),l=!0}catch(d){ae("error loading model:",t,d)}if(l&&ks.cacheModels&&ks.cacheSupported&&!qr[s].inCache)try{let d=await i.save(r);ae("model saved:",r,d)}catch(d){ae("error saving model:",t,d)}return Dd(null,i,`${e||""}`),i}var L4="2.10.1";var j4={};fa(j4,{all:()=>H4,body:()=>Fd,canvas:()=>G4,face:()=>$d,gesture:()=>Md,hand:()=>Pd,object:()=>Od,options:()=>Xn,person:()=>U4});var lr=e=>{if(!e)ae("draw error: invalid canvas");else if(!e.getContext)ae("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)ae("draw error: cannot get canvas context");else return t}return null},Nu=e=>Math.round(e*180/Math.PI),Ma=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let n=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t.alpha})`};function za(e,t,n,s,r){e.fillStyle=Ma(s,r),e.beginPath(),e.arc(t,n,r.pointSize,0,2*Math.PI),e.fill()}function ca(e,t,n,s,r,a){if(e.beginPath(),e.lineWidth=a.lineWidth,a.useCurves){let o=(t+t+s)/2,i=(n+n+r)/2;e.ellipse(o,i,s/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+a.roundRect,n),e.lineTo(t+s-a.roundRect,n),e.quadraticCurveTo(t+s,n,t+s,n+a.roundRect),e.lineTo(t+s,n+r-a.roundRect),e.quadraticCurveTo(t+s,n+r,t+s-a.roundRect,n+r),e.lineTo(t+a.roundRect,n+r),e.quadraticCurveTo(t,n+r,t,n+r-a.roundRect),e.lineTo(t,n+a.roundRect),e.quadraticCurveTo(t,n,t+a.roundRect,n),e.closePath();e.stroke()}function B4(e,t,n){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let s of t)e.strokeStyle=Ma(s[2]||0,n),e.lineTo(Math.trunc(s[0]),Math.trunc(s[1]));e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function dR(e,t,n){if(!(t.length<2)){if(e.lineWidth=n.lineWidth,!n.useCurves||t.length<=2){B4(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let s=0;s0){let a=e.emotion.map(o=>`${Math.trunc(100*o.score)}% ${o.emotion}`);a.length>3&&(a.length=3),r.push(a.join(" "))}((n=e.rotation)==null?void 0:n.angle)&&((s=e.rotation)==null?void 0:s.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${Nu(e.rotation.angle.roll)}\xB0 yaw:${Nu(e.rotation.angle.yaw)}\xB0 pitch:${Nu(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${Nu(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=ft.color;for(let a=r.length-1;a>=0;a--){let o=Math.max(e.box[0],0),i=a*ft.lineHeight+e.box[1];ft.shadowColor&&ft.shadowColor!==""&&(t.fillStyle=ft.shadowColor,t.fillText(r[a],o+5,i+16)),t.fillStyle=ft.labelColor,t.fillText(r[a],o+4,i+15)}}}function gbe(e,t){var n,s,r,a;if(((n=e.annotations)==null?void 0:n.leftEyeIris)&&((s=e.annotations)==null?void 0:s.leftEyeIris[0])){t.strokeStyle=ft.useDepth?"rgba(255, 200, 255, 0.3)":ft.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,i=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],o,i,0,0,2*Math.PI),t.stroke(),ft.fillPolygons&&(t.fillStyle=ft.useDepth?"rgba(255, 255, 200, 0.3)":ft.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((a=e.annotations)==null?void 0:a.rightEyeIris[0])){t.strokeStyle=ft.useDepth?"rgba(255, 200, 255, 0.3)":ft.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,i=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],o,i,0,0,2*Math.PI),t.stroke(),ft.fillPolygons&&(t.fillStyle=ft.useDepth?"rgba(255, 255, 200, 0.3)":ft.color,t.fill())}}function ybe(e,t){var n;if(ft.drawGaze&&((n=e.rotation)==null?void 0:n.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let s=e.box[0]+e.box[2]/2-e.box[3]*Nu(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Nu(e.rotation.angle.pitch)/90,a=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${s} ${e.box[1]}, diff --git a/dist/human.node-gpu.js b/dist/human.node-gpu.js index ca6e76cb3..9dc74183e 100644 --- a/dist/human.node-gpu.js +++ b/dist/human.node-gpu.js @@ -96,7 +96,7 @@ c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var N5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},O5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),N5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);N5(o,"uniform",this.uniform),N5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Ct(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new O5(i,Tt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?kt:wt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(St);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(Et);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var F2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function L5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function G2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>F2&&(A=F2,s=Math.trunc(A*r/n)),s>F2&&(s=F2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new Ct:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,G2(y0,d0))):(G2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=G2(d0),l=N.browser.fromPixels(Ue));else{let g=G2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await W2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function jt(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function It(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var W5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new W5;var w5=V(D());var F5={};pe(F5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>Q1,load:()=>_1,reset:()=>y5,validate:()=>T5,validateModel:()=>a2});var B2=V(D());var Z0,G5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Nt=0,Ot=0,B5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function H5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=B5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Ot;return t.skipAllowed&&A&&r&&Nt===n&&G5[o]?(B5++,G5[o]):(B5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=B2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mB2.dispose(c[m])),G5[o]=i,Nt=n,Ot=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Ft(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,H2=[],Gt=0,Bt=0,D5=Number.MAX_SAFE_INTEGER;async function Ht(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function V5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=D5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Bt;return t.skipAllowed&&r&&A&&Gt===n&&((l=H2[o])==null?void 0:l.age)&&((c=H2[o])==null?void 0:c.age)>0?(D5++,H2[o]):(D5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),H2[o]=d,Gt=n,Bt=v(),y(d)}))}var p0=V(D());var X0,D2=[],Vt=0,Zt=0,Z5=Number.MAX_SAFE_INTEGER,X5=[.2989,.587,.114];async function Xt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function q5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=Z5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Zt;return t.skipAllowed&&r&&A&&Vt===n&&((l=D2[o])==null?void 0:l.gender)&&((c=D2[o])==null?void 0:c.genderScore)>0?(Z5++,D2[o]):(Z5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,X5[0]),m=p0.mul(g,X5[1]),u=p0.mul(M,X5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),D2[o]=d,Vt=n,Zt=v(),y(d)}))}var Z2=V(D());var c0,V2=[],U5=Number.MAX_SAFE_INTEGER,Ut=0,Yt=0;async function Kt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function Y5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Yt,A=U5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ut===n&&V2[o]?(U5++,V2[o]):(U5=0,new Promise(async l=>{let c=Z2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];V2[o]=Math.round(100*i)/100,Ut=n,Yt=v(),Z2.dispose([c,y]),l(V2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},K5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},J5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],q2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],U2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],$t=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},_5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},Y2=(e,t)=>{let o=X2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},K2=e=>{let t=X2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},e3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},$5=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=Qt(t[0],t[1]),s=_t(A,r),a=Qt(-t[0],-t[1]);return _t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function o3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?t3(o,[0,0]):$5,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):$5,i=X2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function r3(e,t,o,n){let r=t.landmarks.length>=K5.count?K5.symmetryLine:Ne.symmetryLine,A=0,s=$5,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=X2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=t3(-A,c),a=_5(t,i,[n,n]),ie.dispose(i)}else a=_5(t,o,[n,n]);else a=_5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},A3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var s3=6,AA=1.4,J0,a3=null,ge=0,R2=null,Qe=()=>ge;async function i3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),a3=L.tensor2d(o3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,a3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function l3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],s3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[s3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=$t(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=Y2(g,t.face.scale||AA),P=K2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var J2={};pe(J2,{connected:()=>o1,kpt:()=>t1});var t1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],o1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),x3=224,aA,iA=5,Q2=[8,16,32,32,32];function y3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function d3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function _2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var p3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},n1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},e5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],f3=0,m3=e=>1-1/(1+Math.exp(e));async function u3(e){var t;if(p3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return y3(),u0.detector}async function h3(e){var t;if(p3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(o1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function r1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-f3,r=n1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&e5!==null)n1++;else{let A={};A.landmarks=xA(e,256),e5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),f3=v(),n1=0}return e5?[e5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,A1=[],g3=0,s1=Number.MAX_SAFE_INTEGER;async function M3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function a1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-g3,n=s1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&A1.length>0?(s1++,A1):(s1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;g3=v(),M0.dispose(s);let l=await mA(a,A,t);A1=l,r(l)}))}var Y=V(D());var t5={};pe(t5,{connected:()=>l1,kpt:()=>i1});var i1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],l1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,P3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},c1=Number.MAX_SAFE_INTEGER;async function R3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function x1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-P3,n=c1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(c1++,[v0]):(c1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),P3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:i1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(l1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,o5=[],w3=0,k3=0,y1=Number.MAX_SAFE_INTEGER;async function E3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function d1(e,t,o,n){var s,a;if(!G0)return[];let r=y1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-k3;return t.skipAllowed&&A&&r&&w3===n&&o5[o]&&o5[o].length>0?(y1++,o5[o]):(y1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),k3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}o5[o]=c,w3=n,l(c)}))}var n5=V(D());var C0,f1=[],S3=0,C3=0,j3=Number.MAX_SAFE_INTEGER;async function I3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function m1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=j3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-C3;return t.skipAllowed&&A&&r&&S3===n&&f1[o]?(j3++,f1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=n5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>n5.dispose(i[x]))}f1[o]=c,S3=n,C3=v(),l(c)})}var r5=V(D());var j0,p1=[],O3=0,L3=0,W3=Number.MAX_SAFE_INTEGER;async function F3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function u1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=W3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-L3;return t.skipAllowed&&A&&r&&O3===n&&p1[o]?(W3++,p1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}p1[o]=c,O3=n,L3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,h1=q0.leftEyeLower0,b1=q0.rightEyeLower0,e2={leftBounds:[h1[0],h1[h1.length-1]],rightBounds:[b1[0],b1[b1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function V3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function A5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},B3=(e,t,o,n,r,A=!1)=>{let s=K2(Y2(e3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},H3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function Z3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=B3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=B3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=H3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=H3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(A5(e,x,"left",null),A5(e,g,"right",null)):P<1?A5(e,x,"left",["EyeUpper0","EyeLower0"]):A5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=D3(e,f,"left"),u=D3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function U3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await l3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await U3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await Z3(Z,w.tensor,k2)),w.mesh=n3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...A3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=q2(O,e),w.boxRaw=U2(O,e),A.push(O)}Re.dispose(h)}else{w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function K3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var J3=Oe,Q3=P2;var $0=V(D());var h0,Te=[],_3=0,$3=0,M1=Number.MAX_SAFE_INTEGER;async function eo(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function v1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function P1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=M1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-_3;return t.skipAllowed&&A&&s&&$3===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(M1++,Te[o]):(M1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=v1(e),f=h0==null?void 0:h0.execute(x);_3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,$3=n,i(r)}))}var G=V(D());var no=V(D());function s5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function ro(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return no.image.cropAndResize(t,A,[0],o)}function Ao(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function a5(e,t=1.5){let o=E2(e),n=s5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function i5(e){let t=E2(e),o=s5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function so(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var to=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=Ao(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,co=1.65,xo=[0,5,9,13,17,1,2],LA=0,WA=2,yo=0,c5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>w1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return a5(i5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=a5(i5(o),co);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=T1(n,[0,0]),c=a.map(x=>[...w1(x,l),x[2]]),y=ao(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-yo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=a5(i5(c),co),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:k1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,k1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,k1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,k1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var fo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function mo(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function uo(e,t){if(!e||!t)return[0,0];let o=mo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=mo(e[1],e[2],t[1],t[2]);return[o,n]}function po(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function ho(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function bo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=bo(e,t,o,n),y=ho(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=uo([u,k],[w,h]),W=po(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=po(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=bo(l,a,c,i):f===Math.max(x,f)?Z=ho(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function go(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=uo(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function x5(e){if(!e||e.length===0)return null;let t=go(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function Mo(e){let t=[];if(!e||e.length===0)return t;let o=go(e);for(let n of fo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var vo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Po;async function z1(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=x5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function S1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new l5(Ve):void 0;return t&&Ze&&(Po=new c5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function To(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),y5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var ko={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(To(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(ko=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))ko[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Ft(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function d5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],zo=4,So=1.6,JA=512,QA=1.4,f5=Number.MAX_SAFE_INTEGER,C1=0,ye=[0,0],A0={boxes:[],hands:[]},Co={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function jo(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{d5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function Io(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[zo]),a.splice(zo,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=_2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function j1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=x5(n.keypoints);for(let i of Object.keys(Co))n.annotations[i]=Co[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function I1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],f5++;let o=(t.hand.skipTime||0)>v()-C1,n=f5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-C1,l=f5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):(A0.boxes=await _A(e,t),C1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))),f5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=_2(i.box,So),x=_2(i.boxRaw,So);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Lo,A=N1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Oo===n&&m5[o]?(N1++,m5[o]):(N1=0,new Promise(async l=>{let c=p5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];m5[o]=Math.round(100*i)/100,Oo=n,Lo=v(),p5.dispose([c,y]),l(m5[o])}))}var Vo=V(D());var S2={};pe(S2,{connected:()=>h5,horizontal:()=>L1,kpt:()=>u5,relative:()=>F1,vertical:()=>W1});var u5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],L1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],W1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],F1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],h5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Go=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function G1(e){for(let t of L1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Bo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Do(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,b5=0,B1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Zo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(d5(["size"],e),l0=await F(e.body.modelPath)),b5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,b5<64&&(b5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:u5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(h5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return G1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:u5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(h5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};G1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function H1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),B1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=B1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};B1=0,s.input=Ho(e,b5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Do(l,[e.shape[2]||1,e.shape[1]||1]),Bo(l.keypoints);Object.keys(s).forEach(l=>Vo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,g5=[],qo=0,D1=Number.MAX_SAFE_INTEGER,v5=0,M5=2.5;async function Uo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;v5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=v5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-M5/c*w[0],k-M5/c*w[1]],[X,I]=[u+M5/c*w[2]-h,k+M5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function V1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-qo,n=D1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&g5.length>0?(D1++,g5):(D1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?g5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[v5,v5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),qo=v();let y=await o7(c,A,t);g5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Ko=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Jo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Qo(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var P5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function _o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function U1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],R5=1,s2=16,a7=50**2;function $o(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:q1(Math.round(M.y/s2),0,P-1),x:q1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=U1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=X1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=$o(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new P5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?_o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(en(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Jo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function Y1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?Qo(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function tn(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,K1=!1;async function J1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function nn(e,t,o){var p,g;if(K1)return{data:[],canvas:null,alpha:null};K1=!0,se||await J1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),K1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},Q1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function y5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function _1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&y5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=h3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=u3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=R3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Zo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=tn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=i3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Kt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Wo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=eo(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=E3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=V3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=K3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Lt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ht(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Xt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=I3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=F3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=jo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=Io(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=M3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Uo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=J1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function T5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function An(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=vt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:F5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await w5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new w5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var $1="2.10.0";var st={};pe(st,{all:()=>At,body:()=>l2,canvas:()=>rt,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>nt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function et(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function sn(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){et(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var N5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},O5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),N5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);N5(o,"uniform",this.uniform),N5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Ct(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new O5(i,Tt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?kt:wt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(St);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(Et);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var F2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function L5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function G2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>F2&&(A=F2,s=Math.trunc(A*r/n)),s>F2&&(s=F2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new Ct:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,G2(y0,d0))):(G2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=G2(d0),l=N.browser.fromPixels(Ue));else{let g=G2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await W2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function jt(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function It(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var W5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new W5;var w5=V(D());var F5={};pe(F5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>Q1,load:()=>_1,reset:()=>y5,validate:()=>T5,validateModel:()=>a2});var B2=V(D());var Z0,G5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Nt=0,Ot=0,B5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function H5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=B5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Ot;return t.skipAllowed&&A&&r&&Nt===n&&G5[o]?(B5++,G5[o]):(B5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=B2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mB2.dispose(c[m])),G5[o]=i,Nt=n,Ot=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Ft(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,H2=[],Gt=0,Bt=0,D5=Number.MAX_SAFE_INTEGER;async function Ht(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function V5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=D5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Bt;return t.skipAllowed&&r&&A&&Gt===n&&((l=H2[o])==null?void 0:l.age)&&((c=H2[o])==null?void 0:c.age)>0?(D5++,H2[o]):(D5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),H2[o]=d,Gt=n,Bt=v(),y(d)}))}var p0=V(D());var X0,D2=[],Vt=0,Zt=0,Z5=Number.MAX_SAFE_INTEGER,X5=[.2989,.587,.114];async function Xt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function q5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=Z5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Zt;return t.skipAllowed&&r&&A&&Vt===n&&((l=D2[o])==null?void 0:l.gender)&&((c=D2[o])==null?void 0:c.genderScore)>0?(Z5++,D2[o]):(Z5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,X5[0]),m=p0.mul(g,X5[1]),u=p0.mul(M,X5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),D2[o]=d,Vt=n,Zt=v(),y(d)}))}var Z2=V(D());var c0,V2=[],U5=Number.MAX_SAFE_INTEGER,Ut=0,Yt=0;async function Kt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function Y5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Yt,A=U5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ut===n&&V2[o]?(U5++,V2[o]):(U5=0,new Promise(async l=>{let c=Z2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];V2[o]=Math.round(100*i)/100,Ut=n,Yt=v(),Z2.dispose([c,y]),l(V2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},K5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},J5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],q2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],U2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],$t=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},_5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},Y2=(e,t)=>{let o=X2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},K2=e=>{let t=X2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},e3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},$5=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=Qt(t[0],t[1]),s=_t(A,r),a=Qt(-t[0],-t[1]);return _t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function o3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?t3(o,[0,0]):$5,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):$5,i=X2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function r3(e,t,o,n){let r=t.landmarks.length>=K5.count?K5.symmetryLine:Ne.symmetryLine,A=0,s=$5,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=X2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=t3(-A,c),a=_5(t,i,[n,n]),ie.dispose(i)}else a=_5(t,o,[n,n]);else a=_5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},A3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var s3=6,AA=1.4,J0,a3=null,ge=0,R2=null,Qe=()=>ge;async function i3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),a3=L.tensor2d(o3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,a3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function l3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],s3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[s3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=$t(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=Y2(g,t.face.scale||AA),P=K2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var J2={};pe(J2,{connected:()=>o1,kpt:()=>t1});var t1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],o1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),x3=224,aA,iA=5,Q2=[8,16,32,32,32];function y3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function d3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function _2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var p3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},n1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},e5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],f3=0,m3=e=>1-1/(1+Math.exp(e));async function u3(e){var t;if(p3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return y3(),u0.detector}async function h3(e){var t;if(p3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(o1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function r1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-f3,r=n1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&e5!==null)n1++;else{let A={};A.landmarks=xA(e,256),e5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),f3=v(),n1=0}return e5?[e5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,A1=[],g3=0,s1=Number.MAX_SAFE_INTEGER;async function M3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function a1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-g3,n=s1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&A1.length>0?(s1++,A1):(s1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;g3=v(),M0.dispose(s);let l=await mA(a,A,t);A1=l,r(l)}))}var Y=V(D());var t5={};pe(t5,{connected:()=>l1,kpt:()=>i1});var i1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],l1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,P3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},c1=Number.MAX_SAFE_INTEGER;async function R3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function x1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-P3,n=c1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(c1++,[v0]):(c1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),P3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:i1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(l1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,o5=[],w3=0,k3=0,y1=Number.MAX_SAFE_INTEGER;async function E3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function d1(e,t,o,n){var s,a;if(!G0)return[];let r=y1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-k3;return t.skipAllowed&&A&&r&&w3===n&&o5[o]&&o5[o].length>0?(y1++,o5[o]):(y1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),k3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}o5[o]=c,w3=n,l(c)}))}var n5=V(D());var C0,f1=[],S3=0,C3=0,j3=Number.MAX_SAFE_INTEGER;async function I3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function m1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=j3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-C3;return t.skipAllowed&&A&&r&&S3===n&&f1[o]?(j3++,f1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=n5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>n5.dispose(i[x]))}f1[o]=c,S3=n,C3=v(),l(c)})}var r5=V(D());var j0,p1=[],O3=0,L3=0,W3=Number.MAX_SAFE_INTEGER;async function F3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function u1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=W3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-L3;return t.skipAllowed&&A&&r&&O3===n&&p1[o]?(W3++,p1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}p1[o]=c,O3=n,L3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,h1=q0.leftEyeLower0,b1=q0.rightEyeLower0,e2={leftBounds:[h1[0],h1[h1.length-1]],rightBounds:[b1[0],b1[b1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function V3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function A5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},B3=(e,t,o,n,r,A=!1)=>{let s=K2(Y2(e3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},H3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function Z3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=B3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=B3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=H3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=H3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(A5(e,x,"left",null),A5(e,g,"right",null)):P<1?A5(e,x,"left",["EyeUpper0","EyeLower0"]):A5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=D3(e,f,"left"),u=D3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function U3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await l3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await U3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await Z3(Z,w.tensor,k2)),w.mesh=n3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...A3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=q2(O,e),w.boxRaw=U2(O,e),A.push(O)}Re.dispose(h)}else{w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function K3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var J3=Oe,Q3=P2;var $0=V(D());var h0,Te=[],_3=0,$3=0,M1=Number.MAX_SAFE_INTEGER;async function eo(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function v1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function P1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=M1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-_3;return t.skipAllowed&&A&&s&&$3===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(M1++,Te[o]):(M1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=v1(e),f=h0==null?void 0:h0.execute(x);_3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,$3=n,i(r)}))}var G=V(D());var no=V(D());function s5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function ro(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return no.image.cropAndResize(t,A,[0],o)}function Ao(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function a5(e,t=1.5){let o=E2(e),n=s5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function i5(e){let t=E2(e),o=s5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function so(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var to=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=Ao(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,co=1.65,xo=[0,5,9,13,17,1,2],LA=0,WA=2,yo=0,c5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>w1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return a5(i5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=a5(i5(o),co);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=T1(n,[0,0]),c=a.map(x=>[...w1(x,l),x[2]]),y=ao(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-yo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=a5(i5(c),co),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:k1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,k1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,k1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,k1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var fo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function mo(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function uo(e,t){if(!e||!t)return[0,0];let o=mo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=mo(e[1],e[2],t[1],t[2]);return[o,n]}function po(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function ho(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function bo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=bo(e,t,o,n),y=ho(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=uo([u,k],[w,h]),W=po(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=po(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=bo(l,a,c,i):f===Math.max(x,f)?Z=ho(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function go(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=uo(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function x5(e){if(!e||e.length===0)return null;let t=go(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function Mo(e){let t=[];if(!e||e.length===0)return t;let o=go(e);for(let n of fo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var vo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Po;async function z1(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=x5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function S1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new l5(Ve):void 0;return t&&Ze&&(Po=new c5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function To(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),y5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var ko={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(To(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(ko=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))ko[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Ft(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function d5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],zo=4,So=1.6,JA=512,QA=1.4,f5=Number.MAX_SAFE_INTEGER,C1=0,ye=[0,0],A0={boxes:[],hands:[]},Co={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function jo(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{d5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function Io(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[zo]),a.splice(zo,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=_2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function j1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=x5(n.keypoints);for(let i of Object.keys(Co))n.annotations[i]=Co[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function I1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],f5++;let o=(t.hand.skipTime||0)>v()-C1,n=f5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-C1,l=f5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):(A0.boxes=await _A(e,t),C1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))),f5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=_2(i.box,So),x=_2(i.boxRaw,So);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Lo,A=N1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Oo===n&&m5[o]?(N1++,m5[o]):(N1=0,new Promise(async l=>{let c=p5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];m5[o]=Math.round(100*i)/100,Oo=n,Lo=v(),p5.dispose([c,y]),l(m5[o])}))}var Vo=V(D());var S2={};pe(S2,{connected:()=>h5,horizontal:()=>L1,kpt:()=>u5,relative:()=>F1,vertical:()=>W1});var u5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],L1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],W1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],F1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],h5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Go=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function G1(e){for(let t of L1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Bo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Do(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,b5=0,B1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Zo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(d5(["size"],e),l0=await F(e.body.modelPath)),b5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,b5<64&&(b5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:u5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(h5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return G1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:u5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(h5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};G1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function H1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),B1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=B1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};B1=0,s.input=Ho(e,b5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Do(l,[e.shape[2]||1,e.shape[1]||1]),Bo(l.keypoints);Object.keys(s).forEach(l=>Vo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,g5=[],qo=0,D1=Number.MAX_SAFE_INTEGER,v5=0,M5=2.5;async function Uo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;v5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=v5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-M5/c*w[0],k-M5/c*w[1]],[X,I]=[u+M5/c*w[2]-h,k+M5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function V1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-qo,n=D1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&g5.length>0?(D1++,g5):(D1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?g5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[v5,v5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),qo=v();let y=await o7(c,A,t);g5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Ko=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Jo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Qo(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var P5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function _o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function U1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],R5=1,s2=16,a7=50**2;function $o(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:q1(Math.round(M.y/s2),0,P-1),x:q1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=U1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=X1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=$o(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new P5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?_o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(en(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Jo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function Y1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?Qo(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function tn(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,K1=!1;async function J1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function nn(e,t,o){var p,g;if(K1)return{data:[],canvas:null,alpha:null};K1=!0,se||await J1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),K1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},Q1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function y5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function _1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&y5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=h3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=u3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=R3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Zo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=tn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=i3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Kt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Wo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=eo(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=E3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=V3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=K3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Lt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ht(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Xt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=I3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=F3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=jo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=Io(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=M3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Uo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=J1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function T5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function An(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=vt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:F5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await w5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new w5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var $1="2.10.1";var st={};pe(st,{all:()=>At,body:()=>l2,canvas:()=>rt,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>nt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function et(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function sn(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){et(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${n} ${e.box[1]}, diff --git a/dist/human.node-wasm.js b/dist/human.node-wasm.js index 29d830073..abc46a215 100644 --- a/dist/human.node-wasm.js +++ b/dist/human.node-wasm.js @@ -96,7 +96,7 @@ c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var O5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},L5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),O5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);O5(o,"uniform",this.uniform),O5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function jt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new L5(i,wt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?Et:kt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(Ct);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(St);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var G2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function W5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function B2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>G2&&(A=G2,s=Math.trunc(A*r/n)),s>G2&&(s=G2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new jt:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,B2(y0,d0))):(B2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=B2(d0),l=N.browser.fromPixels(Ue));else{let g=B2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await F2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function It(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Nt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var F5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new F5;var k5=V(D());var G5={};pe(G5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>_1,load:()=>$1,reset:()=>d5,validate:()=>w5,validateModel:()=>a2});var H2=V(D());var Z0,B5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Ot=0,Lt=0,H5=Number.MAX_SAFE_INTEGER;async function Wt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function D5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=H5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Lt;return t.skipAllowed&&A&&r&&Ot===n&&B5[o]?(H5++,B5[o]):(H5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=H2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mH2.dispose(c[m])),B5[o]=i,Ot=n,Lt=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Gt(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,D2=[],Bt=0,Ht=0,V5=Number.MAX_SAFE_INTEGER;async function Dt(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function Z5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=V5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Ht;return t.skipAllowed&&r&&A&&Bt===n&&((l=D2[o])==null?void 0:l.age)&&((c=D2[o])==null?void 0:c.age)>0?(V5++,D2[o]):(V5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),D2[o]=d,Bt=n,Ht=v(),y(d)}))}var p0=V(D());var X0,V2=[],Zt=0,Xt=0,X5=Number.MAX_SAFE_INTEGER,q5=[.2989,.587,.114];async function qt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function U5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=X5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Xt;return t.skipAllowed&&r&&A&&Zt===n&&((l=V2[o])==null?void 0:l.gender)&&((c=V2[o])==null?void 0:c.genderScore)>0?(X5++,V2[o]):(X5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,q5[0]),m=p0.mul(g,q5[1]),u=p0.mul(M,q5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),V2[o]=d,Zt=n,Xt=v(),y(d)}))}var X2=V(D());var c0,Z2=[],Y5=Number.MAX_SAFE_INTEGER,Yt=0,Kt=0;async function Jt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function K5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Kt,A=Y5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Yt===n&&Z2[o]?(Y5++,Z2[o]):(Y5=0,new Promise(async l=>{let c=X2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];Z2[o]=Math.round(100*i)/100,Yt=n,Kt=v(),X2.dispose([c,y]),l(Z2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},J5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Q5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],q2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],U2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],Y2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],e3=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},$5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},K2=(e,t)=>{let o=q2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},J2=e=>{let t=q2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},t3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},e1=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var _t=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=_t(t[0],t[1]),s=$t(A,r),a=_t(-t[0],-t[1]);return $t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function n3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?o3(o,[0,0]):e1,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):e1,i=q2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function A3(e,t,o,n){let r=t.landmarks.length>=J5.count?J5.symmetryLine:Ne.symmetryLine,A=0,s=e1,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=q2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=o3(-A,c),a=$5(t,i,[n,n]),ie.dispose(i)}else a=$5(t,o,[n,n]);else a=$5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},s3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var a3=6,AA=1.4,J0,i3=null,ge=0,R2=null,Qe=()=>ge;async function l3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),i3=L.tensor2d(n3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,i3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function c3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],a3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[a3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=e3(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=K2(g,t.face.scale||AA),P=J2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var Q2={};pe(Q2,{connected:()=>n1,kpt:()=>o1});var o1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],n1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),y3=224,aA,iA=5,_2=[8,16,32,32,32];function d3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function f3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function $2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var u3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},r1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},t5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],m3=0,p3=e=>1-1/(1+Math.exp(e));async function h3(e){var t;if(u3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return d3(),u0.detector}async function b3(e){var t;if(u3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(n1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function A1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-m3,r=r1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&t5!==null)r1++;else{let A={};A.landmarks=xA(e,256),t5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),m3=v(),r1=0}return t5?[t5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,s1=[],M3=0,a1=Number.MAX_SAFE_INTEGER;async function v3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function i1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-M3,n=a1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&s1.length>0?(a1++,s1):(a1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;M3=v(),M0.dispose(s);let l=await mA(a,A,t);s1=l,r(l)}))}var Y=V(D());var o5={};pe(o5,{connected:()=>c1,kpt:()=>l1});var l1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],c1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,R3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},x1=Number.MAX_SAFE_INTEGER;async function T3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function y1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-R3,n=x1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(x1++,[v0]):(x1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),R3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:l1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(c1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,n5=[],k3=0,E3=0,d1=Number.MAX_SAFE_INTEGER;async function z3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function f1(e,t,o,n){var s,a;if(!G0)return[];let r=d1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-E3;return t.skipAllowed&&A&&r&&k3===n&&n5[o]&&n5[o].length>0?(d1++,n5[o]):(d1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),E3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}n5[o]=c,k3=n,l(c)}))}var r5=V(D());var C0,m1=[],C3=0,j3=0,I3=Number.MAX_SAFE_INTEGER;async function N3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function p1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=I3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-j3;return t.skipAllowed&&A&&r&&C3===n&&m1[o]?(I3++,m1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}m1[o]=c,C3=n,j3=v(),l(c)})}var A5=V(D());var j0,u1=[],L3=0,W3=0,F3=Number.MAX_SAFE_INTEGER;async function G3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function h1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=F3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-W3;return t.skipAllowed&&A&&r&&L3===n&&u1[o]?(F3++,u1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=A5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>A5.dispose(i[x]))}u1[o]=c,L3=n,W3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,b1=q0.leftEyeLower0,g1=q0.rightEyeLower0,e2={leftBounds:[b1[0],b1[b1.length-1]],rightBounds:[g1[0],g1[g1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function Z3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function s5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},H3=(e,t,o,n,r,A=!1)=>{let s=J2(K2(t3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},D3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function X3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=H3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=H3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=D3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=D3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(s5(e,x,"left",null),s5(e,g,"right",null)):P<1?s5(e,x,"left",["EyeUpper0","EyeLower0"]):s5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=V3(e,f,"left"),u=V3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function Y3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await c3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=U2(m,e),w.boxRaw=Y2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await Y3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await X3(Z,w.tensor,k2)),w.mesh=r3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...s3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=U2(O,e),w.boxRaw=Y2(O,e),A.push(O)}Re.dispose(h)}else{w.box=U2(m,e),w.boxRaw=Y2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function J3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var Q3=Oe,_3=P2;var $0=V(D());var h0,Te=[],$3=0,eo=0,v1=Number.MAX_SAFE_INTEGER;async function to(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function P1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function R1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=v1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-$3;return t.skipAllowed&&A&&s&&eo===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(v1++,Te[o]):(v1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=P1(e),f=h0==null?void 0:h0.execute(x);$3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,eo=n,i(r)}))}var G=V(D());var ro=V(D());function a5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Ao(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return ro.image.cropAndResize(t,A,[0],o)}function so(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function i5(e,t=1.5){let o=E2(e),n=a5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function l5(e){let t=E2(e),o=a5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function ao(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var oo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=so(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,xo=1.65,yo=[0,5,9,13,17,1,2],LA=0,WA=2,fo=0,x5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>k1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return i5(l5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=i5(l5(o),xo);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=w1(n,[0,0]),c=a.map(x=>[...k1(x,l),x[2]]),y=io(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-fo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=i5(l5(c),xo),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:E1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,E1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,E1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,E1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var mo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function po(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function ho(e,t){if(!e||!t)return[0,0];let o=po(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=po(e[1],e[2],t[1],t[2]);return[o,n]}function uo(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function bo(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function go(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=go(e,t,o,n),y=bo(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=ho([u,k],[w,h]),W=uo(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=uo(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=go(l,a,c,i):f===Math.max(x,f)?Z=bo(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function Mo(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=ho(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function y5(e){if(!e||e.length===0)return null;let t=Mo(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function vo(e){let t=[];if(!e||e.length===0)return t;let o=Mo(e);for(let n of mo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var Po={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Ro;async function S1(e,t){let o=await Ro.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=y5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function C1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new c5(Ve):void 0;return t&&Ze&&(Ro=new x5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function wo(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),d5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var Eo={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(wo(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(Eo=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))Eo[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Gt(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function f5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],So=4,Co=1.6,JA=512,QA=1.4,m5=Number.MAX_SAFE_INTEGER,j1=0,ye=[0,0],A0={boxes:[],hands:[]},jo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function Io(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{f5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function No(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[So]),a.splice(So,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=$2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function I1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=y5(n.keypoints);for(let i of Object.keys(jo))n.annotations[i]=jo[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function N1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],m5++;let o=(t.hand.skipTime||0)>v()-j1,n=m5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-j1,l=m5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))):(A0.boxes=await _A(e,t),j1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))),m5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=$2(i.box,Co),x=$2(i.boxRaw,Co);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Wo,A=O1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Lo===n&&p5[o]?(O1++,p5[o]):(O1=0,new Promise(async l=>{let c=u5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];p5[o]=Math.round(100*i)/100,Lo=n,Wo=v(),u5.dispose([c,y]),l(p5[o])}))}var Zo=V(D());var S2={};pe(S2,{connected:()=>b5,horizontal:()=>W1,kpt:()=>h5,relative:()=>G1,vertical:()=>F1});var h5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],W1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],F1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],G1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],b5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Bo=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function B1(e){for(let t of W1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Ho(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Vo(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,g5=0,H1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Xo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(f5(["size"],e),l0=await F(e.body.modelPath)),g5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,g5<64&&(g5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:h5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(b5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return B1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:h5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(b5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};B1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function D1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),H1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=H1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};H1=0,s.input=Do(e,g5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Vo(l,[e.shape[2]||1,e.shape[1]||1]),Ho(l.keypoints);Object.keys(s).forEach(l=>Zo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,M5=[],Uo=0,V1=Number.MAX_SAFE_INTEGER,P5=0,v5=2.5;async function Yo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;P5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=P5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-v5/c*w[0],k-v5/c*w[1]],[X,I]=[u+v5/c*w[2]-h,k+v5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function Z1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-Uo,n=V1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&M5.length>0?(V1++,M5):(V1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?M5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[P5,P5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),Uo=v();let y=await o7(c,A,t);M5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Jo=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Qo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function _o(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var R5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function $o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function Y1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],T5=1,s2=16,a7=50**2;function en(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:U1(Math.round(M.y/s2),0,P-1),x:U1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=Y1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=q1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=en(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new R5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?$o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(tn(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Qo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function K1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?_o(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function on(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,J1=!1;async function Q1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function rn(e,t,o){var p,g;if(J1)return{data:[],canvas:null,alpha:null};J1=!0,se||await Q1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),J1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},_1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function d5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function $1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&d5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await C1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await C1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=b3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=h3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=T3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Xo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=on(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=l3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Jt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Fo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=to(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=z3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=Z3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=J3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Wt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Dt(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=qt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=N3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=G3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=Io(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=No(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=v3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Yo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=Q1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function w5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function sn(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=Pt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:G5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await k5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new k5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var et="2.10.0";var at={};pe(at,{all:()=>st,body:()=>l2,canvas:()=>At,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>rt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function tt(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function an(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){tt(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var O5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},L5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),O5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);O5(o,"uniform",this.uniform),O5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function jt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new L5(i,wt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?Et:kt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(Ct);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(St);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var G2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function W5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function B2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>G2&&(A=G2,s=Math.trunc(A*r/n)),s>G2&&(s=G2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new jt:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,B2(y0,d0))):(B2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=B2(d0),l=N.browser.fromPixels(Ue));else{let g=B2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await F2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function It(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Nt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var F5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new F5;var k5=V(D());var G5={};pe(G5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>_1,load:()=>$1,reset:()=>d5,validate:()=>w5,validateModel:()=>a2});var H2=V(D());var Z0,B5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Ot=0,Lt=0,H5=Number.MAX_SAFE_INTEGER;async function Wt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function D5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=H5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Lt;return t.skipAllowed&&A&&r&&Ot===n&&B5[o]?(H5++,B5[o]):(H5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=H2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mH2.dispose(c[m])),B5[o]=i,Ot=n,Lt=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Gt(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,D2=[],Bt=0,Ht=0,V5=Number.MAX_SAFE_INTEGER;async function Dt(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function Z5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=V5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Ht;return t.skipAllowed&&r&&A&&Bt===n&&((l=D2[o])==null?void 0:l.age)&&((c=D2[o])==null?void 0:c.age)>0?(V5++,D2[o]):(V5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),D2[o]=d,Bt=n,Ht=v(),y(d)}))}var p0=V(D());var X0,V2=[],Zt=0,Xt=0,X5=Number.MAX_SAFE_INTEGER,q5=[.2989,.587,.114];async function qt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function U5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=X5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Xt;return t.skipAllowed&&r&&A&&Zt===n&&((l=V2[o])==null?void 0:l.gender)&&((c=V2[o])==null?void 0:c.genderScore)>0?(X5++,V2[o]):(X5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,q5[0]),m=p0.mul(g,q5[1]),u=p0.mul(M,q5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),V2[o]=d,Zt=n,Xt=v(),y(d)}))}var X2=V(D());var c0,Z2=[],Y5=Number.MAX_SAFE_INTEGER,Yt=0,Kt=0;async function Jt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function K5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Kt,A=Y5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Yt===n&&Z2[o]?(Y5++,Z2[o]):(Y5=0,new Promise(async l=>{let c=X2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];Z2[o]=Math.round(100*i)/100,Yt=n,Kt=v(),X2.dispose([c,y]),l(Z2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},J5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Q5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],q2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],U2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],Y2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],e3=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},$5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},K2=(e,t)=>{let o=q2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},J2=e=>{let t=q2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},t3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},e1=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var _t=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=_t(t[0],t[1]),s=$t(A,r),a=_t(-t[0],-t[1]);return $t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function n3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?o3(o,[0,0]):e1,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):e1,i=q2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function A3(e,t,o,n){let r=t.landmarks.length>=J5.count?J5.symmetryLine:Ne.symmetryLine,A=0,s=e1,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=q2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=o3(-A,c),a=$5(t,i,[n,n]),ie.dispose(i)}else a=$5(t,o,[n,n]);else a=$5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},s3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var a3=6,AA=1.4,J0,i3=null,ge=0,R2=null,Qe=()=>ge;async function l3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),i3=L.tensor2d(n3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,i3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function c3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],a3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[a3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=e3(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=K2(g,t.face.scale||AA),P=J2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var Q2={};pe(Q2,{connected:()=>n1,kpt:()=>o1});var o1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],n1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),y3=224,aA,iA=5,_2=[8,16,32,32,32];function d3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function f3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function $2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var u3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},r1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},t5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],m3=0,p3=e=>1-1/(1+Math.exp(e));async function h3(e){var t;if(u3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return d3(),u0.detector}async function b3(e){var t;if(u3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(n1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function A1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-m3,r=r1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&t5!==null)r1++;else{let A={};A.landmarks=xA(e,256),t5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),m3=v(),r1=0}return t5?[t5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,s1=[],M3=0,a1=Number.MAX_SAFE_INTEGER;async function v3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function i1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-M3,n=a1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&s1.length>0?(a1++,s1):(a1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;M3=v(),M0.dispose(s);let l=await mA(a,A,t);s1=l,r(l)}))}var Y=V(D());var o5={};pe(o5,{connected:()=>c1,kpt:()=>l1});var l1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],c1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,R3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},x1=Number.MAX_SAFE_INTEGER;async function T3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function y1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-R3,n=x1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(x1++,[v0]):(x1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),R3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:l1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(c1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,n5=[],k3=0,E3=0,d1=Number.MAX_SAFE_INTEGER;async function z3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function f1(e,t,o,n){var s,a;if(!G0)return[];let r=d1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-E3;return t.skipAllowed&&A&&r&&k3===n&&n5[o]&&n5[o].length>0?(d1++,n5[o]):(d1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),E3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}n5[o]=c,k3=n,l(c)}))}var r5=V(D());var C0,m1=[],C3=0,j3=0,I3=Number.MAX_SAFE_INTEGER;async function N3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function p1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=I3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-j3;return t.skipAllowed&&A&&r&&C3===n&&m1[o]?(I3++,m1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}m1[o]=c,C3=n,j3=v(),l(c)})}var A5=V(D());var j0,u1=[],L3=0,W3=0,F3=Number.MAX_SAFE_INTEGER;async function G3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function h1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=F3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-W3;return t.skipAllowed&&A&&r&&L3===n&&u1[o]?(F3++,u1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=A5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>A5.dispose(i[x]))}u1[o]=c,L3=n,W3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,b1=q0.leftEyeLower0,g1=q0.rightEyeLower0,e2={leftBounds:[b1[0],b1[b1.length-1]],rightBounds:[g1[0],g1[g1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function Z3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function s5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},H3=(e,t,o,n,r,A=!1)=>{let s=J2(K2(t3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},D3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function X3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=H3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=H3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=D3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=D3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(s5(e,x,"left",null),s5(e,g,"right",null)):P<1?s5(e,x,"left",["EyeUpper0","EyeLower0"]):s5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=V3(e,f,"left"),u=V3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function Y3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await c3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=U2(m,e),w.boxRaw=Y2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await Y3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await X3(Z,w.tensor,k2)),w.mesh=r3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...s3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=U2(O,e),w.boxRaw=Y2(O,e),A.push(O)}Re.dispose(h)}else{w.box=U2(m,e),w.boxRaw=Y2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function J3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var Q3=Oe,_3=P2;var $0=V(D());var h0,Te=[],$3=0,eo=0,v1=Number.MAX_SAFE_INTEGER;async function to(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function P1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function R1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=v1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-$3;return t.skipAllowed&&A&&s&&eo===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(v1++,Te[o]):(v1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=P1(e),f=h0==null?void 0:h0.execute(x);$3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,eo=n,i(r)}))}var G=V(D());var ro=V(D());function a5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Ao(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return ro.image.cropAndResize(t,A,[0],o)}function so(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function i5(e,t=1.5){let o=E2(e),n=a5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function l5(e){let t=E2(e),o=a5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function ao(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var oo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=so(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,xo=1.65,yo=[0,5,9,13,17,1,2],LA=0,WA=2,fo=0,x5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>k1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return i5(l5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=i5(l5(o),xo);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=w1(n,[0,0]),c=a.map(x=>[...k1(x,l),x[2]]),y=io(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-fo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=i5(l5(c),xo),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:E1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,E1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,E1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,E1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var mo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function po(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function ho(e,t){if(!e||!t)return[0,0];let o=po(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=po(e[1],e[2],t[1],t[2]);return[o,n]}function uo(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function bo(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function go(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=go(e,t,o,n),y=bo(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=ho([u,k],[w,h]),W=uo(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=uo(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=go(l,a,c,i):f===Math.max(x,f)?Z=bo(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function Mo(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=ho(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function y5(e){if(!e||e.length===0)return null;let t=Mo(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function vo(e){let t=[];if(!e||e.length===0)return t;let o=Mo(e);for(let n of mo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var Po={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Ro;async function S1(e,t){let o=await Ro.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=y5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function C1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new c5(Ve):void 0;return t&&Ze&&(Ro=new x5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function wo(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),d5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var Eo={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(wo(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(Eo=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))Eo[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Gt(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function f5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],So=4,Co=1.6,JA=512,QA=1.4,m5=Number.MAX_SAFE_INTEGER,j1=0,ye=[0,0],A0={boxes:[],hands:[]},jo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function Io(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{f5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function No(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[So]),a.splice(So,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=$2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function I1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=y5(n.keypoints);for(let i of Object.keys(jo))n.annotations[i]=jo[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function N1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],m5++;let o=(t.hand.skipTime||0)>v()-j1,n=m5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-j1,l=m5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))):(A0.boxes=await _A(e,t),j1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>I1(e,y,t))),m5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=$2(i.box,Co),x=$2(i.boxRaw,Co);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Wo,A=O1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Lo===n&&p5[o]?(O1++,p5[o]):(O1=0,new Promise(async l=>{let c=u5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];p5[o]=Math.round(100*i)/100,Lo=n,Wo=v(),u5.dispose([c,y]),l(p5[o])}))}var Zo=V(D());var S2={};pe(S2,{connected:()=>b5,horizontal:()=>W1,kpt:()=>h5,relative:()=>G1,vertical:()=>F1});var h5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],W1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],F1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],G1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],b5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Bo=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function B1(e){for(let t of W1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Ho(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Vo(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,g5=0,H1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Xo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(f5(["size"],e),l0=await F(e.body.modelPath)),g5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,g5<64&&(g5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:h5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(b5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return B1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:h5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(b5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};B1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function D1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),H1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=H1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};H1=0,s.input=Do(e,g5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Vo(l,[e.shape[2]||1,e.shape[1]||1]),Ho(l.keypoints);Object.keys(s).forEach(l=>Zo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,M5=[],Uo=0,V1=Number.MAX_SAFE_INTEGER,P5=0,v5=2.5;async function Yo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;P5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=P5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-v5/c*w[0],k-v5/c*w[1]],[X,I]=[u+v5/c*w[2]-h,k+v5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function Z1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-Uo,n=V1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&M5.length>0?(V1++,M5):(V1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?M5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[P5,P5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),Uo=v();let y=await o7(c,A,t);M5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Jo=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Qo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function _o(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var R5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function $o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function Y1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],T5=1,s2=16,a7=50**2;function en(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:U1(Math.round(M.y/s2),0,P-1),x:U1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=Y1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=q1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=en(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new R5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?$o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(tn(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Qo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function K1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?_o(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function on(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,J1=!1;async function Q1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function rn(e,t,o){var p,g;if(J1)return{data:[],canvas:null,alpha:null};J1=!0,se||await Q1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),J1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},_1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function d5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function $1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&d5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await C1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await C1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=b3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=h3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=T3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Xo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=on(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=l3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Jt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Fo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=to(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=z3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=Z3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=J3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Wt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Dt(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=qt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=N3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=G3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=Io(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=No(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=v3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Yo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=Q1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function w5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function sn(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=Pt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:G5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await k5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new k5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var et="2.10.1";var at={};pe(at,{all:()=>st,body:()=>l2,canvas:()=>At,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>rt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function tt(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function an(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){tt(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${n} ${e.box[1]}, diff --git a/dist/human.node.js b/dist/human.node.js index 9a71e8245..8538de8a5 100644 --- a/dist/human.node.js +++ b/dist/human.node.js @@ -96,7 +96,7 @@ c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var N5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},O5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),N5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);N5(o,"uniform",this.uniform),N5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Ct(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new O5(i,Tt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?kt:wt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(St);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(Et);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var F2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function L5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function G2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>F2&&(A=F2,s=Math.trunc(A*r/n)),s>F2&&(s=F2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new Ct:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,G2(y0,d0))):(G2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=G2(d0),l=N.browser.fromPixels(Ue));else{let g=G2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await W2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function jt(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function It(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var W5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new W5;var w5=V(D());var F5={};pe(F5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>Q1,load:()=>_1,reset:()=>y5,validate:()=>T5,validateModel:()=>a2});var B2=V(D());var Z0,G5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Nt=0,Ot=0,B5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function H5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=B5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Ot;return t.skipAllowed&&A&&r&&Nt===n&&G5[o]?(B5++,G5[o]):(B5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=B2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mB2.dispose(c[m])),G5[o]=i,Nt=n,Ot=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Ft(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,H2=[],Gt=0,Bt=0,D5=Number.MAX_SAFE_INTEGER;async function Ht(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function V5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=D5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Bt;return t.skipAllowed&&r&&A&&Gt===n&&((l=H2[o])==null?void 0:l.age)&&((c=H2[o])==null?void 0:c.age)>0?(D5++,H2[o]):(D5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),H2[o]=d,Gt=n,Bt=v(),y(d)}))}var p0=V(D());var X0,D2=[],Vt=0,Zt=0,Z5=Number.MAX_SAFE_INTEGER,X5=[.2989,.587,.114];async function Xt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function q5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=Z5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Zt;return t.skipAllowed&&r&&A&&Vt===n&&((l=D2[o])==null?void 0:l.gender)&&((c=D2[o])==null?void 0:c.genderScore)>0?(Z5++,D2[o]):(Z5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,X5[0]),m=p0.mul(g,X5[1]),u=p0.mul(M,X5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),D2[o]=d,Vt=n,Zt=v(),y(d)}))}var Z2=V(D());var c0,V2=[],U5=Number.MAX_SAFE_INTEGER,Ut=0,Yt=0;async function Kt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function Y5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Yt,A=U5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ut===n&&V2[o]?(U5++,V2[o]):(U5=0,new Promise(async l=>{let c=Z2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];V2[o]=Math.round(100*i)/100,Ut=n,Yt=v(),Z2.dispose([c,y]),l(V2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},K5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},J5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],q2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],U2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],$t=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},_5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},Y2=(e,t)=>{let o=X2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},K2=e=>{let t=X2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},e3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},$5=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=Qt(t[0],t[1]),s=_t(A,r),a=Qt(-t[0],-t[1]);return _t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function o3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?t3(o,[0,0]):$5,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):$5,i=X2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function r3(e,t,o,n){let r=t.landmarks.length>=K5.count?K5.symmetryLine:Ne.symmetryLine,A=0,s=$5,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=X2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=t3(-A,c),a=_5(t,i,[n,n]),ie.dispose(i)}else a=_5(t,o,[n,n]);else a=_5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},A3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var s3=6,AA=1.4,J0,a3=null,ge=0,R2=null,Qe=()=>ge;async function i3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),a3=L.tensor2d(o3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,a3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function l3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],s3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[s3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=$t(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=Y2(g,t.face.scale||AA),P=K2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var J2={};pe(J2,{connected:()=>o1,kpt:()=>t1});var t1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],o1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),x3=224,aA,iA=5,Q2=[8,16,32,32,32];function y3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function d3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function _2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var p3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},n1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},e5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],f3=0,m3=e=>1-1/(1+Math.exp(e));async function u3(e){var t;if(p3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return y3(),u0.detector}async function h3(e){var t;if(p3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(o1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function r1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-f3,r=n1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&e5!==null)n1++;else{let A={};A.landmarks=xA(e,256),e5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),f3=v(),n1=0}return e5?[e5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,A1=[],g3=0,s1=Number.MAX_SAFE_INTEGER;async function M3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function a1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-g3,n=s1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&A1.length>0?(s1++,A1):(s1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;g3=v(),M0.dispose(s);let l=await mA(a,A,t);A1=l,r(l)}))}var Y=V(D());var t5={};pe(t5,{connected:()=>l1,kpt:()=>i1});var i1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],l1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,P3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},c1=Number.MAX_SAFE_INTEGER;async function R3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function x1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-P3,n=c1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(c1++,[v0]):(c1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),P3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:i1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(l1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,o5=[],w3=0,k3=0,y1=Number.MAX_SAFE_INTEGER;async function E3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function d1(e,t,o,n){var s,a;if(!G0)return[];let r=y1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-k3;return t.skipAllowed&&A&&r&&w3===n&&o5[o]&&o5[o].length>0?(y1++,o5[o]):(y1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),k3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}o5[o]=c,w3=n,l(c)}))}var n5=V(D());var C0,f1=[],S3=0,C3=0,j3=Number.MAX_SAFE_INTEGER;async function I3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function m1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=j3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-C3;return t.skipAllowed&&A&&r&&S3===n&&f1[o]?(j3++,f1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=n5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>n5.dispose(i[x]))}f1[o]=c,S3=n,C3=v(),l(c)})}var r5=V(D());var j0,p1=[],O3=0,L3=0,W3=Number.MAX_SAFE_INTEGER;async function F3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function u1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=W3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-L3;return t.skipAllowed&&A&&r&&O3===n&&p1[o]?(W3++,p1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}p1[o]=c,O3=n,L3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,h1=q0.leftEyeLower0,b1=q0.rightEyeLower0,e2={leftBounds:[h1[0],h1[h1.length-1]],rightBounds:[b1[0],b1[b1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function V3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function A5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},B3=(e,t,o,n,r,A=!1)=>{let s=K2(Y2(e3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},H3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function Z3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=B3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=B3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=H3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=H3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(A5(e,x,"left",null),A5(e,g,"right",null)):P<1?A5(e,x,"left",["EyeUpper0","EyeLower0"]):A5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=D3(e,f,"left"),u=D3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function U3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await l3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await U3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await Z3(Z,w.tensor,k2)),w.mesh=n3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...A3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=q2(O,e),w.boxRaw=U2(O,e),A.push(O)}Re.dispose(h)}else{w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function K3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var J3=Oe,Q3=P2;var $0=V(D());var h0,Te=[],_3=0,$3=0,M1=Number.MAX_SAFE_INTEGER;async function eo(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function v1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function P1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=M1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-_3;return t.skipAllowed&&A&&s&&$3===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(M1++,Te[o]):(M1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=v1(e),f=h0==null?void 0:h0.execute(x);_3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,$3=n,i(r)}))}var G=V(D());var no=V(D());function s5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function ro(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return no.image.cropAndResize(t,A,[0],o)}function Ao(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function a5(e,t=1.5){let o=E2(e),n=s5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function i5(e){let t=E2(e),o=s5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function so(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var to=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=Ao(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,co=1.65,xo=[0,5,9,13,17,1,2],LA=0,WA=2,yo=0,c5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>w1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return a5(i5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=a5(i5(o),co);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=T1(n,[0,0]),c=a.map(x=>[...w1(x,l),x[2]]),y=ao(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-yo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=a5(i5(c),co),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:k1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,k1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,k1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,k1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var fo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function mo(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function uo(e,t){if(!e||!t)return[0,0];let o=mo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=mo(e[1],e[2],t[1],t[2]);return[o,n]}function po(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function ho(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function bo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=bo(e,t,o,n),y=ho(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=uo([u,k],[w,h]),W=po(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=po(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=bo(l,a,c,i):f===Math.max(x,f)?Z=ho(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function go(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=uo(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function x5(e){if(!e||e.length===0)return null;let t=go(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function Mo(e){let t=[];if(!e||e.length===0)return t;let o=go(e);for(let n of fo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var vo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Po;async function z1(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=x5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function S1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new l5(Ve):void 0;return t&&Ze&&(Po=new c5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function To(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),y5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var ko={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(To(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(ko=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))ko[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Ft(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function d5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],zo=4,So=1.6,JA=512,QA=1.4,f5=Number.MAX_SAFE_INTEGER,C1=0,ye=[0,0],A0={boxes:[],hands:[]},Co={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function jo(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{d5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function Io(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[zo]),a.splice(zo,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=_2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function j1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=x5(n.keypoints);for(let i of Object.keys(Co))n.annotations[i]=Co[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function I1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],f5++;let o=(t.hand.skipTime||0)>v()-C1,n=f5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-C1,l=f5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):(A0.boxes=await _A(e,t),C1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))),f5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=_2(i.box,So),x=_2(i.boxRaw,So);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Lo,A=N1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Oo===n&&m5[o]?(N1++,m5[o]):(N1=0,new Promise(async l=>{let c=p5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];m5[o]=Math.round(100*i)/100,Oo=n,Lo=v(),p5.dispose([c,y]),l(m5[o])}))}var Vo=V(D());var S2={};pe(S2,{connected:()=>h5,horizontal:()=>L1,kpt:()=>u5,relative:()=>F1,vertical:()=>W1});var u5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],L1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],W1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],F1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],h5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Go=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function G1(e){for(let t of L1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Bo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Do(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,b5=0,B1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Zo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(d5(["size"],e),l0=await F(e.body.modelPath)),b5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,b5<64&&(b5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:u5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(h5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return G1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:u5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(h5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};G1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function H1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),B1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=B1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};B1=0,s.input=Ho(e,b5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Do(l,[e.shape[2]||1,e.shape[1]||1]),Bo(l.keypoints);Object.keys(s).forEach(l=>Vo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,g5=[],qo=0,D1=Number.MAX_SAFE_INTEGER,v5=0,M5=2.5;async function Uo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;v5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=v5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-M5/c*w[0],k-M5/c*w[1]],[X,I]=[u+M5/c*w[2]-h,k+M5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function V1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-qo,n=D1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&g5.length>0?(D1++,g5):(D1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?g5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[v5,v5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),qo=v();let y=await o7(c,A,t);g5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Ko=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Jo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Qo(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var P5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function _o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function U1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],R5=1,s2=16,a7=50**2;function $o(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:q1(Math.round(M.y/s2),0,P-1),x:q1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=U1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=X1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=$o(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new P5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?_o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(en(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Jo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function Y1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?Qo(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function tn(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,K1=!1;async function J1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function nn(e,t,o){var p,g;if(K1)return{data:[],canvas:null,alpha:null};K1=!0,se||await J1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),K1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},Q1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function y5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function _1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&y5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=h3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=u3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=R3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Zo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=tn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=i3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Kt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Wo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=eo(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=E3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=V3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=K3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Lt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ht(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Xt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=I3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=F3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=jo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=Io(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=M3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Uo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=J1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function T5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function An(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=vt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:F5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await w5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new w5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var $1="2.10.0";var st={};pe(st,{all:()=>At,body:()=>l2,canvas:()=>rt,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>nt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function et(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function sn(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){et(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var N5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},O5=class{constructor(t,o,n){T(this,"uniform",{});T(this,"attribute",{});T(this,"gl");T(this,"id");T(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(b(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)||"unknown"}`),null)):(b("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),A=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!A)){if(!this.id){b("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,A),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){b(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)||"unknown"}`);return}this.gl.useProgram(this.id),N5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);N5(o,"uniform",this.uniform),N5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Ct(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,l=g0(100,100),c={},y={INTERMEDIATE:1},i=l.getContext("webgl");if(!i){b("filter: cannot get webgl context");return}this.gl=i;function d(P,m){if(!(P===l.width&&m===l.height)){if(l.width=P,l.height=m,!s){let u=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}i.viewport(0,0,l.width,l.height),r=[null,null]}}function x(P,m){let u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u);let k=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,k);let w=i.createTexture();return i.bindTexture(i.TEXTURE_2D,w),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,P,m,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,w,0),i.bindTexture(i.TEXTURE_2D,null),i.bindFramebuffer(i.FRAMEBUFFER,null),{fbo:u,texture:w}}function f(P){return r[P]=r[P]||x(l.width,l.height),r[P]}function p(P=0){if(!a)return;let m=null,u=null,k=!1;e===0?m=t:m=f(n).texture||null,e++,o&&!(P&y.INTERMEDIATE)?(u=null,k=e%2===0):(n=(n+1)%2,u=f(n).fbo||null),i.bindTexture(i.TEXTURE_2D,m),i.bindFramebuffer(i.FRAMEBUFFER,u),i.uniform1f(a.uniform.flipY,k?-1:1),i.drawArrays(i.TRIANGLES,0,6)}function g(P){if(c[P])return a=c[P],i.useProgram((a?a.id:null)||null),a;if(a=new O5(i,Tt,P),!a)return b("filter: could not get webgl program"),null;let m=Float32Array.BYTES_PER_ELEMENT,u=4*m;return i.enableVertexAttribArray(a.attribute.pos),i.vertexAttribPointer(a.attribute.pos,2,i.FLOAT,!1,u,0*m),i.enableVertexAttribArray(a.attribute.uv),i.vertexAttribPointer(a.attribute.uv,2,i.FLOAT,!1,u,2*m),c[P]=a,a}let M={colorMatrix:P=>{let m=new Float32Array(P);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;let u=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?kt:wt,k=g(u);!k||(i.uniform1fv(k.uniform.m,m),p())},brightness:P=>{let m=(P||0)+1;M.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},saturation:P=>{let m=(P||0)*2/3+1,u=(m-1)*-.5;M.colorMatrix([m,u,u,0,0,u,m,u,0,0,u,u,m,0,0,0,0,0,1,0])},desaturate:()=>{M.saturation(-1)},contrast:P=>{let m=(P||0)+1,u=-128*(m-1);M.colorMatrix([m,0,0,0,u,0,m,0,0,u,0,0,m,0,u,0,0,0,1,0])},negative:()=>{M.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let m=Math.cos(P),u=Math.sin(P),k=.213,w=.715,h=.072;M.colorMatrix([k+m*(1-k)+u*-k,w+m*-w+u*-w,h+m*-h+u*(1-h),0,0,k+m*-k+u*.143,w+m*(1-w)+u*.14,h+m*-h+u*-.283,0,0,k+m*-k+u*-(1-k),w+m*-w+u*w,h+m*(1-h)+u*h,0,0,0,0,0,1,0])},desaturateLuminance:()=>{M.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{M.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{M.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{M.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{M.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{M.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{M.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{M.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let m=new Float32Array(P),u=1/l.width,k=1/l.height,w=g(St);!w||(i.uniform1fv(w.uniform.m,m),i.uniform2f(w.uniform.px,u,k),p())},detectEdges:()=>{M.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{M.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{M.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let m=P||1;M.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},emboss:P=>{let m=P||1;M.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},blur:P=>{let m=P/7/l.width,u=P/7/l.height,k=g(zt);!k||(i.uniform2f(k.uniform.px,0,u),p(y.INTERMEDIATE),i.uniform2f(k.uniform.px,m,0),p())},pixelate:P=>{let m=P/l.width,u=P/l.height,k=g(Et);!k||(i.uniform2f(k.uniform.size,m,u),p())}};this.add=function(P){let m=Array.prototype.slice.call(arguments,1),u=M[P];A.push({func:u,args:m})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(P){d(P.width,P.height),e=0,t||(t=i.createTexture()),i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,P);for(let m=0;mx.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[q.sub(o[0],n[0]),q.sub(o[1],n[1]),q.sub(o[2],n[2])],l=[q.sub(r[0],n[0]),q.sub(r[1],n[1]),q.sub(r[2],n[2])],c=[q.div(s,l[0]),q.div(s,l[1]),q.div(s,l[2])],y=[q.mul(a[0],c[0]),q.mul(a[1],c[1]),q.mul(a[2],c[2])],i=q.stack([y[0],y[1],y[2]],2),d=q.reshape(i,[1,t.shape[0],t.shape[1],3]);return q.dispose([...o,...n,...r,...a,...l,...c,...y,i,t]),d}var F2=3840,y0=null,d0=null,Ue=null,J,F0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function L5(){F0.inputSum=0,F0.cacheDiff=1,F0.sumMethod=0,F0.inputTensor=void 0}function g0(e,t){let o;if(R.browser)if(R.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof R.Canvas!="undefined"?o=new R.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function G2(e,t){let o=t||g0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Ye(e,t,o=!0){var d,x;if(!e)return t.debug&&b("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof R.Canvas!="undefined"&&e instanceof R.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof N.Tensor){let f=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)f=N.expandDims(e,0);else if(e.shape[2]===4){let p=N.slice3d(e,[0,0,0],[-1,-1,3]);f=N.expandDims(p,0),N.dispose(p)}}else e.shape.length===4&&(e.shape[3]===3?f=N.clone(e):e.shape[3]===4&&(f=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(f==null||f.shape.length!==4||f.shape[0]!==1||f.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape.toString()}`);if(f.dtype==="int32"){let p=N.cast(f,"float32");N.dispose(f),f=p}return{tensor:f,canvas:t.filter.return?d0:null}}if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&b("input stream is not ready"),{tensor:null,canvas:y0};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&b("cannot determine input dimensions"),{tensor:null,canvas:y0};let A=n,s=r;if(A>F2&&(A=F2,s=Math.trunc(A*r/n)),s>F2&&(s=F2,A=Math.trunc(s*n/r)),(((d=t.filter)==null?void 0:d.width)||0)>0?A=t.filter.width:(((x=t.filter)==null?void 0:x.height)||0)>0&&(A=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?s=t.filter.height:(t.filter.width||0)>0&&(s=r*((t.filter.width||0)/n)),!A||!s)throw new Error("input error: cannot determine dimension");(!y0||y0.width!==A||y0.height!==s)&&(y0=g0(A,s));let a=y0.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?a.putImageData(e,0,0):t.filter.flip&&typeof a.translate!="undefined"?(a.translate(n,0),a.scale(-1,1),a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,y0.width,y0.height),(!d0||y0.width!==d0.width||y0.height!==d0.height)&&(d0=g0(y0.width,y0.height)),t.filter.enabled&&R.webgl.supported?(J||(J=R.browser?new Ct:null),R.filter=!!J,J!=null&&J.add?(J.reset(),t.filter.brightness!==0&&J.add("brightness",t.filter.brightness),t.filter.contrast!==0&&J.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&J.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&J.add("blur",t.filter.blur),t.filter.saturation!==0&&J.add("saturation",t.filter.saturation),t.filter.hue!==0&&J.add("hue",t.filter.hue),t.filter.negative&&J.add("negative"),t.filter.sepia&&J.add("sepia"),t.filter.vintage&&J.add("brownie"),t.filter.sepia&&J.add("sepia"),t.filter.kodachrome&&J.add("kodachrome"),t.filter.technicolor&&J.add("technicolor"),t.filter.polaroid&&J.add("polaroid"),t.filter.pixelate!==0&&J.add("pixelate",t.filter.pixelate),J.get()>0?d0=J.apply(y0):d0=J.draw(y0)):(t.debug&&b("input process error: cannot initialize filters"),R.webgl.supported=!1,t.filter.enabled=!1,G2(y0,d0))):(G2(y0,d0),J&&(J=null),R.filter=!!J),!o)return{tensor:null,canvas:d0};if(!d0)throw new Error("canvas error: cannot create output");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(R.browser&&N.browser)l=N.browser?N.browser.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let f=new Uint8Array(e.data.buffer);l=N.tensor(f,[e.height,e.width,c],"int32")}else if((!Ue||d0.width!==Ue.width||d0.height!==Ue.height)&&(Ue=g0(d0.width,d0.height)),N.browser&&R.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=N.browser.fromPixels(d0):(Ue=G2(d0),l=N.browser.fromPixels(Ue));else{let g=G2(d0).getContext("2d").getImageData(0,0,A,s);c=g.data.length/A/s;let M=new Uint8Array(g.data.buffer);l=N.tensor(M,[A,s,c])}if(c===4){let f=N.slice3d(l,[0,0,0],[-1,-1,3]);N.dispose(l),l=f}if(!l)throw new Error("input error: cannot create tensor");let y=N.cast(l,"float32"),i=t.filter.equalization?await W2(y):N.expandDims(y,0);return N.dispose([l,y]),{tensor:i,canvas:t.filter.return?d0:null}}async function jt(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!F0.inputTensor)F0.inputTensor=N.clone(t);else if(F0.inputTensor.shape[1]!==t.shape[1]||F0.inputTensor.shape[2]!==t.shape[2])N.dispose(F0.inputTensor),F0.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,F0.inputTensor),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;N.dispose([F0.inputTensor,n.diff,n.squared,n.sum]),F0.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function It(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||b("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||b("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=N.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?N.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):N.clone(o),n.diff=N.sub(n.input1,n.input2),n.squared=N.mul(n.diff,n.diff),n.sum=N.sum(n.squared);let A=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return N.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),A}var W5=class{constructor(){T(this,"browser");T(this,"node");T(this,"worker");T(this,"platform","");T(this,"agent","");T(this,"backends",[]);T(this,"initial");T(this,"filter");T(this,"tfjs");T(this,"offscreen");T(this,"perfadd",!1);T(this,"tensorflow",{version:void 0,gpu:void 0});T(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});T(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});T(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});T(this,"cpu",{model:void 0,flags:[]});T(this,"kernels",[]);T(this,"Canvas");T(this,"Image");T(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:a0.version["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t!=null&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o!=null&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(a0.engine().registryFactory),this.tensorflow={version:a0.backend().binding?a0.backend().binding.TF_Version:void 0,gpu:a0.backend().binding?a0.backend().binding.isUsingGpuDevice():void 0},this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&a0.getBackend()==="wasm"&&(this.wasm.simd=a0.env().get("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=a0.env().get("WASM_HAS_MULTITHREAD_SUPPORT"));let t=g0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(a0.getBackend()==="webgl"||a0.getBackend()==="humangl")){let n=a0.backend().gpgpu!=="undefined"?await a0.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{if(this.webgpu.supported){let n=await navigator.gpu.requestAdapter();this.webgpu.adapter=n?n.name:void 0}}catch(n){this.webgpu.supported=!1}try{this.kernels=a0.getKernelsForBackend(a0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},R=new W5;var w5=V(D());var F5={};pe(F5,{age:()=>Yn,"anti-spoofing":()=>Tr,antispoof:()=>On,blazeface:()=>Ln,"blazeface-back":()=>Kn,"blazeface-front":()=>Jn,"blazepose-detect":()=>Rr,"blazepose-detector2d":()=>Qn,"blazepose-detector3d":()=>_n,"blazepose-full":()=>$n,"blazepose-heavy":()=>er,"blazepose-lite":()=>tr,default:()=>Fr,efficientpose:()=>or,"efficientpose-i-lite":()=>wr,"efficientpose-ii-lite":()=>kr,"efficientpose-iv":()=>Er,emotion:()=>Wn,faceboxes:()=>nr,facemesh:()=>Fn,"facemesh-attention":()=>Ar,"facemesh-attention-alt":()=>rr,"facemesh-detection-full":()=>sr,"facemesh-detection-short":()=>ar,"facemesh-orig":()=>ir,faceres:()=>Gn,"faceres-deep":()=>lr,gear:()=>cr,gender:()=>yr,"gender-ssrnet-imdb":()=>xr,handdetect:()=>dr,"handlandmark-full":()=>Bn,"handlandmark-lite":()=>fr,"handlandmark-sparse":()=>mr,handskeleton:()=>pr,handtrack:()=>Hn,"insightface-efficientnet-b0":()=>zr,"insightface-ghostnet-strides1":()=>Sr,"insightface-ghostnet-strides2":()=>Cr,"insightface-mobilenet-emore":()=>jr,"insightface-mobilenet-swish":()=>Ir,iris:()=>Dn,liveness:()=>Vn,"mb3-centernet":()=>Zn,meet:()=>ur,mobileface:()=>hr,mobilefacenet:()=>br,models:()=>Xn,"movenet-lightning":()=>qn,"movenet-multipose":()=>gr,"movenet-thunder":()=>Mr,nanodet:()=>vr,"nanodet-e":()=>Nr,"nanodet-g":()=>Or,"nanodet-m":()=>Lr,"nanodet-t":()=>Wr,posenet:()=>Pr,selfie:()=>Un});var On=853098,Ln=538928,Wn=820516,Fn=1477958,Gn=6978814,Bn=5431368,Hn=2964837,Dn=2599092,Vn=592976,Zn=4030290,Xn=0,qn=4650216,Un=212886,Yn=161240,Kn=538928,Jn=402048,Qn=7499400,_n=5928856,$n=6338290,er=27501554,tr=2725490,or=5651240,nr=2013002,rr=2387598,Ar=2382414,sr=1026192,ar=201268,ir=2955780,lr=13957620,cr=1498916,xr=161236,yr=201808,dr=3515612,fr=2023432,mr=5286322,pr=5502280,ur=372228,hr=2183192,br=5171976,gr=9448838,Mr=12477112,vr=7574558,Pr=5032780,Rr=5928804,Tr=853098,wr=2269064,kr=5651240,Er=25643252,zr=13013224,Sr=8093408,Cr=8049584,jr=6938536,Ir=12168584,Nr=12319156,Or=7574558,Lr=1887474,Wr=5294216,Fr={antispoof:On,blazeface:Ln,emotion:Wn,facemesh:Fn,faceres:Gn,"handlandmark-full":Bn,handtrack:Hn,iris:Dn,liveness:Vn,"mb3-centernet":Zn,models:Xn,"movenet-lightning":qn,selfie:Un,age:Yn,"blazeface-back":Kn,"blazeface-front":Jn,"blazepose-detector2d":Qn,"blazepose-detector3d":_n,"blazepose-full":$n,"blazepose-heavy":er,"blazepose-lite":tr,efficientpose:or,faceboxes:nr,"facemesh-attention-alt":rr,"facemesh-attention":Ar,"facemesh-detection-full":sr,"facemesh-detection-short":ar,"facemesh-orig":ir,"faceres-deep":lr,gear:cr,"gender-ssrnet-imdb":xr,gender:yr,handdetect:dr,"handlandmark-lite":fr,"handlandmark-sparse":mr,handskeleton:pr,meet:ur,mobileface:hr,mobilefacenet:br,"movenet-multipose":gr,"movenet-thunder":Mr,nanodet:vr,posenet:Pr,"blazepose-detect":Rr,"anti-spoofing":Tr,"efficientpose-i-lite":wr,"efficientpose-ii-lite":kr,"efficientpose-iv":Er,"insightface-efficientnet-b0":zr,"insightface-ghostnet-strides1":Sr,"insightface-ghostnet-strides2":Cr,"insightface-mobilenet-emore":jr,"insightface-mobilenet-swish":Ir,"nanodet-e":Nr,"nanodet-g":Or,"nanodet-m":Lr,"nanodet-t":Wr};var A2={};pe(A2,{Models:()=>I2,getModelStats:()=>Q1,load:()=>_1,reset:()=>y5,validate:()=>T5,validateModel:()=>a2});var B2=V(D());var Z0,G5=[],Gr=["white","black","asian","indian","other"],Br=[15,23,28,35.5,45.5,55.5,65],Nt=0,Ot=0,B5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return R.initial&&(Z0=null),Z0?e.debug&&b("cached model:",Z0.modelUrl):Z0=await F((t=e.face.gear)==null?void 0:t.modelPath),Z0}async function H5(e,t,o,n){var s,a;if(!Z0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=B5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>v()-Ot;return t.skipAllowed&&A&&r&&Nt===n&&G5[o]?(B5++,G5[o]):(B5=0,new Promise(async l=>{var M,P;if(!(Z0!=null&&Z0.inputs[0].shape))return;let c={},y=[[0,.1,.9,.9]];c.resize=B2.image.cropAndResize(e,y,[0],[Z0.inputs[0].shape[2],Z0.inputs[0].shape[1]]);let i={age:0,gender:"unknown",genderScore:0,race:[]};(M=t.face.gear)!=null&&M.enabled&&([c.age,c.gender,c.race]=Z0.execute(c.resize,["age_output","gender_output","race_output"]));let d=await c.gender.data();i.gender=d[0]>d[1]?"male":"female",i.genderScore=Math.round(100*(d[0]>d[1]?d[0]:d[1]))/100;let x=await c.race.data();for(let m=0;m(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&i.race.push({score:Math.round(100*x[m])/100,race:Gr[m]});i.race.sort((m,u)=>u.score-m.score);let p=Array.from(await c.age.data()).map((m,u)=>[Br[u],m]).sort((m,u)=>u[1]-m[1]),g=p[0][0];for(let m=1;mB2.dispose(c[m])),G5[o]=i,Nt=n,Ot=v(),l(i)}))}var Ke=V(D());var he=V(D()),H={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Ft(){H.tf255=he.scalar(255,"float32"),H.tf1=he.scalar(1,"float32"),H.tf2=he.scalar(2,"float32"),H.tf05=he.scalar(.5,"float32"),H.tf127=he.scalar(127.5,"float32"),H.rgb=he.tensor1d([.2989,.587,.114],"float32")}var E0,H2=[],Gt=0,Bt=0,D5=Number.MAX_SAFE_INTEGER;async function Ht(e){return R.initial&&(E0=null),E0?e.debug&&b("cached model:",E0.modelUrl):E0=await F(e.face.ssrnet.modelPathAge),E0}async function V5(e,t,o,n){var s,a,l,c;if(!E0)return{age:0};let r=D5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Bt;return t.skipAllowed&&r&&A&&Gt===n&&((l=H2[o])==null?void 0:l.age)&&((c=H2[o])==null?void 0:c.age)>0?(D5++,H2[o]):(D5=0,new Promise(async y=>{var x;if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let i={};i.resize=Ke.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),i.enhance=Ke.mul(i.resize,H.tf255);let d={age:0};if((x=t.face.ssrnet)!=null&&x.enabled&&(i.age=E0.execute(i.enhance)),i.age){let f=await i.age.data();d.age=Math.trunc(10*f[0])/10}Object.keys(i).forEach(f=>Ke.dispose(i[f])),H2[o]=d,Gt=n,Bt=v(),y(d)}))}var p0=V(D());var X0,D2=[],Vt=0,Zt=0,Z5=Number.MAX_SAFE_INTEGER,X5=[.2989,.587,.114];async function Xt(e){var t;return R.initial&&(X0=null),X0?e.debug&&b("cached model:",X0.modelUrl):X0=await F((t=e.face.ssrnet)==null?void 0:t.modelPathGender),X0}async function q5(e,t,o,n){var s,a,l,c;if(!X0)return{gender:"unknown",genderScore:0};let r=Z5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>v()-Zt;return t.skipAllowed&&r&&A&&Vt===n&&((l=D2[o])==null?void 0:l.gender)&&((c=D2[o])==null?void 0:c.genderScore)>0?(Z5++,D2[o]):(Z5=0,new Promise(async y=>{var f;if(!(X0!=null&&X0.inputs[0].shape))return;let i={};i.resize=p0.image.resizeBilinear(e,[X0.inputs[0].shape[2],X0.inputs[0].shape[1]],!1),i.enhance=p0.tidy(()=>{let[p,g,M]=p0.split(i.resize,3,3),P=p0.mul(p,X5[0]),m=p0.mul(g,X5[1]),u=p0.mul(M,X5[2]),k=p0.addN([P,m,u]);return p0.mul(p0.sub(k,H.tf05),2)});let d={gender:"unknown",genderScore:0};(f=t.face.ssrnet)!=null&&f.enabled&&(i.gender=X0.execute(i.enhance));let x=await i.gender.data();d.gender=x[0]>x[1]?"female":"male",d.genderScore=x[0]>x[1]?Math.trunc(100*x[0])/100:Math.trunc(100*x[1])/100,Object.keys(i).forEach(p=>p0.dispose(i[p])),D2[o]=d,Vt=n,Zt=v(),y(d)}))}var Z2=V(D());var c0,V2=[],U5=Number.MAX_SAFE_INTEGER,Ut=0,Yt=0;async function Kt(e){var t;return R.initial&&(c0=null),c0?e.debug&&b("cached model:",c0.modelUrl):c0=await F((t=e.face.antispoof)==null?void 0:t.modelPath),c0}async function Y5(e,t,o,n){var s,a;if(!c0||!(c0!=null&&c0.executor))return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>v()-Yt,A=U5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ut===n&&V2[o]?(U5++,V2[o]):(U5=0,new Promise(async l=>{let c=Z2.image.resizeBilinear(e,[c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[2]:0,c0!=null&&c0.inputs[0].shape?c0.inputs[0].shape[1]:0],!1),y=c0==null?void 0:c0.execute(c),i=(await y.data())[0];V2[o]=Math.round(100*i)/100,Ut=n,Yt=v(),Z2.dispose([c,y]),l(V2[o])}))}var L=V(D());var ie=V(D());var q0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[185,40,39,37,0,267,269,270,409],lipsLowerOuter:[61,146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[191,80,81,82,13,312,311,310,415],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],lipsLowerSemiOuter:[76,77,90,180,85,16,315,404,320,307,306],lipsUpperSemiOuter:[184,74,73,72,11,302,303,304,408],lipsLowerSemiInner:[62,96,89,179,86,15,316,403,319,325,292],lipsUpperSemiInner:[183,42,41,38,12,268,271,272,407],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},K5={count:468,mouth:13,symmetryLine:[13,q0.midwayBetweenEyes[0]]},Ne={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},J5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],P2=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Oe=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Dr=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],Vr=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Zr=[33,133,362,263,1,78,308],a4=Dr.map(e=>P2[e]),i4=Vr.map(e=>P2[e]),l4=Zr.map(e=>P2[e]);function be(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Xr=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],qr=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Ur=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Yr=[[474,475],[475,476],[476,477],[477,474]],Kr=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Jr=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Qr=[[469,470],[470,471],[471,472],[472,469]],_r=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],c4={lips:be(Xr),leftEye:be(qr),leftEyebrow:be(Ur),leftIris:be(Yr),rightEye:be(Kr),rightEyebrow:be(Jr),rightIris:be(Qr),faceOval:be(_r)};var Je=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],X2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],q2=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],U2=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],$t=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},_5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],A=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],s=ie.image.cropAndResize(t,[A],[0],o),a=ie.div(s,H.tf255);return ie.dispose(s),a},Y2=(e,t)=>{let o=X2(e),n=Je(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},K2=e=>{let t=X2(e),o=Je(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},e3=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},$5=[[1,0,0],[0,1,0],[0,0,1]],$r=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),eA=(e,t)=>$r(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Le=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],A=Qt(t[0],t[1]),s=_t(A,r),a=Qt(-t[0],-t[1]);return _t(s,a)},oA=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Le(t[0],o),-Le(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},nA=(e,t)=>[Le(e,t[0]),Le(e,t[1])];function o3(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[A[0]/r*(x[0]-r/2),A[1]/r*(x[1]-r/2),x[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,l=a?t3(o,[0,0]):$5,c=a?s.map(x=>[...nA(x,l),x[2]]):s,y=a?oA(n):$5,i=X2(t),d=[Le(i,y[0]),Le(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2]||0)])}function r3(e,t,o,n){let r=t.landmarks.length>=K5.count?K5.symmetryLine:Ne.symmetryLine,A=0,s=$5,a;if(e&&R.kernels.includes("rotatewithoffset"))if(A=eA(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let c=X2(t),y=[c[0]/o.shape[2],c[1]/o.shape[1]],i=ie.image.rotateWithOffset(o,A,0,y);s=t3(-A,c),a=_5(t,i,[n,n]),ie.dispose(i)}else a=_5(t,o,[n,n]);else a=_5(t,o,[n,n]);return[A,s,a]}var rA=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},A3=(e,t)=>{let o=rA(e),n=Je(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var s3=6,AA=1.4,J0,a3=null,ge=0,R2=null,Qe=()=>ge;async function i3(e){var t;return R.initial&&(J0=null),J0?e.debug&&b("cached model:",J0.modelUrl):J0=await F((t=e.face.detector)==null?void 0:t.modelPath),ge=J0.executor&&J0.inputs[0].shape?J0.inputs[0].shape[2]:256,R2=L.scalar(ge,"int32"),a3=L.tensor2d(o3(ge)),J0}function sA(e){let t={};t.boxStarts=L.slice(e,[0,1],[-1,2]),t.centers=L.add(t.boxStarts,a3),t.boxSizes=L.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=L.div(t.boxSizes,R2),t.centersNormalized=L.div(t.centers,R2),t.halfBoxSize=L.div(t.boxSizesNormalized,H.tf2),t.starts=L.sub(t.centersNormalized,t.halfBoxSize),t.ends=L.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=L.mul(t.starts,R2),t.endNormalized=L.mul(t.ends,R2);let o=L.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>L.dispose(t[n])),o}async function l3(e,t){var a,l,c,y;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=L.image.resizeBilinear(e,[ge,ge]),o.div=L.div(o.resized,H.tf127),o.normalized=L.sub(o.div,H.tf05);let n=J0==null?void 0:J0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let i=n.sort((d,x)=>d.size-x.size);o.concat384=L.concat([i[0],i[2]],2),o.concat512=L.concat([i[1],i[3]],2),o.concat=L.concat([o.concat512,o.concat384],1),o.batch=L.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=L.squeeze(n[0]):o.batch=L.squeeze(n);L.dispose(n),o.boxes=sA(o.batch),o.logits=L.slice(o.batch,[0,0],[-1,1]),o.sigmoid=L.sigmoid(o.logits),o.scores=L.squeeze(o.sigmoid),o.nms=await L.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((c=t.face.detector)==null?void 0:c.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let i=0;i(((y=t.face.detector)==null?void 0:y.minConfidence)||0)){let x={};x.bbox=L.slice(o.boxes,[r[i],0],[1,-1]),x.slice=L.slice(o.batch,[r[i],s3-1],[1,-1]),x.squeeze=L.squeeze(x.slice),x.landmarks=L.reshape(x.squeeze,[s3,-1]);let f=await x.bbox.data(),p={startPoint:[f[0],f[1]],endPoint:[f[2],f[3]],landmarks:await x.landmarks.array(),confidence:d},g=$t(p,[(e.shape[2]||0)/ge,(e.shape[1]||0)/ge]),M=Y2(g,t.face.scale||AA),P=K2(M);A.push(P),Object.keys(x).forEach(m=>L.dispose(x[m]))}}return Object.keys(o).forEach(i=>L.dispose(o[i])),A}var S0=V(D());var J2={};pe(J2,{connected:()=>o1,kpt:()=>t1});var t1=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],o1={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var z0=V(D()),x3=224,aA,iA=5,Q2=[8,16,32,32,32];function y3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function le(e,t=[1,1]){let o=[e.map(a=>a[0]),e.map(a=>a[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[n[0],n[1],r[0]-n[0],r[1]-n[1]],s=[A[0]/t[0],A[1]/t[1],A[2]/t[0],A[3]/t[1]];return{box:A,boxRaw:s}}function d3(e,t=[1,1]){let o=[e.map(c=>c[0]),e.map(c=>c[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],A=[(n[0]+r[0])/2,(n[1]+r[1])/2],s=Math.max(A[0]-n[0],A[1]-n[1],-A[0]+r[0],-A[1]+r[1]),a=[Math.trunc(A[0]-s),Math.trunc(A[1]-s),Math.trunc(2*s),Math.trunc(2*s)],l=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:l}}function _2(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var p3={initial:!0},u0={detector:null,landmarks:null},_e={detector:[224,224],landmarks:[256,256]},n1=Number.MAX_SAFE_INTEGER,cA={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},e5=null,T2,Me=[[0,0],[0,0],[0,0],[0,0]],f3=0,m3=e=>1-1/(1+Math.exp(e));async function u3(e){var t;if(p3.initial&&(u0.detector=null),!u0.detector&&e.body.detector&&e.body.detector.modelPath){u0.detector=await F(e.body.detector.modelPath);let o=(t=u0.detector)!=null&&t.executor?Object.values(u0.detector.modelSignature.inputs):void 0;_e.detector[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.detector[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}else e.debug&&u0.detector&&b("cached model:",u0.detector.modelUrl);return y3(),u0.detector}async function h3(e){var t;if(p3.initial&&(u0.landmarks=null),u0.landmarks)e.debug&&b("cached model:",u0.landmarks.modelUrl);else{u0.landmarks=await F(e.body.modelPath);let o=(t=u0.landmarks)!=null&&t.executor?Object.values(u0.landmarks.modelSignature.inputs):void 0;_e.landmarks[0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,_e.landmarks[1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return u0.landmarks}function xA(e,t){var r,A;let o={};if(!((r=e==null?void 0:e.shape)!=null&&r[1])||!((A=e==null?void 0:e.shape)!=null&&A[2]))return e;let n;if(T2&&(o.cropped=S0.image.cropAndResize(e,[T2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let s=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],a=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];Me=[[0,0],s,a,[0,0]],o.pad=S0.pad(o.cropped||e,Me),o.resize=S0.image.resizeBilinear(o.pad,[t,t]),n=S0.div(o.resize,H.tf255)}else e.shape[1]!==t?(o.resize=S0.image.resizeBilinear(o.cropped||e,[t,t]),n=S0.div(o.resize,H.tf255)):n=S0.div(o.cropped||e,H.tf255);return Object.keys(o).forEach(s=>S0.dispose(o[s])),n}function yA(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+Me[2][0]+Me[2][1])/t[0]-Me[2][0]),Math.trunc(o.position[1]*(t[1]+Me[1][0]+Me[1][1])/t[1]-Me[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(T2)for(let o of e)o.positionRaw=[o.positionRaw[0]+T2[1],o.positionRaw[1]+T2[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}function dA(e){let t=e.find(a=>a.part==="leftPalm"),o=e.find(a=>a.part==="leftWrist"),n=e.find(a=>a.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(a=>a.part==="rightPalm"),A=e.find(a=>a.part==="rightWrist"),s=e.find(a=>a.part==="rightIndex");r.position[2]=((A.position[2]||0)+(s.position[2]||0))/2}async function fA(e,t,o){var f,p;if(!((f=u0.landmarks)!=null&&f.executor))return null;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(p=u0.landmarks)==null?void 0:p.execute(e,cA.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(g=>S0.dispose(n[g]));let a=[],l=5;for(let g=0;gg.position),i=le(y,[o[0],o[1]]),d={};for(let[g,M]of Object.entries(o1)){let P=[];for(let m=0;mw.part===M[m]),k=c.find(w=>w.part===M[m+1]);u&&k&&P.push([u.position,k.position])}d[g]=P}return{id:0,score:Math.trunc(100*r)/100,box:i.box,boxRaw:i.boxRaw,keypoints:c,annotations:d}}async function r1(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>v()-f3,r=n1<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&e5!==null)n1++;else{let A={};A.landmarks=xA(e,256),e5=await fA(A.landmarks,t,o),Object.keys(A).forEach(s=>S0.dispose(A[s])),f3=v(),n1=0}return e5?[e5]:[]}var M0=V(D());var $e=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var w0,We=0,A1=[],g3=0,s1=Number.MAX_SAFE_INTEGER;async function M3(e){if(R.initial&&(w0=null),w0)e.debug&&b("cached model:",w0.modelUrl);else{w0=await F(e.object.modelPath);let t=w0!=null&&w0.executor?Object.values(w0.modelSignature.inputs):void 0;We=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return w0}async function mA(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=M0.squeeze(e);let s=M0.split(n.squeeze,6,1);n.stack=M0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=M0.squeeze(n.stack),n.scores=M0.squeeze(s[4]),n.classes=M0.squeeze(s[5]),M0.dispose([e,...s]),n.nms=await M0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),l=0;for(let c of Array.from(a)){let y=Math.trunc(100*A[0][c][4])/100,i=A[0][c][5];if(Number.isNaN(i))continue;let d=$e[i].label,[x,f]=[A[0][c][0]/We,A[0][c][1]/We],p=[x,f,A[0][c][2]/We-x,A[0][c][3]/We-f],g=[Math.trunc(p[0]*t[0]),Math.trunc(p[1]*t[1]),Math.trunc(p[2]*t[0]),Math.trunc(p[3]*t[1])];r.push({id:l++,score:y,class:i,label:d,box:g,boxRaw:p})}return Object.keys(n).forEach(c=>M0.dispose(n[c])),r}async function a1(e,t){if(!(w0!=null&&w0.executor))return[];let o=(t.object.skipTime||0)>v()-g3,n=s1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&A1.length>0?(s1++,A1):(s1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=M0.image.resizeBilinear(e,[We,We]),a=t.object.enabled?w0==null?void 0:w0.execute(s,["tower_0/detections"]):null;g3=v(),M0.dispose(s);let l=await mA(a,A,t);A1=l,r(l)}))}var Y=V(D());var t5={};pe(t5,{connected:()=>l1,kpt:()=>i1});var i1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],l1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var x0,P3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},c1=Number.MAX_SAFE_INTEGER;async function R3(e){return R.initial&&(x0=null),x0?e.debug&&b("cached model:",x0.modelUrl):x0=await F(e.body.modelPath),x0}async function pA(e,t){let[o,n]=e.shape,r=Y.reshape(e,[n*o]),A=Y.max(r,0),s=(await A.data())[0];if(s>t){let a=Y.argMax(r,0),l=Y.mod(a,o),c=(await l.data())[0],y=Y.div(a,o),i=(await y.data())[0];return Y.dispose([r,A,a,l,y]),[c,i,s]}return Y.dispose([r,A]),[0,0,s]}async function x1(e,t){if(!(x0!=null&&x0.executor))return[];let o=(t.body.skipTime||0)>v()-P3,n=c1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(c1++,[v0]):(c1=0,new Promise(async r=>{let A=Y.tidy(()=>{if(!(x0!=null&&x0.inputs[0].shape))return null;let i=Y.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),d=Y.mul(i,H.tf2);return Y.sub(d,H.tf1)}),s;if(t.body.enabled&&(s=x0==null?void 0:x0.execute(A)),P3=v(),Y.dispose(A),s){v0.keypoints.length=0;let i=Y.squeeze(s);Y.dispose(s);let d=Y.unstack(i,2);Y.dispose(i);for(let x=0;x(t.body.minConfidence||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:i1[x],positionRaw:[f/x0.inputs[0].shape[2],p/x0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/x0.inputs[0].shape[2]),Math.round(e.shape[1]*p/x0.inputs[0].shape[1])]})}d.forEach(x=>Y.dispose(x))}v0.score=v0.keypoints.reduce((i,d)=>d.score>i?d.score:i,0);let a=v0.keypoints.map(i=>i.position[0]),l=v0.keypoints.map(i=>i.position[1]);v0.box=[Math.min(...a),Math.min(...l),Math.max(...a)-Math.min(...a),Math.max(...l)-Math.min(...l)];let c=v0.keypoints.map(i=>i.positionRaw[0]),y=v0.keypoints.map(i=>i.positionRaw[1]);v0.boxRaw=[Math.min(...c),Math.min(...y),Math.max(...c)-Math.min(...c),Math.max(...y)-Math.min(...y)];for(let[i,d]of Object.entries(l1)){let x=[];for(let f=0;fM.part===d[f]),g=v0.keypoints.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}v0.annotations[i]=x}r([v0])}))}var Q0=V(D());var uA=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,o5=[],w3=0,k3=0,y1=Number.MAX_SAFE_INTEGER;async function E3(e){var t;return R.initial&&(G0=null),G0?e.debug&&b("cached model:",G0.modelUrl):G0=await F((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function d1(e,t,o,n){var s,a;if(!G0)return[];let r=y1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>v()-k3;return t.skipAllowed&&A&&r&&w3===n&&o5[o]&&o5[o].length>0?(y1++,o5[o]):(y1=0,new Promise(async l=>{var y;let c=[];if((y=t.face.emotion)!=null&&y.enabled){let i={},d=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;i.resize=Q0.image.resizeBilinear(e,[d,d],!1),i.channels=Q0.mul(i.resize,H.rgb),i.grayscale=Q0.sum(i.channels,3,!0),i.grayscaleSub=Q0.sub(i.grayscale,H.tf05),i.grayscaleMul=Q0.mul(i.grayscaleSub,H.tf2),i.emotion=G0==null?void 0:G0.execute(i.grayscaleMul),k3=v();let x=await i.emotion.data();for(let f=0;f(t.face.emotion.minConfidence||0)&&c.push({score:Math.min(.99,Math.trunc(100*x[f])/100),emotion:uA[f]});c.sort((f,p)=>p.score-f.score),Object.keys(i).forEach(f=>Q0.dispose(i[f]))}o5[o]=c,w3=n,l(c)}))}var n5=V(D());var C0,f1=[],S3=0,C3=0,j3=Number.MAX_SAFE_INTEGER;async function I3(e){var t;return R.initial&&(C0=null),C0?e.debug&&b("cached model:",C0.modelUrl):C0=await F((t=e.face.mobilefacenet)==null?void 0:t.modelPath),C0}async function m1(e,t,o,n){var s,a;if(!(C0!=null&&C0.executor))return[];let r=j3<(((s=t.face.mobilefacenet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.mobilefacenet)==null?void 0:a.skipTime)||0)>v()-C3;return t.skipAllowed&&A&&r&&S3===n&&f1[o]?(j3++,f1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.mobilefacenet)==null?void 0:y.enabled)&&(C0==null?void 0:C0.inputs[0].shape)){let i={};i.crop=n5.image.resizeBilinear(e,[C0.inputs[0].shape[2],C0.inputs[0].shape[1]],!1),i.data=C0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>n5.dispose(i[x]))}f1[o]=c,S3=n,C3=v(),l(c)})}var r5=V(D());var j0,p1=[],O3=0,L3=0,W3=Number.MAX_SAFE_INTEGER;async function F3(e){return R.initial&&(j0=null),j0?e.debug&&b("cached model:",j0.modelUrl):j0=await F(e.face.insightface.modelPath),j0}async function u1(e,t,o,n){var s,a;if(!(j0!=null&&j0.executor))return[];let r=W3<(((s=t.face.insightface)==null?void 0:s.skipFrames)||0),A=(((a=t.face.insightface)==null?void 0:a.skipTime)||0)>v()-L3;return t.skipAllowed&&A&&r&&O3===n&&p1[o]?(W3++,p1[o]):new Promise(async l=>{var y;let c=[];if(((y=t.face.insightface)==null?void 0:y.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let i={};i.crop=r5.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),i.data=j0.execute(i.crop);let d=await i.data.data();c=Array.from(d),Object.keys(i).forEach(x=>r5.dispose(i[x]))}p1[o]=c,O3=n,L3=v(),l(c)})}var Re=V(D());var _0=V(D());var I0,ve=0,hA=2.3,h1=q0.leftEyeLower0,b1=q0.rightEyeLower0,e2={leftBounds:[h1[0],h1[h1.length-1]],rightBounds:[b1[0],b1[b1.length-1]]},t2={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function V3(e){var t,o;return R.initial&&(I0=null),I0?e.debug&&b("cached model:",I0.modelUrl):I0=await F((t=e.face.iris)==null?void 0:t.modelPath),ve=(I0==null?void 0:I0.executor)&&((o=I0.inputs)==null?void 0:o[0].shape)?I0.inputs[0].shape[2]:0,ve===-1&&(ve=64),I0}function A5(e,t,o,n){for(let r=0;r{let t=e[e2.leftBounds[0]][2],o=e[e2.rightBounds[0]][2];return t-o},B3=(e,t,o,n,r,A=!1)=>{let s=K2(Y2(e3([e[o],e[n]]),hA)),a=Je(s),l=_0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ve,ve]);if(A&&R.kernels.includes("flipleftright")){let c=_0.image.flipLeftRight(l);_0.dispose(l),l=c}return{box:s,boxSize:a,crop:l}},H3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A{let n=e[q0[`${o}EyeUpper0`][t2.upperCenter]][2],r=e[q0[`${o}EyeLower0`][t2.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let l=A;return a===2?l=n:a===4&&(l=r),[s[0],s[1],l]})};async function Z3(e,t,o){if(!(I0!=null&&I0.executor))return e;let{box:n,boxSize:r,crop:A}=B3(e,t,e2.leftBounds[0],e2.leftBounds[1],o,!0),{box:s,boxSize:a,crop:l}=B3(e,t,e2.rightBounds[0],e2.rightBounds[1],o,!0),c=_0.concat([A,l]);_0.dispose(A),_0.dispose(l);let y=I0.execute(c);_0.dispose(c);let i=await y.data();_0.dispose(y);let d=i.slice(0,t2.numCoordinates*3),{rawCoords:x,iris:f}=H3(d,n,r,!0),p=i.slice(t2.numCoordinates*3),{rawCoords:g,iris:M}=H3(p,s,a,!1),P=bA(e);Math.abs(P)<30?(A5(e,x,"left",null),A5(e,g,"right",null)):P<1?A5(e,x,"left",["EyeUpper0","EyeLower0"]):A5(e,g,"right",["EyeUpper0","EyeLower0"]);let m=D3(e,f,"left"),u=D3(e,M,"right");return e.concat(m).concat(u)}var gA=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],MA=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],vA=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],PA=[[474,475],[475,476],[476,477],[477,474]],RA=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],TA=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],wA=[[469,470],[470,471],[471,472],[472,469]],kA=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]];function Pe(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var EA={lips:Pe(gA),leftEye:Pe(MA),leftEyebrow:Pe(vA),leftIris:Pe(PA),rightEye:Pe(RA),rightEyebrow:Pe(TA),rightIris:Pe(wA),faceOval:Pe(kA)},zA=Object.entries(EA).map(([e,t])=>t.map(o=>[o,e])).flat(),D4=new Map(zA),w2=[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],Fe=[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],Ge=[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417];async function U3(e,t){var A,s,a,l,c,y,i,d,x,f;let o={lips:await((s=(A=t.filter(p=>p.size===160))==null?void 0:A[0])==null?void 0:s.data()),irisL:await((l=(a=t.filter(p=>p.size===10))==null?void 0:a[0])==null?void 0:l.data()),eyeL:await((y=(c=t.filter(p=>p.size===142))==null?void 0:c[0])==null?void 0:y.data()),irisR:await((d=(i=t.filter(p=>p.size===10))==null?void 0:i[1])==null?void 0:d.data()),eyeR:await((f=(x=t.filter(p=>p.size===142))==null?void 0:x[1])==null?void 0:f.data())};for(let p of Object.values(o))if(!p)return e;let n=Fe.reduce((p,g)=>p+=e[g][2],0)/Fe.length;for(let p=0;pp+=e[g][2],0)/Ge.length;for(let p=0;pv()-Ae.timestamp,n=Ae.skipped<(((c=t.face.detector)==null?void 0:c.skipFrames)||0);!t.skipAllowed||!o||!n||Ae.boxes.length===0?(Ae.boxes=await l3(e,t),Ae.timestamp=v(),Ae.skipped=0):Ae.skipped++;let r=[],A=[],s=0,a=k2;for(let P=0;PI.shape[I.shape.length-1]===1).data();if(w.faceScore=Math.round(100*X[0])/100,w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(m.confidence=w.faceScore,t.face.mesh.keepInvalid){w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(I=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*I[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*I[1]/Qe()]),w.meshRaw=w.mesh.map(I=>[I[0]/(e.shape[2]||1),I[1]/(e.shape[1]||1),(I[2]||0)/a]);for(let I of Object.keys(Ne))w.annotations[I]=[w.mesh[Ne[I]]]}}else{let I=h.find(j=>j.shape[j.shape.length-1]===1404),W=Re.reshape(I,[-1,3]),Z=await W.array();Re.dispose(W),(p=t.face.attention)!=null&&p.enabled?Z=await U3(Z,h):(g=t.face.iris)!=null&&g.enabled&&(Z=await Z3(Z,w.tensor,k2)),w.mesh=n3(Z,m,u,k,k2),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/a]);for(let j of Object.keys(q0))w.annotations[j]=q0[j].map(m0=>w.mesh[m0]);w.score=w.faceScore;let O={...A3(w.mesh,m),confidence:m.confidence,landmarks:m.landmarks};w.box=q2(O,e),w.boxRaw=U2(O,e),A.push(O)}Re.dispose(h)}else{w.box=q2(m,e),w.boxRaw=U2(m,e),w.score=w.boxScore,w.mesh=m.landmarks.map(h=>[(m.startPoint[0]+m.endPoint[0])/2+(m.endPoint[0]+m.startPoint[0])*h[0]/Qe(),(m.startPoint[1]+m.endPoint[1])/2+(m.endPoint[1]+m.startPoint[1])*h[1]/Qe()]),w.meshRaw=w.mesh.map(h=>[h[0]/(e.shape[2]||0),h[1]/(e.shape[1]||0),(h[2]||0)/a]);for(let h of Object.keys(Ne))w.annotations[h]=[w.mesh[Ne[h]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):Re.dispose(w.tensor)}return Ae.boxes=A,r}async function K3(e){var t,o,n,r,A,s;return R.initial&&(_=null),((t=e.face.attention)==null?void 0:t.enabled)&&(_==null?void 0:_.signature)&&Object.keys(((o=_==null?void 0:_.signature)==null?void 0:o.outputs)||{}).length<6&&(_=null),_?e.debug&&b("cached model:",_.modelUrl):(n=e.face.attention)!=null&&n.enabled?_=await F(e.face.attention.modelPath):_=await F((r=e.face.mesh)==null?void 0:r.modelPath),k2=_.executor&&((A=_==null?void 0:_.inputs)==null?void 0:A[0].shape)?(s=_==null?void 0:_.inputs)==null?void 0:s[0].shape[2]:256,_}var J3=Oe,Q3=P2;var $0=V(D());var h0,Te=[],_3=0,$3=0,M1=Number.MAX_SAFE_INTEGER;async function eo(e){var t;return R.initial&&(h0=null),h0?e.debug&&b("cached model:",h0.modelUrl):h0=await F((t=e.face.description)==null?void 0:t.modelPath),h0}function v1(e){let t=e.image||e.tensor||e;if(!(h0!=null&&h0.inputs[0].shape))return t;let o=$0.image.resizeBilinear(t,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),n=$0.mul(o,H.tf255);return $0.dispose(o),n}async function P1(e,t,o,n){var a,l,c,y;let r={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(!(h0!=null&&h0.executor))return r;let A=M1<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((l=t.face.description)==null?void 0:l.skipTime)||0)>v()-_3;return t.skipAllowed&&A&&s&&$3===n&&((c=Te==null?void 0:Te[o])==null?void 0:c.age)>0&&((y=Te==null?void 0:Te[o])==null?void 0:y.genderScore)>0?(M1++,Te[o]):(M1=0,new Promise(async i=>{var d;if((d=t.face.description)!=null&&d.enabled){let x=v1(e),f=h0==null?void 0:h0.execute(x);_3=v(),$0.dispose(x);let g=await f.find(B=>B.shape[1]===1).data(),M=Math.trunc(200*Math.abs(g[0]-.5))/100;M>(t.face.description.minConfidence||0)&&(r.gender=g[0]<=.5?"female":"male",r.genderScore=Math.min(.99,M));let P=$0.argMax(f.find(B=>B.shape[1]===100),1),m=(await P.data())[0];$0.dispose(P);let k=await f.find(B=>B.shape[1]===100).data();r.age=Math.round(k[m-1]>k[m+1]?10*m-100*k[m-1]:10*m+100*k[m+1])/10,(Number.isNaN(g[0])||Number.isNaN(k[0]))&&b("faceres error:",{model:h0,result:f});let w=f.find(B=>B.shape[1]===1024),h=w?await w.data():[];r.descriptor=Array.from(h),f.forEach(B=>$0.dispose(B))}Te[o]=r,$3=n,i(r)}))}var G=V(D());var no=V(D());function s5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function E2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function ro(e,t,o){let n=t.shape[1],r=t.shape[2],A=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return no.image.cropAndResize(t,A,[0],o)}function Ao(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(A=>[A[0]*t[0],A[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function a5(e,t=1.5){let o=E2(e),n=s5(e),r=[t*n[0]/2,t*n[1]/2],A=[o[0]-r[0],o[1]-r[1]],s=[o[0]+r[0],o[1]+r[1]];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function i5(e){let t=E2(e),o=s5(e),r=Math.max(...o)/2,A=[t[0]-r,t[1]-r],s=[t[0]+r,t[1]+r];return{startPoint:A,endPoint:s,palmLandmarks:e.palmLandmarks}}function CA(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function so(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return CA(o)}var to=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function we(e,t){let o=0;for(let n=0;n[s.x,s.y]),this.anchorsTensor=G.tensor2d(this.anchors),this.inputSize=((A=(r=(n=(o=this==null?void 0:this.model)==null?void 0:o.inputs)==null?void 0:n[0])==null?void 0:r.shape)==null?void 0:A[2])||0,this.inputSizeTensor=G.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=G.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=G.slice(t,[0,0],[-1,2]),o.boxSizes=G.slice(t,[0,2],[-1,2]),o.div=G.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=G.add(o.div,this.anchorsTensor),o.halfBoxSizes=G.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=G.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=G.mul(o.sub,this.inputSizeTensor),o.add=G.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=G.mul(o.add,this.inputSizeTensor);let n=G.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>G.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=G.reshape(t,[-1,7,2]),n.div=G.div(n.reshape,this.inputSizeTensor),n.landmarks=G.add(n.div,this.anchors[o]?this.anchors[o]:0);let r=G.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>G.dispose(n[A])),r}async predict(t,o){var a;let n={};n.resize=G.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=G.div(n.resize,H.tf127),n.image=G.sub(n.div,H.tf1),n.batched=this.model.execute(n.image),n.predictions=G.squeeze(n.batched),n.slice=G.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=G.sigmoid(n.slice),n.scores=G.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=G.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await G.image.nonMaxSuppressionAsync(n.norm,n.scores,3*(((a=o.hand)==null?void 0:a.maxDetected)||1),o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let l of A){let c={};c.box=G.slice(n.norm,[l,0],[1,-1]),c.slice=G.slice(n.predictions,[l,5],[1,14]),c.norm=this.normalizeLandmarks(c.slice,l),c.palmLandmarks=G.reshape(c.norm,[-1,2]);let y=await c.box.data(),i=y.slice(0,2),d=y.slice(2,4),x=await c.palmLandmarks.array(),f={startPoint:i,endPoint:d,palmLandmarks:x,confidence:r[l]},p=Ao(f,[(t.shape[2]||1)/this.inputSize,(t.shape[1]||0)/this.inputSize]);s.push(p),Object.keys(c).forEach(g=>G.dispose(c[g]))}return Object.keys(n).forEach(l=>G.dispose(n[l])),s}};var N0=V(D());var OA=5,co=1.65,xo=[0,5,9,13,17,1,2],LA=0,WA=2,yo=0,c5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");var n,r,A;this.handDetector=t,this.handPoseModel=o,this.inputSize=((A=(r=(n=this.handPoseModel)==null?void 0:n.inputs)==null?void 0:r[0].shape)==null?void 0:A[2])||0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(s=>s[0]),n=t.map(s=>s[1]),r=[Math.min(...o),Math.min(...n)],A=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:A}}getBoxForPalmLandmarks(t,o){let n=t.map(A=>w1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return a5(i5(r),OA)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=a5(i5(o),co);n.palmLandmarks=[];for(let r=0;r[s[0]*(x[0]-this.inputSize/2),s[1]*(x[1]-this.inputSize/2),s[2]*x[2]]),l=T1(n,[0,0]),c=a.map(x=>[...w1(x,l),x[2]]),y=ao(r),i=[...E2(o),1],d=[we(i,y[0]),we(i,y[1])];return c.map(x=>[Math.trunc(x[0]+d[0]),Math.trunc(x[1]+d[1]),Math.trunc(x[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>v()-yo,s=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&A&&s&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let a=[];for(let l=0;l=o.hand.minConfidence/4){let k=N0.reshape(m,[-1,3]),w=await k.array();N0.dispose(m),N0.dispose(k);let h=this.transformRawCoords(w,p,y,f),B=this.getBoxForHandLandmarks(h);this.storedBoxes[l]={...B,confidence:u};let X={landmarks:h,confidence:u,boxConfidence:c.confidence,fingerConfidence:u,box:{topLeft:B.startPoint,bottomRight:B.endPoint}};a.push(X)}else this.storedBoxes[l]=null;N0.dispose(m)}else{let y=a5(i5(c),co),i={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:y.startPoint,bottomRight:y.endPoint},landmarks:[]};a.push(i)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var P0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>P0.nameMapping[e],getPoints:e=>P0.pointsMapping[e]},Ee={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Ee.nameMapping[e]},$={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>$.nameMapping[e]},ke=class{constructor(t){T(this,"name");T(this,"curls");T(this,"directions");T(this,"weights");T(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,A)=>r+A,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let A=t[r],s=this.curls[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}for(let r in o){let A=o[r],s=this.directions[r];if(typeof s=="undefined"){n+=this.weightsRelative[r];continue}for(let[a,l]of s)if(A===a){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:ee,index:ce,middle:xe,ring:Be,pinky:He}=P0,{none:te,half:GA,full:oe}=Ee,{verticalUp:o2,verticalDown:ns,horizontalLeft:k1,horizontalRight:BA,diagonalUpRight:HA,diagonalUpLeft:n2,diagonalDownRight:rs,diagonalDownLeft:As}=$,ze=new ke("thumbs up");ze.curl(ee,te,1);ze.direction(ee,o2,1);ze.direction(ee,n2,.25);ze.direction(ee,HA,.25);for(let e of[P0.index,P0.middle,P0.ring,P0.pinky])ze.curl(e,oe,1),ze.direction(e,k1,1),ze.direction(e,BA,1);var i0=new ke("victory");i0.curl(ee,GA,.5);i0.curl(ee,te,.5);i0.direction(ee,o2,1);i0.direction(ee,n2,1);i0.curl(ce,te,1);i0.direction(ce,o2,.75);i0.direction(ce,n2,1);i0.curl(xe,te,1);i0.direction(xe,o2,1);i0.direction(xe,n2,.75);i0.curl(Be,oe,1);i0.direction(Be,o2,.2);i0.direction(Be,n2,1);i0.direction(Be,k1,.2);i0.curl(He,oe,1);i0.direction(He,o2,.2);i0.direction(He,n2,1);i0.direction(He,k1,.2);i0.weight(ce,2);i0.weight(xe,2);var Se=new ke("point");Se.curl(ee,oe,1);Se.curl(ce,te,.5);Se.curl(xe,oe,.5);Se.curl(Be,oe,.5);Se.curl(He,oe,.5);Se.weight(ce,2);Se.weight(xe,2);var Ce=new ke("middle finger");Ce.curl(ee,te,1);Ce.curl(ce,oe,.5);Ce.curl(xe,oe,.5);Ce.curl(Be,oe,.5);Ce.curl(He,oe,.5);Ce.weight(ce,2);Ce.weight(xe,2);var r2=new ke("open palm");r2.curl(ee,te,.75);r2.curl(ce,te,.75);r2.curl(xe,te,.75);r2.curl(Be,te,.75);r2.curl(He,te,.75);var fo=[ze,i0,Se,Ce,r2];var DA=.7,De={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function mo(e,t,o,n){let r=(t-n)/(e-o),A=Math.atan(r)*180/Math.PI;return A<=0?A=-A:A>0&&(A=180-A),A}function uo(e,t){if(!e||!t)return[0,0];let o=mo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=mo(e[1],e[2],t[1],t[2]);return[o,n]}function po(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function VA(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],A=t[0]-o[0],s=e[1]-t[1],a=e[1]-o[1],l=t[1]-o[1],c=e[2]-t[2],y=e[2]-o[2],i=t[2]-o[2],d=Math.sqrt(n*n+s*s+c*c),x=Math.sqrt(r*r+a*a+y*y),f=Math.sqrt(A*A+l*l+i*i),p=(f*f+d*d-x*x)/(2*f*d);p>1?p=1:p<-1&&(p=-1);let g=Math.acos(p);g=57.2958*g%180;let M;return g>De.NO_CURL_START_LIMIT?M=Ee.none:g>De.HALF_CURL_START_LIMIT?M=Ee.half:M=Ee.full,M}function ho(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=$.horizontalLeft:r=$.horizontalRight:n===Math.abs(t)?t>0?r=$.horizontalLeft:r=$.horizontalRight:o>0?r=$.horizontalLeft:r=$.horizontalRight,r}function bo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=$.verticalDown:r=$.verticalUp:n===Math.abs(t)?t<0?r=$.verticalDown:r=$.verticalUp:o<0?r=$.verticalDown:r=$.verticalUp,r}function ZA(e,t,o,n,r,A,s,a){let l,c=bo(e,t,o,n),y=ho(r,A,s,a);return c===$.verticalUp?y===$.horizontalLeft?l=$.diagonalUpLeft:l=$.diagonalUpRight:y===$.horizontalLeft?l=$.diagonalDownLeft:l=$.diagonalDownRight,l}function XA(e,t,o,n){let r=e[0]-t[0],A=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],l=e[1]-o[1],c=t[1]-o[1],y=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),i=Math.max(Math.abs(a),Math.abs(l),Math.abs(c)),d=0,x=0,f=0,p=i/(y+1e-5);p>1.5?d+=De.DISTANCE_VOTE_POWER:p>.66?x+=De.DISTANCE_VOTE_POWER:f+=De.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+a*a),M=Math.sqrt(A*A+l*l),P=Math.sqrt(s*s+c*c),m=Math.max(g,M,P),u=e[0],k=e[1],w=o[0],h=o[1];m===g?(w=o[0],h=o[1]):m===P&&(u=t[0],k=t[1]);let I=uo([u,k],[w,h]),W=po(I,De.TOTAL_ANGLE_VOTE_POWER);d+=W[0],x+=W[1],f+=W[2];for(let O of n){let j=po(O,De.SINGLE_ANGLE_VOTE_POWER);d+=j[0],x+=j[1],f+=j[2]}let Z;return d===Math.max(d,x,f)?Z=bo(l,a,c,i):f===Math.max(x,f)?Z=ho(A,r,s,y):Z=ZA(l,a,c,i,A,r,s,y),Z}function go(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of P0.all){let s=P0.getPoints(A),a=[],l=[];for(let c of s){let y=e[c[0]],i=e[c[1]],d=uo(y,i),x=d[0],f=d[1];a.push(x),l.push(f)}t.push(a),o.push(l)}for(let A of P0.all){let s=A===P0.thumb?1:0,a=P0.getPoints(A),l=e[a[s][0]],c=e[a[s+1][1]],y=e[a[3][1]],i=VA(l,c,y),d=XA(l,c,y,t[A].slice(s));n[A]=i,r[A]=d}return{curls:n,directions:r}}function x5(e){if(!e||e.length===0)return null;let t=go(e),o={};for(let n of P0.all)o[P0.getName(n)]={curl:Ee.getName(t.curls[n]),direction:$.getName(t.directions[n])};return o}function Mo(e){let t=[];if(!e||e.length===0)return t;let o=go(e);for(let n of fo){let r=n.matchAgainst(o.curls,o.directions);r>=DA&&t.push({name:n.name,confidence:r})}return t}var vo={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},Ve,Ze,Po;async function z1(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[i]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(s&&s.length>0){for(let y of s)y[0]a[2]&&(a[2]=y[0]),y[1]>a[3]&&(a[3]=y[1]);a[2]-=a[0],a[3]-=a[1],l=[a[0]/(e.shape[2]||0),a[1]/(e.shape[1]||0),a[2]/(e.shape[2]||0),a[3]/(e.shape[1]||0)]}else a=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let c=x5(s);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:a,boxRaw:l,keypoints:s,annotations:A,landmarks:c})}return n}async function S1(e){var o,n;R.initial&&(Ve=null,Ze=null),!Ve||!Ze?[Ve,Ze]=await Promise.all([e.hand.enabled?F((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?F((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&b("cached model:",Ve.modelUrl),e.debug&&b("cached model:",Ze.modelUrl));let t=Ve?new l5(Ve):void 0;return t&&Ze&&(Po=new c5(t,Ze)),[Ve,Ze]}var K=V(D());var r0=V(D());var Q={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function qA(){let e=Q.gl;!e||(Q.extensions=e.getSupportedExtensions())}function To(e){var t;if(e.config.backend==="humangl"&&(Q.name in r0.engine().registry&&!((t=Q==null?void 0:Q.gl)!=null&&t.getParameter(Q.gl.VERSION))&&(b("humangl error: backend invalid context"),y5(e)),!r0.findBackend(Q.name))){try{Q.canvas=g0(100,100)}catch(n){b("humangl error: cannot create canvas:",n);return}try{if(Q.gl=Q.canvas.getContext("webgl2",Q.webGLattr),!Q.gl){b("humangl error: cannot get webgl context");return}if(!Q.gl.getParameter(Q.gl.VERSION).includes("2.0")){b("backend override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Q.canvas&&(Q.canvas.addEventListener("webglcontextlost",r=>{throw b("humangl error:",r.type),b("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Q.canvas.addEventListener("webglcontextrestored",r=>{b("humangl error: context restored:",r)}),Q.canvas.addEventListener("webglcontextcreationerror",r=>{b("humangl error: context create:",r)}))}catch(n){b("humangl error: cannot get webgl context:",n);return}try{r0.setWebGLContext(2,Q.gl)}catch(n){b("humangl error: cannot set webgl context:",n);return}try{let n=new r0.GPGPUContext(Q.gl);r0.registerBackend(Q.name,()=>new r0.MathBackendWebGL(n),Q.priority)}catch(n){b("humangl error: cannot register webgl backend:",n);return}try{r0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:Q.name};r0.registerKernel(A)})}catch(n){b("humangl error: cannot update webgl backend registration:",n);return}try{r0.env().flagRegistry.WEBGL_VERSION&&r0.env().set("WEBGL_VERSION",2)}catch(n){b("humangl error: cannot set WebGL backend flags:",n);return}qA();let o=r0.backend().getGPGPUContext?r0.backend().getGPGPUContext().gl:null;o?e.config.debug&&b("humangl backend registered:",{webgl:o.getParameter(o.VERSION),renderer:o.getParameter(o.RENDERER)}):b("humangl error: no current gl context:",o,Q.gl)}}var E=V(D());function UA(e){let t=[];if(!R.kernels.includes("mod")){let o={kernelName:"Mod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.sub(n.inputs.a,E.mul(E.div(n.inputs.a,n.inputs.b),n.inputs.b)))};E.registerKernel(o),R.kernels.push("mod"),t.push("mod")}if(!R.kernels.includes("floormod")){let o={kernelName:"FloorMod",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>E.add(E.mul(E.floorDiv(n.inputs.a/n.inputs.b),n.inputs.b),E.mod(n.inputs.a,n.inputs.b)))};E.registerKernel(o),R.kernels.push("floormod"),t.push("floormod")}if(!R.kernels.includes("rotatewithoffset")&&e.softwareKernels){let o={kernelName:"RotateWithOffset",backendName:E.getBackend(),kernelFunc:n=>E.tidy(()=>{let r=E.getBackend();E.setBackend("cpu");let A=E.image.rotateWithOffset(n.inputs.image,n.attrs.radians,n.attrs.fillValue,n.attrs.center);return E.setBackend(r),A})};E.registerKernel(o),R.kernels.push("rotatewithoffset"),t.push("rotatewithoffset")}t.length>0&&e.debug&&b("registered kernels:",t)}var ko={};async function z2(e,t=!1){if(e.state="backend",t||R.initial||e.config.backend&&e.config.backend.length>0&&E.getBackend()!==e.config.backend){let o=v();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&b("running inside web worker"),R.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&b("override: backend set to tensorflow while running in browser"),e.config.backend="webgl"),R.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&b(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),R.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")b("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="webgl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&b("enumerated webgpu adapter:",r),!r)b("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="webgl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;b("webgpu adapter info:",A)}}let n=Object.keys(E.engine().registryFactory);if(e.config.backend==="humangl"&&!n.includes("humangl")&&(To(e),n=Object.keys(E.engine().registryFactory)),e.config.debug&&b("available backends:",n),n.includes(e.config.backend)||(b(`error: backend ${e.config.backend} not found in registry`),e.config.backend=R.node?"tensorflow":"webgl",e.config.debug&&b(`override: setting backend ${e.config.backend}`)),e.config.debug&&b("setting backend:",[e.config.backend]),e.config.backend==="wasm"){if(E.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY&&E.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0),e.config.debug&&b("wasm path:",e.config.wasmPath),typeof E.setWasmPaths!="undefined")E.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=!1,A=!1;try{r=await E.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"),A=await E.env().getAsync("WASM_HAS_SIMD_SUPPORT"),e.config.debug&&b(`wasm execution: ${A?"simd":"no simd"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!A&&b("warning: wasm simd support is not enabled")}catch(s){b("wasm detection failed")}}try{await E.setBackend(e.config.backend),await E.ready()}catch(r){return b("error: cannot set backend:",e.config.backend,r),!1}e.config.debug&&(ko=JSON.parse(JSON.stringify(E.env().flags)))}if((E.getBackend()==="humangl"||E.getBackend()==="webgl")&&(E.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS&&E.env().set("WEBGL_USE_SHAPES_UNIFORMS",!0),E.env().flagRegistry.WEBGL_EXP_CONV&&E.env().set("WEBGL_EXP_CONV",!0),e.config.debug&&typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(b("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),E.env().set("WEBGL_DELETE_TEXTURE_THRESHOLD",0))),E.getBackend(),e.config.debug){let n=E.env().flags,r={};for(let A of Object.keys(n))ko[A]!==n[A]&&(r[A]=n[A]);e.config.debug&&Object.keys(r).length>0&&b("backend:",E.getBackend(),"flags:",r)}if(e.config.flags&&Object.keys(e.config.flags).length>0){e.config.debug&&b("flags:",e.config.flags);for(let[n,r]of Object.entries(e.config.flags))E.env().set(n,r)}E.enableProdMode(),Ft(),e.performance.initBackend=Math.trunc(v()-o),e.config.backend=E.getBackend(),await R.updateBackend(),UA(e.config),R.initial=!1}return!0}function d5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&b("kernelFunc",o,t.backend)}};E.registerKernel(n)}R.kernels=E.getKernelsForBackend(E.getBackend()).map(o=>o.kernelName.toLowerCase())}var s0=[null,null],YA=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],je=[[0,0],[0,0]],KA=["hand","fist","pinch","point","face","tip","pinchtip"],zo=4,So=1.6,JA=512,QA=1.4,f5=Number.MAX_SAFE_INTEGER,C1=0,ye=[0,0],A0={boxes:[],hands:[]},Co={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function jo(e){var t;if(R.initial&&(s0[0]=null),s0[0])e.debug&&b("cached model:",s0[0].modelUrl);else{d5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),s0[0]=await F((t=e.hand.detector)==null?void 0:t.modelPath);let o=s0[0].executor?Object.values(s0[0].modelSignature.inputs):void 0;je[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[0]}async function Io(e){var t;if(R.initial&&(s0[1]=null),s0[1])e.debug&&b("cached model:",s0[1].modelUrl);else{s0[1]=await F((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=s0[1].executor?Object.values(s0[1].modelSignature.inputs):void 0;je[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,je[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return s0[1]}async function _A(e,t){let o=[];if(!e||!s0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),A=Math.min(Math.round((e.shape[1]||0)/8)*8,JA),s=Math.round(A*r/8)*8;n.resize=K.image.resizeBilinear(e,[A,s]),n.cast=K.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await s0[0].executeAsync(n.cast,YA),n.boxes=K.squeeze(n.rawBoxes,[0,2]),n.scores=K.squeeze(n.rawScores,[0]);let a=K.unstack(n.scores,1);K.dispose(a[zo]),a.splice(zo,1),n.filtered=K.stack(a,1),K.dispose(a),n.max=K.max(n.filtered,1),n.argmax=K.argMax(n.filtered,1);let l=0;n.nms=await K.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let c=await n.nms.data(),y=await n.max.data(),i=await n.argmax.data();for(let d of Array.from(c)){let x=K.slice(n.boxes,d,1),f=await x.data();K.dispose(x);let p=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=_2(p,QA),M=[Math.trunc(p[0]*ye[0]),Math.trunc(p[1]*ye[1]),Math.trunc(p[2]*ye[0]),Math.trunc(p[3]*ye[1])],P=y[d],m=KA[i[d]],u={id:l++,score:P,box:M,boxRaw:g,label:m};o.push(u)}return Object.keys(n).forEach(d=>K.dispose(n[d])),o.sort((d,x)=>x.score-d.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function j1(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&s0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},A=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=K.image.cropAndResize(e,[A],[0],[je[1][0],je[1][1]],"bilinear"),r.div=K.div(r.crop,H.tf255),[r.score,r.keypoints]=s0[1].execute(r.div,["Identity_1","Identity"]);let s=(await r.score.data())[0],a=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(a>=(o.hand.minConfidence||0)){n.fingerScore=a,r.reshaped=K.reshape(r.keypoints,[-1,3]);let y=(await r.reshaped.array()).map(i=>[i[0]/je[1][1],i[1]/je[1][0],i[2]||0]).map(i=>[i[0]*t.boxRaw[2],i[1]*t.boxRaw[3],i[2]||0]);n.keypoints=y.map(i=>[ye[0]*(i[0]+t.boxRaw[0]),ye[1]*(i[1]+t.boxRaw[1]),i[2]||0]),n.landmarks=x5(n.keypoints);for(let i of Object.keys(Co))n.annotations[i]=Co[i].map(d=>n.landmarks&&n.keypoints[d]?n.keypoints[d]:null)}Object.keys(r).forEach(l=>K.dispose(r[l]))}return n}async function I1(e,t){var r,A;if(!((r=s0[0])!=null&&r.executor)||!((A=s0[1])!=null&&A.executor)||!s0[0].inputs[0].shape||!s0[1].inputs[0].shape)return[];ye=[e.shape[2]||0,e.shape[1]||0],f5++;let o=(t.hand.skipTime||0)>v()-C1,n=f5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>v()-C1,l=f5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):t.skipAllowed&&a&&l&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))):(A0.boxes=await _A(e,t),C1=v(),A0.hands=await Promise.all(A0.boxes.map(y=>j1(e,y,t))),f5=0);let c=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let y=0;y.05&&i.box[3]/(e.shape[1]||1)>.05&&A0.hands[y].fingerScore&&A0.hands[y].fingerScore>(t.hand.minConfidence||0)){let d=_2(i.box,So),x=_2(i.boxRaw,So);A0.boxes.push({...c[y],box:d,boxRaw:x})}}for(let y=0;yv()-Lo,A=N1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Oo===n&&m5[o]?(N1++,m5[o]):(N1=0,new Promise(async l=>{let c=p5.image.resizeBilinear(e,[f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[2]:0,f0!=null&&f0.inputs[0].shape?f0.inputs[0].shape[1]:0],!1),y=f0==null?void 0:f0.execute(c),i=(await y.data())[0];m5[o]=Math.round(100*i)/100,Oo=n,Lo=v(),p5.dispose([c,y]),l(m5[o])}))}var Vo=V(D());var S2={};pe(S2,{connected:()=>h5,horizontal:()=>L1,kpt:()=>u5,relative:()=>F1,vertical:()=>W1});var u5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],L1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],W1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],F1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],h5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ie=V(D()),Go=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function G1(e){for(let t of L1){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),A=e.keypoints.findIndex(c=>c&&c.part===o[0]),s=e.keypoints.findIndex(c=>c&&c.part===o[1]);if(!e.keypoints[A]||!e.keypoints[s])continue;let a=e.keypoints[n]?[Math.abs(e.keypoints[A].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[A].position[0]-e.keypoints[r].position[0])]:[0,0];if(a[0]>a[1]||l[0]>l[1]){let c=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=c}}}function Bo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=Ie.pad(e,O0.padding),o.resize=Ie.image.resizeBilinear(o.pad,[t,t]);let n=Ie.cast(o.resize,"int32");return Object.keys(o).forEach(s=>Ie.dispose(o[s])),n}function Do(e,t){e.keypoints=e.keypoints.filter(n=>n==null?void 0:n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+O0.padding[2][0]+O0.padding[2][1])/t[0]-O0.padding[2][0],n.position[1]*(t[1]+O0.padding[1][0]+O0.padding[1][1])/t[1]-O0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=le(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var l0,b5=0,B1=Number.MAX_SAFE_INTEGER,Xe={boxes:[],bodies:[],last:0};async function Zo(e){var t;return R.initial&&(l0=null),l0?e.debug&&b("cached model:",l0.modelUrl):(d5(["size"],e),l0=await F(e.body.modelPath)),b5=(l0==null?void 0:l0.executor)&&((t=l0==null?void 0:l0.inputs)==null?void 0:t[0].shape)?l0.inputs[0].shape[2]:0,b5<64&&(b5=256),l0}function e7(e,t,o){let n=e[0][0],r=[],A=0;for(let y=0;yt.body.minConfidence){let i=[n[y][1],n[y][0]];r.push({score:Math.round(100*A)/100,part:u5[y],positionRaw:i,position:[Math.round((o.shape[2]||0)*i[0]),Math.round((o.shape[1]||0)*i[1])]})}A=r.reduce((y,i)=>i.score>y?i.score:y,0);let s=[],a=le(r.map(y=>y.position),[o.shape[2],o.shape[1]]),l={};for(let[y,i]of Object.entries(h5)){let d=[];for(let x=0;xg.part===i[x]),p=r.find(g=>g.part===i[x+1]);f&&p&&f.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&d.push([f.position,p.position])}l[y]=d}let c={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:l};return G1(c),s.push(c),s}function t7(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let i=0;i<17;i++){let d=A[3*i+2];if(d>t.body.minConfidence){let x=[A[3*i+1],A[3*i+0]];a.push({part:u5[i],score:Math.round(100*d)/100,positionRaw:x,position:[Math.round((o.shape[2]||0)*x[0]),Math.round((o.shape[1]||0)*x[1])]})}}let l=le(a.map(i=>i.position),[o.shape[2],o.shape[1]]),c={};for(let[i,d]of Object.entries(h5)){let x=[];for(let f=0;fM.part===d[f]),g=a.find(M=>M.part===d[f+1]);p&&g&&p.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&x.push([p.position,g.position])}c[i]=x}let y={id:r,score:s,box:l.box,boxRaw:l.boxRaw,keypoints:[...a],annotations:c};G1(y),n.push(y)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function H1(e,t){var r;if(!(l0!=null&&l0.executor)||!((r=l0==null?void 0:l0.inputs)!=null&&r[0].shape))return[];t.skipAllowed||(Xe.boxes.length=0),B1++;let o=(t.body.skipTime||0)>v()-Xe.last,n=B1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?Xe.bodies:new Promise(async A=>{let s={};B1=0,s.input=Ho(e,b5),s.res=l0==null?void 0:l0.execute(s.input),Xe.last=v();let a=await s.res.array();Xe.bodies=s.res.shape[2]===17?e7(a,t,e):t7(a,t,e);for(let l of Xe.bodies)Do(l,[e.shape[2]||1,e.shape[1]||1]),Bo(l.keypoints);Object.keys(s).forEach(l=>Vo.dispose(s[l])),A(Xe.bodies)})}var L0=V(D());var U0,g5=[],qo=0,D1=Number.MAX_SAFE_INTEGER,v5=0,M5=2.5;async function Uo(e){if(!U0||R.initial){U0=await F(e.object.modelPath);let t=U0!=null&&U0.executor?Object.values(U0.modelSignature.inputs):void 0;v5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):416}else e.debug&&b("cached model:",U0.modelUrl);return U0}async function o7(e,t,o){let n=0,r=[],A=v5;for(let c of[1,2,4]){let y=c*13,i=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)===$e.length)),d=await i.array(),x=L0.squeeze(e.find(M=>M.shape[1]===y**2&&(M.shape[2]||0)<$e.length)),f=x.reshape([-1,4,x.shape[1]/4]),p=f.argMax(2),g=await p.array();for(let M=0;M(o.object.minConfidence||0)&&P!==61){let u=(.5+Math.trunc(M%y))/y,k=(.5+Math.trunc(M/y))/y,w=g[M].map(j=>j*(y/c/A)),[h,B]=[u-M5/c*w[0],k-M5/c*w[1]],[X,I]=[u+M5/c*w[2]-h,k+M5/c*w[3]-B],W=[h,B,X,I];W=W.map(j=>Math.max(0,Math.min(j,1)));let Z=[W[0]*t[0],W[1]*t[1],W[2]*t[0],W[3]*t[1]],O={id:n++,score:Math.round(100*m)/100,class:P+1,label:$e[P].label,box:Z.map(j=>Math.trunc(j)),boxRaw:W};r.push(O)}}L0.dispose([i,x,f,p])}let s=r.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),a=r.map(c=>c.score),l=[];if(s&&s.length>0){let c=await L0.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);l=await c.data(),L0.dispose(c)}return r=r.filter((c,y)=>l.includes(y)).sort((c,y)=>y.score-c.score),r}async function V1(e,t){if(!(U0!=null&&U0.executor))return[];let o=(t.object.skipTime||0)>v()-qo,n=D1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&g5.length>0?(D1++,g5):(D1=0,!R.kernels.includes("mod")||!R.kernels.includes("sparsetodense")?g5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=L0.image.resizeBilinear(e,[v5,v5],!1),a=L0.div(s,H.tf255),l=L0.transpose(a,[0,3,1,2]),c;t.object.enabled&&(c=U0.execute(l)),qo=v();let y=await o7(c,A,t);g5=y,L0.dispose([s,a,l,...c]),r(y)}))}var R0=V(D());var j2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n7=j2.length,C2=j2.reduce((e,t,o)=>(e[t]=o,e),{}),r7=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],js=r7.map(([e,t])=>[C2[e],C2[t]]),Ko=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Jo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:A},{position:{x:s,y:a}})=>({maxX:Math.max(o,s),maxY:Math.max(n,a),minX:Math.min(r,s),minY:Math.min(A,a)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Qo(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(c,y)=>({id:y,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/n,c.box[2]/r,c.box[3]/n],box:[Math.trunc(c.box[0]*s),Math.trunc(c.box[1]*A),Math.trunc(c.box[2]*s),Math.trunc(c.box[3]*A)],keypoints:c.keypoints.map(({score:i,part:d,position:x})=>({score:i,part:d,position:[Math.trunc(x.x*s),Math.trunc(x.y*A)],positionRaw:[x.x/n,x.y/n]})),annotations:{}});return e.map((c,y)=>a(c,y))}var P5=class{constructor(t,o){T(this,"priorityQueue");T(this,"numberOfElements");T(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function _o(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function U1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var W0,s7=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],R5=1,s2=16,a7=50**2;function $o(e,t,o,n,r,A,s=2){let a=M=>({y:A.get(M.y,M.x,e),x:A.get(M.y,M.x,A.shape[2]/2+e)}),l=(M,P,m)=>({y:q1(Math.round(M.y/s2),0,P-1),x:q1(Math.round(M.x/s2),0,m-1)}),[c,y]=n.shape,i=l(t.position,c,y),d=a(i),f=U1(t.position,d);for(let M=0;M[C2[d],C2[x]]),s=A.map(([,d])=>d),a=A.map(([d])=>d),l=t.shape[2],c=s.length,y=new Array(l),i=X1(e.part,s2,o);y[e.part.id]={score:e.score,part:j2[e.part.id],position:i};for(let d=c-1;d>=0;--d){let x=s[d],f=a[d];y[x]&&!y[f]&&(y[f]=$o(d,y[x],f,t,o,r))}for(let d=0;dt){a=!1;break}if(!a)break}return a}function c7(e,t){let[o,n,r]=t.shape,A=new P5(o*n*r,({score:s})=>s);for(let s=0;s{var s;let A=(s=r[n])==null?void 0:s.position;return A?_o(o,t,A.y,A.x)<=a7:!1})}function x7(e,t){return t.reduce((n,{position:r,score:A},s)=>(en(e,r,s)||(n+=A),n),0)/t.length}function y7(e,t,o,n,r,A){let s=[],a=c7(A,t);for(;s.lengthx.score>A);let i=x7(s,y),d=Jo(y);i>A&&s.push({keypoints:y,box:d,score:Math.round(100*i)/100})}return s}async function Y1(e,t){if(!(W0!=null&&W0.executor))return[];let o=R0.tidy(()=>{if(!W0.inputs[0].shape)return[];let s=R0.image.resizeBilinear(e,[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]),a=R0.sub(R0.div(R0.cast(s,"float32"),127.5),1),c=W0.execute(a,s7).map(y=>R0.squeeze(y,[0]));return c[1]=R0.sigmoid(c[1]),c}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)R0.dispose(s);let r=y7(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return W0.inputs[0].shape?Qo(r,[e.shape[1],e.shape[2]],[W0.inputs[0].shape[2],W0.inputs[0].shape[1]]):[]}async function tn(e){return!W0||R.initial?W0=await F(e.body.modelPath):e.debug&&b("cached model:",W0.modelUrl),W0}var e0=V(D());var se,K1=!1;async function J1(e){return!se||R.initial?se=await F(e.segmentation.modelPath):e.debug&&b("cached model:",se.modelUrl),se}async function nn(e,t,o){var p,g;if(K1)return{data:[],canvas:null,alpha:null};K1=!0,se||await J1(o);let n=await Ye(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,A=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=e0.image.resizeBilinear(n.tensor,[se.inputs[0].shape?se.inputs[0].shape[1]:0,se.inputs[0].shape?se.inputs[0].shape[2]:0],!1),e0.dispose(n.tensor),s.norm=e0.div(s.resize,H.tf255),s.res=se.execute(s.norm),s.squeeze=e0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=e0.softmax(s.squeeze),[s.bg,s.fg]=e0.unstack(s.softmax,2),s.expand=e0.expandDims(s.fg,2),s.pad=e0.expandDims(s.expand,0),s.crop=e0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=e0.squeeze(s.crop,0)):s.data=e0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(R.node&&!R.Canvas&&typeof ImageData=="undefined")return o.debug&&b("canvas support missing"),Object.keys(s).forEach(M=>e0.dispose(s[M])),{data:a,canvas:null,alpha:null};let l=g0(r,A);e0.browser&&await e0.browser.toPixels(s.data,l);let c=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`);let y=c.getImageData(0,0,r,A),i=g0(r,A),d=i.getContext("2d");n.canvas&&d.drawImage(n.canvas,0,0),d.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`),d.drawImage(l,0,0),d.globalCompositeOperation="source-over",d.filter="none";let x=d.getImageData(0,0,r,A);for(let M=0;Me0.dispose(s[M])),K1=!1,{data:a,canvas:i,alpha:l}}var I2=class{constructor(){T(this,"ssrnetage",null);T(this,"gear",null);T(this,"blazeposedetect",null);T(this,"blazepose",null);T(this,"centernet",null);T(this,"efficientpose",null);T(this,"mobilefacenet",null);T(this,"insightface",null);T(this,"emotion",null);T(this,"facedetect",null);T(this,"faceiris",null);T(this,"facemesh",null);T(this,"faceres",null);T(this,"ssrnetgender",null);T(this,"handpose",null);T(this,"handskeleton",null);T(this,"handtrack",null);T(this,"liveness",null);T(this,"movenet",null);T(this,"nanodet",null);T(this,"posenet",null);T(this,"segmentation",null);T(this,"antispoof",null)}},Q1=e=>{let t=0,o=0,n=0;for(let A of Object.values(ne))t+=A.sizeFromManifest,o+=A.sizeLoadedWeights,n+=A.sizeDesired;let r=n>0?o/n:0;return{numLoadedModels:Object.values(ne).length,numEnabledModels:void 0,numDefinedModels:Object.keys(e.models).length,percentageLoaded:r,totalSizeFromManifest:t,totalSizeWeights:o,totalSizeLoading:n,totalSizeEnabled:void 0,modelStats:Object.values(ne)}};function y5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function _1(e){var t,o,n,r,A,s,a,l,c,y,i,d,x,f,p,g,M,P,m,u,k,w,h,B,X,I;R.initial&&y5(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await S1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((A=e.config.body.modelPath)==null?void 0:A.includes("blazepose"))&&(e.models.blazepose=h3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=u3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((s=e.config.body.modelPath)==null?void 0:s.includes("efficientpose"))&&(e.models.efficientpose=R3(e.config)),e.config.body.enabled&&!e.models.movenet&&((a=e.config.body.modelPath)==null?void 0:a.includes("movenet"))&&(e.models.movenet=Zo(e.config)),e.config.body.enabled&&!e.models.posenet&&((l=e.config.body.modelPath)==null?void 0:l.includes("posenet"))&&(e.models.posenet=tn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=i3(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=Kt(e.config)),e.config.face.enabled&&((y=e.config.face.liveness)==null?void 0:y.enabled)&&!e.models.liveness&&(e.models.liveness=Wo(e.config)),e.config.face.enabled&&((i=e.config.face.description)==null?void 0:i.enabled)&&!e.models.faceres&&(e.models.faceres=eo(e.config)),e.config.face.enabled&&((d=e.config.face.emotion)==null?void 0:d.enabled)&&!e.models.emotion&&(e.models.emotion=E3(e.config)),e.config.face.enabled&&((x=e.config.face.iris)==null?void 0:x.enabled)&&!((f=e.config.face.attention)!=null&&f.enabled)&&!e.models.faceiris&&(e.models.faceiris=V3(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=K3(e.config)),e.config.face.enabled&&((g=e.config.face.gear)==null?void 0:g.enabled)&&!e.models.gear&&(e.models.gear=Lt(e.config)),e.config.face.enabled&&((M=e.config.face.ssrnet)==null?void 0:M.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ht(e.config)),e.config.face.enabled&&((P=e.config.face.ssrnet)==null?void 0:P.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Xt(e.config)),e.config.face.enabled&&((m=e.config.face.mobilefacenet)==null?void 0:m.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=I3(e.config)),e.config.face.enabled&&((u=e.config.face.insightface)==null?void 0:u.enabled)&&!e.models.insightface&&(e.models.insightface=F3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((w=(k=e.config.hand.detector)==null?void 0:k.modelPath)==null?void 0:w.includes("handtrack"))&&(e.models.handtrack=jo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((B=(h=e.config.hand.detector)==null?void 0:h.modelPath)==null?void 0:B.includes("handtrack"))&&(e.models.handskeleton=Io(e.config)),e.config.object.enabled&&!e.models.centernet&&((X=e.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(e.models.centernet=M3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((I=e.config.object.modelPath)==null?void 0:I.includes("nanodet"))&&(e.models.nanodet=Uo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=J1(e.config));for await(let W of Object.keys(e.models))e.models[W]&&typeof e.models[W]!="undefined"&&(e.models[W]=await e.models[W])}var B0;function a2(e,t,o){var c;if(e&&(B0=e),!t||(B0||b("instance not registred"),!B0.config.validateModels))return null;let n=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"],r=["biasadd","fusedbatchnormv3","matmul"],A=[],s=[],a=t.modelUrl,l=t.executor;if((c=l==null?void 0:l.graph)!=null&&c.nodes)for(let y of Object.values(l.graph.nodes)){let i=y.op.toLowerCase();A.includes(i)||A.push(i)}else!l&&B0.config.debug&&b("model not loaded",o);for(let y of A)!n.includes(y)&&!r.includes(y)&&!B0.env.kernels.includes(y)&&!B0.env.kernels.includes(y.replace("_",""))&&!B0.env.kernels.includes(y.replace("native",""))&&!B0.env.kernels.includes(y.replace("v2",""))&&s.push(y);return B0.config.debug&&s.length>0&&b("model validation failed:",o,s),s.length>0?{name:o,missing:s,ops:A,url:a}:null}function T5(e){B0=e;let t=[];for(let o of Object.keys(B0.models)){let n=B0.models[o];if(!n)continue;let r=a2(B0,n,o);r&&t.push(r)}return t}var k0={cacheModels:!0,cacheSupported:!0,verbose:!0,debug:!1,modelBasePath:""},ne={};async function d7(e,t){return k0.debug&&b("load model fetch:",e,t),fetch(e,t)}function An(e){k0.cacheModels=e.cacheModels,k0.verbose=e.debug,k0.modelBasePath=e.modelBasePath}async function F(e){var c,y,i;let t=vt(k0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.includes("/")?t.split("/"):t.split("\\"),n=o[o.length-1].replace(".json",""),r="indexeddb://"+n;ne[n]={name:n,sizeFromManifest:0,sizeLoadedWeights:0,sizeDesired:F5[n],inCache:!1},k0.cacheSupported=typeof window!="undefined"&&typeof window.localStorage!="undefined"&&typeof window.indexedDB!="undefined";let A={};try{A=k0.cacheSupported&&k0.cacheModels?await w5.io.listModels():{}}catch(d){k0.cacheSupported=!1}ne[n].inCache=k0.cacheSupported&&k0.cacheModels&&Object.keys(A).includes(r);let s=typeof fetch=="undefined"?{}:{fetchFunc:(d,x)=>d7(d,x)},a=new w5.GraphModel(ne[n].inCache?r:t,s),l=!1;try{a.findIOHandler(),k0.debug&&b("model load handler:",a.handler);let d=await a.handler.load();ne[n].sizeFromManifest=((c=d==null?void 0:d.weightData)==null?void 0:c.byteLength)||0,a.loadSync(d),ne[n].sizeLoadedWeights=((i=(y=a.artifacts)==null?void 0:y.weightData)==null?void 0:i.byteLength)||0,k0.verbose&&b("load:",{model:n,url:a.modelUrl,bytes:ne[n].sizeLoadedWeights}),l=!0}catch(d){b("error loading model:",t,d)}if(l&&k0.cacheModels&&k0.cacheSupported&&!ne[n].inCache)try{let d=await a.save(r);b("model saved:",r,d)}catch(d){b("error saving model:",t,d)}return a2(null,a,`${e||""}`),a}var re=V(D());var $1="2.10.1";var st={};pe(st,{all:()=>At,body:()=>l2,canvas:()=>rt,face:()=>i2,gesture:()=>y2,hand:()=>c2,object:()=>x2,options:()=>b0,person:()=>nt});var H0=e=>{if(!e)b("draw error: invalid canvas");else if(!e.getContext)b("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)b("draw error: cannot get canvas context");else return t}return null},qe=e=>Math.round(e*180/Math.PI),de=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function fe(e,t,o,n,r){e.fillStyle=de(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function ae(e,t,o,n,r,A){if(e.beginPath(),e.lineWidth=A.lineWidth,A.useCurves){let s=(t+t+n)/2,a=(o+o+r)/2;e.ellipse(s,a,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+A.roundRect,o),e.lineTo(t+n-A.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+A.roundRect),e.lineTo(t+n,o+r-A.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-A.roundRect,o+r),e.lineTo(t+A.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-A.roundRect),e.lineTo(t,o+A.roundRect),e.quadraticCurveTo(t,o,t+A.roundRect,o),e.closePath();e.stroke()}function et(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=de(n[2]||0,o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function sn(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){et(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let A=e.emotion.map(s=>`${Math.trunc(100*s.score)}% ${s.emotion}`);A.length>3&&(A.length=3),r.push(A.join(" "))}((o=e.rotation)==null?void 0:o.angle)&&((n=e.rotation)==null?void 0:n.gaze)&&(e.rotation.angle.roll&&r.push(`roll: ${qe(e.rotation.angle.roll)}\xB0 yaw:${qe(e.rotation.angle.yaw)}\xB0 pitch:${qe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${qe(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=U.color;for(let A=r.length-1;A>=0;A--){let s=Math.max(e.box[0],0),a=A*U.lineHeight+e.box[1];U.shadowColor&&U.shadowColor!==""&&(t.fillStyle=U.shadowColor,t.fillText(r[A],s+5,a+16)),t.fillStyle=U.labelColor,t.fillText(r[A],s+4,a+15)}}}function u7(e,t){var o,n,r,A;if(((o=e.annotations)==null?void 0:o.leftEyeIris)&&((n=e.annotations)==null?void 0:n.leftEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,a=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}if(((r=e.annotations)==null?void 0:r.rightEyeIris)&&((A=e.annotations)==null?void 0:A.rightEyeIris[0])){t.strokeStyle=U.useDepth?"rgba(255, 200, 255, 0.3)":U.color,t.beginPath();let s=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,a=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],s,a,0,0,2*Math.PI),t.stroke(),U.fillPolygons&&(t.fillStyle=U.useDepth?"rgba(255, 255, 200, 0.3)":U.color,t.fill())}}function h7(e,t){var o;if(U.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*qe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*qe(e.rotation.angle.pitch)/90,A=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${n} ${e.box[1]}, diff --git a/test/build.log b/test/build.log index b8e4c0404..698baef03 100644 --- a/test/build.log +++ b/test/build.log @@ -1,39 +1,39 @@ -2022-09-07 10:52:03 DATA:  Build {"name":"@vladmandic/human","version":"2.10.0"} -2022-09-07 10:52:03 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.0"} -2022-09-07 10:52:03 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} -2022-09-07 10:52:03 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.7","typescript":"4.8.2","typedoc":"0.23.14","eslint":"8.23.0"} -2022-09-07 10:52:03 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} -2022-09-07 10:52:03 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":656955,"outputBytes":308860} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":656959,"outputBytes":308864} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":657011,"outputBytes":308914} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":656930,"outputBytes":307734} -2022-09-07 10:52:03 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3478261,"outputBytes":1687921} -2022-09-07 10:52:03 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3478261,"outputBytes":3109077} -2022-09-07 10:52:08 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30} -2022-09-07 10:52:10 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} -2022-09-07 10:52:10 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134} -2022-09-07 10:52:10 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15488,"outputBytes":7788} -2022-09-07 10:52:21 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0} -2022-09-07 10:52:21 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} -2022-09-07 10:52:21 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} -2022-09-07 10:52:21 INFO:  Done... -2022-09-07 10:52:22 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193} -2022-09-07 10:52:22 STATE: Copy: {"input":"types/human.d.ts"} -2022-09-07 10:52:22 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} -2022-09-07 10:52:22 STATE: Models {"folder":"./models","models":13} -2022-09-07 10:52:22 STATE: Models {"folder":"../human-models/models","models":42} -2022-09-07 10:52:22 STATE: Models {"folder":"../blazepose/model/","models":4} -2022-09-07 10:52:22 STATE: Models {"folder":"../anti-spoofing/model","models":1} -2022-09-07 10:52:22 STATE: Models {"folder":"../efficientpose/models","models":3} -2022-09-07 10:52:22 STATE: Models {"folder":"../insightface/models","models":5} -2022-09-07 10:52:22 STATE: Models {"folder":"../movenet/models","models":3} -2022-09-07 10:52:22 STATE: Models {"folder":"../nanodet/models","models":4} -2022-09-07 10:52:23 STATE: Models: {"count":57,"totalSize":383017442} -2022-09-07 10:52:23 INFO:  Human Build complete... {"logFile":"test/build.log"} +2022-09-07 12:39:03 DATA:  Build {"name":"@vladmandic/human","version":"2.10.1"} +2022-09-07 12:39:03 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.1"} +2022-09-07 12:39:03 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} +2022-09-07 12:39:03 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.7","typescript":"4.8.2","typedoc":"0.23.14","eslint":"8.23.0"} +2022-09-07 12:39:03 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} +2022-09-07 12:39:03 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":656955,"outputBytes":308860} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":656959,"outputBytes":308864} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":657011,"outputBytes":308914} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":656930,"outputBytes":307734} +2022-09-07 12:39:03 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3478261,"outputBytes":1687921} +2022-09-07 12:39:03 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3478261,"outputBytes":3109077} +2022-09-07 12:39:08 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30} +2022-09-07 12:39:10 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} +2022-09-07 12:39:10 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134} +2022-09-07 12:39:10 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15488,"outputBytes":7788} +2022-09-07 12:39:21 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0} +2022-09-07 12:39:21 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} +2022-09-07 12:39:21 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} +2022-09-07 12:39:21 INFO:  Done... +2022-09-07 12:39:22 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193} +2022-09-07 12:39:22 STATE: Copy: {"input":"types/human.d.ts"} +2022-09-07 12:39:22 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} +2022-09-07 12:39:22 STATE: Models {"folder":"./models","models":13} +2022-09-07 12:39:22 STATE: Models {"folder":"../human-models/models","models":42} +2022-09-07 12:39:22 STATE: Models {"folder":"../blazepose/model/","models":4} +2022-09-07 12:39:22 STATE: Models {"folder":"../anti-spoofing/model","models":1} +2022-09-07 12:39:22 STATE: Models {"folder":"../efficientpose/models","models":3} +2022-09-07 12:39:22 STATE: Models {"folder":"../insightface/models","models":5} +2022-09-07 12:39:22 STATE: Models {"folder":"../movenet/models","models":3} +2022-09-07 12:39:22 STATE: Models {"folder":"../nanodet/models","models":4} +2022-09-07 12:39:22 STATE: Models: {"count":57,"totalSize":383017442} +2022-09-07 12:39:22 INFO:  Human Build complete... {"logFile":"test/build.log"} diff --git a/test/test.log b/test/test.log index 53862cf8d..89a8480b7 100644 --- a/test/test.log +++ b/test/test.log @@ -1,1000 +1,999 @@ -2022-09-07 10:52:40 INFO:  @vladmandic/human version 2.10.0 -2022-09-07 10:52:40 INFO:  User: vlado Platform: linux Arch: x64 Node: v18.1.0 -2022-09-07 10:52:40 INFO:  demos: [{"cmd":"../demo/nodejs/node.js","args":[]},{"cmd":"../demo/nodejs/node-simple.js","args":[]},{"cmd":"../demo/nodejs/node-fetch.js","args":[]},{"cmd":"../demo/nodejs/node-event.js","args":["samples/in/ai-body.jpg"]},{"cmd":"../demo/nodejs/node-similarity.js","args":["samples/in/ai-face.jpg","samples/in/ai-upper.jpg"]},{"cmd":"../demo/nodejs/node-canvas.js","args":["samples/in/ai-body.jpg","samples/out/ai-body.jpg"]},{"cmd":"../demo/multithread/node-multiprocess.js","args":[]},{"cmd":"../demo/facematch/node-match.js","args":[]}] -2022-09-07 10:52:40 INFO:  {"cmd":"../demo/nodejs/node.js","args":[]} start -2022-09-07 10:52:41 INFO:  {"cmd":"../demo/nodejs/node-simple.js","args":[]} start -2022-09-07 10:52:41 INFO:  {"cmd":"../demo/nodejs/node-fetch.js","args":[]} start -2022-09-07 10:52:44 INFO:  {"cmd":"../demo/nodejs/node-event.js","args":["samples/in/ai-body.jpg"]} start -2022-09-07 10:52:44 INFO:  {"cmd":"../demo/nodejs/node-similarity.js","args":["samples/in/ai-face.jpg","samples/in/ai-upper.jpg"]} start -2022-09-07 10:52:45 INFO:  {"cmd":"../demo/nodejs/node-canvas.js","args":["samples/in/ai-body.jpg","samples/out/ai-body.jpg"]} start -2022-09-07 10:52:46 INFO:  {"cmd":"../demo/multithread/node-multiprocess.js","args":[]} start -2022-09-07 10:52:47 INFO:  {"cmd":"../demo/facematch/node-match.js","args":[]} start -2022-09-07 10:52:49 INFO:  tests: ["test-node-load.js","test-node-gear.js","test-backend-node.js","test-backend-node-gpu.js","test-backend-node-wasm.js"] -2022-09-07 10:52:49 INFO:  -2022-09-07 10:52:49 INFO:  test-node-load.js start -2022-09-07 10:52:49 INFO:  test-node-load.js load start {"human":"2.10.0","tf":"3.20.0","progress":0} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":0,"progress":0} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":10,"progress":0} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":20,"progress":0.05339166087267679} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":30,"progress":0.2135162934143239} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":57,"progress":0.3299591712723044} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":77,"progress":0.5125946867158943} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":89,"progress":0.7259096583739463} -2022-09-07 10:52:49 STATE: test-node-load.js passed {"progress":1} -2022-09-07 10:52:49 INFO:  test-node-load.js load final {"progress":1} -2022-09-07 10:52:49 DATA:  test-node-load.js load interval {"elapsed":360,"progress":1} -2022-09-07 10:52:49 INFO:  -2022-09-07 10:52:49 INFO:  test-node-gear.js start -2022-09-07 10:52:49 DATA:  test-node-gear.js input: ["samples/in/ai-face.jpg"] -2022-09-07 10:52:51 STATE: test-node-gear.js passed: gear faceres samples/in/ai-face.jpg -2022-09-07 10:52:51 DATA:  test-node-gear.js results {"face":0,"model":"faceres","image":"samples/in/ai-face.jpg","age":23.5,"gender":"female","genderScore":0.92} -2022-09-07 10:52:51 STATE: test-node-gear.js passed: gear gear samples/in/ai-face.jpg -2022-09-07 10:52:51 DATA:  test-node-gear.js results {"face":0,"model":"gear","image":"samples/in/ai-face.jpg","age":23.3,"gender":"female","genderScore":0.51,"race":[{"score":0.93,"race":"white"}]} -2022-09-07 10:52:51 STATE: test-node-gear.js passed: gear ssrnet samples/in/ai-face.jpg -2022-09-07 10:52:51 DATA:  test-node-gear.js results {"face":0,"model":"ssrnet","image":"samples/in/ai-face.jpg","age":23.4,"gender":"female","genderScore":0.99} -2022-09-07 10:52:51 INFO:  -2022-09-07 10:52:51 INFO:  test-backend-node.js start -2022-09-07 10:52:51 INFO:  test-backend-node.js test: configuration validation -2022-09-07 10:52:51 STATE: test-backend-node.js passed: configuration default validation [] -2022-09-07 10:52:51 STATE: test-backend-node.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-09-07 10:52:51 INFO:  test-backend-node.js test: model load -2022-09-07 10:52:51 STATE: test-backend-node.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"file://models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"file://models/emotion.json"},{"name":"facedetect","loaded":true,"url":"file://models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"file://models/iris.json"},{"name":"facemesh","loaded":true,"url":"file://models/facemesh.json"},{"name":"faceres","loaded":true,"url":"file://models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"file://models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"file://models/handtrack.json"},{"name":"liveness","loaded":true,"url":"file://models/liveness.json"},{"name":"movenet","loaded":true,"url":"file://models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"file://models/selfie.json"},{"name":"antispoof","loaded":true,"url":"file://models/antispoof.json"}] -2022-09-07 10:52:51 INFO:  test-backend-node.js memory: {"memory":{"unreliable":true,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} -2022-09-07 10:52:51 INFO:  test-backend-node.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} -2022-09-07 10:52:51 INFO:  test-backend-node.js test: warmup -2022-09-07 10:52:51 STATE: test-backend-node.js passed: create human -2022-09-07 10:52:51 INFO:  test-backend-node.js human version: 2.10.0 -2022-09-07 10:52:51 INFO:  test-backend-node.js platform: linux x64 agent: NodeJS v18.1.0 -2022-09-07 10:52:51 INFO:  test-backend-node.js tfjs version: 3.20.0 -2022-09-07 10:52:51 INFO:  test-backend-node.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","tensorflow"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{"version":"2.7.3-dev20220521","gpu":false},"wasm":{"supported":true,"backend":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":169} -2022-09-07 10:52:51 STATE: test-backend-node.js passed: set backend: tensorflow -2022-09-07 10:52:51 STATE: test-backend-node.js tensors 1921 -2022-09-07 10:52:51 STATE: test-backend-node.js passed: load models -2022-09-07 10:52:51 STATE: test-backend-node.js result: defined models: 23 loaded models: 12 -2022-09-07 10:52:51 STATE: test-backend-node.js passed: warmup: none default -2022-09-07 10:52:51 DATA:  test-backend-node.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-09-07 10:52:51 DATA:  test-backend-node.js result: performance: load: null total: null -2022-09-07 10:52:51 STATE: test-backend-node.js passed: warmup none result match -2022-09-07 10:52:51 STATE: test-backend-node.js event: image -2022-09-07 10:52:51 STATE: test-backend-node.js event: detect -2022-09-07 10:52:51 STATE: test-backend-node.js event: warmup -2022-09-07 10:52:51 STATE: test-backend-node.js passed: warmup: face default -2022-09-07 10:52:51 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4} -2022-09-07 10:52:51 DATA:  test-backend-node.js result: performance: load: null total: 340 -2022-09-07 10:52:51 STATE: test-backend-node.js passed: warmup face result match -2022-09-07 10:52:51 STATE: test-backend-node.js event: image -2022-09-07 10:52:52 STATE: test-backend-node.js event: detect -2022-09-07 10:52:52 STATE: test-backend-node.js event: warmup -2022-09-07 10:52:52 STATE: test-backend-node.js passed: warmup: body default -2022-09-07 10:52:52 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:52 DATA:  test-backend-node.js result: performance: load: null total: 242 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: warmup body result match -2022-09-07 10:52:52 STATE: test-backend-node.js details: {"face":{"boxScore":0.92,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.63,"emotion":"angry"},{"score":0.22,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.52,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 10% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} -2022-09-07 10:52:52 INFO:  test-backend-node.js test: details verification -2022-09-07 10:52:52 STATE: test-backend-node.js start default -2022-09-07 10:52:52 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:52 STATE: test-backend-node.js event: image -2022-09-07 10:52:52 STATE: test-backend-node.js event: detect -2022-09-07 10:52:52 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg default -2022-09-07 10:52:52 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:52 DATA:  test-backend-node.js result: performance: load: null total: 240 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face length 1 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face score 1 0.93 1 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face arrays 4 478 1024 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face anti-spoofing 0.79 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details face liveness 0.83 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details body length 1 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details body 0.92 17 6 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details hand length 1 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details hand 0.51 0.73 point -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details hand arrays 21 5 7 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details gesture length 7 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details object length 1 -2022-09-07 10:52:52 STATE: test-backend-node.js passed: details object 0.72 person -2022-09-07 10:52:52 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} -2022-09-07 10:52:52 STATE: test-backend-node.js event: image -2022-09-07 10:52:53 STATE: test-backend-node.js event: detect -2022-09-07 10:52:53 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-09-07 10:52:53 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} -2022-09-07 10:52:53 STATE: test-backend-node.js event: image -2022-09-07 10:52:53 STATE: test-backend-node.js event: detect -2022-09-07 10:52:53 STATE: test-backend-node.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-09-07 10:52:53 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:53 STATE: test-backend-node.js event: image -2022-09-07 10:52:53 STATE: test-backend-node.js event: detect -2022-09-07 10:52:53 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-09-07 10:52:53 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:53 STATE: test-backend-node.js event: image -2022-09-07 10:52:54 STATE: test-backend-node.js event: detect -2022-09-07 10:52:54 STATE: test-backend-node.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-09-07 10:52:54 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-09-07 10:52:54 STATE: test-backend-node.js event: image -2022-09-07 10:52:54 STATE: test-backend-node.js event: detect -2022-09-07 10:52:54 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-09-07 10:52:54 INFO:  test-backend-node.js test default -2022-09-07 10:52:54 STATE: test-backend-node.js start async -2022-09-07 10:52:54 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:54 STATE: test-backend-node.js event: image -2022-09-07 10:52:54 STATE: test-backend-node.js event: detect -2022-09-07 10:52:54 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg async -2022-09-07 10:52:54 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:54 DATA:  test-backend-node.js result: performance: load: null total: 204 -2022-09-07 10:52:54 STATE: test-backend-node.js passed: default result face match 1 female 0.97 -2022-09-07 10:52:54 INFO:  test-backend-node.js test sync -2022-09-07 10:52:54 STATE: test-backend-node.js start sync -2022-09-07 10:52:55 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:55 STATE: test-backend-node.js event: image -2022-09-07 10:52:55 STATE: test-backend-node.js event: detect -2022-09-07 10:52:55 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg sync -2022-09-07 10:52:55 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:55 DATA:  test-backend-node.js result: performance: load: null total: 215 -2022-09-07 10:52:55 STATE: test-backend-node.js passed: default sync 1 female 0.97 -2022-09-07 10:52:55 INFO:  test-backend-node.js test: image process -2022-09-07 10:52:55 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:52:55 STATE: test-backend-node.js passed: image input null [1,256,256,3] -2022-09-07 10:52:55 INFO:  test-backend-node.js test: image null -2022-09-07 10:52:55 STATE: test-backend-node.js passed: invalid input could not convert input to tensor -2022-09-07 10:52:55 INFO:  test-backend-node.js test face similarity -2022-09-07 10:52:55 STATE: test-backend-node.js start face similarity -2022-09-07 10:52:55 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:52:55 STATE: test-backend-node.js event: image -2022-09-07 10:52:55 STATE: test-backend-node.js event: detect -2022-09-07 10:52:55 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face similarity -2022-09-07 10:52:55 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} -2022-09-07 10:52:55 DATA:  test-backend-node.js result: performance: load: null total: 199 -2022-09-07 10:52:55 STATE: test-backend-node.js start face similarity -2022-09-07 10:52:55 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:55 STATE: test-backend-node.js event: image -2022-09-07 10:52:55 STATE: test-backend-node.js event: detect -2022-09-07 10:52:55 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg face similarity -2022-09-07 10:52:55 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:55 DATA:  test-backend-node.js result: performance: load: null total: 204 -2022-09-07 10:52:55 STATE: test-backend-node.js start face similarity -2022-09-07 10:52:56 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:52:56 STATE: test-backend-node.js event: image -2022-09-07 10:52:56 STATE: test-backend-node.js event: detect -2022-09-07 10:52:56 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg face similarity -2022-09-07 10:52:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} -2022-09-07 10:52:56 DATA:  test-backend-node.js result: performance: load: null total: 182 -2022-09-07 10:52:56 STATE: test-backend-node.js passed: face descriptor -2022-09-07 10:52:56 STATE: test-backend-node.js passed: face similarity {"similarity":[1,0.44727452329649126,0.5567935850640406],"descriptors":[1024,1024,1024]} -2022-09-07 10:52:56 INFO:  test-backend-node.js test object -2022-09-07 10:52:56 STATE: test-backend-node.js start object -2022-09-07 10:52:56 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:56 STATE: test-backend-node.js event: image -2022-09-07 10:52:56 STATE: test-backend-node.js event: detect -2022-09-07 10:52:56 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:52:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:56 DATA:  test-backend-node.js result: performance: load: null total: 207 -2022-09-07 10:52:56 STATE: test-backend-node.js passed: centernet -2022-09-07 10:52:56 STATE: test-backend-node.js start object -2022-09-07 10:52:57 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:57 STATE: test-backend-node.js event: image -2022-09-07 10:52:57 STATE: test-backend-node.js event: detect -2022-09-07 10:52:57 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:52:57 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 3 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.86,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:52:57 DATA:  test-backend-node.js result: performance: load: null total: 212 -2022-09-07 10:52:57 STATE: test-backend-node.js passed: nanodet -2022-09-07 10:52:57 INFO:  test-backend-node.js test sensitive -2022-09-07 10:52:57 STATE: test-backend-node.js start sensitive -2022-09-07 10:52:57 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:52:57 STATE: test-backend-node.js event: image -2022-09-07 10:52:58 STATE: test-backend-node.js event: detect -2022-09-07 10:52:58 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg sensitive -2022-09-07 10:52:58 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:52:58 DATA:  test-backend-node.js result: performance: load: null total: 169 -2022-09-07 10:52:58 STATE: test-backend-node.js passed: sensitive result match -2022-09-07 10:52:58 STATE: test-backend-node.js passed: sensitive face result match -2022-09-07 10:52:58 STATE: test-backend-node.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] -2022-09-07 10:52:58 STATE: test-backend-node.js passed: sensitive body result match -2022-09-07 10:52:58 STATE: test-backend-node.js passed: sensitive hand result match -2022-09-07 10:52:58 INFO:  test-backend-node.js test body -2022-09-07 10:52:58 STATE: test-backend-node.js start blazepose -2022-09-07 10:53:00 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:00 STATE: test-backend-node.js event: image -2022-09-07 10:53:00 STATE: test-backend-node.js event: detect -2022-09-07 10:53:00 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg blazepose -2022-09-07 10:53:00 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.99,"keypoints":39} -2022-09-07 10:53:00 DATA:  test-backend-node.js result: performance: load: null total: 231 -2022-09-07 10:53:00 STATE: test-backend-node.js passed: blazepose -2022-09-07 10:53:00 STATE: test-backend-node.js start efficientpose -2022-09-07 10:53:01 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:01 STATE: test-backend-node.js event: image -2022-09-07 10:53:01 STATE: test-backend-node.js event: detect -2022-09-07 10:53:01 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg efficientpose -2022-09-07 10:53:01 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.75,"keypoints":13} -2022-09-07 10:53:01 DATA:  test-backend-node.js result: performance: load: null total: 275 -2022-09-07 10:53:01 STATE: test-backend-node.js passed: efficientpose -2022-09-07 10:53:01 STATE: test-backend-node.js start posenet -2022-09-07 10:53:02 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:02 STATE: test-backend-node.js event: image -2022-09-07 10:53:02 STATE: test-backend-node.js event: detect -2022-09-07 10:53:02 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg posenet -2022-09-07 10:53:02 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.96,"keypoints":16} -2022-09-07 10:53:02 DATA:  test-backend-node.js result: performance: load: null total: 191 -2022-09-07 10:53:02 STATE: test-backend-node.js passed: posenet -2022-09-07 10:53:02 STATE: test-backend-node.js start movenet -2022-09-07 10:53:02 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:02 STATE: test-backend-node.js event: image -2022-09-07 10:53:02 STATE: test-backend-node.js event: detect -2022-09-07 10:53:02 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg movenet -2022-09-07 10:53:02 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:02 DATA:  test-backend-node.js result: performance: load: null total: 173 -2022-09-07 10:53:02 STATE: test-backend-node.js passed: movenet -2022-09-07 10:53:02 INFO:  test-backend-node.js test face matching -2022-09-07 10:53:02 STATE: test-backend-node.js passed: face database 40 -2022-09-07 10:53:02 STATE: test-backend-node.js passed: face match {"first":{"index":4,"similarity":0.7827852615252829}} {"second":{"index":4,"similarity":0.5002052633015844}} {"third":{"index":4,"similarity":0.5401587887998899}} -2022-09-07 10:53:02 INFO:  test-backend-node.js test face similarity alternative -2022-09-07 10:53:02 STATE: test-backend-node.js start face embeddings -2022-09-07 10:53:03 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:03 STATE: test-backend-node.js event: image -2022-09-07 10:53:03 STATE: test-backend-node.js event: detect -2022-09-07 10:53:03 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:03 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:03 DATA:  test-backend-node.js result: performance: load: null total: 184 -2022-09-07 10:53:03 STATE: test-backend-node.js passed: mobilefacenet {"embedding":192} -2022-09-07 10:53:03 STATE: test-backend-node.js start face embeddings -2022-09-07 10:53:04 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:04 STATE: test-backend-node.js event: image -2022-09-07 10:53:04 STATE: test-backend-node.js event: detect -2022-09-07 10:53:04 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:04 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:04 DATA:  test-backend-node.js result: performance: load: null total: 191 -2022-09-07 10:53:04 STATE: test-backend-node.js passed: insightface {"embedding":512} -2022-09-07 10:53:04 INFO:  test-backend-node.js test face attention -2022-09-07 10:53:04 STATE: test-backend-node.js start face attention -2022-09-07 10:53:04 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:04 STATE: test-backend-node.js event: image -2022-09-07 10:53:04 STATE: test-backend-node.js event: detect -2022-09-07 10:53:04 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face attention -2022-09-07 10:53:04 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:04 DATA:  test-backend-node.js result: performance: load: null total: 173 -2022-09-07 10:53:04 STATE: test-backend-node.js passed: face attention -2022-09-07 10:53:04 INFO:  test-backend-node.js test detectors -2022-09-07 10:53:04 STATE: test-backend-node.js start detectors -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:05 STATE: test-backend-node.js event: image -2022-09-07 10:53:05 STATE: test-backend-node.js event: detect -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg detectors -2022-09-07 10:53:05 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:05 DATA:  test-backend-node.js result: performance: load: null total: 134 -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detector result face match -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detector result hand match -2022-09-07 10:53:05 INFO:  test-backend-node.js test: multi-instance -2022-09-07 10:53:05 STATE: test-backend-node.js start multi instance -2022-09-07 10:53:05 STATE: test-backend-node.js event: image -2022-09-07 10:53:05 STATE: test-backend-node.js event: detect -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detect: random multi instance -2022-09-07 10:53:05 DATA:  test-backend-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} -2022-09-07 10:53:05 DATA:  test-backend-node.js result: performance: load: null total: 87 -2022-09-07 10:53:05 INFO:  test-backend-node.js test: first instance -2022-09-07 10:53:05 STATE: test-backend-node.js start multi instance -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:05 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:05 DATA:  test-backend-node.js result: performance: load: null total: 114 -2022-09-07 10:53:05 INFO:  test-backend-node.js test: second instance -2022-09-07 10:53:05 STATE: test-backend-node.js start multi instance -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:53:05 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:05 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:05 DATA:  test-backend-node.js result: performance: load: null total: 97 -2022-09-07 10:53:05 INFO:  test-backend-node.js test: concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js start concurrent -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:05 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:06 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-09-07 10:53:06 STATE: test-backend-node.js event: image -2022-09-07 10:53:06 STATE: test-backend-node.js event: image -2022-09-07 10:53:06 STATE: test-backend-node.js event: image -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1133 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1133 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1134 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1134 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1134 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 1134 -2022-09-07 10:53:07 STATE: test-backend-node.js event: detect -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 861 -2022-09-07 10:53:07 STATE: test-backend-node.js event: detect -2022-09-07 10:53:07 STATE: test-backend-node.js event: detect -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 861 -2022-09-07 10:53:07 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:07 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:07 DATA:  test-backend-node.js result: performance: load: null total: 861 -2022-09-07 10:53:07 INFO:  test-backend-node.js test: monkey-patch -2022-09-07 10:53:07 STATE: test-backend-node.js event: image -2022-09-07 10:53:07 STATE: test-backend-node.js event: detect -2022-09-07 10:53:07 STATE: test-backend-node.js passed: monkey patch -2022-09-07 10:53:07 STATE: test-backend-node.js passed: segmentation [65536] -2022-09-07 10:53:07 STATE: test-backend-node.js passeed: equal usage -2022-09-07 10:53:07 INFO:  test-backend-node.js test: input compare -2022-09-07 10:53:07 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:07 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-09-07 10:53:07 STATE: test-backend-node.js passed: image compare 0 23.275441687091504 -2022-09-07 10:53:07 INFO:  test-backend-node.js events: {"image":29,"detect":29,"warmup":2} -2022-09-07 10:53:07 INFO:  test-backend-node.js tensors 4147 -2022-09-07 10:53:07 INFO:  test-backend-node.js test complete: 16283 ms -2022-09-07 10:53:07 INFO:  -2022-09-07 10:53:07 INFO:  test-backend-node-gpu.js start -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js test: configuration validation -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: configuration default validation [] -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js test: model load -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"file://models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"file://models/emotion.json"},{"name":"facedetect","loaded":true,"url":"file://models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"file://models/iris.json"},{"name":"facemesh","loaded":true,"url":"file://models/facemesh.json"},{"name":"faceres","loaded":true,"url":"file://models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"file://models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"file://models/handtrack.json"},{"name":"liveness","loaded":true,"url":"file://models/liveness.json"},{"name":"movenet","loaded":true,"url":"file://models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"file://models/selfie.json"},{"name":"antispoof","loaded":true,"url":"file://models/antispoof.json"}] -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js memory: {"memory":{"unreliable":true,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js test: warmup -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: create human -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js human version: 2.10.0 -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js platform: linux x64 agent: NodeJS v18.1.0 -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js tfjs version: 3.20.0 -2022-09-07 10:53:08 INFO:  test-backend-node-gpu.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","tensorflow"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{"version":"2.7.3-dev20220521","gpu":true},"wasm":{"supported":true,"backend":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":169} -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: set backend: tensorflow -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js tensors 1921 -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: load models -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js result: defined models: 23 loaded models: 12 -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: warmup: none default -2022-09-07 10:53:08 DATA:  test-backend-node-gpu.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-09-07 10:53:08 DATA:  test-backend-node-gpu.js result: performance: load: null total: null -2022-09-07 10:53:08 STATE: test-backend-node-gpu.js passed: warmup none result match -2022-09-07 10:53:09 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:13 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:13 STATE: test-backend-node-gpu.js event: warmup -2022-09-07 10:53:13 STATE: test-backend-node-gpu.js passed: warmup: face default -2022-09-07 10:53:13 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4} -2022-09-07 10:53:13 DATA:  test-backend-node-gpu.js result: performance: load: null total: 4552 -2022-09-07 10:53:13 STATE: test-backend-node-gpu.js passed: warmup face result match -2022-09-07 10:53:13 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: warmup -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: warmup: body default -2022-09-07 10:53:14 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 180 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: warmup body result match -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js details: {"face":{"boxScore":0.92,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.63,"emotion":"angry"},{"score":0.22,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.52,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 10% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} -2022-09-07 10:53:14 INFO:  test-backend-node-gpu.js test: details verification -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js start default -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-09-07 10:53:14 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 155 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face length 1 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face score 1 0.93 1 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face arrays 4 478 1024 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face anti-spoofing 0.79 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details face liveness 0.83 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details body length 1 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details body 0.92 17 6 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details hand length 1 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details hand 0.51 0.73 point -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details hand arrays 21 5 7 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details gesture length 7 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details object length 1 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: details object 0.72 person -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} -2022-09-07 10:53:14 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-09-07 10:53:15 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-09-07 10:53:16 INFO:  test-backend-node-gpu.js test default -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js start async -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg async -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 153 -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: default result face match 1 female 0.97 -2022-09-07 10:53:16 INFO:  test-backend-node-gpu.js test sync -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js start sync -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg sync -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 178 -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: default sync 1 female 0.97 -2022-09-07 10:53:16 INFO:  test-backend-node-gpu.js test: image process -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: image input null [1,256,256,3] -2022-09-07 10:53:16 INFO:  test-backend-node-gpu.js test: image null -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: invalid input could not convert input to tensor -2022-09-07 10:53:16 INFO:  test-backend-node-gpu.js test face similarity -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js start face similarity -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face similarity -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} -2022-09-07 10:53:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 148 -2022-09-07 10:53:16 STATE: test-backend-node-gpu.js start face similarity -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg face similarity -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: performance: load: null total: 162 -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js start face similarity -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg face similarity -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: performance: load: null total: 133 -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: face descriptor -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: face similarity {"similarity":[1,0.447238756461232,0.556914029877052],"descriptors":[1024,1024,1024]} -2022-09-07 10:53:17 INFO:  test-backend-node-gpu.js test object -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js start object -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:17 DATA:  test-backend-node-gpu.js result: performance: load: null total: 159 -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js passed: centernet -2022-09-07 10:53:17 STATE: test-backend-node-gpu.js start object -2022-09-07 10:53:18 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:18 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:53:19 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 3 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.86,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:19 DATA:  test-backend-node-gpu.js result: performance: load: null total: 571 -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: nanodet -2022-09-07 10:53:19 INFO:  test-backend-node-gpu.js test sensitive -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js start sensitive -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg sensitive -2022-09-07 10:53:19 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:19 DATA:  test-backend-node-gpu.js result: performance: load: null total: 130 -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: sensitive result match -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: sensitive face result match -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: sensitive body result match -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js passed: sensitive hand result match -2022-09-07 10:53:19 INFO:  test-backend-node-gpu.js test body -2022-09-07 10:53:19 STATE: test-backend-node-gpu.js start blazepose -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg blazepose -2022-09-07 10:53:21 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.99,"keypoints":39} -2022-09-07 10:53:21 DATA:  test-backend-node-gpu.js result: performance: load: null total: 290 -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js passed: blazepose -2022-09-07 10:53:21 STATE: test-backend-node-gpu.js start efficientpose -2022-09-07 10:53:22 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:22 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg efficientpose -2022-09-07 10:53:23 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.75,"keypoints":13} -2022-09-07 10:53:23 DATA:  test-backend-node-gpu.js result: performance: load: null total: 809 -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js passed: efficientpose -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js start posenet -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg posenet -2022-09-07 10:53:23 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.96,"keypoints":16} -2022-09-07 10:53:23 DATA:  test-backend-node-gpu.js result: performance: load: null total: 146 -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js passed: posenet -2022-09-07 10:53:23 STATE: test-backend-node-gpu.js start movenet -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg movenet -2022-09-07 10:53:24 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:24 DATA:  test-backend-node-gpu.js result: performance: load: null total: 131 -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: movenet -2022-09-07 10:53:24 INFO:  test-backend-node-gpu.js test face matching -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: face database 40 -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: face match {"first":{"index":4,"similarity":0.7828184453007331}} {"second":{"index":4,"similarity":0.5001334216773398}} {"third":{"index":4,"similarity":0.5403054967489764}} -2022-09-07 10:53:24 INFO:  test-backend-node-gpu.js test face similarity alternative -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js start face embeddings -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:24 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:24 DATA:  test-backend-node-gpu.js result: performance: load: null total: 176 -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js passed: mobilefacenet {"embedding":192} -2022-09-07 10:53:24 STATE: test-backend-node-gpu.js start face embeddings -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:25 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:25 DATA:  test-backend-node-gpu.js result: performance: load: null total: 172 -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js passed: insightface {"embedding":512} -2022-09-07 10:53:25 INFO:  test-backend-node-gpu.js test face attention -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js start face attention -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:25 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face attention -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: performance: load: null total: 247 -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: face attention -2022-09-07 10:53:26 INFO:  test-backend-node-gpu.js test detectors -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start detectors -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg detectors -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: performance: load: null total: 113 -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detector result face match -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detector result hand match -2022-09-07 10:53:26 INFO:  test-backend-node-gpu.js test: multi-instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start multi instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detect: random multi instance -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: performance: load: null total: 58 -2022-09-07 10:53:26 INFO:  test-backend-node-gpu.js test: first instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start multi instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: performance: load: null total: 90 -2022-09-07 10:53:26 INFO:  test-backend-node-gpu.js test: second instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start multi instance -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:26 DATA:  test-backend-node-gpu.js result: performance: load: null total: 74 -2022-09-07 10:53:26 INFO:  test-backend-node-gpu.js test: concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js start concurrent -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:26 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:27 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 916 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 664 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 664 -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:28 DATA:  test-backend-node-gpu.js result: performance: load: null total: 664 -2022-09-07 10:53:28 INFO:  test-backend-node-gpu.js test: monkey-patch -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js event: image -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js event: detect -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: monkey patch -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: segmentation [65536] -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passeed: equal usage -2022-09-07 10:53:28 INFO:  test-backend-node-gpu.js test: input compare -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-09-07 10:53:28 STATE: test-backend-node-gpu.js passed: image compare 0 23.275441687091504 -2022-09-07 10:53:28 INFO:  test-backend-node-gpu.js events: {"image":29,"detect":29,"warmup":2} -2022-09-07 10:53:28 INFO:  test-backend-node-gpu.js tensors 4147 -2022-09-07 10:53:28 INFO:  test-backend-node-gpu.js test complete: 19820 ms -2022-09-07 10:53:29 INFO:  -2022-09-07 10:53:29 INFO:  test-backend-node-wasm.js start -2022-09-07 10:53:30 DATA:  test-backend-node-wasm.js stdout: 2022-09-07 10:53:30 INFO:  { supported: true, backend: true, simd: true, multithread: false } -2022-09-07 10:53:30 STATE: test-backend-node-wasm.js passed: model server: https://vladmandic.github.io/human/models/ -2022-09-07 10:53:30 INFO:  test-backend-node-wasm.js test: configuration validation -2022-09-07 10:53:30 STATE: test-backend-node-wasm.js passed: configuration default validation [] -2022-09-07 10:53:30 STATE: test-backend-node-wasm.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-09-07 10:53:30 INFO:  test-backend-node-wasm.js test: model load -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"https://vladmandic.github.io/human/models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"https://vladmandic.github.io/human/models/emotion.json"},{"name":"facedetect","loaded":true,"url":"https://vladmandic.github.io/human/models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"https://vladmandic.github.io/human/models/iris.json"},{"name":"facemesh","loaded":true,"url":"https://vladmandic.github.io/human/models/facemesh.json"},{"name":"faceres","loaded":true,"url":"https://vladmandic.github.io/human/models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"https://vladmandic.github.io/human/models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"https://vladmandic.github.io/human/models/handtrack.json"},{"name":"liveness","loaded":true,"url":"https://vladmandic.github.io/human/models/liveness.json"},{"name":"movenet","loaded":true,"url":"https://vladmandic.github.io/human/models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"https://vladmandic.github.io/human/models/selfie.json"},{"name":"antispoof","loaded":true,"url":"https://vladmandic.github.io/human/models/antispoof.json"}] -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js memory: {"memory":{"unreliable":false,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js test: warmup -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: create human -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js human version: 2.10.0 -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js platform: linux x64 agent: NodeJS v18.1.0 -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js tfjs version: 3.20.0 -2022-09-07 10:53:32 INFO:  test-backend-node-wasm.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","wasm"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{},"wasm":{"supported":true,"backend":true,"simd":true,"multithread":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":126} -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: set backend: wasm -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js tensors 1921 -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: load models -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js result: defined models: 23 loaded models: 12 -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: warmup: none default -2022-09-07 10:53:32 DATA:  test-backend-node-wasm.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-09-07 10:53:32 DATA:  test-backend-node-wasm.js result: performance: load: null total: null -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js passed: warmup none result match -2022-09-07 10:53:32 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: warmup -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js passed: warmup: face default -2022-09-07 10:53:33 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} -2022-09-07 10:53:33 DATA:  test-backend-node-wasm.js result: performance: load: null total: 505 -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js passed: warmup face result match -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: warmup -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js passed: warmup: body default -2022-09-07 10:53:33 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:33 DATA:  test-backend-node-wasm.js result: performance: load: null total: 357 -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js passed: warmup body result match -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js details: {"face":{"boxScore":0.93,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.51,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 21% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} -2022-09-07 10:53:33 INFO:  test-backend-node-wasm.js test: details verification -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js start default -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:33 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-09-07 10:53:34 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:34 DATA:  test-backend-node-wasm.js result: performance: load: null total: 330 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face length 1 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face score 1 0.93 1 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face arrays 4 478 1024 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face anti-spoofing 0.79 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details face liveness 0.83 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details body length 1 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details body 0.92 17 6 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details hand length 1 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details hand 0.51 0.73 point -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details hand arrays 21 5 7 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details gesture length 7 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details object length 1 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: details object 0.72 person -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1413675264} -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1413675264} -2022-09-07 10:53:34 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:35 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-09-07 10:53:36 INFO:  test-backend-node-wasm.js test default -2022-09-07 10:53:36 STATE: test-backend-node-wasm.js start async -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg async -2022-09-07 10:53:37 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:37 DATA:  test-backend-node-wasm.js result: performance: load: null total: 318 -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js passed: default result face match 1 female 0.97 -2022-09-07 10:53:37 INFO:  test-backend-node-wasm.js test sync -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js start sync -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:37 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg sync -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 369 -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: default sync 1 female 0.97 -2022-09-07 10:53:38 INFO:  test-backend-node-wasm.js test: image process -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: image input null [1,256,256,3] -2022-09-07 10:53:38 INFO:  test-backend-node-wasm.js test: image null -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: invalid input could not convert input to tensor -2022-09-07 10:53:38 INFO:  test-backend-node-wasm.js test face similarity -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js start face similarity -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face similarity -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 308 -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js start face similarity -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg face similarity -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 330 -2022-09-07 10:53:38 STATE: test-backend-node-wasm.js start face similarity -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg face similarity -2022-09-07 10:53:39 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} -2022-09-07 10:53:39 DATA:  test-backend-node-wasm.js result: performance: load: null total: 293 -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: face descriptor -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: face similarity {"similarity":[1,0.5266119940661309,0.4858842904087851],"descriptors":[1024,1024,1024]} -2022-09-07 10:53:39 INFO:  test-backend-node-wasm.js test object -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js start object -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:53:39 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-09-07 10:53:39 DATA:  test-backend-node-wasm.js result: performance: load: null total: 347 -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js passed: centernet -2022-09-07 10:53:39 STATE: test-backend-node-wasm.js start object -2022-09-07 10:53:41 WARN:  test-backend-node-wasm.js missing kernel ops {"title":"object","model":"nanodet","url":"https://vladmandic.github.io/human-models/models/nanodet.json","missing":["sparsetodense"],"backkend":"wasm"} -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg object -2022-09-07 10:53:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 254 -2022-09-07 10:53:41 ERROR: test-backend-node-wasm.js failed: nanodet [] -2022-09-07 10:53:41 INFO:  test-backend-node-wasm.js test sensitive -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js start sensitive -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:41 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg sensitive -2022-09-07 10:53:42 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:42 DATA:  test-backend-node-wasm.js result: performance: load: null total: 267 -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: sensitive result match -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: sensitive face result match -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: sensitive face emotion result [{"score":0.46,"emotion":"neutral"},{"score":0.24,"emotion":"fear"},{"score":0.17,"emotion":"sad"}] -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: sensitive body result match -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js passed: sensitive hand result match -2022-09-07 10:53:42 INFO:  test-backend-node-wasm.js test body -2022-09-07 10:53:42 STATE: test-backend-node-wasm.js start blazepose -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg blazepose -2022-09-07 10:53:45 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.99,"keypoints":39} -2022-09-07 10:53:45 DATA:  test-backend-node-wasm.js result: performance: load: null total: 416 -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js passed: blazepose -2022-09-07 10:53:45 STATE: test-backend-node-wasm.js start efficientpose -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg efficientpose -2022-09-07 10:53:46 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.75,"keypoints":13} -2022-09-07 10:53:46 DATA:  test-backend-node-wasm.js result: performance: load: null total: 625 -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js passed: efficientpose -2022-09-07 10:53:46 STATE: test-backend-node-wasm.js start posenet -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg posenet -2022-09-07 10:53:47 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.96,"keypoints":16} -2022-09-07 10:53:47 DATA:  test-backend-node-wasm.js result: performance: load: null total: 285 -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js passed: posenet -2022-09-07 10:53:47 STATE: test-backend-node-wasm.js start movenet -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg movenet -2022-09-07 10:53:48 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:48 DATA:  test-backend-node-wasm.js result: performance: load: null total: 233 -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: movenet -2022-09-07 10:53:48 INFO:  test-backend-node-wasm.js test face matching -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: face database 40 -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: face match {"first":{"index":4,"similarity":0.7827852754786533}} {"second":{"index":4,"similarity":0.5660821189104794}} {"third":{"index":4,"similarity":0.45074189882665594}} -2022-09-07 10:53:48 INFO:  test-backend-node-wasm.js test face similarity alternative -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js start face embeddings -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:48 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:49 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:49 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:49 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:49 DATA:  test-backend-node-wasm.js result: performance: load: null total: 244 -2022-09-07 10:53:49 STATE: test-backend-node-wasm.js passed: mobilefacenet {"embedding":192} -2022-09-07 10:53:49 STATE: test-backend-node-wasm.js start face embeddings -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face embeddings -2022-09-07 10:53:50 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:50 DATA:  test-backend-node-wasm.js result: performance: load: null total: 287 -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js passed: insightface {"embedding":512} -2022-09-07 10:53:50 INFO:  test-backend-node-wasm.js test face attention -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js start face attention -2022-09-07 10:53:50 WARN:  test-backend-node-wasm.js missing kernel ops {"title":"face attention","model":"facemesh","url":"https://vladmandic.github.io/human-models/models/facemesh-attention.json","missing":["atan2"],"backkend":"wasm"} -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face attention -2022-09-07 10:53:50 DATA:  test-backend-node-wasm.js result: face: 0 body: 1 hand: 1 gesture: 2 object: 0 person: 0 {} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:50 DATA:  test-backend-node-wasm.js result: performance: load: null total: 119 -2022-09-07 10:53:50 ERROR: test-backend-node-wasm.js failed: face attention {"annotations":0} -2022-09-07 10:53:50 INFO:  test-backend-node-wasm.js test detectors -2022-09-07 10:53:50 STATE: test-backend-node-wasm.js start detectors -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg detectors -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: performance: load: null total: 114 -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detector result face match -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detector result hand match -2022-09-07 10:53:51 INFO:  test-backend-node-wasm.js test: multi-instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start multi instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detect: random multi instance -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: performance: load: null total: 103 -2022-09-07 10:53:51 INFO:  test-backend-node-wasm.js test: first instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start multi instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: performance: load: null total: 116 -2022-09-07 10:53:51 INFO:  test-backend-node-wasm.js test: second instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start multi instance -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg multi instance -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:51 DATA:  test-backend-node-wasm.js result: performance: load: null total: 111 -2022-09-07 10:53:51 INFO:  test-backend-node-wasm.js test: concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js start concurrent -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:51 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:52 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1224 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 910 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 910 -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} -2022-09-07 10:53:53 DATA:  test-backend-node-wasm.js result: performance: load: null total: 910 -2022-09-07 10:53:53 INFO:  test-backend-node-wasm.js test: monkey-patch -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js event: image -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js event: detect -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: monkey patch -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: segmentation [65536] -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passeed: equal usage -2022-09-07 10:53:53 INFO:  test-backend-node-wasm.js test: input compare -2022-09-07 10:53:53 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-09-07 10:53:54 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-09-07 10:53:54 STATE: test-backend-node-wasm.js passed: image compare 0 23.280073018790848 -2022-09-07 10:53:54 INFO:  test-backend-node-wasm.js events: {"image":29,"detect":29,"warmup":2} -2022-09-07 10:53:54 INFO:  test-backend-node-wasm.js tensors 4149 -2022-09-07 10:53:54 INFO:  test-backend-node-wasm.js test complete: 23533 ms -2022-09-07 10:53:54 STATE: all tests complete -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node-simple.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node-fetch.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node-event.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node-similarity.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/nodejs/node-canvas.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/multithread/node-multiprocess.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"../demo/facematch/node-match.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"test-node-load.js","passed":1,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"test-node-gear.js","passed":3,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"test-backend-node.js","passed":125,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"test-backend-node-gpu.js","passed":125,"failed":0} -2022-09-07 10:53:54 INFO:  status {"test":"test-backend-node-wasm.js","passed":124,"failed":2} -2022-09-07 10:53:54 INFO:  failures {"count":2} -2022-09-07 10:53:54 WARN:  failed {"test":"test-backend-node-wasm.js","message":["error",["failed: nanodet",[]]]} -2022-09-07 10:53:54 WARN:  failed {"test":"test-backend-node-wasm.js","message":["error",["failed: face attention",{"annotations":0}]]} +2022-09-07 12:40:29 INFO:  @vladmandic/human version 2.10.1 +2022-09-07 12:40:29 INFO:  User: vlado Platform: linux Arch: x64 Node: v18.1.0 +2022-09-07 12:40:29 INFO:  demos: [{"cmd":"../demo/nodejs/node.js","args":[]},{"cmd":"../demo/nodejs/node-simple.js","args":[]},{"cmd":"../demo/nodejs/node-fetch.js","args":[]},{"cmd":"../demo/nodejs/node-event.js","args":["samples/in/ai-body.jpg"]},{"cmd":"../demo/nodejs/node-similarity.js","args":["samples/in/ai-face.jpg","samples/in/ai-upper.jpg"]},{"cmd":"../demo/nodejs/node-canvas.js","args":["samples/in/ai-body.jpg","samples/out/ai-body.jpg"]},{"cmd":"../demo/multithread/node-multiprocess.js","args":[]},{"cmd":"../demo/facematch/node-match.js","args":[]}] +2022-09-07 12:40:29 INFO:  {"cmd":"../demo/nodejs/node.js","args":[]} start +2022-09-07 12:40:30 INFO:  {"cmd":"../demo/nodejs/node-simple.js","args":[]} start +2022-09-07 12:40:30 INFO:  {"cmd":"../demo/nodejs/node-fetch.js","args":[]} start +2022-09-07 12:40:33 INFO:  {"cmd":"../demo/nodejs/node-event.js","args":["samples/in/ai-body.jpg"]} start +2022-09-07 12:40:34 INFO:  {"cmd":"../demo/nodejs/node-similarity.js","args":["samples/in/ai-face.jpg","samples/in/ai-upper.jpg"]} start +2022-09-07 12:40:34 INFO:  {"cmd":"../demo/nodejs/node-canvas.js","args":["samples/in/ai-body.jpg","samples/out/ai-body.jpg"]} start +2022-09-07 12:40:35 INFO:  {"cmd":"../demo/multithread/node-multiprocess.js","args":[]} start +2022-09-07 12:40:36 INFO:  {"cmd":"../demo/facematch/node-match.js","args":[]} start +2022-09-07 12:40:38 INFO:  tests: ["test-node-load.js","test-node-gear.js","test-backend-node.js","test-backend-node-gpu.js","test-backend-node-wasm.js"] +2022-09-07 12:40:38 INFO:  +2022-09-07 12:40:38 INFO:  test-node-load.js start +2022-09-07 12:40:38 INFO:  test-node-load.js load start {"human":"2.10.1","tf":"3.20.0","progress":0} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":0,"progress":0} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":12,"progress":0} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":26,"progress":0.11143791531203556} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":58,"progress":0.3299591712723044} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":94,"progress":0.5125946867158943} +2022-09-07 12:40:38 DATA:  test-node-load.js load interval {"elapsed":122,"progress":0.7259096583739463} +2022-09-07 12:40:38 STATE: test-node-load.js passed {"progress":1} +2022-09-07 12:40:38 INFO:  test-node-load.js load final {"progress":1} +2022-09-07 12:40:39 DATA:  test-node-load.js load interval {"elapsed":415,"progress":1} +2022-09-07 12:40:39 INFO:  +2022-09-07 12:40:39 INFO:  test-node-gear.js start +2022-09-07 12:40:39 DATA:  test-node-gear.js input: ["samples/in/ai-face.jpg"] +2022-09-07 12:40:40 STATE: test-node-gear.js passed: gear faceres samples/in/ai-face.jpg +2022-09-07 12:40:40 DATA:  test-node-gear.js results {"face":0,"model":"faceres","image":"samples/in/ai-face.jpg","age":23.5,"gender":"female","genderScore":0.92} +2022-09-07 12:40:40 STATE: test-node-gear.js passed: gear gear samples/in/ai-face.jpg +2022-09-07 12:40:40 DATA:  test-node-gear.js results {"face":0,"model":"gear","image":"samples/in/ai-face.jpg","age":23.3,"gender":"female","genderScore":0.51,"race":[{"score":0.93,"race":"white"}]} +2022-09-07 12:40:40 STATE: test-node-gear.js passed: gear ssrnet samples/in/ai-face.jpg +2022-09-07 12:40:40 DATA:  test-node-gear.js results {"face":0,"model":"ssrnet","image":"samples/in/ai-face.jpg","age":23.4,"gender":"female","genderScore":0.99} +2022-09-07 12:40:40 INFO:  +2022-09-07 12:40:40 INFO:  test-backend-node.js start +2022-09-07 12:40:40 INFO:  test-backend-node.js test: configuration validation +2022-09-07 12:40:40 STATE: test-backend-node.js passed: configuration default validation [] +2022-09-07 12:40:40 STATE: test-backend-node.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-09-07 12:40:40 INFO:  test-backend-node.js test: model load +2022-09-07 12:40:40 STATE: test-backend-node.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"file://models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"file://models/emotion.json"},{"name":"facedetect","loaded":true,"url":"file://models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"file://models/iris.json"},{"name":"facemesh","loaded":true,"url":"file://models/facemesh.json"},{"name":"faceres","loaded":true,"url":"file://models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"file://models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"file://models/handtrack.json"},{"name":"liveness","loaded":true,"url":"file://models/liveness.json"},{"name":"movenet","loaded":true,"url":"file://models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"file://models/selfie.json"},{"name":"antispoof","loaded":true,"url":"file://models/antispoof.json"}] +2022-09-07 12:40:40 INFO:  test-backend-node.js memory: {"memory":{"unreliable":true,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} +2022-09-07 12:40:40 INFO:  test-backend-node.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} +2022-09-07 12:40:40 INFO:  test-backend-node.js test: warmup +2022-09-07 12:40:40 STATE: test-backend-node.js passed: create human +2022-09-07 12:40:40 INFO:  test-backend-node.js human version: 2.10.1 +2022-09-07 12:40:40 INFO:  test-backend-node.js platform: linux x64 agent: NodeJS v18.1.0 +2022-09-07 12:40:40 INFO:  test-backend-node.js tfjs version: 3.20.0 +2022-09-07 12:40:40 INFO:  test-backend-node.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","tensorflow"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{"version":"2.7.3-dev20220521","gpu":false},"wasm":{"supported":true,"backend":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":169} +2022-09-07 12:40:40 STATE: test-backend-node.js passed: set backend: tensorflow +2022-09-07 12:40:40 STATE: test-backend-node.js tensors 1921 +2022-09-07 12:40:40 STATE: test-backend-node.js passed: load models +2022-09-07 12:40:40 STATE: test-backend-node.js result: defined models: 23 loaded models: 12 +2022-09-07 12:40:40 STATE: test-backend-node.js passed: warmup: none default +2022-09-07 12:40:40 DATA:  test-backend-node.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-09-07 12:40:40 DATA:  test-backend-node.js result: performance: load: null total: null +2022-09-07 12:40:40 STATE: test-backend-node.js passed: warmup none result match +2022-09-07 12:40:40 STATE: test-backend-node.js event: image +2022-09-07 12:40:41 STATE: test-backend-node.js event: detect +2022-09-07 12:40:41 STATE: test-backend-node.js event: warmup +2022-09-07 12:40:41 STATE: test-backend-node.js passed: warmup: face default +2022-09-07 12:40:41 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4} +2022-09-07 12:40:41 DATA:  test-backend-node.js result: performance: load: null total: 357 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: warmup face result match +2022-09-07 12:40:41 STATE: test-backend-node.js event: image +2022-09-07 12:40:41 STATE: test-backend-node.js event: detect +2022-09-07 12:40:41 STATE: test-backend-node.js event: warmup +2022-09-07 12:40:41 STATE: test-backend-node.js passed: warmup: body default +2022-09-07 12:40:41 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:41 DATA:  test-backend-node.js result: performance: load: null total: 261 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: warmup body result match +2022-09-07 12:40:41 STATE: test-backend-node.js details: {"face":{"boxScore":0.92,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.63,"emotion":"angry"},{"score":0.22,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.52,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 10% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} +2022-09-07 12:40:41 INFO:  test-backend-node.js test: details verification +2022-09-07 12:40:41 STATE: test-backend-node.js start default +2022-09-07 12:40:41 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:41 STATE: test-backend-node.js event: image +2022-09-07 12:40:41 STATE: test-backend-node.js event: detect +2022-09-07 12:40:41 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg default +2022-09-07 12:40:41 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:41 DATA:  test-backend-node.js result: performance: load: null total: 232 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face length 1 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face score 1 0.93 1 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face arrays 4 478 1024 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face anti-spoofing 0.79 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details face liveness 0.83 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details body length 1 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details body 0.92 17 6 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details hand length 1 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details hand 0.51 0.73 point +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details hand arrays 21 5 7 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details gesture length 7 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details object length 1 +2022-09-07 12:40:41 STATE: test-backend-node.js passed: details object 0.72 person +2022-09-07 12:40:42 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} +2022-09-07 12:40:42 STATE: test-backend-node.js event: image +2022-09-07 12:40:42 STATE: test-backend-node.js event: detect +2022-09-07 12:40:42 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-09-07 12:40:42 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} +2022-09-07 12:40:42 STATE: test-backend-node.js event: image +2022-09-07 12:40:42 STATE: test-backend-node.js event: detect +2022-09-07 12:40:42 STATE: test-backend-node.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-09-07 12:40:43 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:43 STATE: test-backend-node.js event: image +2022-09-07 12:40:43 STATE: test-backend-node.js event: detect +2022-09-07 12:40:43 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-09-07 12:40:43 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:43 STATE: test-backend-node.js event: image +2022-09-07 12:40:43 STATE: test-backend-node.js event: detect +2022-09-07 12:40:43 STATE: test-backend-node.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-09-07 12:40:43 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-09-07 12:40:43 STATE: test-backend-node.js event: image +2022-09-07 12:40:44 STATE: test-backend-node.js event: detect +2022-09-07 12:40:44 STATE: test-backend-node.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-09-07 12:40:44 INFO:  test-backend-node.js test default +2022-09-07 12:40:44 STATE: test-backend-node.js start async +2022-09-07 12:40:44 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:44 STATE: test-backend-node.js event: image +2022-09-07 12:40:44 STATE: test-backend-node.js event: detect +2022-09-07 12:40:44 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg async +2022-09-07 12:40:44 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:44 DATA:  test-backend-node.js result: performance: load: null total: 206 +2022-09-07 12:40:44 STATE: test-backend-node.js passed: default result face match 1 female 0.97 +2022-09-07 12:40:44 INFO:  test-backend-node.js test sync +2022-09-07 12:40:44 STATE: test-backend-node.js start sync +2022-09-07 12:40:44 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:44 STATE: test-backend-node.js event: image +2022-09-07 12:40:44 STATE: test-backend-node.js event: detect +2022-09-07 12:40:44 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg sync +2022-09-07 12:40:44 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:44 DATA:  test-backend-node.js result: performance: load: null total: 205 +2022-09-07 12:40:44 STATE: test-backend-node.js passed: default sync 1 female 0.97 +2022-09-07 12:40:44 INFO:  test-backend-node.js test: image process +2022-09-07 12:40:44 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:44 STATE: test-backend-node.js passed: image input null [1,256,256,3] +2022-09-07 12:40:44 INFO:  test-backend-node.js test: image null +2022-09-07 12:40:44 STATE: test-backend-node.js passed: invalid input could not convert input to tensor +2022-09-07 12:40:44 INFO:  test-backend-node.js test face similarity +2022-09-07 12:40:44 STATE: test-backend-node.js start face similarity +2022-09-07 12:40:44 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:44 STATE: test-backend-node.js event: image +2022-09-07 12:40:44 STATE: test-backend-node.js event: detect +2022-09-07 12:40:44 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face similarity +2022-09-07 12:40:44 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} +2022-09-07 12:40:44 DATA:  test-backend-node.js result: performance: load: null total: 213 +2022-09-07 12:40:44 STATE: test-backend-node.js start face similarity +2022-09-07 12:40:45 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:45 STATE: test-backend-node.js event: image +2022-09-07 12:40:45 STATE: test-backend-node.js event: detect +2022-09-07 12:40:45 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg face similarity +2022-09-07 12:40:45 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:45 DATA:  test-backend-node.js result: performance: load: null total: 205 +2022-09-07 12:40:45 STATE: test-backend-node.js start face similarity +2022-09-07 12:40:45 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:45 STATE: test-backend-node.js event: image +2022-09-07 12:40:45 STATE: test-backend-node.js event: detect +2022-09-07 12:40:45 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg face similarity +2022-09-07 12:40:45 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} +2022-09-07 12:40:45 DATA:  test-backend-node.js result: performance: load: null total: 183 +2022-09-07 12:40:45 STATE: test-backend-node.js passed: face descriptor +2022-09-07 12:40:45 STATE: test-backend-node.js passed: face similarity {"similarity":[1,0.44727452329649126,0.5567935850640406],"descriptors":[1024,1024,1024]} +2022-09-07 12:40:45 INFO:  test-backend-node.js test object +2022-09-07 12:40:45 STATE: test-backend-node.js start object +2022-09-07 12:40:45 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:45 STATE: test-backend-node.js event: image +2022-09-07 12:40:45 STATE: test-backend-node.js event: detect +2022-09-07 12:40:45 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:40:45 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:45 DATA:  test-backend-node.js result: performance: load: null total: 207 +2022-09-07 12:40:45 STATE: test-backend-node.js passed: centernet +2022-09-07 12:40:45 STATE: test-backend-node.js start object +2022-09-07 12:40:46 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:46 STATE: test-backend-node.js event: image +2022-09-07 12:40:47 STATE: test-backend-node.js event: detect +2022-09-07 12:40:47 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:40:47 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 3 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.86,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:40:47 DATA:  test-backend-node.js result: performance: load: null total: 223 +2022-09-07 12:40:47 STATE: test-backend-node.js passed: nanodet +2022-09-07 12:40:47 INFO:  test-backend-node.js test sensitive +2022-09-07 12:40:47 STATE: test-backend-node.js start sensitive +2022-09-07 12:40:47 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:47 STATE: test-backend-node.js event: image +2022-09-07 12:40:47 STATE: test-backend-node.js event: detect +2022-09-07 12:40:47 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg sensitive +2022-09-07 12:40:47 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:47 DATA:  test-backend-node.js result: performance: load: null total: 166 +2022-09-07 12:40:47 STATE: test-backend-node.js passed: sensitive result match +2022-09-07 12:40:47 STATE: test-backend-node.js passed: sensitive face result match +2022-09-07 12:40:47 STATE: test-backend-node.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] +2022-09-07 12:40:47 STATE: test-backend-node.js passed: sensitive body result match +2022-09-07 12:40:47 STATE: test-backend-node.js passed: sensitive hand result match +2022-09-07 12:40:47 INFO:  test-backend-node.js test body +2022-09-07 12:40:47 STATE: test-backend-node.js start blazepose +2022-09-07 12:40:49 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:49 STATE: test-backend-node.js event: image +2022-09-07 12:40:49 STATE: test-backend-node.js event: detect +2022-09-07 12:40:49 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg blazepose +2022-09-07 12:40:49 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.99,"keypoints":39} +2022-09-07 12:40:49 DATA:  test-backend-node.js result: performance: load: null total: 214 +2022-09-07 12:40:49 STATE: test-backend-node.js passed: blazepose +2022-09-07 12:40:49 STATE: test-backend-node.js start efficientpose +2022-09-07 12:40:50 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:50 STATE: test-backend-node.js event: image +2022-09-07 12:40:50 STATE: test-backend-node.js event: detect +2022-09-07 12:40:50 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg efficientpose +2022-09-07 12:40:50 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.75,"keypoints":13} +2022-09-07 12:40:50 DATA:  test-backend-node.js result: performance: load: null total: 250 +2022-09-07 12:40:50 STATE: test-backend-node.js passed: efficientpose +2022-09-07 12:40:50 STATE: test-backend-node.js start posenet +2022-09-07 12:40:51 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:51 STATE: test-backend-node.js event: image +2022-09-07 12:40:51 STATE: test-backend-node.js event: detect +2022-09-07 12:40:51 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg posenet +2022-09-07 12:40:51 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.96,"keypoints":16} +2022-09-07 12:40:51 DATA:  test-backend-node.js result: performance: load: null total: 172 +2022-09-07 12:40:51 STATE: test-backend-node.js passed: posenet +2022-09-07 12:40:51 STATE: test-backend-node.js start movenet +2022-09-07 12:40:51 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:51 STATE: test-backend-node.js event: image +2022-09-07 12:40:51 STATE: test-backend-node.js event: detect +2022-09-07 12:40:51 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg movenet +2022-09-07 12:40:51 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:51 DATA:  test-backend-node.js result: performance: load: null total: 165 +2022-09-07 12:40:51 STATE: test-backend-node.js passed: movenet +2022-09-07 12:40:51 INFO:  test-backend-node.js test face matching +2022-09-07 12:40:51 STATE: test-backend-node.js passed: face database 40 +2022-09-07 12:40:51 STATE: test-backend-node.js passed: face match {"first":{"index":4,"similarity":0.7827852615252829}} {"second":{"index":4,"similarity":0.5002052633015844}} {"third":{"index":4,"similarity":0.5401587887998899}} +2022-09-07 12:40:51 INFO:  test-backend-node.js test face similarity alternative +2022-09-07 12:40:51 STATE: test-backend-node.js start face embeddings +2022-09-07 12:40:52 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:52 STATE: test-backend-node.js event: image +2022-09-07 12:40:52 STATE: test-backend-node.js event: detect +2022-09-07 12:40:52 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:40:52 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:52 DATA:  test-backend-node.js result: performance: load: null total: 180 +2022-09-07 12:40:52 STATE: test-backend-node.js passed: mobilefacenet {"embedding":192} +2022-09-07 12:40:52 STATE: test-backend-node.js start face embeddings +2022-09-07 12:40:53 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:53 STATE: test-backend-node.js event: image +2022-09-07 12:40:53 STATE: test-backend-node.js event: detect +2022-09-07 12:40:53 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:40:53 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:53 DATA:  test-backend-node.js result: performance: load: null total: 201 +2022-09-07 12:40:53 STATE: test-backend-node.js passed: insightface {"embedding":512} +2022-09-07 12:40:53 INFO:  test-backend-node.js test face attention +2022-09-07 12:40:53 STATE: test-backend-node.js start face attention +2022-09-07 12:40:54 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:54 STATE: test-backend-node.js event: image +2022-09-07 12:40:54 STATE: test-backend-node.js event: detect +2022-09-07 12:40:54 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg face attention +2022-09-07 12:40:54 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:54 DATA:  test-backend-node.js result: performance: load: null total: 178 +2022-09-07 12:40:54 STATE: test-backend-node.js passed: face attention +2022-09-07 12:40:54 INFO:  test-backend-node.js test detectors +2022-09-07 12:40:54 STATE: test-backend-node.js start detectors +2022-09-07 12:40:54 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:54 STATE: test-backend-node.js event: image +2022-09-07 12:40:54 STATE: test-backend-node.js event: detect +2022-09-07 12:40:54 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg detectors +2022-09-07 12:40:54 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:54 DATA:  test-backend-node.js result: performance: load: null total: 127 +2022-09-07 12:40:54 STATE: test-backend-node.js passed: detector result face match +2022-09-07 12:40:54 STATE: test-backend-node.js passed: detector result hand match +2022-09-07 12:40:54 INFO:  test-backend-node.js test: multi-instance +2022-09-07 12:40:54 STATE: test-backend-node.js start multi instance +2022-09-07 12:40:54 STATE: test-backend-node.js event: image +2022-09-07 12:40:54 STATE: test-backend-node.js event: detect +2022-09-07 12:40:54 STATE: test-backend-node.js passed: detect: random multi instance +2022-09-07 12:40:54 DATA:  test-backend-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} +2022-09-07 12:40:54 DATA:  test-backend-node.js result: performance: load: null total: 91 +2022-09-07 12:40:54 INFO:  test-backend-node.js test: first instance +2022-09-07 12:40:54 STATE: test-backend-node.js start multi instance +2022-09-07 12:40:54 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:40:55 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:40:55 DATA:  test-backend-node.js result: performance: load: null total: 112 +2022-09-07 12:40:55 INFO:  test-backend-node.js test: second instance +2022-09-07 12:40:55 STATE: test-backend-node.js start multi instance +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:40:55 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:40:55 DATA:  test-backend-node.js result: performance: load: null total: 107 +2022-09-07 12:40:55 INFO:  test-backend-node.js test: concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js start concurrent +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:55 STATE: test-backend-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-09-07 12:40:56 STATE: test-backend-node.js event: image +2022-09-07 12:40:56 STATE: test-backend-node.js event: image +2022-09-07 12:40:56 STATE: test-backend-node.js event: image +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1190 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1190 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1191 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1191 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1191 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 1191 +2022-09-07 12:40:56 STATE: test-backend-node.js event: detect +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 944 +2022-09-07 12:40:56 STATE: test-backend-node.js event: detect +2022-09-07 12:40:56 STATE: test-backend-node.js event: detect +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 944 +2022-09-07 12:40:56 STATE: test-backend-node.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:40:56 DATA:  test-backend-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:40:56 DATA:  test-backend-node.js result: performance: load: null total: 944 +2022-09-07 12:40:56 INFO:  test-backend-node.js test: monkey-patch +2022-09-07 12:40:56 STATE: test-backend-node.js event: image +2022-09-07 12:40:57 STATE: test-backend-node.js event: detect +2022-09-07 12:40:57 STATE: test-backend-node.js passed: monkey patch +2022-09-07 12:40:57 STATE: test-backend-node.js passed: segmentation [65536] +2022-09-07 12:40:57 STATE: test-backend-node.js passeed: equal usage +2022-09-07 12:40:57 INFO:  test-backend-node.js test: input compare +2022-09-07 12:40:57 STATE: test-backend-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:40:57 STATE: test-backend-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-09-07 12:40:57 STATE: test-backend-node.js passed: image compare 0 23.275441687091504 +2022-09-07 12:40:57 INFO:  test-backend-node.js events: {"image":29,"detect":29,"warmup":2} +2022-09-07 12:40:57 INFO:  test-backend-node.js tensors 4147 +2022-09-07 12:40:57 INFO:  test-backend-node.js test complete: 16543 ms +2022-09-07 12:40:57 INFO:  +2022-09-07 12:40:57 INFO:  test-backend-node-gpu.js start +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js test: configuration validation +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: configuration default validation [] +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js test: model load +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"file://models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"file://models/emotion.json"},{"name":"facedetect","loaded":true,"url":"file://models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"file://models/iris.json"},{"name":"facemesh","loaded":true,"url":"file://models/facemesh.json"},{"name":"faceres","loaded":true,"url":"file://models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"file://models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"file://models/handtrack.json"},{"name":"liveness","loaded":true,"url":"file://models/liveness.json"},{"name":"movenet","loaded":true,"url":"file://models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"file://models/selfie.json"},{"name":"antispoof","loaded":true,"url":"file://models/antispoof.json"}] +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js memory: {"memory":{"unreliable":true,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js test: warmup +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: create human +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js human version: 2.10.1 +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js platform: linux x64 agent: NodeJS v18.1.0 +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js tfjs version: 3.20.0 +2022-09-07 12:40:58 INFO:  test-backend-node-gpu.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","tensorflow"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{"version":"2.7.3-dev20220521","gpu":true},"wasm":{"supported":true,"backend":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":169} +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: set backend: tensorflow +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js tensors 1921 +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: load models +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js result: defined models: 23 loaded models: 12 +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: warmup: none default +2022-09-07 12:40:58 DATA:  test-backend-node-gpu.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-09-07 12:40:58 DATA:  test-backend-node-gpu.js result: performance: load: null total: null +2022-09-07 12:40:58 STATE: test-backend-node-gpu.js passed: warmup none result match +2022-09-07 12:40:59 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: warmup +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: warmup: face default +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4} +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: performance: load: null total: 3374 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: warmup face result match +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: warmup +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: warmup: body default +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: performance: load: null total: 159 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: warmup body result match +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js details: {"face":{"boxScore":0.92,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.63,"emotion":"angry"},{"score":0.22,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.52,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 10% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} +2022-09-07 12:41:02 INFO:  test-backend-node-gpu.js test: details verification +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js start default +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:02 DATA:  test-backend-node-gpu.js result: performance: load: null total: 137 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face length 1 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face score 1 0.93 1 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face arrays 4 478 1024 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face anti-spoofing 0.79 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details face liveness 0.83 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details body length 1 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details body 0.92 17 6 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details hand length 1 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details hand 0.51 0.73 point +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details hand arrays 21 5 7 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details gesture length 7 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details object length 1 +2022-09-07 12:41:02 STATE: test-backend-node-gpu.js passed: details object 0.72 person +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:03 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-09-07 12:41:04 INFO:  test-backend-node-gpu.js test default +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js start async +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg async +2022-09-07 12:41:04 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:04 DATA:  test-backend-node-gpu.js result: performance: load: null total: 142 +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js passed: default result face match 1 female 0.97 +2022-09-07 12:41:04 INFO:  test-backend-node-gpu.js test sync +2022-09-07 12:41:04 STATE: test-backend-node-gpu.js start sync +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg sync +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: performance: load: null total: 163 +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: default sync 1 female 0.97 +2022-09-07 12:41:05 INFO:  test-backend-node-gpu.js test: image process +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: image input null [1,256,256,3] +2022-09-07 12:41:05 INFO:  test-backend-node-gpu.js test: image null +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: invalid input could not convert input to tensor +2022-09-07 12:41:05 INFO:  test-backend-node-gpu.js test face similarity +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js start face similarity +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face similarity +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: performance: load: null total: 145 +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js start face similarity +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg face similarity +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: performance: load: null total: 152 +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js start face similarity +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg face similarity +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} +2022-09-07 12:41:05 DATA:  test-backend-node-gpu.js result: performance: load: null total: 153 +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: face descriptor +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js passed: face similarity {"similarity":[1,0.447238756461232,0.556914029877052],"descriptors":[1024,1024,1024]} +2022-09-07 12:41:05 INFO:  test-backend-node-gpu.js test object +2022-09-07 12:41:05 STATE: test-backend-node-gpu.js start object +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:41:06 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:06 DATA:  test-backend-node-gpu.js result: performance: load: null total: 158 +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js passed: centernet +2022-09-07 12:41:06 STATE: test-backend-node-gpu.js start object +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:41:07 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 3 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.86,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:07 DATA:  test-backend-node-gpu.js result: performance: load: null total: 549 +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js passed: nanodet +2022-09-07 12:41:07 INFO:  test-backend-node-gpu.js test sensitive +2022-09-07 12:41:07 STATE: test-backend-node-gpu.js start sensitive +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg sensitive +2022-09-07 12:41:08 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:08 DATA:  test-backend-node-gpu.js result: performance: load: null total: 142 +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: sensitive result match +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: sensitive face result match +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: sensitive body result match +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js passed: sensitive hand result match +2022-09-07 12:41:08 INFO:  test-backend-node-gpu.js test body +2022-09-07 12:41:08 STATE: test-backend-node-gpu.js start blazepose +2022-09-07 12:41:09 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:09 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg blazepose +2022-09-07 12:41:10 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.99,"keypoints":39} +2022-09-07 12:41:10 DATA:  test-backend-node-gpu.js result: performance: load: null total: 267 +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js passed: blazepose +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js start efficientpose +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:10 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg efficientpose +2022-09-07 12:41:11 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.75,"keypoints":13} +2022-09-07 12:41:11 DATA:  test-backend-node-gpu.js result: performance: load: null total: 819 +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js passed: efficientpose +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js start posenet +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:11 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg posenet +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.96,"keypoints":16} +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: performance: load: null total: 160 +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: posenet +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js start movenet +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg movenet +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 0 person: 1 {"score":1,"age":23.7,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: performance: load: null total: 120 +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: movenet +2022-09-07 12:41:12 INFO:  test-backend-node-gpu.js test face matching +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: face database 40 +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: face match {"first":{"index":4,"similarity":0.7828184453007331}} {"second":{"index":4,"similarity":0.5001334216773398}} {"third":{"index":4,"similarity":0.5403054967489764}} +2022-09-07 12:41:12 INFO:  test-backend-node-gpu.js test face similarity alternative +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js start face embeddings +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:12 DATA:  test-backend-node-gpu.js result: performance: load: null total: 159 +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js passed: mobilefacenet {"embedding":192} +2022-09-07 12:41:12 STATE: test-backend-node-gpu.js start face embeddings +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:41:13 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:13 DATA:  test-backend-node-gpu.js result: performance: load: null total: 164 +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js passed: insightface {"embedding":512} +2022-09-07 12:41:13 INFO:  test-backend-node-gpu.js test face attention +2022-09-07 12:41:13 STATE: test-backend-node-gpu.js start face attention +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg face attention +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 278 +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: face attention +2022-09-07 12:41:14 INFO:  test-backend-node-gpu.js test detectors +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js start detectors +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg detectors +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 99 +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detector result face match +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detector result hand match +2022-09-07 12:41:14 INFO:  test-backend-node-gpu.js test: multi-instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js start multi instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detect: random multi instance +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 50 +2022-09-07 12:41:14 INFO:  test-backend-node-gpu.js test: first instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js start multi instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:14 DATA:  test-backend-node-gpu.js result: performance: load: null total: 68 +2022-09-07 12:41:14 INFO:  test-backend-node-gpu.js test: second instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js start multi instance +2022-09-07 12:41:14 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:41:15 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:15 DATA:  test-backend-node-gpu.js result: performance: load: null total: 59 +2022-09-07 12:41:15 INFO:  test-backend-node-gpu.js test: concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js start concurrent +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:15 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 817 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 818 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 818 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 818 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 818 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 818 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 564 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 564 +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:16 DATA:  test-backend-node-gpu.js result: performance: load: null total: 564 +2022-09-07 12:41:16 INFO:  test-backend-node-gpu.js test: monkey-patch +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js event: image +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js event: detect +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: monkey patch +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: segmentation [65536] +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passeed: equal usage +2022-09-07 12:41:16 INFO:  test-backend-node-gpu.js test: input compare +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-09-07 12:41:16 STATE: test-backend-node-gpu.js passed: image compare 0 23.275441687091504 +2022-09-07 12:41:16 INFO:  test-backend-node-gpu.js events: {"image":29,"detect":29,"warmup":2} +2022-09-07 12:41:16 INFO:  test-backend-node-gpu.js tensors 4147 +2022-09-07 12:41:16 INFO:  test-backend-node-gpu.js test complete: 18199 ms +2022-09-07 12:41:18 INFO:  +2022-09-07 12:41:18 INFO:  test-backend-node-wasm.js start +2022-09-07 12:41:18 DATA:  test-backend-node-wasm.js stdout: 2022-09-07 12:41:18 INFO:  { supported: true, backend: true, simd: true, multithread: false } +2022-09-07 12:41:18 STATE: test-backend-node-wasm.js passed: model server: https://vladmandic.github.io/human/models/ +2022-09-07 12:41:18 INFO:  test-backend-node-wasm.js test: configuration validation +2022-09-07 12:41:18 STATE: test-backend-node-wasm.js passed: configuration default validation [] +2022-09-07 12:41:18 STATE: test-backend-node-wasm.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-09-07 12:41:18 INFO:  test-backend-node-wasm.js test: model load +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: models loaded 23 12 [{"name":"ssrnetage","loaded":false,"url":null},{"name":"gear","loaded":false,"url":null},{"name":"blazeposedetect","loaded":false,"url":null},{"name":"blazepose","loaded":false,"url":null},{"name":"centernet","loaded":true,"url":"https://vladmandic.github.io/human/models/mb3-centernet.json"},{"name":"efficientpose","loaded":false,"url":null},{"name":"mobilefacenet","loaded":false,"url":null},{"name":"insightface","loaded":false,"url":null},{"name":"emotion","loaded":true,"url":"https://vladmandic.github.io/human/models/emotion.json"},{"name":"facedetect","loaded":true,"url":"https://vladmandic.github.io/human/models/blazeface.json"},{"name":"faceiris","loaded":true,"url":"https://vladmandic.github.io/human/models/iris.json"},{"name":"facemesh","loaded":true,"url":"https://vladmandic.github.io/human/models/facemesh.json"},{"name":"faceres","loaded":true,"url":"https://vladmandic.github.io/human/models/faceres.json"},{"name":"ssrnetgender","loaded":false,"url":null},{"name":"handpose","loaded":false,"url":null},{"name":"handskeleton","loaded":true,"url":"https://vladmandic.github.io/human/models/handlandmark-full.json"},{"name":"handtrack","loaded":true,"url":"https://vladmandic.github.io/human/models/handtrack.json"},{"name":"liveness","loaded":true,"url":"https://vladmandic.github.io/human/models/liveness.json"},{"name":"movenet","loaded":true,"url":"https://vladmandic.github.io/human/models/movenet-lightning.json"},{"name":"nanodet","loaded":false,"url":null},{"name":"posenet","loaded":false,"url":null},{"name":"segmentation","loaded":true,"url":"https://vladmandic.github.io/human/models/selfie.json"},{"name":"antispoof","loaded":true,"url":"https://vladmandic.github.io/human/models/antispoof.json"}] +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js memory: {"memory":{"unreliable":false,"numTensors":1921,"numDataBuffers":1921,"numBytes":63673064}} +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js state: {"state":{"registeredVariables":{},"nextTapeNodeId":0,"numBytes":63673064,"numTensors":1921,"numStringTensors":0,"numDataBuffers":1921,"gradientDepth":0,"kernelDepth":0,"scopeStack":[],"numDataMovesStack":[],"nextScopeId":0,"tensorInfo":{},"profiling":false,"activeProfile":{"newBytes":0,"newTensors":0,"peakBytes":0,"kernels":[],"result":null,"kernelNames":[]}}} +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js test: warmup +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: create human +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js human version: 2.10.1 +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js platform: linux x64 agent: NodeJS v18.1.0 +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js tfjs version: 3.20.0 +2022-09-07 12:41:20 INFO:  test-backend-node-wasm.js env: {"browser":false,"node":true,"platform":"linux x64","agent":"NodeJS v18.1.0","backends":["cpu","wasm"],"initial":false,"tfjs":{"version":"3.20.0"},"offscreen":false,"perfadd":false,"tensorflow":{},"wasm":{"supported":true,"backend":true,"simd":true,"multithread":false},"webgl":{"supported":false,"backend":false},"webgpu":{"supported":false,"backend":false},"cpu":{"flags":[]},"kernels":126} +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: set backend: wasm +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js tensors 1921 +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: load models +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js result: defined models: 23 loaded models: 12 +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: warmup: none default +2022-09-07 12:41:20 DATA:  test-backend-node-wasm.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-09-07 12:41:20 DATA:  test-backend-node-wasm.js result: performance: load: null total: null +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js passed: warmup none result match +2022-09-07 12:41:20 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js event: warmup +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js passed: warmup: face default +2022-09-07 12:41:21 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} +2022-09-07 12:41:21 DATA:  test-backend-node-wasm.js result: performance: load: null total: 519 +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js passed: warmup face result match +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js event: warmup +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js passed: warmup: body default +2022-09-07 12:41:21 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:21 DATA:  test-backend-node-wasm.js result: performance: load: null total: 453 +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js passed: warmup body result match +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js details: {"face":{"boxScore":0.93,"faceScore":1,"age":23.7,"gender":"female","genderScore":0.97},"emotion":[{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}],"body":{"score":0.92,"keypoints":17},"hand":{"boxScore":0.51,"fingerScore":0.73,"keypoints":21},"gestures":[{"face":0,"gesture":"facing right"},{"face":0,"gesture":"mouth 21% open"},{"hand":0,"gesture":"pinky forward"},{"hand":0,"gesture":"palm up"},{"hand":0,"gesture":"open palm"},{"iris":0,"gesture":"looking left"},{"iris":0,"gesture":"looking up"}]} +2022-09-07 12:41:21 INFO:  test-backend-node-wasm.js test: details verification +2022-09-07 12:41:21 STATE: test-backend-node-wasm.js start default +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-09-07 12:41:22 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 7 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:22 DATA:  test-backend-node-wasm.js result: performance: load: null total: 349 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face length 1 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face score 1 0.93 1 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face arrays 4 478 1024 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face anti-spoofing 0.79 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details face liveness 0.83 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details body length 1 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details body 0.92 17 6 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details hand length 1 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details hand 0.51 0.73 point +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details hand arrays 21 5 7 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details gesture length 7 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details object length 1 +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: details object 0.72 person +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1413675264} +2022-09-07 12:41:22 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1413675264} +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:23 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-09-07 12:41:24 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-09-07 12:41:25 INFO:  test-backend-node-wasm.js test default +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js start async +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg async +2022-09-07 12:41:25 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:25 DATA:  test-backend-node-wasm.js result: performance: load: null total: 327 +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js passed: default result face match 1 female 0.97 +2022-09-07 12:41:25 INFO:  test-backend-node-wasm.js test sync +2022-09-07 12:41:25 STATE: test-backend-node-wasm.js start sync +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg sync +2022-09-07 12:41:26 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:26 DATA:  test-backend-node-wasm.js result: performance: load: null total: 311 +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: default sync 1 female 0.97 +2022-09-07 12:41:26 INFO:  test-backend-node-wasm.js test: image process +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: image input null [1,256,256,3] +2022-09-07 12:41:26 INFO:  test-backend-node-wasm.js test: image null +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: invalid input could not convert input to tensor +2022-09-07 12:41:26 INFO:  test-backend-node-wasm.js test face similarity +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js start face similarity +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face similarity +2022-09-07 12:41:26 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 6 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":3} +2022-09-07 12:41:26 DATA:  test-backend-node-wasm.js result: performance: load: null total: 296 +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js start face similarity +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:26 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg face similarity +2022-09-07 12:41:27 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:27 DATA:  test-backend-node-wasm.js result: performance: load: null total: 310 +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js start face similarity +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg face similarity +2022-09-07 12:41:27 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"score":1,"age":23.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":7} +2022-09-07 12:41:27 DATA:  test-backend-node-wasm.js result: performance: load: null total: 279 +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: face descriptor +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: face similarity {"similarity":[1,0.5266119940661309,0.4858842904087851],"descriptors":[1024,1024,1024]} +2022-09-07 12:41:27 INFO:  test-backend-node-wasm.js test object +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js start object +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:27 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:28 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:28 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:41:28 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-09-07 12:41:28 DATA:  test-backend-node-wasm.js result: performance: load: null total: 306 +2022-09-07 12:41:28 STATE: test-backend-node-wasm.js passed: centernet +2022-09-07 12:41:28 STATE: test-backend-node-wasm.js start object +2022-09-07 12:41:29 WARN:  test-backend-node-wasm.js missing kernel ops {"title":"object","model":"nanodet","url":"https://vladmandic.github.io/human-models/models/nanodet.json","missing":["sparsetodense"],"backkend":"wasm"} +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg object +2022-09-07 12:41:29 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 8 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:29 DATA:  test-backend-node-wasm.js result: performance: load: null total: 212 +2022-09-07 12:41:29 ERROR: test-backend-node-wasm.js failed: nanodet [] +2022-09-07 12:41:29 INFO:  test-backend-node-wasm.js test sensitive +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js start sensitive +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg sensitive +2022-09-07 12:41:29 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:29 DATA:  test-backend-node-wasm.js result: performance: load: null total: 235 +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: sensitive result match +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: sensitive face result match +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: sensitive face emotion result [{"score":0.46,"emotion":"neutral"},{"score":0.24,"emotion":"fear"},{"score":0.17,"emotion":"sad"}] +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: sensitive body result match +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js passed: sensitive hand result match +2022-09-07 12:41:29 INFO:  test-backend-node-wasm.js test body +2022-09-07 12:41:29 STATE: test-backend-node-wasm.js start blazepose +2022-09-07 12:41:32 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:32 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg blazepose +2022-09-07 12:41:33 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.99,"keypoints":39} +2022-09-07 12:41:33 DATA:  test-backend-node-wasm.js result: performance: load: null total: 380 +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js passed: blazepose +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js start efficientpose +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:33 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:34 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:34 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg efficientpose +2022-09-07 12:41:34 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.75,"keypoints":13} +2022-09-07 12:41:34 DATA:  test-backend-node-wasm.js result: performance: load: null total: 625 +2022-09-07 12:41:34 STATE: test-backend-node-wasm.js passed: efficientpose +2022-09-07 12:41:34 STATE: test-backend-node-wasm.js start posenet +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg posenet +2022-09-07 12:41:35 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.96,"keypoints":16} +2022-09-07 12:41:35 DATA:  test-backend-node-wasm.js result: performance: load: null total: 286 +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: posenet +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js start movenet +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg movenet +2022-09-07 12:41:35 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 0 person: 1 {"score":1,"age":29.6,"gender":"female"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:35 DATA:  test-backend-node-wasm.js result: performance: load: null total: 246 +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: movenet +2022-09-07 12:41:35 INFO:  test-backend-node-wasm.js test face matching +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: face database 40 +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js passed: face match {"first":{"index":4,"similarity":0.7827852754786533}} {"second":{"index":4,"similarity":0.5660821189104794}} {"third":{"index":4,"similarity":0.45074189882665594}} +2022-09-07 12:41:35 INFO:  test-backend-node-wasm.js test face similarity alternative +2022-09-07 12:41:35 STATE: test-backend-node-wasm.js start face embeddings +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:41:36 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:36 DATA:  test-backend-node-wasm.js result: performance: load: null total: 230 +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js passed: mobilefacenet {"embedding":192} +2022-09-07 12:41:36 STATE: test-backend-node-wasm.js start face embeddings +2022-09-07 12:41:37 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:37 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face embeddings +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 8 object: 0 person: 1 {"score":1,"age":23.5,"gender":"female"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 279 +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: insightface {"embedding":512} +2022-09-07 12:41:38 INFO:  test-backend-node-wasm.js test face attention +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js start face attention +2022-09-07 12:41:38 WARN:  test-backend-node-wasm.js missing kernel ops {"title":"face attention","model":"facemesh","url":"https://vladmandic.github.io/human-models/models/facemesh-attention.json","missing":["atan2"],"backkend":"wasm"} +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg face attention +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: face: 0 body: 1 hand: 1 gesture: 2 object: 0 person: 0 {} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 119 +2022-09-07 12:41:38 ERROR: test-backend-node-wasm.js failed: face attention {"annotations":0} +2022-09-07 12:41:38 INFO:  test-backend-node-wasm.js test detectors +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js start detectors +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg detectors +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:38 DATA:  test-backend-node-wasm.js result: performance: load: null total: 117 +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: detector result face match +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js passed: detector result hand match +2022-09-07 12:41:38 INFO:  test-backend-node-wasm.js test: multi-instance +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js start multi instance +2022-09-07 12:41:38 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: detect: random multi instance +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0} +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: performance: load: null total: 95 +2022-09-07 12:41:39 INFO:  test-backend-node-wasm.js test: first instance +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start multi instance +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: performance: load: null total: 105 +2022-09-07 12:41:39 INFO:  test-backend-node-wasm.js test: second instance +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start multi instance +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg multi instance +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:39 DATA:  test-backend-node-wasm.js result: performance: load: null total: 108 +2022-09-07 12:41:39 INFO:  test-backend-node-wasm.js test: concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js start concurrent +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:39 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:40 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1225 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1225 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1226 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1226 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1226 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 1226 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-upper.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 0 person: 1 {"score":0.96,"gender":"unknown"} {} {"score":0.75,"keypoints":7} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 919 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-face.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.91,"gender":"unknown"} {} {"score":0.47,"keypoints":3} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 919 +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: detect: samples/in/ai-body.jpg concurrent +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 0 person: 1 {"score":0.93,"gender":"unknown"} {} {"score":0.92,"keypoints":17} +2022-09-07 12:41:41 DATA:  test-backend-node-wasm.js result: performance: load: null total: 919 +2022-09-07 12:41:41 INFO:  test-backend-node-wasm.js test: monkey-patch +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js event: image +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js event: detect +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: monkey patch +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: segmentation [65536] +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passeed: equal usage +2022-09-07 12:41:41 INFO:  test-backend-node-wasm.js test: input compare +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-09-07 12:41:41 STATE: test-backend-node-wasm.js passed: image compare 0 23.280073018790848 +2022-09-07 12:41:41 INFO:  test-backend-node-wasm.js events: {"image":29,"detect":29,"warmup":2} +2022-09-07 12:41:41 INFO:  test-backend-node-wasm.js tensors 4149 +2022-09-07 12:41:41 INFO:  test-backend-node-wasm.js test complete: 22938 ms +2022-09-07 12:41:41 STATE: all tests complete +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node-simple.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node-fetch.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node-event.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node-similarity.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/nodejs/node-canvas.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/multithread/node-multiprocess.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"../demo/facematch/node-match.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"test-node-load.js","passed":1,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"test-node-gear.js","passed":3,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"test-backend-node.js","passed":125,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"test-backend-node-gpu.js","passed":125,"failed":0} +2022-09-07 12:41:41 INFO:  status {"test":"test-backend-node-wasm.js","passed":124,"failed":2} +2022-09-07 12:41:41 INFO:  failures {"count":2} +2022-09-07 12:41:41 WARN:  failed {"test":"test-backend-node-wasm.js","message":["error",["failed: nanodet",[]]]} +2022-09-07 12:41:41 WARN:  failed {"test":"test-backend-node-wasm.js","message":["error",["failed: face attention",{"annotations":0}]]} diff --git a/typedoc/classes/Env.html b/typedoc/classes/Env.html index 1cb06a262..9012b79a4 100644 --- a/typedoc/classes/Env.html +++ b/typedoc/classes/Env.html @@ -1,16 +1,16 @@ -Env | @vladmandic/human - v2.10.0
+Env | @vladmandic/human - v2.10.1
+
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -299,7 +299,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -385,7 +385,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -820,7 +820,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -3642,7 +3642,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -205,7 +205,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -48,7 +48,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -46,7 +46,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -48,7 +48,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -56,7 +56,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -67,7 +67,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -60,7 +60,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -42,7 +42,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -44,7 +44,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -42,7 +42,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -42,7 +42,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -46,7 +46,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    -

    @vladmandic/human - v2.10.0

    +

    @vladmandic/human - v2.10.1

    @@ -141,7 +141,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0 +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -106,7 +106,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -88,7 +88,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -96,7 +96,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -246,7 +246,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -203,7 +203,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -90,7 +90,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -90,7 +90,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -144,7 +144,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -101,7 +101,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -140,7 +140,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -98,7 +98,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -98,7 +98,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -90,7 +90,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -90,7 +90,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -98,7 +98,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -212,7 +212,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -217,7 +217,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -99,7 +99,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -56,7 +56,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -156,7 +156,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -128,7 +128,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -75,7 +75,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -114,7 +114,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -96,7 +96,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -114,7 +114,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -129,7 +129,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -102,7 +102,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -70,7 +70,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -100,7 +100,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -69,7 +69,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -48,7 +48,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -54,7 +54,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    AnyCanvas: HTMLCanvasElement | OffscreenCanvas
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    AnyImage: HTMLImageElement | typeof Image
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    AnyVideo: HTMLMediaElement | HTMLVideoElement
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BackendType: ["cpu", "wasm", "webgl", "humangl", "tensorflow", "webgpu"]
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyAnnotationBlazePose: "leftLeg" | "rightLeg" | "torso" | "leftArm" | "rightArm" | "leftEye" | "rightEye" | "mouth"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyAnnotationEfficientPose: "leftLeg" | "rightLeg" | "torso" | "leftArm" | "rightArm" | "head"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyGesture: `leaning ${"left" | "right"}` | `raise ${"left" | "right"} hand` | "i give up"
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyLandmarkBlazePose: "nose" | "leftEyeInside" | "leftEye" | "leftEyeOutside" | "rightEyeInside" | "rightEye" | "rightEyeOutside" | "leftEar" | "rightEar" | "leftMouth" | "rightMouth" | "leftShoulder" | "rightShoulder" | "leftElbow" | "rightElbow" | "leftWrist" | "rightWrist" | "leftPinky" | "rightPinky" | "leftIndex" | "rightIndex" | "leftThumb" | "rightThumb" | "leftHip" | "rightHip" | "leftKnee" | "rightKnee" | "leftAnkle" | "rightAnkle" | "leftHeel" | "rightHeel" | "leftFoot" | "rightFoot" | "bodyCenter" | "bodyTop" | "leftPalm" | "leftHand" | "rightPalm" | "rightHand"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyLandmarkEfficientNet: "head" | "neck" | "rightShoulder" | "rightElbow" | "rightWrist" | "chest" | "leftShoulder" | "leftElbow" | "leftWrist" | "bodyCenter" | "rightHip" | "rightKnee" | "rightAnkle" | "leftHip" | "leftKnee" | "leftAnkle"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyLandmarkMoveNet: "nose" | "leftEye" | "rightEye" | "leftEar" | "rightEar" | "leftShoulder" | "rightShoulder" | "leftElbow" | "rightElbow" | "leftWrist" | "rightWrist" | "leftHip" | "rightHip" | "leftKnee" | "rightKnee" | "leftAnkle" | "rightAnkle"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    BodyLandmarkPoseNet: "nose" | "leftEye" | "rightEye" | "leftEar" | "rightEar" | "leftShoulder" | "rightShoulder" | "leftElbow" | "rightElbow" | "leftWrist" | "rightWrist" | "leftHip" | "rightHip" | "leftKnee" | "rightKnee" | "leftAnkle" | "rightAnkle"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Box: [number, number, number, number]
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Emotion: "angry" | "disgust" | "fear" | "happy" | "sad" | "surprise" | "neutral"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Events: "create" | "load" | "image" | "result" | "warmup" | "error"
    @@ -41,7 +41,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    ExternalCanvas: typeof Canvas
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    FaceGesture: `facing ${"left" | "center" | "right"}` | `blink ${"left" | "right"} eye` | `mouth ${number}% open` | `head ${"up" | "down"}`
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    FaceLandmark: "leftEye" | "rightEye" | "nose" | "mouth" | "leftEar" | "rightEar" | "symmetryLine" | "silhouette" | "lipsUpperOuter" | "lipsLowerOuter" | "lipsUpperInner" | "lipsLowerInner" | "rightEyeUpper0" | "rightEyeLower0" | "rightEyeUpper1" | "rightEyeLower1" | "rightEyeUpper2" | "rightEyeLower2" | "rightEyeLower3" | "rightEyebrowUpper" | "rightEyebrowLower" | "rightEyeIris" | "leftEyeUpper0" | "leftEyeLower0" | "leftEyeUpper1" | "leftEyeLower1" | "leftEyeUpper2" | "leftEyeLower2" | "leftEyeLower3" | "leftEyebrowUpper" | "leftEyebrowLower" | "leftEyeIris" | "midwayBetweenEyes" | "noseTip" | "noseBottom" | "noseRightCorner" | "noseLeftCorner" | "rightCheek" | "leftCheek"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Finger: "index" | "middle" | "pinky" | "ring" | "thumb" | "palm"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    FingerCurl: "none" | "half" | "full"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    FingerDirection: "verticalUp" | "verticalDown" | "horizontalLeft" | "horizontalRight" | "diagonalUpRight" | "diagonalUpLeft" | "diagonalDownRight" | "diagonalDownLeft"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Gender: "male" | "female" | "unknown"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    GestureResult: { face: number; gesture: FaceGesture } | { gesture: IrisGesture; iris: number } | { body: number; gesture: BodyGesture } | { gesture: HandGesture; hand: number }
    @@ -39,7 +39,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    HandGesture: `${"thumb" | "index" | "middle" | "ring" | "pinky"} forward` | `${"thumb" | "index" | "middle" | "ring" | "pinky"} up` | "victory" | "thumbs up"
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    HandType: "hand" | "fist" | "pinch" | "point" | "face" | "tip" | "pinchtip"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    ImageObjects: ImageData | ImageBitmap
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    IrisGesture: "facing center" | `looking ${"left" | "right" | "up" | "down"}` | "looking center"
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    ObjectType: "person" | "bicycle" | "car" | "motorcycle" | "airplane" | "bus" | "train" | "truck" | "boat" | "traffic light" | "fire hydrant" | "stop sign" | "parking meter" | "bench" | "bird" | "cat" | "dog" | "horse" | "sheep" | "cow" | "elephant" | "bear" | "zebra" | "giraffe" | "backpack" | "umbrella" | "handbag" | "tie" | "suitcase" | "frisbee" | "skis" | "snowboard" | "sports ball" | "kite" | "baseball bat" | "baseball glove" | "skateboard" | "surfboard" | "tennis racket" | "bottle" | "wine glass" | "cup" | "fork" | "knife" | "spoon" | "bowl" | "banana" | "apple" | "sandwich" | "orange" | "broccoli" | "carrot" | "hot dog" | "pizza" | "donut" | "cake" | "chair" | "couch" | "potted plant" | "bed" | "dining table" | "toilet" | "tv" | "laptop" | "mouse" | "remote" | "keyboard" | "cell phone" | "microwave" | "oven" | "toaster" | "sink" | "refrigerator" | "book" | "clock" | "vase" | "scissors" | "teddy bear" | "hair drier" | "toothbrush"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Point: [number, number, number?]
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    Race: "white" | "black" | "asian" | "indian" | "other"
    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    TensorLike: TypedArray | number | boolean | string | RecursiveArray<number | number[] | TypedArray> | RecursiveArray<boolean> | RecursiveArray<string> | Uint8Array[]
    @@ -35,7 +35,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    WarmupType: ["" | "none" | "face" | "full" | "body"]
    @@ -34,7 +34,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -35,7 +35,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -33,7 +33,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    defaults: Config = ...
    @@ -36,7 +36,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    @@ -35,7 +35,7 @@

    Theme

    • Preparing search index...
    • -
    • The search index is not available
    @vladmandic/human - v2.10.0
    +
  • The search index is not available
  • @vladmandic/human - v2.10.1
    env: Env = ...