diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c03089c..651a153b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # @vladmandic/human - Version: **2.8.0** + Version: **2.8.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,11 +9,12 @@ ## Changelog -### **HEAD -> main** 2022/05/30 mandic00@live.com +### **2.8.1** 2022/06/08 mandic00@live.com -### **origin/main** 2022/05/29 mandic00@live.com +### **origin/main** 2022/06/02 mandic00@live.com +- add faceboxes prototype - full rebuild ### **2.7.4** 2022/05/24 mandic00@live.com diff --git a/TODO.md b/TODO.md index 408513ef..9a0c255a 100644 --- a/TODO.md +++ b/TODO.md @@ -47,18 +47,3 @@ Feature is automatically disabled in **NodeJS** without user impact

## Pending Release Changes - -- Updated **FaceMesh-Landmarks** models -- Added **FaceMesh-with-Attention** model is disabled by defauls, enable using - `config.face.mesh.attention = true` -- If **FaceMesh-with-Attention** model is enabled, Iris model gets disabled - as its functionality is superseded by attention model -- Results include more detailed face mesh annotations - `result.face[].annotations` -- Update benchmarks: `demo/benchmark` -- Slight performance improvement with canvas reads using `WASM` backend -- Default to RTM version of `WASM` binaries -- Enhanced `WebGPU` compatibility -- Support for **NodeJS v18** -- Updated **Known Issues** - See diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index 109c05db..486687cc 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -96,7 +96,7 @@ var Y2=Object.defineProperty;var ho=Object.getOwnPropertyDescriptor;var bo=Objec c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var Q2=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},_2=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:(u(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(u("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){u("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)){u(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),Q2(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);Q2(o,"uniform",this.uniform),Q2(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function F1(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,l=l0(100,100),x={},d={INTERMEDIATE:1},y=l.getContext("webgl");if(!y){u("filter: cannot get webgl context");return}this.gl=y;function c(g,f){if(!(g===l.width&&f===l.height)){if(l.width=g,l.height=f,!a){let M=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=y.createBuffer(),y.bindBuffer(y.ARRAY_BUFFER,a),y.bufferData(y.ARRAY_BUFFER,M,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,l.width,l.height),r=[null,null]}}function m(g,f){let M=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,M);let C=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,C);let k=y.createTexture();return y.bindTexture(y.TEXTURE_2D,k),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,g,f,0,y.RGBA,y.UNSIGNED_BYTE,null),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,k,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:M,texture:k}}function h(g){return r[g]=r[g]||m(l.width,l.height),r[g]}function p(g=0){if(!i)return;let f=null,M=null,C=!1;e===0?f=t:f=h(n).texture||null,e++,o&&!(g&d.INTERMEDIATE)?(M=null,C=e%2===0):(n=(n+1)%2,M=h(n).fbo||null),y.bindTexture(y.TEXTURE_2D,f),y.bindFramebuffer(y.FRAMEBUFFER,M),y.uniform1f(i.uniform.flipY,C?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function R(g){if(x[g])return i=x[g],y.useProgram((i?i.id:null)||null),i;if(i=new _2(y,j1,g),!i)return u("filter: could not get webgl program"),null;let f=Float32Array.BYTES_PER_ELEMENT,M=4*f;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,M,0*f),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,M,2*f),x[g]=i,i}let P={colorMatrix:g=>{let f=new Float32Array(g);f[4]/=255,f[9]/=255,f[14]/=255,f[19]/=255;let M=f[18]===1&&f[3]===0&&f[8]===0&&f[13]===0&&f[15]===0&&f[16]===0&&f[17]===0&&f[19]===0?N1:I1,C=R(M);!C||(y.uniform1fv(C.uniform.m,f),p())},brightness:g=>{let f=(g||0)+1;P.colorMatrix([f,0,0,0,0,0,f,0,0,0,0,0,f,0,0,0,0,0,1,0])},saturation:g=>{let f=(g||0)*2/3+1,M=(f-1)*-.5;P.colorMatrix([f,M,M,0,0,M,f,M,0,0,M,M,f,0,0,0,0,0,1,0])},desaturate:()=>{P.saturation(-1)},contrast:g=>{let f=(g||0)+1,M=-128*(f-1);P.colorMatrix([f,0,0,0,M,0,f,0,0,M,0,0,f,0,M,0,0,0,1,0])},negative:()=>{P.contrast(-2)},hue:g=>{g=(g||0)/180*Math.PI;let f=Math.cos(g),M=Math.sin(g),C=.213,k=.715,I=.072;P.colorMatrix([C+f*(1-C)+M*-C,k+f*-k+M*-k,I+f*-I+M*(1-I),0,0,C+f*-C+M*.143,k+f*(1-k)+M*.14,I+f*-I+M*-.283,0,0,C+f*-C+M*-(1-C),k+f*-k+M*k,I+f*(1-I)+M*I,0,0,0,0,0,1,0])},desaturateLuminance:()=>{P.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:()=>{P.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:g=>{let f=new Float32Array(g),M=1/l.width,C=1/l.height,k=R(W1);!k||(y.uniform1fv(k.uniform.m,f),y.uniform2f(k.uniform.px,M,C),p())},detectEdges:()=>{P.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{P.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{P.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:g=>{let f=g||1;P.convolution.call(this,[0,-1*f,0,-1*f,1+4*f,-1*f,0,-1*f,0])},emboss:g=>{let f=g||1;P.convolution.call(this,[-2*f,-1*f,0,-1*f,1,1*f,0,1*f,2*f])},blur:g=>{let f=g/7/l.width,M=g/7/l.height,C=R(L1);!C||(y.uniform2f(C.uniform.px,0,M),p(d.INTERMEDIATE),y.uniform2f(C.uniform.px,f,0),p())},pixelate:g=>{let f=g/l.width,M=g/l.height,C=R(O1);!C||(y.uniform2f(C.uniform.size,f,M),p())}};this.add=function(g){let f=Array.prototype.slice.call(arguments,1),M=P[g];s.push({func:M,args:f})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(g){c(g.width,g.height),e=0,t||(t=y.createTexture()),y.bindTexture(y.TEXTURE_2D,t),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,g);for(let f=0;fm.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])],l=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,l[0]),A.div(a,l[1]),A.div(a,l[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],y=A.stack([d[0],d[1],d[2]],2),c=A.reshape(y,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...l,...x,...d,y,t]),c}var a2=3840,G=null,$=null,be=null,U,O0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function l0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function i2(e,t){let o=t||l0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function ge(e,t,o=!0){if(!e)return t.debug&&u("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof he)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 he){let n=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)n=A.expandDims(e,0);else if(e.shape[2]===4){let r=A.slice3d(e,[0,0,0],[-1,-1,3]);n=A.expandDims(r,0),A.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=A.clone(e):e.shape[3]===4&&(n=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=A.cast(n,"float32");A.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?$:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&u("input stream is not ready"),{tensor:null,canvas:G};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&&u("cannot determine input dimensions"),{tensor:null,canvas:G};let s=n,a=r;if(s>a2&&(s=a2,a=Math.trunc(s*r/n)),a>a2&&(a=a2,s=Math.trunc(a*n/r)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.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");(!G||(G==null?void 0:G.width)!==s||(G==null?void 0:G.height)!==a)&&(G=l0(s,a));let i=G.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,G==null?void 0:G.width,G==null?void 0:G.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,G==null?void 0:G.width,G==null?void 0:G.height),(!$||G.width!==$.width||(G==null?void 0:G.height)!==($==null?void 0:$.height))&&($=l0(G.width,G.height)),t.filter.enabled&&v.webgl.supported?(U||(U=v.browser?new F1:null),v.filter=!!U,!U||!U.add?(t.debug&&u("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,i2(G,$)):(U.reset(),t.filter.brightness!==0&&U.add("brightness",t.filter.brightness),t.filter.contrast!==0&&U.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&U.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&U.add("blur",t.filter.blur),t.filter.saturation!==0&&U.add("saturation",t.filter.saturation),t.filter.hue!==0&&U.add("hue",t.filter.hue),t.filter.negative&&U.add("negative"),t.filter.sepia&&U.add("sepia"),t.filter.vintage&&U.add("brownie"),t.filter.sepia&&U.add("sepia"),t.filter.kodachrome&&U.add("kodachrome"),t.filter.technicolor&&U.add("technicolor"),t.filter.polaroid&&U.add("polaroid"),t.filter.pixelate!==0&&U.add("pixelate",t.filter.pixelate),U.get()>0?$=U.apply(G):$=U.draw(G))):(i2(G,$),U&&(U=null),v.filter=!!U),!o)return{tensor:null,canvas:$};if(!$)throw new Error("canvas error: cannot create output");let l,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&A.browser)l=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);l=A.tensor(c,[e.height,e.width,x],"int32")}else if((!be||$.width!==be.width||$.height!==be.height)&&(be=l0($.width,$.height)),A.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=A.browser.fromPixels($):(be=i2($),l=A.browser.fromPixels(be));else{let h=i2($).getContext("2d").getImageData(0,0,s,a);x=h.data.length/s/a;let p=new Uint8Array(h.data.buffer);l=A.tensor(p,[s,a,x])}if(x===4){let c=A.slice3d(l,[0,0,0],[-1,-1,3]);A.dispose(l),l=c}if(!l)throw new Error("input error: cannot create tensor");let d=A.cast(l,"float32"),y=t.filter.equalization?await s2(d):A.expandDims(d,0);return A.dispose([l,d]),{tensor:y,canvas:t.filter.return?$:null}}}async function G1(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(!O0.inputTensor)O0.inputTensor=A.clone(t);else if(O0.inputTensor.shape[1]!==t.shape[1]||O0.inputTensor.shape[2]!==t.shape[2])A.dispose(O0.inputTensor),O0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,O0.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([O0.inputTensor,n.diff,n.squared,n.sum]),O0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function B1(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||u("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||u("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 $2=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,"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:qe["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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=l0(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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new $2;var L0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function jo(e,t){return L0.debug&&u("load model fetch:",e,t),fetch(e,t)}function H1(e){L0.cacheModels=e.cacheModels,L0.verbose=e.debug,L0.modelBasePath=e.modelBasePath}async function L(e){let t=C1(L0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await A.io.listModels(),s=L0.cacheModels&&Object.keys(r).includes(n),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>jo(x,d)},i=new J2(s?n:t,a),l=!1;try{i.findIOHandler(),L0.debug&&u("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),L0.verbose&&u("load model:",i.modelUrl),l=!0}catch(x){u("error loading model:",t,x)}if(l&&L0.cacheModels&&!s)try{let x=await i.save(n);u("model saved:",n,x)}catch(x){u("error saving model:",t,x)}return i}var e5="2.8.0";var d1={};ne(d1,{Models:()=>o2,load:()=>x1,reset:()=>D2,validate:()=>c1});var M0,t5=[],Oo=["white","black","asian","indian","other"],Lo=[15,23,28,35.5,45.5,55.5,65],V1=0,D1=0,o5=Number.MAX_SAFE_INTEGER;async function Z1(e){return v.initial&&(M0=null),M0?e.debug&&u("cached model:",M0.modelUrl):M0=await L(e.face.gear),M0}async function n5(e,t,o,n){var a,i;if(!M0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=o5<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>b()-D1;return t.skipAllowed&&s&&r&&V1===n&&t5[o]?(o5++,t5[o]):(o5=0,new Promise(async l=>{var P,g;if(!(M0!=null&&M0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[M0.inputs[0].shape[2],M0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(P=t.face.gear)!=null&&P.enabled&&([x.age,x.gender,x.race]=M0.execute(x.resize,["age_output","gender_output","race_output"]));let c=await x.gender.data();y.gender=c[0]>c[1]?"male":"female",y.genderScore=Math.round(100*(c[0]>c[1]?c[0]:c[1]))/100;let m=await x.race.data();for(let f=0;f(((g=t.face.gear)==null?void 0:g.minConfidence)||.2)&&y.race.push({score:Math.round(100*m[f])/100,race:Oo[f]});y.race.sort((f,M)=>M.score-f.score);let p=Array.from(await x.age.data()).map((f,M)=>[Lo[M],f]).sort((f,M)=>M[1]-f[1]),R=p[0][0];for(let f=1;fA.dispose(x[f])),t5[o]=y,V1=n,D1=b(),l(y)}))}var W={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function q1(){W.tf255=A.scalar(255,"float32"),W.tf1=A.scalar(1,"float32"),W.tf2=A.scalar(2,"float32"),W.tf05=A.scalar(.5,"float32"),W.tf127=A.scalar(127.5,"float32"),W.rgb=A.tensor1d([.2989,.587,.114],"float32")}var c0,l2=[],U1=0,Y1=0,r5=Number.MAX_SAFE_INTEGER;async function K1(e){return v.initial&&(c0=null),c0?e.debug&&u("cached model:",c0.modelUrl):c0=await L(e.face.ssrnet.modelPathAge),c0}async function A5(e,t,o,n){var a,i,l,x;if(!c0)return{age:0};let r=r5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>b()-Y1;return t.skipAllowed&&r&&s&&U1===n&&((l=l2[o])==null?void 0:l.age)&&((x=l2[o])==null?void 0:x.age)>0?(r5++,l2[o]):(r5=0,new Promise(async d=>{if(!(c0!=null&&c0.inputs)||!c0.inputs[0]||!c0.inputs[0].shape)return;let y={};y.resize=A.image.resizeBilinear(e,[c0.inputs[0].shape[2],c0.inputs[0].shape[1]],!1),y.enhance=A.mul(y.resize,W.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=c0.execute(y.enhance)),y.age){let m=await y.age.data();c.age=Math.trunc(10*m[0])/10}Object.keys(y).forEach(m=>A.dispose(y[m])),l2[o]=c,U1=n,Y1=b(),d(c)}))}var R0,y2=[],Q1=0,_1=0,s5=Number.MAX_SAFE_INTEGER,a5=[.2989,.587,.114];async function $1(e){return v.initial&&(R0=null),R0?e.debug&&u("cached model:",R0.modelUrl):R0=await L(e.face.ssrnet.modelPathGender),R0}async function i5(e,t,o,n){var a,i,l,x;if(!R0)return{gender:"unknown",genderScore:0};let r=s5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>b()-_1;return t.skipAllowed&&r&&s&&Q1===n&&((l=y2[o])==null?void 0:l.gender)&&((x=y2[o])==null?void 0:x.genderScore)>0?(s5++,y2[o]):(s5=0,new Promise(async d=>{if(!(R0!=null&&R0.inputs[0].shape))return;let y={};y.resize=A.image.resizeBilinear(e,[R0.inputs[0].shape[2],R0.inputs[0].shape[1]],!1),y.enhance=A.tidy(()=>{let[h,p,R]=A.split(y.resize,3,3),P=A.mul(h,a5[0]),g=A.mul(p,a5[1]),f=A.mul(R,a5[2]),M=A.addN([P,g,f]);return A.mul(A.sub(M,W.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=R0.execute(y.enhance));let m=await y.gender.data();c.gender=m[0]>m[1]?"female":"male",c.genderScore=m[0]>m[1]?Math.trunc(100*m[0])/100:Math.trunc(100*m[1])/100,Object.keys(y).forEach(h=>A.dispose(y[h])),y2[o]=c,Q1=n,_1=b(),d(c)}))}var r0,x2=[],l5=Number.MAX_SAFE_INTEGER,tt=0,ot=0;async function nt(e){var t;return v.initial&&(r0=null),r0?e.debug&&u("cached model:",r0.modelUrl):r0=await L((t=e.face.antispoof)==null?void 0:t.modelPath),r0}async function y5(e,t,o,n){var a,i;if(!r0)return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>b()-ot,s=l5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&tt===n&&x2[o]?(l5++,x2[o]):(l5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[2]:0,r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[1]:0],!1),d=r0==null?void 0:r0.execute(x),y=(await d.data())[0];x2[o]=Math.round(100*y)/100,tt=n,ot=b(),A.dispose([x,d]),l(x2[o])}))}var T0={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]},x5={count:468,mouth:13,symmetryLine:[13,T0.midwayBetweenEyes[0]]},Ae={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},c5=[{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]}],Ye=[[.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]],se=[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 Fo=[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],Go=[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],Bo=[33,133,362,263,1,78,308],sA=Fo.map(e=>Ye[e]),aA=Go.map(e=>Ye[e]),iA=Bo.map(e=>Ye[e]);function X0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Ho=[[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]],Vo=[[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]],Do=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Zo=[[474,475],[475,476],[476,477],[477,474]],Xo=[[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]],qo=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Uo=[[469,470],[470,471],[471,472],[472,469]],Yo=[[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]],lA={lips:X0(Ho),leftEye:X0(Vo),leftEyebrow:X0(Do),leftIris:X0(Zo),rightEye:X0(Xo),rightEyebrow:X0(qo),rightIris:X0(Uo),faceOval:X0(Yo)};var Pe=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],c2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],d2=(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],f2=(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],at=(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}},f5=(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,W.tf255);return A.dispose(a),i},m2=(e,t)=>{let o=c2(e),n=Pe(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}},p2=e=>{let t=c2(e),o=Pe(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}},it=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}},m5=[[1,0,0],[0,1,0],[0,0,1]],Ko=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Jo=(e,t)=>Ko(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var At=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],ae=(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=At(t[0],t[1]),a=st(s,r),i=At(-t[0],-t[1]);return st(a,i)},_o=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-ae(t[0],o),-ae(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},$o=(e,t)=>[ae(e,t[0]),ae(e,t[1])];function yt(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*(m[0]-r/2),s[1]/r*(m[1]-r/2),m[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,l=i?lt(o,[0,0]):m5,x=i?a.map(m=>[...$o(m,l),m[2]]):a,d=i?_o(n):m5,y=c2(t),c=[ae(y,d[0]),ae(y,d[1])];return x.map(m=>[Math.trunc(m[0]+c[0]),Math.trunc(m[1]+c[1]),Math.trunc(m[2]||0)])}function ct(e,t,o,n){let r=t.landmarks.length>=x5.count?x5.symmetryLine:Ae.symmetryLine,s=0,a=m5,i;if(e&&v.kernels.includes("rotatewithoffset"))if(s=Jo(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=c2(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],y=A.image.rotateWithOffset(o,s,0,d);a=lt(-s,x),i=f5(t,y,[n,n]),A.dispose(y)}else i=f5(t,o,[n,n]);else i=f5(t,o,[n,n]);return[s,a,i]}var en=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]},dt=(e,t)=>{let o=en(e),n=Pe(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 ft=6,tn=1.4,z0,mt=null,q0=0,Ke=null,Me=()=>q0;async function pt(e){var t;return v.initial&&(z0=null),z0?e.debug&&u("cached model:",z0.modelUrl):z0=await L((t=e.face.detector)==null?void 0:t.modelPath),q0=z0.inputs[0].shape?z0.inputs[0].shape[2]:0,Ke=A.scalar(q0,"int32"),mt=A.tensor2d(yt(q0)),z0}function on(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,mt),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,Ke),t.centersNormalized=A.div(t.centers,Ke),t.halfBoxSize=A.div(t.boxSizesNormalized,W.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,Ke),t.endNormalized=A.mul(t.ends,Ke);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function ut(e,t){var i,l,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,[q0,q0]),o.div=A.div(o.resized,W.tf127),o.normalized=A.sub(o.div,W.tf05);let n=z0==null?void 0:z0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let y=n.sort((c,m)=>c.size-m.size);o.concat384=A.concat([y[0],y[2]],2),o.concat512=A.concat([y[1],y[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=on(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,((l=t.face.detector)==null?void 0:l.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 y=0;y(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let m={};m.bbox=A.slice(o.boxes,[r[y],0],[1,-1]),m.slice=A.slice(o.batch,[r[y],ft-1],[1,-1]),m.squeeze=A.squeeze(m.slice),m.landmarks=A.reshape(m.squeeze,[ft,-1]);let h=await m.bbox.data(),p={startPoint:[h[0],h[1]],endPoint:[h[2],h[3]],landmarks:await m.landmarks.array(),confidence:c},R=at(p,[(e.shape[2]||0)/q0,(e.shape[1]||0)/q0]),P=m2(R,t.face.scale||tn),g=p2(P);s.push(g),Object.keys(m).forEach(f=>A.dispose(m[f]))}}return Object.keys(o).forEach(y=>A.dispose(o[y])),s}var u2={};ne(u2,{connected:()=>h5,kpt:()=>u5});var u5=["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"],h5={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 bt=224,nn,rn=5,h2=[8,16,32,32,32];async function gt(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function W0(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 Pt(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)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function b2(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 Tt={initial:!0},d0={detector:null,landmarks:null},Re={detector:[224,224],landmarks:[256,256]},b5=Number.MAX_SAFE_INTEGER,sn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},P2=null,Je,U0=[[0,0],[0,0],[0,0],[0,0]],Mt=0,Rt=e=>1-1/(1+Math.exp(e));async function vt(e){if(Tt.initial&&(d0.detector=null),!d0.detector&&e.body.detector&&e.body.detector.modelPath){d0.detector=await L(e.body.detector.modelPath);let t=Object.values(d0.detector.modelSignature.inputs);Re.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Re.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&d0.detector&&u("cached model:",d0.detector.modelUrl);return await gt(),d0.detector}async function wt(e){if(Tt.initial&&(d0.landmarks=null),d0.landmarks)e.debug&&u("cached model:",d0.landmarks.modelUrl);else{d0.landmarks=await L(e.body.modelPath);let t=Object.values(d0.landmarks.modelSignature.inputs);Re.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Re.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return d0.landmarks}async function an(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(Je&&(o.cropped=A.image.cropAndResize(e,[Je],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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],s=[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];U0=[[0,0],r,s,[0,0]],o.pad=A.pad(o.cropped||e,U0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,W.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,W.tf255)):n=A.div(o.cropped||e,W.tf255);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function ln(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+U0[2][0]+U0[2][1])/t[0]-U0[2][0]),Math.trunc(o.position[1]*(t[1]+U0[1][0]+U0[1][1])/t[1]-U0[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(Je)for(let o of e)o.positionRaw=[o.positionRaw[0]+Je[1],o.positionRaw[1]+Je[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}async function yn(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 xn(e,t,o){var h;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(h=d0.landmarks)==null?void 0:h.execute(e,sn.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(p=>A.dispose(n[p]));let i=[],l=5;for(let p=0;pp.position),y=W0(d,[o[0],o[1]]),c={};for(let[p,R]of Object.entries(h5)){let P=[];for(let g=0;gC.part===R[g]),M=x.find(C=>C.part===R[g+1]);f&&M&&P.push([f.position,M.position])}c[p]=P}return{id:0,score:Math.trunc(100*r)/100,box:y.box,boxRaw:y.boxRaw,keypoints:x,annotations:c}}async function g5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>b()-Mt,r=b5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&P2!==null)b5++;else{let s={};s.landmarks=await an(e,256),P2=await xn(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),Mt=b(),b5=0}return P2?[P2]:[]}var Te=[{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 F0,ie=0,P5=[],Et=0,M5=Number.MAX_SAFE_INTEGER;async function zt(e){if(v.initial&&(F0=null),F0)e.debug&&u("cached model:",F0.modelUrl);else{F0=await L(e.object.modelPath);let t=Object.values(F0.modelSignature.inputs);ie=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return F0}async function cn(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(),l=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,y=s[0][x][5],c=Te[y].label,[m,h]=[s[0][x][0]/ie,s[0][x][1]/ie],p=[m,h,s[0][x][2]/ie-m,s[0][x][3]/ie-h],R=[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:d,class:y,label:c,box:R,boxRaw:p})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function R5(e,t){let o=(t.object.skipTime||0)>b()-Et,n=M5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&P5.length>0?(M5++,P5):(M5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ie,ie]),i=t.object.enabled?F0==null?void 0:F0.execute(a,["tower_0/detections"]):null;Et=b(),A.dispose(a);let l=await cn(i,s,t);P5=l,r(l)}))}var M2={};ne(M2,{connected:()=>v5,kpt:()=>T5});var T5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],v5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var A0,Ct=0,y0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},w5=Number.MAX_SAFE_INTEGER;async function jt(e){return v.initial&&(A0=null),A0?e.debug&&u("cached model:",A0.modelUrl):A0=await L(e.body.modelPath),A0}async function dn(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.dispose([r,s]),a>t){let i=A.argMax(r,0),l=A.mod(i,o),x=(await l.data())[0],d=A.div(i,A.scalar(o,"int32")),y=(await d.data())[0];return A.dispose([l,d]),[x,y,a]}return[0,0,a]}async function k5(e,t){let o=(t.body.skipTime||0)>b()-Ct,n=w5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(y0.keypoints).length>0?(w5++,[y0]):(w5=0,new Promise(async r=>{var y;let s=A.tidy(()=>{if(!(A0!=null&&A0.inputs[0].shape))return null;let c=A.image.resizeBilinear(e,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),m=A.mul(c,W.tf2);return A.sub(m,W.tf1)}),a;if(t.body.enabled&&(a=A0==null?void 0:A0.execute(s)),Ct=b(),A.dispose(s),a){y0.keypoints.length=0;let c=a.squeeze();A.dispose(a);let m=c.unstack(2);A.dispose(c);for(let h=0;h(((y=t.body)==null?void 0:y.minConfidence)||0)&&y0.keypoints.push({score:Math.round(100*P)/100,part:T5[h],positionRaw:[p/A0.inputs[0].shape[2],R/A0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*p/A0.inputs[0].shape[2]),Math.round(e.shape[1]*R/A0.inputs[0].shape[1])]})}m.forEach(h=>A.dispose(h))}y0.score=y0.keypoints.reduce((c,m)=>m.score>c?m.score:c,0);let i=y0.keypoints.map(c=>c.position[0]),l=y0.keypoints.map(c=>c.position[1]);y0.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let x=y0.keypoints.map(c=>c.positionRaw[0]),d=y0.keypoints.map(c=>c.positionRaw[1]);y0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[c,m]of Object.entries(v5)){let h=[];for(let p=0;pg.part===m[p]),P=y0.keypoints.find(g=>g.part===m[p+1]);R&&P&&R.score>(t.body.minConfidence||0)&&P.score>(t.body.minConfidence||0)&&h.push([R.position,P.position])}y0.annotations[c]=h}r([y0])}))}var fn=["angry","disgust","fear","happy","sad","surprise","neutral"],g0,R2=[],Nt=0,Ot=0,E5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return v.initial&&(g0=null),g0?e.debug&&u("cached model:",g0.modelUrl):g0=await L((t=e.face.emotion)==null?void 0:t.modelPath),g0}async function z5(e,t,o,n){var a,i;if(!g0)return[];let r=E5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>b()-Ot;return t.skipAllowed&&s&&r&&Nt===n&&R2[o]&&R2[o].length>0?(E5++,R2[o]):(E5=0,new Promise(async l=>{var d,y;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let c={},m=g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0;c.resize=A.image.resizeBilinear(e,[m,m],!1),c.channels=A.mul(c.resize,W.rgb),c.grayscale=A.sum(c.channels,3,!0),c.grayscaleSub=A.sub(c.grayscale,W.tf05),c.grayscaleMul=A.mul(c.grayscaleSub,W.tf2),c.emotion=g0==null?void 0:g0.execute(c.grayscaleMul),Ot=b();let h=await c.emotion.data();for(let p=0;p(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&x.push({score:Math.min(.99,Math.trunc(100*h[p])/100),emotion:fn[p]});x.sort((p,R)=>R.score-p.score),Object.keys(c).forEach(p=>A.dispose(c[p]))}R2[o]=x,Nt=n,l(x)}))}var f0,S5=[],Ft=0,Gt=0,Bt=Number.MAX_SAFE_INTEGER;async function Ht(e){return v.initial&&(f0=null),f0?e.debug&&u("cached model:",f0.modelUrl):f0=await L(e.face.mobilefacenet.modelPath),f0}async function C5(e,t,o,n){var a,i;if(!f0)return[];let r=Bt<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>b()-Gt;return t.skipAllowed&&s&&r&&Ft===n&&S5[o]?(Bt++,S5[o]):new Promise(async l=>{var d;let x=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(f0==null?void 0:f0.inputs[0].shape)){let y={};y.crop=A.image.resizeBilinear(e,[f0.inputs[0].shape[2],f0.inputs[0].shape[1]],!1),y.data=f0==null?void 0:f0.execute(y.crop);let c=await y.data.data();x=Array.from(c)}S5[o]=x,Ft=n,Gt=b(),l(x)})}var G0,Y0=0,mn=2.3,j5=T0.leftEyeLower0,I5=T0.rightEyeLower0,ve={leftBounds:[j5[0],j5[j5.length-1]],rightBounds:[I5[0],I5[I5.length-1]]},we={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function qt(e){var t;return v.initial&&(G0=null),G0?e.debug&&u("cached model:",G0.modelUrl):G0=await L((t=e.face.iris)==null?void 0:t.modelPath),Y0=G0.inputs[0].shape?G0.inputs[0].shape[2]:0,Y0===-1&&(Y0=64),G0}function T2(e,t,o,n){for(let r=0;r{let t=e[ve.leftBounds[0]][2],o=e[ve.rightBounds[0]][2];return t-o},Dt=(e,t,o,n,r,s=!1)=>{let a=p2(m2(it([e[o],e[n]]),mn)),i=Pe(a),l=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[Y0,Y0]);if(s&&v.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(l);A.dispose(l),l=x}return{box:a,boxSize:i,crop:l}},Zt=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[T0[`${o}EyeUpper0`][we.upperCenter]][2],r=e[T0[`${o}EyeLower0`][we.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let l=s;return i===2?l=n:i===4&&(l=r),[a[0],a[1],l]})};async function Ut(e,t,o,n){if(!G0)return o.debug&&u("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:s,crop:a}=Dt(e,t,ve.leftBounds[0],ve.leftBounds[1],n,!0),{box:i,boxSize:l,crop:x}=Dt(e,t,ve.rightBounds[0],ve.rightBounds[1],n,!0),d=A.concat([a,x]);A.dispose(a),A.dispose(x);let y=G0.execute(d);A.dispose(d);let c=await y.data();A.dispose(y);let m=c.slice(0,we.numCoordinates*3),{rawCoords:h,iris:p}=Zt(m,r,s,!0),R=c.slice(we.numCoordinates*3),{rawCoords:P,iris:g}=Zt(R,i,l,!1),f=pn(e);Math.abs(f)<30?(T2(e,h,"left",null),T2(e,P,"right",null)):f<1?T2(e,h,"left",["EyeUpper0","EyeLower0"]):T2(e,P,"right",["EyeUpper0","EyeLower0"]);let M=Xt(e,p,"left"),C=Xt(e,g,"right");return e.concat(M).concat(C)}var un=[[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]],hn=[[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]],bn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],gn=[[474,475],[475,476],[476,477],[477,474]],Pn=[[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]],Mn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Rn=[[469,470],[470,471],[471,472],[472,469]],Tn=[[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 K0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var vn={lips:K0(un),leftEye:K0(hn),leftEyebrow:K0(bn),leftIris:K0(gn),rightEye:K0(Pn),rightEyebrow:K0(Mn),rightIris:K0(Rn),faceOval:K0(Tn)},wn=Object.entries(vn).map(([e,t])=>t.map(o=>[o,e])).flat(),FA=new Map(wn),Qe=[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],le=[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 Jt(e,t){let o={lips:await t.filter(s=>s.size===160)[0].data(),irisL:await t.filter(s=>s.size===10)[0].data(),eyeL:await t.filter(s=>s.size===142)[0].data(),irisR:await t.filter(s=>s.size===10)[1].data(),eyeR:await t.filter(s=>s.size===142)[1].data()},n=le.reduce((s,a)=>s+=e[a][2],0)/le.length;for(let s=0;ss+=e[a][2],0)/ye.length;for(let s=0;sb()-S0.timestamp,n=S0.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!o||!n||S0.boxes.length===0?(S0.boxes=await ut(e,t),S0.timestamp=b(),S0.skipped=0):S0.skipped++;let r=[],s=[],a=0;for(let g=0;gF.shape[F.shape.length-1]===1),O=I.find(F=>F.shape[F.shape.length-1]===1404),Z=await j.data();k.faceScore=Math.round(100*Z[0])/100;let H=A.reshape(O,[-1,3]),D=await H.array();if(k.faceScore<(((m=t.face.detector)==null?void 0:m.minConfidence)||1)){if(f.confidence=k.faceScore,(h=t.face.mesh)!=null&&h.keepInvalid){k.box=d2(f,e),k.boxRaw=f2(f,e),k.score=k.boxScore,k.mesh=f.landmarks.map(F=>[(f.startPoint[0]+f.endPoint[0])/2+(f.endPoint[0]+f.startPoint[0])*F[0]/Me(),(f.startPoint[1]+f.endPoint[1])/2+(f.endPoint[1]+f.startPoint[1])*F[1]/Me()]),k.meshRaw=k.mesh.map(F=>[F[0]/(e.shape[2]||0),F[1]/(e.shape[1]||0),(F[2]||0)/xe]);for(let F of Object.keys(Ae))k.annotations[F]=[k.mesh[Ae[F]]]}}else{(p=t.face.attention)!=null&&p.enabled?D=await Jt(D,I):(R=t.face.iris)!=null&&R.enabled&&(D=await Ut(D,k.tensor,t,xe)),k.mesh=xt(D,f,M,C,xe),k.meshRaw=k.mesh.map(z=>[z[0]/(e.shape[2]||0),z[1]/(e.shape[1]||0),(z[2]||0)/xe]);for(let z of Object.keys(T0))k.annotations[z]=T0[z].map(h0=>k.mesh[h0]);k.score=k.faceScore;let F={...dt(k.mesh,f),confidence:f.confidence,landmarks:f.landmarks};k.box=d2(F,e),k.boxRaw=f2(F,e),s.push(F)}A.dispose([...I,H])}else{k.box=d2(f,e),k.boxRaw=f2(f,e),k.score=k.boxScore,k.mesh=f.landmarks.map(I=>[(f.startPoint[0]+f.endPoint[0])/2+(f.endPoint[0]+f.startPoint[0])*I[0]/Me(),(f.startPoint[1]+f.endPoint[1])/2+(f.endPoint[1]+f.startPoint[1])*I[1]/Me()]),k.meshRaw=k.mesh.map(I=>[I[0]/(e.shape[2]||0),I[1]/(e.shape[1]||0),(I[2]||0)/xe]);for(let I of Object.keys(Ae))k.annotations[I]=[k.mesh[Ae[I]]]}k.score>(((P=t.face.detector)==null?void 0:P.minConfidence)||1)?r.push(k):A.dispose(k.tensor)}return S0.boxes=s,r}async function _t(e){var t,o,n,r,s,a;return v.initial&&(s0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(s0==null?void 0:s0.signature)&&Object.keys(((n=s0==null?void 0:s0.signature)==null?void 0:n.outputs)||{}).length<6&&(s0=null),s0?e.debug&&u("cached model:",s0.modelUrl):(r=e.face.attention)!=null&&r.enabled?s0=await L((s=e.face.attention)==null?void 0:s.modelPath):s0=await L((a=e.face.mesh)==null?void 0:a.modelPath),xe=s0.inputs[0].shape?s0.inputs[0].shape[2]:0,s0}var $t=se,e3=Ye;var m0,v2=[],t3=0,o3=0,O5=Number.MAX_SAFE_INTEGER;async function n3(e){var t;return v.initial&&(m0=null),m0?e.debug&&u("cached model:",m0.modelUrl):m0=await L((t=e.face.description)==null?void 0:t.modelPath),m0}function L5(e){let t=e.image||e.tensor||e;if(!(m0!=null&&m0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),n=A.mul(o,W.tf255);return A.dispose(o),n}async function W5(e,t,o,n){var a,i,l,x;if(!m0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=O5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>b()-t3;return t.skipAllowed&&r&&s&&o3===n&&((l=v2[o])==null?void 0:l.age)&&((x=v2[o])==null?void 0:x.age)>0?(O5++,v2[o]):(O5=0,new Promise(async d=>{var c,m;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let h=L5(e),p=m0==null?void 0:m0.execute(h);t3=b(),A.dispose(h);let P=await(await p.find(O=>O.shape[1]===1)).data(),g=Math.trunc(200*Math.abs(P[0]-.5))/100;g>(((m=t.face.description)==null?void 0:m.minConfidence)||0)&&(y.gender=P[0]<=.5?"female":"male",y.genderScore=Math.min(.99,g));let f=A.argMax(p.find(O=>O.shape[1]===100),1),M=(await f.data())[0];A.dispose(f);let k=await p.find(O=>O.shape[1]===100).data();y.age=Math.round(k[M-1]>k[M+1]?10*M-100*k[M-1]:10*M+100*k[M+1])/10;let I=p.find(O=>O.shape[1]===1024),j=I?await I.data():[];y.descriptor=Array.from(j),p.forEach(O=>A.dispose(O))}v2[o]=y,o3=n,d(y)}))}function w2(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function _e(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function s3(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 a3(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 k2(e,t=1.5){let o=_e(e),n=w2(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 E2(e){let t=_e(e),o=w2(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 En(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function i3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return En(o)}var r3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function J0(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[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]);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,W.tf127),n.image=A.sub(n.div,W.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*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let i of s){let l={};l.box=A.slice(n.norm,[i,0],[1,-1]),l.slice=A.slice(n.predictions,[i,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,i),l.palmLandmarks=A.reshape(l.norm,[-1,2]);let x=await l.box.data(),d=x.slice(0,2),y=x.slice(2,4),c=await l.palmLandmarks.array(),m={startPoint:d,endPoint:y,palmLandmarks:c,confidence:r[i]},h=a3(m,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(h),Object.keys(l).forEach(p=>A.dispose(l[p]))}return Object.keys(n).forEach(i=>A.dispose(n[i])),a}};var jn=5,c3=1.65,d3=[0,5,9,13,17,1,2],In=0,Nn=2,f3=0,S2=class{constructor(t,o){w(this,"handDetector");w(this,"handPoseModel");w(this,"inputSize");w(this,"storedBoxes");w(this,"skipped");w(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>B5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return k2(E2(r),jn)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=k2(E2(o),c3);n.palmLandmarks=[];for(let r=0;r[a[0]*(m[0]-this.inputSize/2),a[1]*(m[1]-this.inputSize/2),a[2]*m[2]]),l=G5(n,[0,0]),x=i.map(m=>[...B5(m,l),m[2]]),d=l3(r),y=[..._e(o),1],c=[J0(y,d[0]),J0(y,d[1])];return x.map(m=>[Math.trunc(m[0]+c[0]),Math.trunc(m[1]+c[1]),Math.trunc(m[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>b()-f3,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 l=0;l=o.hand.minConfidence/4){let C=A.reshape(f,[-1,3]),k=await C.array();A.dispose(f),A.dispose(C);let I=this.transformRawCoords(k,p,d,h),j=this.getBoxForHandLandmarks(I);this.storedBoxes[l]={...j,confidence:M};let O={landmarks:I,confidence:M,boxConfidence:x.confidence,fingerConfidence:M,box:{topLeft:j.startPoint,bottomRight:j.endPoint}};i.push(O)}else this.storedBoxes[l]=null;A.dispose(f)}else{let d=k2(E2(x),c3),y={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var x0={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=>x0.nameMapping[e],getPoints:e=>x0.pointsMapping[e]},_0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>_0.nameMapping[e]},K={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=>K.nameMapping[e]},Q0=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,l]of a)if(s===i){n+=l*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,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:v0,index:B0,middle:H0,ring:ce,pinky:de}=x0,{none:w0,half:Ln,full:k0}=_0,{verticalUp:ke,verticalDown:$A,horizontalLeft:H5,horizontalRight:Wn,diagonalUpRight:Fn,diagonalUpLeft:Ee,diagonalDownRight:e7,diagonalDownLeft:t7}=K,$0=new Q0("thumbs up");$0.curl(v0,w0,1);$0.direction(v0,ke,1);$0.direction(v0,Ee,.25);$0.direction(v0,Fn,.25);for(let e of[x0.index,x0.middle,x0.ring,x0.pinky])$0.curl(e,k0,1),$0.direction(e,H5,1),$0.direction(e,Wn,1);var e0=new Q0("victory");e0.curl(v0,Ln,.5);e0.curl(v0,w0,.5);e0.direction(v0,ke,1);e0.direction(v0,Ee,1);e0.curl(B0,w0,1);e0.direction(B0,ke,.75);e0.direction(B0,Ee,1);e0.curl(H0,w0,1);e0.direction(H0,ke,1);e0.direction(H0,Ee,.75);e0.curl(ce,k0,1);e0.direction(ce,ke,.2);e0.direction(ce,Ee,1);e0.direction(ce,H5,.2);e0.curl(de,k0,1);e0.direction(de,ke,.2);e0.direction(de,Ee,1);e0.direction(de,H5,.2);e0.weight(B0,2);e0.weight(H0,2);var ee=new Q0("point");ee.curl(v0,k0,1);ee.curl(B0,w0,.5);ee.curl(H0,k0,.5);ee.curl(ce,k0,.5);ee.curl(de,k0,.5);ee.weight(B0,2);ee.weight(H0,2);var te=new Q0("middle finger");te.curl(v0,w0,1);te.curl(B0,k0,.5);te.curl(H0,k0,.5);te.curl(ce,k0,.5);te.curl(de,k0,.5);te.weight(B0,2);te.weight(H0,2);var ze=new Q0("open palm");ze.curl(v0,w0,.75);ze.curl(B0,w0,.75);ze.curl(H0,w0,.75);ze.curl(ce,w0,.75);ze.curl(de,w0,.75);var m3=[$0,e0,ee,te,ze];var Gn=.7,fe={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 p3(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 h3(e,t){if(!e||!t)return[0,0];let o=p3(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=p3(e[1],e[2],t[1],t[2]);return[o,n]}function u3(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 Bn(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],l=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(n*n+a*a+x*x),m=Math.sqrt(r*r+i*i+d*d),h=Math.sqrt(s*s+l*l+y*y),p=(h*h+c*c-m*m)/(2*h*c);p>1?p=1:p<-1&&(p=-1);let R=Math.acos(p);R=57.2958*R%180;let P;return R>fe.NO_CURL_START_LIMIT?P=_0.none:R>fe.HALF_CURL_START_LIMIT?P=_0.half:P=_0.full,P}function b3(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=K.horizontalLeft:r=K.horizontalRight:n===Math.abs(t)?t>0?r=K.horizontalLeft:r=K.horizontalRight:o>0?r=K.horizontalLeft:r=K.horizontalRight,r}function g3(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=K.verticalDown:r=K.verticalUp:n===Math.abs(t)?t<0?r=K.verticalDown:r=K.verticalUp:o<0?r=K.verticalDown:r=K.verticalUp,r}function Hn(e,t,o,n,r,s,a,i){let l,x=g3(e,t,o,n),d=b3(r,s,a,i);return x===K.verticalUp?d===K.horizontalLeft?l=K.diagonalUpLeft:l=K.diagonalUpRight:d===K.horizontalLeft?l=K.diagonalDownLeft:l=K.diagonalDownRight,l}function Vn(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],l=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(l),Math.abs(x)),c=0,m=0,h=0,p=y/(d+1e-5);p>1.5?c+=fe.DISTANCE_VOTE_POWER:p>.66?m+=fe.DISTANCE_VOTE_POWER:h+=fe.DISTANCE_VOTE_POWER;let R=Math.sqrt(r*r+i*i),P=Math.sqrt(s*s+l*l),g=Math.sqrt(a*a+x*x),f=Math.max(R,P,g),M=e[0],C=e[1],k=o[0],I=o[1];f===R?(k=o[0],I=o[1]):f===g&&(M=t[0],C=t[1]);let Z=h3([M,C],[k,I]),H=u3(Z,fe.TOTAL_ANGLE_VOTE_POWER);c+=H[0],m+=H[1],h+=H[2];for(let F of n){let z=u3(F,fe.SINGLE_ANGLE_VOTE_POWER);c+=z[0],m+=z[1],h+=z[2]}let D;return c===Math.max(c,m,h)?D=g3(l,i,x,y):h===Math.max(m,h)?D=b3(s,r,a,d):D=Hn(l,i,x,y,s,r,a,d),D}function P3(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of x0.all){let a=x0.getPoints(s),i=[],l=[];for(let x of a){let d=e[x[0]],y=e[x[1]],c=h3(d,y),m=c[0],h=c[1];i.push(m),l.push(h)}t.push(i),o.push(l)}for(let s of x0.all){let a=s===x0.thumb?1:0,i=x0.getPoints(s),l=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],y=Bn(l,x,d),c=Vn(l,x,d,t[s].slice(a));n[s]=y,r[s]=c}return{curls:n,directions:r}}function C2(e){if(!e||e.length===0)return null;let t=P3(e),o={};for(let n of x0.all)o[x0.getName(n)]={curl:_0.getName(t.curls[n]),direction:K.getName(t.directions[n])};return o}function M3(e){let t=[];if(!e||e.length===0)return t;let o=P3(e);for(let n of m3){let r=n.matchAgainst(o.curls,o.directions);r>=Gn&&t.push({name:n.name,confidence:r})}return t}var R3={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]},Se,Ce,T3;async function D5(e,t){let o=await T3.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[y]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[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],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=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 x=C2(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:l,keypoints:a,annotations:s,landmarks:x})}return n}async function Z5(e){var o,n;v.initial&&(Se=null,Ce=null),!Se||!Ce?[Se,Ce]=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&&u("cached model:",Se.modelUrl),e.debug&&u("cached model:",Ce.modelUrl));let t=new z2(Se);return T3=new S2(t,Ce),[Se,Ce]}var o0=[null,null],Dn=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],oe=[[0,0],[0,0]],Zn=["hand","fist","pinch","point","face","tip","pinchtip"],w3=4,k3=1.6,Xn=512,qn=1.4,j2=Number.MAX_SAFE_INTEGER,X5=0,V0=[0,0],Q={boxes:[],hands:[]},E3={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 z3(e){var t;if(v.initial&&(o0[0]=null),o0[0])e.debug&&u("cached model:",o0[0].modelUrl);else{I2(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),o0[0]=await L((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(o0[0].modelSignature.inputs);oe[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[0]}async function S3(e){var t;if(v.initial&&(o0[1]=null),o0[1])e.debug&&u("cached model:",o0[1].modelUrl);else{o0[1]=await L((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(o0[1].modelSignature.inputs);oe[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[1]}async function Un(e,t){let o=[];if(!e||!o0[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,Xn),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 o0[0].executeAsync(n.cast,Dn),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[w3]),i.splice(w3,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 l=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(),y=await n.argmax.data();for(let c of Array.from(x)){let m=A.slice(n.boxes,c,1),h=await m.data();A.dispose(m);let p=[h[1],h[0],h[3]-h[1],h[2]-h[0]],R=b2(p,qn),P=[Math.trunc(p[0]*V0[0]),Math.trunc(p[1]*V0[1]),Math.trunc(p[2]*V0[0]),Math.trunc(p[3]*V0[1])],g=d[c],f=Zn[y[c]],M={id:l++,score:g,box:P,boxRaw:R,label:f};o.push(M)}return Object.keys(n).forEach(c=>A.dispose(n[c])),o.sort((c,m)=>m.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function q5(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&&o0[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],[oe[1][0],oe[1][1]],"bilinear"),r.div=A.div(r.crop,W.tf255),[r.score,r.keypoints]=o0[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(y=>[y[0]/oe[1][1],y[1]/oe[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);n.keypoints=d.map(y=>[V0[0]*(y[0]+t.boxRaw[0]),V0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),n.landmarks=C2(n.keypoints);for(let y of Object.keys(E3))n.annotations[y]=E3[y].map(c=>n.landmarks&&n.keypoints[c]?n.keypoints[c]:null)}Object.keys(r).forEach(l=>A.dispose(r[l]))}return n}async function U5(e,t){var r,s;if(!o0[0]||!o0[1]||!((r=o0[0])!=null&&r.inputs[0].shape)||!((s=o0[1])!=null&&s.inputs[0].shape))return[];V0=[e.shape[2]||0,e.shape[1]||0],j2++;let o=(t.hand.skipTime||0)>b()-X5,n=j2<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Q.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>b()-X5,l=j2<3*(t.hand.skipFrames||0);t.skipAllowed&&Q.hands.length===t.hand.maxDetected?Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))):t.skipAllowed&&i&&l&&Q.hands.length>0?Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))):(Q.boxes=await Un(e,t),X5=b(),Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))),j2=0);let x=[...Q.boxes];if(Q.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&y.box[3]/(e.shape[1]||1)>.05&&Q.hands[d].fingerScore&&Q.hands[d].fingerScore>(t.hand.minConfidence||0)){let c=b2(y.box,k3),m=b2(y.boxRaw,k3);Q.boxes.push({...x[d],box:c,boxRaw:m})}}for(let d=0;db()-I3,s=Y5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&j3===n&&N2[o]?(Y5++,N2[o]):(Y5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[a0!=null&&a0.inputs[0].shape?a0.inputs[0].shape[2]:0,a0!=null&&a0.inputs[0].shape?a0.inputs[0].shape[1]:0],!1),d=a0==null?void 0:a0.execute(x),y=(await d.data())[0];N2[o]=Math.round(100*y)/100,j3=n,I3=b(),A.dispose([x,d]),l(N2[o])}))}var $e={};ne($e,{connected:()=>L2,horizontal:()=>J5,kpt:()=>O2,relative:()=>_5,vertical:()=>Q5});var O2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],J5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Q5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],_5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],L2={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var L3=.005,p0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function $5(e){for(let t of J5){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],l=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]||l[0]>l[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function W3(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,p0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function G3(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+p0.padding[2][0]+p0.padding[2][1])/t[0]-p0.padding[2][0],n.position[1]*(t[1]+p0.padding[1][0]+p0.padding[1][1])/t[1]-p0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=W0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var u0,W2=0,e1=Number.MAX_SAFE_INTEGER,me={boxes:[],bodies:[],last:0};async function B3(e){return v.initial&&(u0=null),u0?e.debug&&u("cached model:",u0.modelUrl):(I2(["size"],e),u0=await L(e.body.modelPath)),W2=u0.inputs[0].shape?u0.inputs[0].shape[2]:0,W2<64&&(W2=256),u0}async function Kn(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let y=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:O2[d],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=r.reduce((d,y)=>y.score>d?y.score:d,0);let a=[],i=W0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),l={};for(let[d,y]of Object.entries(L2)){let c=[];for(let m=0;mR.part===y[m]),p=r.find(R=>R.part===y[m+1]);h&&p&&h.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&c.push([h.position,p.position])}l[d]=c}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return $5(x),a.push(x),a}async function Jn(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let y=0;y<17;y++){let c=s[3*y+2];if(c>t.body.minConfidence){let m=[s[3*y+1],s[3*y+0]];i.push({part:O2[y],score:Math.round(100*c)/100,positionRaw:m,position:[Math.round((o.shape[2]||0)*m[0]),Math.round((o.shape[1]||0)*m[1])]})}}let l=W0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),x={};for(let[y,c]of Object.entries(L2)){let m=[];for(let h=0;hP.part===c[h]),R=i.find(P=>P.part===c[h+1]);p&&R&&p.score>(t.body.minConfidence||0)&&R.score>(t.body.minConfidence||0)&&m.push([p.position,R.position])}x[y]=m}let d={id:r,score:a,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:x};$5(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 t1(e,t){if(!u0||!(u0!=null&&u0.inputs[0].shape))return[];t.skipAllowed||(me.boxes.length=0),e1++;let o=(t.body.skipTime||0)>b()-me.last,n=e1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?me.bodies:new Promise(async r=>{let s={};e1=0,s.input=F3(e,W2),s.res=u0==null?void 0:u0.execute(s.input),me.last=b();let a=await s.res.array();me.bodies=s.res.shape[2]===17?await Kn(a,t,e):await Jn(a,t,e);for(let i of me.bodies)G3(i,[e.shape[2]||1,e.shape[1]||1]),W3(i.keypoints);Object.keys(s).forEach(i=>A.dispose(s[i])),r(me.bodies)})}var je,F2=[],V3=0,o1=Number.MAX_SAFE_INTEGER,B2=0,G2=2.5;async function D3(e){if(!je||v.initial){je=await L(e.object.modelPath);let t=Object.values(je.modelSignature.inputs);B2=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&u("cached model:",je.modelUrl);return je}async function Qn(e,t,o){let n=0,r=[];for(let l of[1,2,4])A.tidy(async()=>{let x=l*13,d=A.squeeze(e.find(p=>p.shape[1]===x**2&&(p.shape[2]||0)===Te.length)),y=A.squeeze(e.find(p=>p.shape[1]===x**2&&(p.shape[2]||0)(o.object.minConfidence||0)&&R!==61){let g=(.5+Math.trunc(p%x))/x,f=(.5+Math.trunc(p/x))/x,M=m[p].map(D=>D*(x/l/B2)),[C,k]=[g-G2/l*M[0],f-G2/l*M[1]],[I,j]=[g+G2/l*M[2]-C,f+G2/l*M[3]-k],O=[C,k,I,j];O=O.map(D=>Math.max(0,Math.min(D,1)));let Z=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],H={id:n++,score:Math.round(100*P)/100,class:R+1,label:Te[R].label,box:Z.map(D=>Math.trunc(D)),boxRaw:O};r.push(H)}}});e.forEach(l=>A.dispose(l));let s=r.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),a=r.map(l=>l.score),i=[];if(s&&s.length>0){let l=await A.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await l.data(),A.dispose(l)}return r=r.filter((l,x)=>i.includes(x)).sort((l,x)=>x.score-l.score),r}async function n1(e,t){let o=(t.object.skipTime||0)>b()-V3,n=o1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&F2.length>0?(o1++,F2):(o1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?F2:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[B2,B2],!1),i=A.div(a,W.tf255),l=i.transpose([0,3,1,2]);A.dispose(i),A.dispose(a);let x;t.object.enabled&&(x=je.execute(l)),V3=b(),A.dispose(l);let d=await Qn(x,s,t);F2=d,r(d)}))}var t2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],_n=t2.length,e2=t2.reduce((e,t,o)=>(e[t]=o,e),{}),$n=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],v7=$n.map(([e,t])=>[e2[e],e2[t]]),X3=[["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 q3(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 U3(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:y,part:c,position:m})=>({score:y,part:c,position:[Math.trunc(m.x*a),Math.trunc(m.y*s)],positionRaw:[m.x/n,m.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var H2=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 Y3(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function a1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var E0,tr=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],V2=1,Ie=16,or=50**2;function K3(e,t,o,n,r,s,a=2){let i=P=>({y:s.get(P.y,P.x,e),x:s.get(P.y,P.x,s.shape[2]/2+e)}),l=(P,g,f)=>({y:s1(Math.round(P.y/Ie),0,g-1),x:s1(Math.round(P.x/Ie),0,f-1)}),[x,d]=n.shape,y=l(t.position,x,d),c=i(y),h=a1(t.position,c);for(let P=0;P[e2[c],e2[m]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),l=t.shape[2],x=a.length,d=new Array(l),y=A1(e.part,Ie,o);d[e.part.id]={score:e.score,part:t2[e.part.id],position:y};for(let c=x-1;c>=0;--c){let m=a[c],h=i[c];d[m]&&!d[h]&&(d[h]=K3(c,d[m],h,t,o,r))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function Ar(e,t){let[o,n,r]=t.shape,s=new H2(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?Y3(o,t,s.y,s.x)<=or:!1})}function sr(e,t){return t.reduce((n,{position:r,score:s},a)=>(J3(e,r,a)||(n+=s),n),0)/t.length}function ar(e,t,o,n,r,s){let a=[],i=Ar(s,t);for(;a.lengthm.score>s);let y=sr(a,d),c=q3(d);y>s&&a.push({keypoints:d,box:c,score:Math.round(100*y)/100})}return a}async function i1(e,t){let o=A.tidy(()=>{if(!E0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=E0.execute(i,tr).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=await ar(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return E0.inputs[0].shape?U3(r,[e.shape[1],e.shape[2]],[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]):[]}async function Q3(e){return!E0||v.initial?E0=await L(e.body.modelPath):e.debug&&u("cached model:",E0.modelUrl),E0}var C0,l1=!1;async function y1(e){return!C0||v.initial?C0=await L(e.segmentation.modelPath):e.debug&&u("cached model:",C0.modelUrl),C0}async function $3(e,t,o){var p,R;if(l1)return{data:[],canvas:null,alpha:null};l1=!0,C0||await y1(o);let n=await ge(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,s=((R=n.tensor)==null?void 0:R.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[C0.inputs[0].shape?C0.inputs[0].shape[1]:0,C0.inputs[0].shape?C0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,W.tf255),a.res=C0.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(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&u("canvas support missing"),Object.keys(a).forEach(P=>A.dispose(a[P])),{data:i,canvas:null,alpha:null};let l=l0(r,s);A.browser&&await A.browser.toPixels(a.data,l);let x=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),y=l0(r,s),c=y.getContext("2d");n.canvas&&c.drawImage(n.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(l,0,0),c.globalCompositeOperation="source-over",c.filter="none";let m=c.getImageData(0,0,r,s);for(let P=0;PA.dispose(a[P])),l1=!1,{data:i,canvas:y,alpha:l}}var o2=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,"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)}};function D2(e){for(let t of Object.keys(e.models))e.models[t]=null}async function x1(e){var t,o,n,r,s,a,i,l,x,d,y,c,m,h,p,R,P,g,f,M,C,k,I,j,O,Z,H,D,F,z,h0;v.initial&&D2(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 Z5(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 Z5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=wt(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=vt(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=jt(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(x=e.config.body)==null?void 0:x.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=B3(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=Q3(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=pt(e.config)),e.config.face.enabled&&((m=e.config.face.antispoof)==null?void 0:m.enabled)&&!e.models.antispoof&&(e.models.antispoof=nt(e.config)),e.config.face.enabled&&((h=e.config.face.liveness)==null?void 0:h.enabled)&&!e.models.liveness&&(e.models.liveness=N3(e.config)),e.config.face.enabled&&((p=e.config.face.description)==null?void 0:p.enabled)&&!e.models.faceres&&(e.models.faceres=n3(e.config)),e.config.face.enabled&&((R=e.config.face.emotion)==null?void 0:R.enabled)&&!e.models.emotion&&(e.models.emotion=Lt(e.config)),e.config.face.enabled&&((P=e.config.face.iris)==null?void 0:P.enabled)&&!((g=e.config.face.attention)!=null&&g.enabled)&&!e.models.faceiris&&(e.models.faceiris=qt(e.config)),e.config.face.enabled&&((f=e.config.face.mesh)==null?void 0:f.enabled)&&!e.models.facemesh&&(e.models.facemesh=_t(e.config)),e.config.face.enabled&&((M=e.config.face.gear)==null?void 0:M.enabled)&&!e.models.gear&&(e.models.gear=Z1(e.config)),e.config.face.enabled&&((C=e.config.face.ssrnet)==null?void 0:C.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=K1(e.config)),e.config.face.enabled&&((k=e.config.face.ssrnet)==null?void 0:k.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=$1(e.config)),e.config.face.enabled&&((I=e.config.face.mobilefacenet)==null?void 0:I.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=Ht(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((O=(j=e.config.hand.detector)==null?void 0:j.modelPath)==null?void 0:O.includes("handtrack"))&&(e.models.handtrack=z3(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((H=(Z=e.config.hand.detector)==null?void 0:Z.modelPath)==null?void 0:H.includes("handtrack"))&&(e.models.handskeleton=S3(e.config)),e.config.object.enabled&&!e.models.centernet&&((F=(D=e.config.object)==null?void 0:D.modelPath)==null?void 0:F.includes("centernet"))&&(e.models.centernet=zt(e.config)),e.config.object.enabled&&!e.models.nanodet&&((h0=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:h0.includes("nanodet"))&&(e.models.nanodet=D3(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=y1(e.config));for await(let b0 of Object.keys(e.models))e.models[b0]&&typeof e.models[b0]!="undefined"&&(e.models[b0]=await e.models[b0])}async function c1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let l=i.op.toLowerCase();r.includes(l)||r.push(l)}else!s&&e.config.debug&&u("model signature not determined:",o);let a=[];for(let i of r)!t.includes(i)&&!e.env.kernels.includes(i)&&!e.env.kernels.includes(i.replace("_",""))&&!e.env.kernels.includes(i.replace("native",""))&&!e.env.kernels.includes(i.replace("v2",""))&&a.push(i);e.config.debug&&a.length>0&&u("model validation failed:",o,a)}}var Y={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 ir(){let e=Y.gl;!e||(Y.extensions=e.getSupportedExtensions())}async function to(e){var t;if(e.config.backend==="humangl"&&(Y.name in A.engine().registry&&(!Y.gl||!Y.gl.getParameter(Y.gl.VERSION))&&(u("error: humangl backend invalid context"),D2(e)),!A.findBackend(Y.name))){try{Y.canvas=await l0(100,100)}catch(n){u("error: cannot create canvas:",n);return}try{if(Y.gl=(t=Y.canvas)==null?void 0:t.getContext("webgl2",Y.webGLattr),!Y.gl.getParameter(Y.gl.VERSION).includes("2.0")){u("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Y.canvas&&(Y.canvas.addEventListener("webglcontextlost",async r=>{throw u("error: humangl:",r.type),u("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Y.canvas.addEventListener("webglcontextrestored",r=>{u("error: humangl context restored:",r)}),Y.canvas.addEventListener("webglcontextcreationerror",r=>{u("error: humangl context create:",r)}))}catch(n){u("error: cannot get WebGL context:",n);return}try{A.setWebGLContext(2,Y.gl)}catch(n){u("error: cannot set WebGL context:",n);return}try{let n=new A.GPGPUContext(Y.gl);A.registerBackend(Y.name,()=>new A.MathBackendWebGL(n),Y.priority)}catch(n){u("error: cannot register WebGL backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:Y.name};A.registerKernel(s)})}catch(n){u("error: cannot update WebGL backend registration:",n);return}let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;if(o)u(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{u("error: no current gl context:",o,Y.gl);return}try{A.ENV.set("WEBGL_VERSION",2)}catch(n){u("error: cannot set WebGL backend flags:",n);return}ir(),u("backend registered:",Y.name)}}function lr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.sub(t.inputs.a,A.mul(A.div(t.inputs.a,t.inputs.b),t.inputs.b)))};A.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+A.mod(t.inputs.a,t.inputs.b))};A.registerKernel(e),v.kernels.push("floormod")}}async function Z2(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=b();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&u("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&u("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&u(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")u("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&u("enumerated webgpu adapter:",r),!r)u("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let s="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;u("webgpu adapter info:",s)}}e.config.backend==="humangl"&&await to(e);let n=Object.keys(A.engine().registryFactory);if(e.config.debug&&u("available backends:",n),n.includes(e.config.backend)||(u(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&u(`override: setting backend ${e.config.backend}`)),e.config.debug&&u("setting backend:",e.config.backend),e.config.backend==="wasm"){try{A.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(a){}if(e.config.debug&&u("wasm path:",e.config.wasmPath),typeof(A==null?void 0:A.setWasmPaths)!="undefined")await 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=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&u(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&u("warning: wasm simd support is not enabled")}try{await A.setBackend(e.config.backend),await A.ready(),q1()}catch(r){return u("error: cannot set backend:",e.config.backend,r),!1}}if(A.getBackend()==="humangl"&&(A.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),A.ENV.set("WEBGL_CPU_FORWARD",!0),A.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(u("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),A.backend().getGPGPUContext)){let n=await A.backend().getGPGPUContext().gl;e.config.debug&&u(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}A.getBackend(),A.enableProdMode(),await A.ready(),e.performance.initBackend=Math.trunc(b()-o),e.config.backend=A.getBackend(),await v.updateBackend(),lr()}return!0}function I2(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&u("kernelFunc",o,t.backend)}};A.registerKernel(n)}v.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var ro={};ne(ro,{all:()=>b1,body:()=>Oe,canvas:()=>h1,face:()=>Ne,gesture:()=>Fe,hand:()=>Le,object:()=>We,options:()=>i0,person:()=>u1});var P0=e=>{if(!e)u("draw error: invalid canvas");else if(!e.getContext)u("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)u("draw error: cannot get canvas context");else return t}return null},pe=e=>Math.round(e*180/Math.PI),D0=(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=D0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function j0(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 f1(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=D0(n[2],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function no(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){f1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${pe(e.rotation.angle.roll)}\xB0 yaw:${pe(e.rotation.angle.yaw)}\xB0 pitch:${pe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${pe(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=B.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),s=n*B.lineHeight+e.box[1];B.shadowColor&&B.shadowColor!==""&&(t.fillStyle=B.shadowColor,t.fillText(o[n],r+5,s+16)),t.fillStyle=B.labelColor,t.fillText(o[n],r+4,s+15)}}}function cr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=B.useDepth?"rgba(255, 200, 255, 0.3)":B.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),B.fillPolygons&&(t.fillStyle=B.useDepth?"rgba(255, 255, 200, 0.3)":B.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=B.useDepth?"rgba(255, 200, 255, 0.3)":B.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),B.fillPolygons&&(t.fillStyle=B.useDepth?"rgba(255, 255, 200, 0.3)":B.color,t.fill())}}function dr(e,t){var o;if(B.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]*pe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*pe(e.rotation.angle.pitch)/90,s=new Path2D(` +`;var Q2=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},_2=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:(u(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(u("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){u("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)){u(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),Q2(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);Q2(o,"uniform",this.uniform),Q2(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function F1(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,l=l0(100,100),x={},d={INTERMEDIATE:1},y=l.getContext("webgl");if(!y){u("filter: cannot get webgl context");return}this.gl=y;function c(g,f){if(!(g===l.width&&f===l.height)){if(l.width=g,l.height=f,!a){let M=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=y.createBuffer(),y.bindBuffer(y.ARRAY_BUFFER,a),y.bufferData(y.ARRAY_BUFFER,M,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,l.width,l.height),r=[null,null]}}function m(g,f){let M=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,M);let C=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,C);let k=y.createTexture();return y.bindTexture(y.TEXTURE_2D,k),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,g,f,0,y.RGBA,y.UNSIGNED_BYTE,null),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,k,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:M,texture:k}}function h(g){return r[g]=r[g]||m(l.width,l.height),r[g]}function p(g=0){if(!i)return;let f=null,M=null,C=!1;e===0?f=t:f=h(n).texture||null,e++,o&&!(g&d.INTERMEDIATE)?(M=null,C=e%2===0):(n=(n+1)%2,M=h(n).fbo||null),y.bindTexture(y.TEXTURE_2D,f),y.bindFramebuffer(y.FRAMEBUFFER,M),y.uniform1f(i.uniform.flipY,C?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function R(g){if(x[g])return i=x[g],y.useProgram((i?i.id:null)||null),i;if(i=new _2(y,j1,g),!i)return u("filter: could not get webgl program"),null;let f=Float32Array.BYTES_PER_ELEMENT,M=4*f;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,M,0*f),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,M,2*f),x[g]=i,i}let P={colorMatrix:g=>{let f=new Float32Array(g);f[4]/=255,f[9]/=255,f[14]/=255,f[19]/=255;let M=f[18]===1&&f[3]===0&&f[8]===0&&f[13]===0&&f[15]===0&&f[16]===0&&f[17]===0&&f[19]===0?N1:I1,C=R(M);!C||(y.uniform1fv(C.uniform.m,f),p())},brightness:g=>{let f=(g||0)+1;P.colorMatrix([f,0,0,0,0,0,f,0,0,0,0,0,f,0,0,0,0,0,1,0])},saturation:g=>{let f=(g||0)*2/3+1,M=(f-1)*-.5;P.colorMatrix([f,M,M,0,0,M,f,M,0,0,M,M,f,0,0,0,0,0,1,0])},desaturate:()=>{P.saturation(-1)},contrast:g=>{let f=(g||0)+1,M=-128*(f-1);P.colorMatrix([f,0,0,0,M,0,f,0,0,M,0,0,f,0,M,0,0,0,1,0])},negative:()=>{P.contrast(-2)},hue:g=>{g=(g||0)/180*Math.PI;let f=Math.cos(g),M=Math.sin(g),C=.213,k=.715,I=.072;P.colorMatrix([C+f*(1-C)+M*-C,k+f*-k+M*-k,I+f*-I+M*(1-I),0,0,C+f*-C+M*.143,k+f*(1-k)+M*.14,I+f*-I+M*-.283,0,0,C+f*-C+M*-(1-C),k+f*-k+M*k,I+f*(1-I)+M*I,0,0,0,0,0,1,0])},desaturateLuminance:()=>{P.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:()=>{P.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.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:()=>{P.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:g=>{let f=new Float32Array(g),M=1/l.width,C=1/l.height,k=R(W1);!k||(y.uniform1fv(k.uniform.m,f),y.uniform2f(k.uniform.px,M,C),p())},detectEdges:()=>{P.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{P.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{P.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:g=>{let f=g||1;P.convolution.call(this,[0,-1*f,0,-1*f,1+4*f,-1*f,0,-1*f,0])},emboss:g=>{let f=g||1;P.convolution.call(this,[-2*f,-1*f,0,-1*f,1,1*f,0,1*f,2*f])},blur:g=>{let f=g/7/l.width,M=g/7/l.height,C=R(L1);!C||(y.uniform2f(C.uniform.px,0,M),p(d.INTERMEDIATE),y.uniform2f(C.uniform.px,f,0),p())},pixelate:g=>{let f=g/l.width,M=g/l.height,C=R(O1);!C||(y.uniform2f(C.uniform.size,f,M),p())}};this.add=function(g){let f=Array.prototype.slice.call(arguments,1),M=P[g];s.push({func:M,args:f})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(g){c(g.width,g.height),e=0,t||(t=y.createTexture()),y.bindTexture(y.TEXTURE_2D,t),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,g);for(let f=0;fm.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])],l=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,l[0]),A.div(a,l[1]),A.div(a,l[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],y=A.stack([d[0],d[1],d[2]],2),c=A.reshape(y,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...l,...x,...d,y,t]),c}var a2=3840,G=null,$=null,be=null,U,O0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function l0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function i2(e,t){let o=t||l0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function ge(e,t,o=!0){if(!e)return t.debug&&u("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof he)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 he){let n=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)n=A.expandDims(e,0);else if(e.shape[2]===4){let r=A.slice3d(e,[0,0,0],[-1,-1,3]);n=A.expandDims(r,0),A.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=A.clone(e):e.shape[3]===4&&(n=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=A.cast(n,"float32");A.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?$:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&u("input stream is not ready"),{tensor:null,canvas:G};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&&u("cannot determine input dimensions"),{tensor:null,canvas:G};let s=n,a=r;if(s>a2&&(s=a2,a=Math.trunc(s*r/n)),a>a2&&(a=a2,s=Math.trunc(a*n/r)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.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");(!G||(G==null?void 0:G.width)!==s||(G==null?void 0:G.height)!==a)&&(G=l0(s,a));let i=G.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,G==null?void 0:G.width,G==null?void 0:G.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,G==null?void 0:G.width,G==null?void 0:G.height),(!$||G.width!==$.width||(G==null?void 0:G.height)!==($==null?void 0:$.height))&&($=l0(G.width,G.height)),t.filter.enabled&&v.webgl.supported?(U||(U=v.browser?new F1:null),v.filter=!!U,!U||!U.add?(t.debug&&u("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,i2(G,$)):(U.reset(),t.filter.brightness!==0&&U.add("brightness",t.filter.brightness),t.filter.contrast!==0&&U.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&U.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&U.add("blur",t.filter.blur),t.filter.saturation!==0&&U.add("saturation",t.filter.saturation),t.filter.hue!==0&&U.add("hue",t.filter.hue),t.filter.negative&&U.add("negative"),t.filter.sepia&&U.add("sepia"),t.filter.vintage&&U.add("brownie"),t.filter.sepia&&U.add("sepia"),t.filter.kodachrome&&U.add("kodachrome"),t.filter.technicolor&&U.add("technicolor"),t.filter.polaroid&&U.add("polaroid"),t.filter.pixelate!==0&&U.add("pixelate",t.filter.pixelate),U.get()>0?$=U.apply(G):$=U.draw(G))):(i2(G,$),U&&(U=null),v.filter=!!U),!o)return{tensor:null,canvas:$};if(!$)throw new Error("canvas error: cannot create output");let l,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&A.browser)l=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);l=A.tensor(c,[e.height,e.width,x],"int32")}else if((!be||$.width!==be.width||$.height!==be.height)&&(be=l0($.width,$.height)),A.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=A.browser.fromPixels($):(be=i2($),l=A.browser.fromPixels(be));else{let h=i2($).getContext("2d").getImageData(0,0,s,a);x=h.data.length/s/a;let p=new Uint8Array(h.data.buffer);l=A.tensor(p,[s,a,x])}if(x===4){let c=A.slice3d(l,[0,0,0],[-1,-1,3]);A.dispose(l),l=c}if(!l)throw new Error("input error: cannot create tensor");let d=A.cast(l,"float32"),y=t.filter.equalization?await s2(d):A.expandDims(d,0);return A.dispose([l,d]),{tensor:y,canvas:t.filter.return?$:null}}}async function G1(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(!O0.inputTensor)O0.inputTensor=A.clone(t);else if(O0.inputTensor.shape[1]!==t.shape[1]||O0.inputTensor.shape[2]!==t.shape[2])A.dispose(O0.inputTensor),O0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,O0.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([O0.inputTensor,n.diff,n.squared,n.sum]),O0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function B1(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||u("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||u("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 $2=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,"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:qe["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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=l0(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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new $2;var L0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function jo(e,t){return L0.debug&&u("load model fetch:",e,t),fetch(e,t)}function H1(e){L0.cacheModels=e.cacheModels,L0.verbose=e.debug,L0.modelBasePath=e.modelBasePath}async function L(e){let t=C1(L0.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await A.io.listModels(),s=L0.cacheModels&&Object.keys(r).includes(n),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>jo(x,d)},i=new J2(s?n:t,a),l=!1;try{i.findIOHandler(),L0.debug&&u("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),L0.verbose&&u("load model:",i.modelUrl),l=!0}catch(x){u("error loading model:",t,x)}if(l&&L0.cacheModels&&!s)try{let x=await i.save(n);u("model saved:",n,x)}catch(x){u("error saving model:",t,x)}return i}var e5="2.8.1";var d1={};ne(d1,{Models:()=>o2,load:()=>x1,reset:()=>D2,validate:()=>c1});var M0,t5=[],Oo=["white","black","asian","indian","other"],Lo=[15,23,28,35.5,45.5,55.5,65],V1=0,D1=0,o5=Number.MAX_SAFE_INTEGER;async function Z1(e){return v.initial&&(M0=null),M0?e.debug&&u("cached model:",M0.modelUrl):M0=await L(e.face.gear),M0}async function n5(e,t,o,n){var a,i;if(!M0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=o5<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>b()-D1;return t.skipAllowed&&s&&r&&V1===n&&t5[o]?(o5++,t5[o]):(o5=0,new Promise(async l=>{var P,g;if(!(M0!=null&&M0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[M0.inputs[0].shape[2],M0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(P=t.face.gear)!=null&&P.enabled&&([x.age,x.gender,x.race]=M0.execute(x.resize,["age_output","gender_output","race_output"]));let c=await x.gender.data();y.gender=c[0]>c[1]?"male":"female",y.genderScore=Math.round(100*(c[0]>c[1]?c[0]:c[1]))/100;let m=await x.race.data();for(let f=0;f(((g=t.face.gear)==null?void 0:g.minConfidence)||.2)&&y.race.push({score:Math.round(100*m[f])/100,race:Oo[f]});y.race.sort((f,M)=>M.score-f.score);let p=Array.from(await x.age.data()).map((f,M)=>[Lo[M],f]).sort((f,M)=>M[1]-f[1]),R=p[0][0];for(let f=1;fA.dispose(x[f])),t5[o]=y,V1=n,D1=b(),l(y)}))}var W={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function q1(){W.tf255=A.scalar(255,"float32"),W.tf1=A.scalar(1,"float32"),W.tf2=A.scalar(2,"float32"),W.tf05=A.scalar(.5,"float32"),W.tf127=A.scalar(127.5,"float32"),W.rgb=A.tensor1d([.2989,.587,.114],"float32")}var c0,l2=[],U1=0,Y1=0,r5=Number.MAX_SAFE_INTEGER;async function K1(e){return v.initial&&(c0=null),c0?e.debug&&u("cached model:",c0.modelUrl):c0=await L(e.face.ssrnet.modelPathAge),c0}async function A5(e,t,o,n){var a,i,l,x;if(!c0)return{age:0};let r=r5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>b()-Y1;return t.skipAllowed&&r&&s&&U1===n&&((l=l2[o])==null?void 0:l.age)&&((x=l2[o])==null?void 0:x.age)>0?(r5++,l2[o]):(r5=0,new Promise(async d=>{if(!(c0!=null&&c0.inputs)||!c0.inputs[0]||!c0.inputs[0].shape)return;let y={};y.resize=A.image.resizeBilinear(e,[c0.inputs[0].shape[2],c0.inputs[0].shape[1]],!1),y.enhance=A.mul(y.resize,W.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=c0.execute(y.enhance)),y.age){let m=await y.age.data();c.age=Math.trunc(10*m[0])/10}Object.keys(y).forEach(m=>A.dispose(y[m])),l2[o]=c,U1=n,Y1=b(),d(c)}))}var R0,y2=[],Q1=0,_1=0,s5=Number.MAX_SAFE_INTEGER,a5=[.2989,.587,.114];async function $1(e){return v.initial&&(R0=null),R0?e.debug&&u("cached model:",R0.modelUrl):R0=await L(e.face.ssrnet.modelPathGender),R0}async function i5(e,t,o,n){var a,i,l,x;if(!R0)return{gender:"unknown",genderScore:0};let r=s5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>b()-_1;return t.skipAllowed&&r&&s&&Q1===n&&((l=y2[o])==null?void 0:l.gender)&&((x=y2[o])==null?void 0:x.genderScore)>0?(s5++,y2[o]):(s5=0,new Promise(async d=>{if(!(R0!=null&&R0.inputs[0].shape))return;let y={};y.resize=A.image.resizeBilinear(e,[R0.inputs[0].shape[2],R0.inputs[0].shape[1]],!1),y.enhance=A.tidy(()=>{let[h,p,R]=A.split(y.resize,3,3),P=A.mul(h,a5[0]),g=A.mul(p,a5[1]),f=A.mul(R,a5[2]),M=A.addN([P,g,f]);return A.mul(A.sub(M,W.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=R0.execute(y.enhance));let m=await y.gender.data();c.gender=m[0]>m[1]?"female":"male",c.genderScore=m[0]>m[1]?Math.trunc(100*m[0])/100:Math.trunc(100*m[1])/100,Object.keys(y).forEach(h=>A.dispose(y[h])),y2[o]=c,Q1=n,_1=b(),d(c)}))}var r0,x2=[],l5=Number.MAX_SAFE_INTEGER,tt=0,ot=0;async function nt(e){var t;return v.initial&&(r0=null),r0?e.debug&&u("cached model:",r0.modelUrl):r0=await L((t=e.face.antispoof)==null?void 0:t.modelPath),r0}async function y5(e,t,o,n){var a,i;if(!r0)return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>b()-ot,s=l5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&tt===n&&x2[o]?(l5++,x2[o]):(l5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[2]:0,r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[1]:0],!1),d=r0==null?void 0:r0.execute(x),y=(await d.data())[0];x2[o]=Math.round(100*y)/100,tt=n,ot=b(),A.dispose([x,d]),l(x2[o])}))}var T0={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]},x5={count:468,mouth:13,symmetryLine:[13,T0.midwayBetweenEyes[0]]},Ae={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},c5=[{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]}],Ye=[[.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]],se=[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 Fo=[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],Go=[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],Bo=[33,133,362,263,1,78,308],sA=Fo.map(e=>Ye[e]),aA=Go.map(e=>Ye[e]),iA=Bo.map(e=>Ye[e]);function X0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Ho=[[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]],Vo=[[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]],Do=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Zo=[[474,475],[475,476],[476,477],[477,474]],Xo=[[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]],qo=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Uo=[[469,470],[470,471],[471,472],[472,469]],Yo=[[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]],lA={lips:X0(Ho),leftEye:X0(Vo),leftEyebrow:X0(Do),leftIris:X0(Zo),rightEye:X0(Xo),rightEyebrow:X0(qo),rightIris:X0(Uo),faceOval:X0(Yo)};var Pe=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],c2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],d2=(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],f2=(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],at=(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}},f5=(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,W.tf255);return A.dispose(a),i},m2=(e,t)=>{let o=c2(e),n=Pe(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}},p2=e=>{let t=c2(e),o=Pe(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}},it=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}},m5=[[1,0,0],[0,1,0],[0,0,1]],Ko=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Jo=(e,t)=>Ko(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var At=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],ae=(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=At(t[0],t[1]),a=st(s,r),i=At(-t[0],-t[1]);return st(a,i)},_o=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-ae(t[0],o),-ae(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},$o=(e,t)=>[ae(e,t[0]),ae(e,t[1])];function yt(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*(m[0]-r/2),s[1]/r*(m[1]-r/2),m[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,l=i?lt(o,[0,0]):m5,x=i?a.map(m=>[...$o(m,l),m[2]]):a,d=i?_o(n):m5,y=c2(t),c=[ae(y,d[0]),ae(y,d[1])];return x.map(m=>[Math.trunc(m[0]+c[0]),Math.trunc(m[1]+c[1]),Math.trunc(m[2]||0)])}function ct(e,t,o,n){let r=t.landmarks.length>=x5.count?x5.symmetryLine:Ae.symmetryLine,s=0,a=m5,i;if(e&&v.kernels.includes("rotatewithoffset"))if(s=Jo(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=c2(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],y=A.image.rotateWithOffset(o,s,0,d);a=lt(-s,x),i=f5(t,y,[n,n]),A.dispose(y)}else i=f5(t,o,[n,n]);else i=f5(t,o,[n,n]);return[s,a,i]}var en=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]},dt=(e,t)=>{let o=en(e),n=Pe(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 ft=6,tn=1.4,z0,mt=null,q0=0,Ke=null,Me=()=>q0;async function pt(e){var t;return v.initial&&(z0=null),z0?e.debug&&u("cached model:",z0.modelUrl):z0=await L((t=e.face.detector)==null?void 0:t.modelPath),q0=z0.inputs[0].shape?z0.inputs[0].shape[2]:0,Ke=A.scalar(q0,"int32"),mt=A.tensor2d(yt(q0)),z0}function on(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,mt),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,Ke),t.centersNormalized=A.div(t.centers,Ke),t.halfBoxSize=A.div(t.boxSizesNormalized,W.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,Ke),t.endNormalized=A.mul(t.ends,Ke);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function ut(e,t){var i,l,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,[q0,q0]),o.div=A.div(o.resized,W.tf127),o.normalized=A.sub(o.div,W.tf05);let n=z0==null?void 0:z0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let y=n.sort((c,m)=>c.size-m.size);o.concat384=A.concat([y[0],y[2]],2),o.concat512=A.concat([y[1],y[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=on(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,((l=t.face.detector)==null?void 0:l.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 y=0;y(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let m={};m.bbox=A.slice(o.boxes,[r[y],0],[1,-1]),m.slice=A.slice(o.batch,[r[y],ft-1],[1,-1]),m.squeeze=A.squeeze(m.slice),m.landmarks=A.reshape(m.squeeze,[ft,-1]);let h=await m.bbox.data(),p={startPoint:[h[0],h[1]],endPoint:[h[2],h[3]],landmarks:await m.landmarks.array(),confidence:c},R=at(p,[(e.shape[2]||0)/q0,(e.shape[1]||0)/q0]),P=m2(R,t.face.scale||tn),g=p2(P);s.push(g),Object.keys(m).forEach(f=>A.dispose(m[f]))}}return Object.keys(o).forEach(y=>A.dispose(o[y])),s}var u2={};ne(u2,{connected:()=>h5,kpt:()=>u5});var u5=["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"],h5={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 bt=224,nn,rn=5,h2=[8,16,32,32,32];async function gt(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function W0(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 Pt(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)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function b2(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 Tt={initial:!0},d0={detector:null,landmarks:null},Re={detector:[224,224],landmarks:[256,256]},b5=Number.MAX_SAFE_INTEGER,sn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},P2=null,Je,U0=[[0,0],[0,0],[0,0],[0,0]],Mt=0,Rt=e=>1-1/(1+Math.exp(e));async function vt(e){if(Tt.initial&&(d0.detector=null),!d0.detector&&e.body.detector&&e.body.detector.modelPath){d0.detector=await L(e.body.detector.modelPath);let t=Object.values(d0.detector.modelSignature.inputs);Re.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Re.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&d0.detector&&u("cached model:",d0.detector.modelUrl);return await gt(),d0.detector}async function wt(e){if(Tt.initial&&(d0.landmarks=null),d0.landmarks)e.debug&&u("cached model:",d0.landmarks.modelUrl);else{d0.landmarks=await L(e.body.modelPath);let t=Object.values(d0.landmarks.modelSignature.inputs);Re.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Re.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return d0.landmarks}async function an(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(Je&&(o.cropped=A.image.cropAndResize(e,[Je],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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],s=[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];U0=[[0,0],r,s,[0,0]],o.pad=A.pad(o.cropped||e,U0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,W.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,W.tf255)):n=A.div(o.cropped||e,W.tf255);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function ln(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+U0[2][0]+U0[2][1])/t[0]-U0[2][0]),Math.trunc(o.position[1]*(t[1]+U0[1][0]+U0[1][1])/t[1]-U0[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(Je)for(let o of e)o.positionRaw=[o.positionRaw[0]+Je[1],o.positionRaw[1]+Je[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}async function yn(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 xn(e,t,o){var h;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(h=d0.landmarks)==null?void 0:h.execute(e,sn.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(p=>A.dispose(n[p]));let i=[],l=5;for(let p=0;pp.position),y=W0(d,[o[0],o[1]]),c={};for(let[p,R]of Object.entries(h5)){let P=[];for(let g=0;gC.part===R[g]),M=x.find(C=>C.part===R[g+1]);f&&M&&P.push([f.position,M.position])}c[p]=P}return{id:0,score:Math.trunc(100*r)/100,box:y.box,boxRaw:y.boxRaw,keypoints:x,annotations:c}}async function g5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>b()-Mt,r=b5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&P2!==null)b5++;else{let s={};s.landmarks=await an(e,256),P2=await xn(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),Mt=b(),b5=0}return P2?[P2]:[]}var Te=[{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 F0,ie=0,P5=[],Et=0,M5=Number.MAX_SAFE_INTEGER;async function zt(e){if(v.initial&&(F0=null),F0)e.debug&&u("cached model:",F0.modelUrl);else{F0=await L(e.object.modelPath);let t=Object.values(F0.modelSignature.inputs);ie=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return F0}async function cn(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(),l=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,y=s[0][x][5],c=Te[y].label,[m,h]=[s[0][x][0]/ie,s[0][x][1]/ie],p=[m,h,s[0][x][2]/ie-m,s[0][x][3]/ie-h],R=[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:d,class:y,label:c,box:R,boxRaw:p})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function R5(e,t){let o=(t.object.skipTime||0)>b()-Et,n=M5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&P5.length>0?(M5++,P5):(M5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ie,ie]),i=t.object.enabled?F0==null?void 0:F0.execute(a,["tower_0/detections"]):null;Et=b(),A.dispose(a);let l=await cn(i,s,t);P5=l,r(l)}))}var M2={};ne(M2,{connected:()=>v5,kpt:()=>T5});var T5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],v5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var A0,Ct=0,y0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},w5=Number.MAX_SAFE_INTEGER;async function jt(e){return v.initial&&(A0=null),A0?e.debug&&u("cached model:",A0.modelUrl):A0=await L(e.body.modelPath),A0}async function dn(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.dispose([r,s]),a>t){let i=A.argMax(r,0),l=A.mod(i,o),x=(await l.data())[0],d=A.div(i,A.scalar(o,"int32")),y=(await d.data())[0];return A.dispose([l,d]),[x,y,a]}return[0,0,a]}async function k5(e,t){let o=(t.body.skipTime||0)>b()-Ct,n=w5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(y0.keypoints).length>0?(w5++,[y0]):(w5=0,new Promise(async r=>{var y;let s=A.tidy(()=>{if(!(A0!=null&&A0.inputs[0].shape))return null;let c=A.image.resizeBilinear(e,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),m=A.mul(c,W.tf2);return A.sub(m,W.tf1)}),a;if(t.body.enabled&&(a=A0==null?void 0:A0.execute(s)),Ct=b(),A.dispose(s),a){y0.keypoints.length=0;let c=a.squeeze();A.dispose(a);let m=c.unstack(2);A.dispose(c);for(let h=0;h(((y=t.body)==null?void 0:y.minConfidence)||0)&&y0.keypoints.push({score:Math.round(100*P)/100,part:T5[h],positionRaw:[p/A0.inputs[0].shape[2],R/A0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*p/A0.inputs[0].shape[2]),Math.round(e.shape[1]*R/A0.inputs[0].shape[1])]})}m.forEach(h=>A.dispose(h))}y0.score=y0.keypoints.reduce((c,m)=>m.score>c?m.score:c,0);let i=y0.keypoints.map(c=>c.position[0]),l=y0.keypoints.map(c=>c.position[1]);y0.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let x=y0.keypoints.map(c=>c.positionRaw[0]),d=y0.keypoints.map(c=>c.positionRaw[1]);y0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[c,m]of Object.entries(v5)){let h=[];for(let p=0;pg.part===m[p]),P=y0.keypoints.find(g=>g.part===m[p+1]);R&&P&&R.score>(t.body.minConfidence||0)&&P.score>(t.body.minConfidence||0)&&h.push([R.position,P.position])}y0.annotations[c]=h}r([y0])}))}var fn=["angry","disgust","fear","happy","sad","surprise","neutral"],g0,R2=[],Nt=0,Ot=0,E5=Number.MAX_SAFE_INTEGER;async function Lt(e){var t;return v.initial&&(g0=null),g0?e.debug&&u("cached model:",g0.modelUrl):g0=await L((t=e.face.emotion)==null?void 0:t.modelPath),g0}async function z5(e,t,o,n){var a,i;if(!g0)return[];let r=E5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>b()-Ot;return t.skipAllowed&&s&&r&&Nt===n&&R2[o]&&R2[o].length>0?(E5++,R2[o]):(E5=0,new Promise(async l=>{var d,y;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let c={},m=g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0;c.resize=A.image.resizeBilinear(e,[m,m],!1),c.channels=A.mul(c.resize,W.rgb),c.grayscale=A.sum(c.channels,3,!0),c.grayscaleSub=A.sub(c.grayscale,W.tf05),c.grayscaleMul=A.mul(c.grayscaleSub,W.tf2),c.emotion=g0==null?void 0:g0.execute(c.grayscaleMul),Ot=b();let h=await c.emotion.data();for(let p=0;p(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&x.push({score:Math.min(.99,Math.trunc(100*h[p])/100),emotion:fn[p]});x.sort((p,R)=>R.score-p.score),Object.keys(c).forEach(p=>A.dispose(c[p]))}R2[o]=x,Nt=n,l(x)}))}var f0,S5=[],Ft=0,Gt=0,Bt=Number.MAX_SAFE_INTEGER;async function Ht(e){return v.initial&&(f0=null),f0?e.debug&&u("cached model:",f0.modelUrl):f0=await L(e.face.mobilefacenet.modelPath),f0}async function C5(e,t,o,n){var a,i;if(!f0)return[];let r=Bt<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>b()-Gt;return t.skipAllowed&&s&&r&&Ft===n&&S5[o]?(Bt++,S5[o]):new Promise(async l=>{var d;let x=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(f0==null?void 0:f0.inputs[0].shape)){let y={};y.crop=A.image.resizeBilinear(e,[f0.inputs[0].shape[2],f0.inputs[0].shape[1]],!1),y.data=f0==null?void 0:f0.execute(y.crop);let c=await y.data.data();x=Array.from(c)}S5[o]=x,Ft=n,Gt=b(),l(x)})}var G0,Y0=0,mn=2.3,j5=T0.leftEyeLower0,I5=T0.rightEyeLower0,ve={leftBounds:[j5[0],j5[j5.length-1]],rightBounds:[I5[0],I5[I5.length-1]]},we={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function qt(e){var t;return v.initial&&(G0=null),G0?e.debug&&u("cached model:",G0.modelUrl):G0=await L((t=e.face.iris)==null?void 0:t.modelPath),Y0=G0.inputs[0].shape?G0.inputs[0].shape[2]:0,Y0===-1&&(Y0=64),G0}function T2(e,t,o,n){for(let r=0;r{let t=e[ve.leftBounds[0]][2],o=e[ve.rightBounds[0]][2];return t-o},Dt=(e,t,o,n,r,s=!1)=>{let a=p2(m2(it([e[o],e[n]]),mn)),i=Pe(a),l=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[Y0,Y0]);if(s&&v.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(l);A.dispose(l),l=x}return{box:a,boxSize:i,crop:l}},Zt=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[T0[`${o}EyeUpper0`][we.upperCenter]][2],r=e[T0[`${o}EyeLower0`][we.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let l=s;return i===2?l=n:i===4&&(l=r),[a[0],a[1],l]})};async function Ut(e,t,o,n){if(!G0)return o.debug&&u("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:s,crop:a}=Dt(e,t,ve.leftBounds[0],ve.leftBounds[1],n,!0),{box:i,boxSize:l,crop:x}=Dt(e,t,ve.rightBounds[0],ve.rightBounds[1],n,!0),d=A.concat([a,x]);A.dispose(a),A.dispose(x);let y=G0.execute(d);A.dispose(d);let c=await y.data();A.dispose(y);let m=c.slice(0,we.numCoordinates*3),{rawCoords:h,iris:p}=Zt(m,r,s,!0),R=c.slice(we.numCoordinates*3),{rawCoords:P,iris:g}=Zt(R,i,l,!1),f=pn(e);Math.abs(f)<30?(T2(e,h,"left",null),T2(e,P,"right",null)):f<1?T2(e,h,"left",["EyeUpper0","EyeLower0"]):T2(e,P,"right",["EyeUpper0","EyeLower0"]);let M=Xt(e,p,"left"),C=Xt(e,g,"right");return e.concat(M).concat(C)}var un=[[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]],hn=[[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]],bn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],gn=[[474,475],[475,476],[476,477],[477,474]],Pn=[[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]],Mn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Rn=[[469,470],[470,471],[471,472],[472,469]],Tn=[[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 K0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var vn={lips:K0(un),leftEye:K0(hn),leftEyebrow:K0(bn),leftIris:K0(gn),rightEye:K0(Pn),rightEyebrow:K0(Mn),rightIris:K0(Rn),faceOval:K0(Tn)},wn=Object.entries(vn).map(([e,t])=>t.map(o=>[o,e])).flat(),FA=new Map(wn),Qe=[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],le=[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 Jt(e,t){let o={lips:await t.filter(s=>s.size===160)[0].data(),irisL:await t.filter(s=>s.size===10)[0].data(),eyeL:await t.filter(s=>s.size===142)[0].data(),irisR:await t.filter(s=>s.size===10)[1].data(),eyeR:await t.filter(s=>s.size===142)[1].data()},n=le.reduce((s,a)=>s+=e[a][2],0)/le.length;for(let s=0;ss+=e[a][2],0)/ye.length;for(let s=0;sb()-S0.timestamp,n=S0.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!o||!n||S0.boxes.length===0?(S0.boxes=await ut(e,t),S0.timestamp=b(),S0.skipped=0):S0.skipped++;let r=[],s=[],a=0;for(let g=0;gF.shape[F.shape.length-1]===1),O=I.find(F=>F.shape[F.shape.length-1]===1404),Z=await j.data();k.faceScore=Math.round(100*Z[0])/100;let H=A.reshape(O,[-1,3]),D=await H.array();if(k.faceScore<(((m=t.face.detector)==null?void 0:m.minConfidence)||1)){if(f.confidence=k.faceScore,(h=t.face.mesh)!=null&&h.keepInvalid){k.box=d2(f,e),k.boxRaw=f2(f,e),k.score=k.boxScore,k.mesh=f.landmarks.map(F=>[(f.startPoint[0]+f.endPoint[0])/2+(f.endPoint[0]+f.startPoint[0])*F[0]/Me(),(f.startPoint[1]+f.endPoint[1])/2+(f.endPoint[1]+f.startPoint[1])*F[1]/Me()]),k.meshRaw=k.mesh.map(F=>[F[0]/(e.shape[2]||0),F[1]/(e.shape[1]||0),(F[2]||0)/xe]);for(let F of Object.keys(Ae))k.annotations[F]=[k.mesh[Ae[F]]]}}else{(p=t.face.attention)!=null&&p.enabled?D=await Jt(D,I):(R=t.face.iris)!=null&&R.enabled&&(D=await Ut(D,k.tensor,t,xe)),k.mesh=xt(D,f,M,C,xe),k.meshRaw=k.mesh.map(z=>[z[0]/(e.shape[2]||0),z[1]/(e.shape[1]||0),(z[2]||0)/xe]);for(let z of Object.keys(T0))k.annotations[z]=T0[z].map(h0=>k.mesh[h0]);k.score=k.faceScore;let F={...dt(k.mesh,f),confidence:f.confidence,landmarks:f.landmarks};k.box=d2(F,e),k.boxRaw=f2(F,e),s.push(F)}A.dispose([...I,H])}else{k.box=d2(f,e),k.boxRaw=f2(f,e),k.score=k.boxScore,k.mesh=f.landmarks.map(I=>[(f.startPoint[0]+f.endPoint[0])/2+(f.endPoint[0]+f.startPoint[0])*I[0]/Me(),(f.startPoint[1]+f.endPoint[1])/2+(f.endPoint[1]+f.startPoint[1])*I[1]/Me()]),k.meshRaw=k.mesh.map(I=>[I[0]/(e.shape[2]||0),I[1]/(e.shape[1]||0),(I[2]||0)/xe]);for(let I of Object.keys(Ae))k.annotations[I]=[k.mesh[Ae[I]]]}k.score>(((P=t.face.detector)==null?void 0:P.minConfidence)||1)?r.push(k):A.dispose(k.tensor)}return S0.boxes=s,r}async function _t(e){var t,o,n,r,s,a;return v.initial&&(s0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(s0==null?void 0:s0.signature)&&Object.keys(((n=s0==null?void 0:s0.signature)==null?void 0:n.outputs)||{}).length<6&&(s0=null),s0?e.debug&&u("cached model:",s0.modelUrl):(r=e.face.attention)!=null&&r.enabled?s0=await L((s=e.face.attention)==null?void 0:s.modelPath):s0=await L((a=e.face.mesh)==null?void 0:a.modelPath),xe=s0.inputs[0].shape?s0.inputs[0].shape[2]:0,s0}var $t=se,e3=Ye;var m0,v2=[],t3=0,o3=0,O5=Number.MAX_SAFE_INTEGER;async function n3(e){var t;return v.initial&&(m0=null),m0?e.debug&&u("cached model:",m0.modelUrl):m0=await L((t=e.face.description)==null?void 0:t.modelPath),m0}function L5(e){let t=e.image||e.tensor||e;if(!(m0!=null&&m0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),n=A.mul(o,W.tf255);return A.dispose(o),n}async function W5(e,t,o,n){var a,i,l,x;if(!m0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=O5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>b()-t3;return t.skipAllowed&&r&&s&&o3===n&&((l=v2[o])==null?void 0:l.age)&&((x=v2[o])==null?void 0:x.age)>0?(O5++,v2[o]):(O5=0,new Promise(async d=>{var c,m;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let h=L5(e),p=m0==null?void 0:m0.execute(h);t3=b(),A.dispose(h);let P=await(await p.find(O=>O.shape[1]===1)).data(),g=Math.trunc(200*Math.abs(P[0]-.5))/100;g>(((m=t.face.description)==null?void 0:m.minConfidence)||0)&&(y.gender=P[0]<=.5?"female":"male",y.genderScore=Math.min(.99,g));let f=A.argMax(p.find(O=>O.shape[1]===100),1),M=(await f.data())[0];A.dispose(f);let k=await p.find(O=>O.shape[1]===100).data();y.age=Math.round(k[M-1]>k[M+1]?10*M-100*k[M-1]:10*M+100*k[M+1])/10;let I=p.find(O=>O.shape[1]===1024),j=I?await I.data():[];y.descriptor=Array.from(j),p.forEach(O=>A.dispose(O))}v2[o]=y,o3=n,d(y)}))}function w2(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function _e(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function s3(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 a3(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 k2(e,t=1.5){let o=_e(e),n=w2(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 E2(e){let t=_e(e),o=w2(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 En(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function i3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return En(o)}var r3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function J0(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[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]);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,W.tf127),n.image=A.sub(n.div,W.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*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let i of s){let l={};l.box=A.slice(n.norm,[i,0],[1,-1]),l.slice=A.slice(n.predictions,[i,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,i),l.palmLandmarks=A.reshape(l.norm,[-1,2]);let x=await l.box.data(),d=x.slice(0,2),y=x.slice(2,4),c=await l.palmLandmarks.array(),m={startPoint:d,endPoint:y,palmLandmarks:c,confidence:r[i]},h=a3(m,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(h),Object.keys(l).forEach(p=>A.dispose(l[p]))}return Object.keys(n).forEach(i=>A.dispose(n[i])),a}};var jn=5,c3=1.65,d3=[0,5,9,13,17,1,2],In=0,Nn=2,f3=0,S2=class{constructor(t,o){w(this,"handDetector");w(this,"handPoseModel");w(this,"inputSize");w(this,"storedBoxes");w(this,"skipped");w(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>B5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return k2(E2(r),jn)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=k2(E2(o),c3);n.palmLandmarks=[];for(let r=0;r[a[0]*(m[0]-this.inputSize/2),a[1]*(m[1]-this.inputSize/2),a[2]*m[2]]),l=G5(n,[0,0]),x=i.map(m=>[...B5(m,l),m[2]]),d=l3(r),y=[..._e(o),1],c=[J0(y,d[0]),J0(y,d[1])];return x.map(m=>[Math.trunc(m[0]+c[0]),Math.trunc(m[1]+c[1]),Math.trunc(m[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>b()-f3,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 l=0;l=o.hand.minConfidence/4){let C=A.reshape(f,[-1,3]),k=await C.array();A.dispose(f),A.dispose(C);let I=this.transformRawCoords(k,p,d,h),j=this.getBoxForHandLandmarks(I);this.storedBoxes[l]={...j,confidence:M};let O={landmarks:I,confidence:M,boxConfidence:x.confidence,fingerConfidence:M,box:{topLeft:j.startPoint,bottomRight:j.endPoint}};i.push(O)}else this.storedBoxes[l]=null;A.dispose(f)}else{let d=k2(E2(x),c3),y={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var x0={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=>x0.nameMapping[e],getPoints:e=>x0.pointsMapping[e]},_0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>_0.nameMapping[e]},K={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=>K.nameMapping[e]},Q0=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,l]of a)if(s===i){n+=l*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,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:v0,index:B0,middle:H0,ring:ce,pinky:de}=x0,{none:w0,half:Ln,full:k0}=_0,{verticalUp:ke,verticalDown:$A,horizontalLeft:H5,horizontalRight:Wn,diagonalUpRight:Fn,diagonalUpLeft:Ee,diagonalDownRight:e7,diagonalDownLeft:t7}=K,$0=new Q0("thumbs up");$0.curl(v0,w0,1);$0.direction(v0,ke,1);$0.direction(v0,Ee,.25);$0.direction(v0,Fn,.25);for(let e of[x0.index,x0.middle,x0.ring,x0.pinky])$0.curl(e,k0,1),$0.direction(e,H5,1),$0.direction(e,Wn,1);var e0=new Q0("victory");e0.curl(v0,Ln,.5);e0.curl(v0,w0,.5);e0.direction(v0,ke,1);e0.direction(v0,Ee,1);e0.curl(B0,w0,1);e0.direction(B0,ke,.75);e0.direction(B0,Ee,1);e0.curl(H0,w0,1);e0.direction(H0,ke,1);e0.direction(H0,Ee,.75);e0.curl(ce,k0,1);e0.direction(ce,ke,.2);e0.direction(ce,Ee,1);e0.direction(ce,H5,.2);e0.curl(de,k0,1);e0.direction(de,ke,.2);e0.direction(de,Ee,1);e0.direction(de,H5,.2);e0.weight(B0,2);e0.weight(H0,2);var ee=new Q0("point");ee.curl(v0,k0,1);ee.curl(B0,w0,.5);ee.curl(H0,k0,.5);ee.curl(ce,k0,.5);ee.curl(de,k0,.5);ee.weight(B0,2);ee.weight(H0,2);var te=new Q0("middle finger");te.curl(v0,w0,1);te.curl(B0,k0,.5);te.curl(H0,k0,.5);te.curl(ce,k0,.5);te.curl(de,k0,.5);te.weight(B0,2);te.weight(H0,2);var ze=new Q0("open palm");ze.curl(v0,w0,.75);ze.curl(B0,w0,.75);ze.curl(H0,w0,.75);ze.curl(ce,w0,.75);ze.curl(de,w0,.75);var m3=[$0,e0,ee,te,ze];var Gn=.7,fe={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 p3(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 h3(e,t){if(!e||!t)return[0,0];let o=p3(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=p3(e[1],e[2],t[1],t[2]);return[o,n]}function u3(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 Bn(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],l=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(n*n+a*a+x*x),m=Math.sqrt(r*r+i*i+d*d),h=Math.sqrt(s*s+l*l+y*y),p=(h*h+c*c-m*m)/(2*h*c);p>1?p=1:p<-1&&(p=-1);let R=Math.acos(p);R=57.2958*R%180;let P;return R>fe.NO_CURL_START_LIMIT?P=_0.none:R>fe.HALF_CURL_START_LIMIT?P=_0.half:P=_0.full,P}function b3(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=K.horizontalLeft:r=K.horizontalRight:n===Math.abs(t)?t>0?r=K.horizontalLeft:r=K.horizontalRight:o>0?r=K.horizontalLeft:r=K.horizontalRight,r}function g3(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=K.verticalDown:r=K.verticalUp:n===Math.abs(t)?t<0?r=K.verticalDown:r=K.verticalUp:o<0?r=K.verticalDown:r=K.verticalUp,r}function Hn(e,t,o,n,r,s,a,i){let l,x=g3(e,t,o,n),d=b3(r,s,a,i);return x===K.verticalUp?d===K.horizontalLeft?l=K.diagonalUpLeft:l=K.diagonalUpRight:d===K.horizontalLeft?l=K.diagonalDownLeft:l=K.diagonalDownRight,l}function Vn(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],l=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(l),Math.abs(x)),c=0,m=0,h=0,p=y/(d+1e-5);p>1.5?c+=fe.DISTANCE_VOTE_POWER:p>.66?m+=fe.DISTANCE_VOTE_POWER:h+=fe.DISTANCE_VOTE_POWER;let R=Math.sqrt(r*r+i*i),P=Math.sqrt(s*s+l*l),g=Math.sqrt(a*a+x*x),f=Math.max(R,P,g),M=e[0],C=e[1],k=o[0],I=o[1];f===R?(k=o[0],I=o[1]):f===g&&(M=t[0],C=t[1]);let Z=h3([M,C],[k,I]),H=u3(Z,fe.TOTAL_ANGLE_VOTE_POWER);c+=H[0],m+=H[1],h+=H[2];for(let F of n){let z=u3(F,fe.SINGLE_ANGLE_VOTE_POWER);c+=z[0],m+=z[1],h+=z[2]}let D;return c===Math.max(c,m,h)?D=g3(l,i,x,y):h===Math.max(m,h)?D=b3(s,r,a,d):D=Hn(l,i,x,y,s,r,a,d),D}function P3(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of x0.all){let a=x0.getPoints(s),i=[],l=[];for(let x of a){let d=e[x[0]],y=e[x[1]],c=h3(d,y),m=c[0],h=c[1];i.push(m),l.push(h)}t.push(i),o.push(l)}for(let s of x0.all){let a=s===x0.thumb?1:0,i=x0.getPoints(s),l=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],y=Bn(l,x,d),c=Vn(l,x,d,t[s].slice(a));n[s]=y,r[s]=c}return{curls:n,directions:r}}function C2(e){if(!e||e.length===0)return null;let t=P3(e),o={};for(let n of x0.all)o[x0.getName(n)]={curl:_0.getName(t.curls[n]),direction:K.getName(t.directions[n])};return o}function M3(e){let t=[];if(!e||e.length===0)return t;let o=P3(e);for(let n of m3){let r=n.matchAgainst(o.curls,o.directions);r>=Gn&&t.push({name:n.name,confidence:r})}return t}var R3={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]},Se,Ce,T3;async function D5(e,t){let o=await T3.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[y]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[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],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=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 x=C2(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:l,keypoints:a,annotations:s,landmarks:x})}return n}async function Z5(e){var o,n;v.initial&&(Se=null,Ce=null),!Se||!Ce?[Se,Ce]=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&&u("cached model:",Se.modelUrl),e.debug&&u("cached model:",Ce.modelUrl));let t=new z2(Se);return T3=new S2(t,Ce),[Se,Ce]}var o0=[null,null],Dn=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],oe=[[0,0],[0,0]],Zn=["hand","fist","pinch","point","face","tip","pinchtip"],w3=4,k3=1.6,Xn=512,qn=1.4,j2=Number.MAX_SAFE_INTEGER,X5=0,V0=[0,0],Q={boxes:[],hands:[]},E3={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 z3(e){var t;if(v.initial&&(o0[0]=null),o0[0])e.debug&&u("cached model:",o0[0].modelUrl);else{I2(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),o0[0]=await L((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(o0[0].modelSignature.inputs);oe[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[0]}async function S3(e){var t;if(v.initial&&(o0[1]=null),o0[1])e.debug&&u("cached model:",o0[1].modelUrl);else{o0[1]=await L((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(o0[1].modelSignature.inputs);oe[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[1]}async function Un(e,t){let o=[];if(!e||!o0[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,Xn),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 o0[0].executeAsync(n.cast,Dn),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[w3]),i.splice(w3,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 l=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(),y=await n.argmax.data();for(let c of Array.from(x)){let m=A.slice(n.boxes,c,1),h=await m.data();A.dispose(m);let p=[h[1],h[0],h[3]-h[1],h[2]-h[0]],R=b2(p,qn),P=[Math.trunc(p[0]*V0[0]),Math.trunc(p[1]*V0[1]),Math.trunc(p[2]*V0[0]),Math.trunc(p[3]*V0[1])],g=d[c],f=Zn[y[c]],M={id:l++,score:g,box:P,boxRaw:R,label:f};o.push(M)}return Object.keys(n).forEach(c=>A.dispose(n[c])),o.sort((c,m)=>m.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function q5(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&&o0[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],[oe[1][0],oe[1][1]],"bilinear"),r.div=A.div(r.crop,W.tf255),[r.score,r.keypoints]=o0[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(y=>[y[0]/oe[1][1],y[1]/oe[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);n.keypoints=d.map(y=>[V0[0]*(y[0]+t.boxRaw[0]),V0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),n.landmarks=C2(n.keypoints);for(let y of Object.keys(E3))n.annotations[y]=E3[y].map(c=>n.landmarks&&n.keypoints[c]?n.keypoints[c]:null)}Object.keys(r).forEach(l=>A.dispose(r[l]))}return n}async function U5(e,t){var r,s;if(!o0[0]||!o0[1]||!((r=o0[0])!=null&&r.inputs[0].shape)||!((s=o0[1])!=null&&s.inputs[0].shape))return[];V0=[e.shape[2]||0,e.shape[1]||0],j2++;let o=(t.hand.skipTime||0)>b()-X5,n=j2<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Q.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>b()-X5,l=j2<3*(t.hand.skipFrames||0);t.skipAllowed&&Q.hands.length===t.hand.maxDetected?Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))):t.skipAllowed&&i&&l&&Q.hands.length>0?Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))):(Q.boxes=await Un(e,t),X5=b(),Q.hands=await Promise.all(Q.boxes.map(d=>q5(e,d,t))),j2=0);let x=[...Q.boxes];if(Q.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&y.box[3]/(e.shape[1]||1)>.05&&Q.hands[d].fingerScore&&Q.hands[d].fingerScore>(t.hand.minConfidence||0)){let c=b2(y.box,k3),m=b2(y.boxRaw,k3);Q.boxes.push({...x[d],box:c,boxRaw:m})}}for(let d=0;db()-I3,s=Y5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&j3===n&&N2[o]?(Y5++,N2[o]):(Y5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[a0!=null&&a0.inputs[0].shape?a0.inputs[0].shape[2]:0,a0!=null&&a0.inputs[0].shape?a0.inputs[0].shape[1]:0],!1),d=a0==null?void 0:a0.execute(x),y=(await d.data())[0];N2[o]=Math.round(100*y)/100,j3=n,I3=b(),A.dispose([x,d]),l(N2[o])}))}var $e={};ne($e,{connected:()=>L2,horizontal:()=>J5,kpt:()=>O2,relative:()=>_5,vertical:()=>Q5});var O2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],J5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Q5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],_5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],L2={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var L3=.005,p0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function $5(e){for(let t of J5){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],l=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]||l[0]>l[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function W3(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,p0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function G3(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+p0.padding[2][0]+p0.padding[2][1])/t[0]-p0.padding[2][0],n.position[1]*(t[1]+p0.padding[1][0]+p0.padding[1][1])/t[1]-p0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=W0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var u0,W2=0,e1=Number.MAX_SAFE_INTEGER,me={boxes:[],bodies:[],last:0};async function B3(e){return v.initial&&(u0=null),u0?e.debug&&u("cached model:",u0.modelUrl):(I2(["size"],e),u0=await L(e.body.modelPath)),W2=u0.inputs[0].shape?u0.inputs[0].shape[2]:0,W2<64&&(W2=256),u0}async function Kn(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let y=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:O2[d],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=r.reduce((d,y)=>y.score>d?y.score:d,0);let a=[],i=W0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),l={};for(let[d,y]of Object.entries(L2)){let c=[];for(let m=0;mR.part===y[m]),p=r.find(R=>R.part===y[m+1]);h&&p&&h.score>(t.body.minConfidence||0)&&p.score>(t.body.minConfidence||0)&&c.push([h.position,p.position])}l[d]=c}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return $5(x),a.push(x),a}async function Jn(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let y=0;y<17;y++){let c=s[3*y+2];if(c>t.body.minConfidence){let m=[s[3*y+1],s[3*y+0]];i.push({part:O2[y],score:Math.round(100*c)/100,positionRaw:m,position:[Math.round((o.shape[2]||0)*m[0]),Math.round((o.shape[1]||0)*m[1])]})}}let l=W0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),x={};for(let[y,c]of Object.entries(L2)){let m=[];for(let h=0;hP.part===c[h]),R=i.find(P=>P.part===c[h+1]);p&&R&&p.score>(t.body.minConfidence||0)&&R.score>(t.body.minConfidence||0)&&m.push([p.position,R.position])}x[y]=m}let d={id:r,score:a,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:x};$5(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 t1(e,t){if(!u0||!(u0!=null&&u0.inputs[0].shape))return[];t.skipAllowed||(me.boxes.length=0),e1++;let o=(t.body.skipTime||0)>b()-me.last,n=e1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?me.bodies:new Promise(async r=>{let s={};e1=0,s.input=F3(e,W2),s.res=u0==null?void 0:u0.execute(s.input),me.last=b();let a=await s.res.array();me.bodies=s.res.shape[2]===17?await Kn(a,t,e):await Jn(a,t,e);for(let i of me.bodies)G3(i,[e.shape[2]||1,e.shape[1]||1]),W3(i.keypoints);Object.keys(s).forEach(i=>A.dispose(s[i])),r(me.bodies)})}var je,F2=[],V3=0,o1=Number.MAX_SAFE_INTEGER,B2=0,G2=2.5;async function D3(e){if(!je||v.initial){je=await L(e.object.modelPath);let t=Object.values(je.modelSignature.inputs);B2=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&u("cached model:",je.modelUrl);return je}async function Qn(e,t,o){let n=0,r=[];for(let l of[1,2,4])A.tidy(async()=>{let x=l*13,d=A.squeeze(e.find(p=>p.shape[1]===x**2&&(p.shape[2]||0)===Te.length)),y=A.squeeze(e.find(p=>p.shape[1]===x**2&&(p.shape[2]||0)(o.object.minConfidence||0)&&R!==61){let g=(.5+Math.trunc(p%x))/x,f=(.5+Math.trunc(p/x))/x,M=m[p].map(D=>D*(x/l/B2)),[C,k]=[g-G2/l*M[0],f-G2/l*M[1]],[I,j]=[g+G2/l*M[2]-C,f+G2/l*M[3]-k],O=[C,k,I,j];O=O.map(D=>Math.max(0,Math.min(D,1)));let Z=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],H={id:n++,score:Math.round(100*P)/100,class:R+1,label:Te[R].label,box:Z.map(D=>Math.trunc(D)),boxRaw:O};r.push(H)}}});e.forEach(l=>A.dispose(l));let s=r.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),a=r.map(l=>l.score),i=[];if(s&&s.length>0){let l=await A.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await l.data(),A.dispose(l)}return r=r.filter((l,x)=>i.includes(x)).sort((l,x)=>x.score-l.score),r}async function n1(e,t){let o=(t.object.skipTime||0)>b()-V3,n=o1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&F2.length>0?(o1++,F2):(o1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?F2:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[B2,B2],!1),i=A.div(a,W.tf255),l=i.transpose([0,3,1,2]);A.dispose(i),A.dispose(a);let x;t.object.enabled&&(x=je.execute(l)),V3=b(),A.dispose(l);let d=await Qn(x,s,t);F2=d,r(d)}))}var t2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],_n=t2.length,e2=t2.reduce((e,t,o)=>(e[t]=o,e),{}),$n=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],v7=$n.map(([e,t])=>[e2[e],e2[t]]),X3=[["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 q3(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 U3(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:y,part:c,position:m})=>({score:y,part:c,position:[Math.trunc(m.x*a),Math.trunc(m.y*s)],positionRaw:[m.x/n,m.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var H2=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 Y3(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function a1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var E0,tr=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],V2=1,Ie=16,or=50**2;function K3(e,t,o,n,r,s,a=2){let i=P=>({y:s.get(P.y,P.x,e),x:s.get(P.y,P.x,s.shape[2]/2+e)}),l=(P,g,f)=>({y:s1(Math.round(P.y/Ie),0,g-1),x:s1(Math.round(P.x/Ie),0,f-1)}),[x,d]=n.shape,y=l(t.position,x,d),c=i(y),h=a1(t.position,c);for(let P=0;P[e2[c],e2[m]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),l=t.shape[2],x=a.length,d=new Array(l),y=A1(e.part,Ie,o);d[e.part.id]={score:e.score,part:t2[e.part.id],position:y};for(let c=x-1;c>=0;--c){let m=a[c],h=i[c];d[m]&&!d[h]&&(d[h]=K3(c,d[m],h,t,o,r))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function Ar(e,t){let[o,n,r]=t.shape,s=new H2(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?Y3(o,t,s.y,s.x)<=or:!1})}function sr(e,t){return t.reduce((n,{position:r,score:s},a)=>(J3(e,r,a)||(n+=s),n),0)/t.length}function ar(e,t,o,n,r,s){let a=[],i=Ar(s,t);for(;a.lengthm.score>s);let y=sr(a,d),c=q3(d);y>s&&a.push({keypoints:d,box:c,score:Math.round(100*y)/100})}return a}async function i1(e,t){let o=A.tidy(()=>{if(!E0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=E0.execute(i,tr).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=await ar(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return E0.inputs[0].shape?U3(r,[e.shape[1],e.shape[2]],[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]):[]}async function Q3(e){return!E0||v.initial?E0=await L(e.body.modelPath):e.debug&&u("cached model:",E0.modelUrl),E0}var C0,l1=!1;async function y1(e){return!C0||v.initial?C0=await L(e.segmentation.modelPath):e.debug&&u("cached model:",C0.modelUrl),C0}async function $3(e,t,o){var p,R;if(l1)return{data:[],canvas:null,alpha:null};l1=!0,C0||await y1(o);let n=await ge(e,o),r=((p=n.tensor)==null?void 0:p.shape[2])||0,s=((R=n.tensor)==null?void 0:R.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[C0.inputs[0].shape?C0.inputs[0].shape[1]:0,C0.inputs[0].shape?C0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,W.tf255),a.res=C0.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(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&u("canvas support missing"),Object.keys(a).forEach(P=>A.dispose(a[P])),{data:i,canvas:null,alpha:null};let l=l0(r,s);A.browser&&await A.browser.toPixels(a.data,l);let x=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),y=l0(r,s),c=y.getContext("2d");n.canvas&&c.drawImage(n.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(l,0,0),c.globalCompositeOperation="source-over",c.filter="none";let m=c.getImageData(0,0,r,s);for(let P=0;PA.dispose(a[P])),l1=!1,{data:i,canvas:y,alpha:l}}var o2=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,"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)}};function D2(e){for(let t of Object.keys(e.models))e.models[t]=null}async function x1(e){var t,o,n,r,s,a,i,l,x,d,y,c,m,h,p,R,P,g,f,M,C,k,I,j,O,Z,H,D,F,z,h0;v.initial&&D2(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 Z5(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 Z5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=wt(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=vt(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=jt(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(x=e.config.body)==null?void 0:x.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=B3(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=Q3(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=pt(e.config)),e.config.face.enabled&&((m=e.config.face.antispoof)==null?void 0:m.enabled)&&!e.models.antispoof&&(e.models.antispoof=nt(e.config)),e.config.face.enabled&&((h=e.config.face.liveness)==null?void 0:h.enabled)&&!e.models.liveness&&(e.models.liveness=N3(e.config)),e.config.face.enabled&&((p=e.config.face.description)==null?void 0:p.enabled)&&!e.models.faceres&&(e.models.faceres=n3(e.config)),e.config.face.enabled&&((R=e.config.face.emotion)==null?void 0:R.enabled)&&!e.models.emotion&&(e.models.emotion=Lt(e.config)),e.config.face.enabled&&((P=e.config.face.iris)==null?void 0:P.enabled)&&!((g=e.config.face.attention)!=null&&g.enabled)&&!e.models.faceiris&&(e.models.faceiris=qt(e.config)),e.config.face.enabled&&((f=e.config.face.mesh)==null?void 0:f.enabled)&&!e.models.facemesh&&(e.models.facemesh=_t(e.config)),e.config.face.enabled&&((M=e.config.face.gear)==null?void 0:M.enabled)&&!e.models.gear&&(e.models.gear=Z1(e.config)),e.config.face.enabled&&((C=e.config.face.ssrnet)==null?void 0:C.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=K1(e.config)),e.config.face.enabled&&((k=e.config.face.ssrnet)==null?void 0:k.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=$1(e.config)),e.config.face.enabled&&((I=e.config.face.mobilefacenet)==null?void 0:I.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=Ht(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((O=(j=e.config.hand.detector)==null?void 0:j.modelPath)==null?void 0:O.includes("handtrack"))&&(e.models.handtrack=z3(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((H=(Z=e.config.hand.detector)==null?void 0:Z.modelPath)==null?void 0:H.includes("handtrack"))&&(e.models.handskeleton=S3(e.config)),e.config.object.enabled&&!e.models.centernet&&((F=(D=e.config.object)==null?void 0:D.modelPath)==null?void 0:F.includes("centernet"))&&(e.models.centernet=zt(e.config)),e.config.object.enabled&&!e.models.nanodet&&((h0=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:h0.includes("nanodet"))&&(e.models.nanodet=D3(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=y1(e.config));for await(let b0 of Object.keys(e.models))e.models[b0]&&typeof e.models[b0]!="undefined"&&(e.models[b0]=await e.models[b0])}async function c1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let l=i.op.toLowerCase();r.includes(l)||r.push(l)}else!s&&e.config.debug&&u("model signature not determined:",o);let a=[];for(let i of r)!t.includes(i)&&!e.env.kernels.includes(i)&&!e.env.kernels.includes(i.replace("_",""))&&!e.env.kernels.includes(i.replace("native",""))&&!e.env.kernels.includes(i.replace("v2",""))&&a.push(i);e.config.debug&&a.length>0&&u("model validation failed:",o,a)}}var Y={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 ir(){let e=Y.gl;!e||(Y.extensions=e.getSupportedExtensions())}async function to(e){var t;if(e.config.backend==="humangl"&&(Y.name in A.engine().registry&&(!Y.gl||!Y.gl.getParameter(Y.gl.VERSION))&&(u("error: humangl backend invalid context"),D2(e)),!A.findBackend(Y.name))){try{Y.canvas=await l0(100,100)}catch(n){u("error: cannot create canvas:",n);return}try{if(Y.gl=(t=Y.canvas)==null?void 0:t.getContext("webgl2",Y.webGLattr),!Y.gl.getParameter(Y.gl.VERSION).includes("2.0")){u("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Y.canvas&&(Y.canvas.addEventListener("webglcontextlost",async r=>{throw u("error: humangl:",r.type),u("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Y.canvas.addEventListener("webglcontextrestored",r=>{u("error: humangl context restored:",r)}),Y.canvas.addEventListener("webglcontextcreationerror",r=>{u("error: humangl context create:",r)}))}catch(n){u("error: cannot get WebGL context:",n);return}try{A.setWebGLContext(2,Y.gl)}catch(n){u("error: cannot set WebGL context:",n);return}try{let n=new A.GPGPUContext(Y.gl);A.registerBackend(Y.name,()=>new A.MathBackendWebGL(n),Y.priority)}catch(n){u("error: cannot register WebGL backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:Y.name};A.registerKernel(s)})}catch(n){u("error: cannot update WebGL backend registration:",n);return}let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;if(o)u(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{u("error: no current gl context:",o,Y.gl);return}try{A.ENV.set("WEBGL_VERSION",2)}catch(n){u("error: cannot set WebGL backend flags:",n);return}ir(),u("backend registered:",Y.name)}}function lr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.sub(t.inputs.a,A.mul(A.div(t.inputs.a,t.inputs.b),t.inputs.b)))};A.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+A.mod(t.inputs.a,t.inputs.b))};A.registerKernel(e),v.kernels.push("floormod")}}async function Z2(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=b();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&u("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&u("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&u(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")u("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&u("enumerated webgpu adapter:",r),!r)u("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let s="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;u("webgpu adapter info:",s)}}e.config.backend==="humangl"&&await to(e);let n=Object.keys(A.engine().registryFactory);if(e.config.debug&&u("available backends:",n),n.includes(e.config.backend)||(u(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&u(`override: setting backend ${e.config.backend}`)),e.config.debug&&u("setting backend:",e.config.backend),e.config.backend==="wasm"){try{A.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(a){}if(e.config.debug&&u("wasm path:",e.config.wasmPath),typeof(A==null?void 0:A.setWasmPaths)!="undefined")await 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=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&u(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&u("warning: wasm simd support is not enabled")}try{await A.setBackend(e.config.backend),await A.ready(),q1()}catch(r){return u("error: cannot set backend:",e.config.backend,r),!1}}if(A.getBackend()==="humangl"&&(A.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),A.ENV.set("WEBGL_CPU_FORWARD",!0),A.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(u("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),A.backend().getGPGPUContext)){let n=await A.backend().getGPGPUContext().gl;e.config.debug&&u(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}A.getBackend(),A.enableProdMode(),await A.ready(),e.performance.initBackend=Math.trunc(b()-o),e.config.backend=A.getBackend(),await v.updateBackend(),lr()}return!0}function I2(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&u("kernelFunc",o,t.backend)}};A.registerKernel(n)}v.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var ro={};ne(ro,{all:()=>b1,body:()=>Oe,canvas:()=>h1,face:()=>Ne,gesture:()=>Fe,hand:()=>Le,object:()=>We,options:()=>i0,person:()=>u1});var P0=e=>{if(!e)u("draw error: invalid canvas");else if(!e.getContext)u("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)u("draw error: cannot get canvas context");else return t}return null},pe=e=>Math.round(e*180/Math.PI),D0=(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=D0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function j0(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 f1(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=D0(n[2],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function no(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){f1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${pe(e.rotation.angle.roll)}\xB0 yaw:${pe(e.rotation.angle.yaw)}\xB0 pitch:${pe(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${pe(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=B.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),s=n*B.lineHeight+e.box[1];B.shadowColor&&B.shadowColor!==""&&(t.fillStyle=B.shadowColor,t.fillText(o[n],r+5,s+16)),t.fillStyle=B.labelColor,t.fillText(o[n],r+4,s+15)}}}function cr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=B.useDepth?"rgba(255, 200, 255, 0.3)":B.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),B.fillPolygons&&(t.fillStyle=B.useDepth?"rgba(255, 255, 200, 0.3)":B.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=B.useDepth?"rgba(255, 200, 255, 0.3)":B.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),B.fillPolygons&&(t.fillStyle=B.useDepth?"rgba(255, 255, 200, 0.3)":B.color,t.fill())}}function dr(e,t){var o;if(B.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]*pe(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*pe(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 2e1fa494..d85422f8 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -39209,7 +39209,7 @@ async function loadModel(modelPath) { } // package.json -var version = "2.8.0"; +var version = "2.8.1"; // src/models.ts var models_exports = {}; diff --git a/dist/human.js b/dist/human.js index 02a05f50..28897f3a 100644 --- a/dist/human.js +++ b/dist/human.js @@ -6982,7 +6982,7 @@ return a / b;`,Ooe=` c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var HA=(e,t,r)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(a,s)=>(r[s]=0,a))},qA=class{constructor(t,r,n){fe(this,"uniform",{});fe(this,"attribute",{});fe(this,"gl");fe(this,"id");fe(this,"compile",(t,r)=>{let n=this.gl.createShader(r);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(se(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(se("filter: could not create shader"),null)});this.gl=t;let a=this.compile(r,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!a||!s)){if(!this.id){se("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,a),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){se(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),HA(r,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=this.gl.getAttribLocation(this.id,i);HA(r,"uniform",this.uniform),HA(n,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=this.gl.getUniformLocation(this.id,i)}}};function PC(){let e=0,t=null,r=!1,n=-1,a=[null,null],s=[],i=null,o=null,l=Zr(100,100),u={},d={INTERMEDIATE:1},h=l.getContext("webgl");if(!h){se("filter: cannot get webgl context");return}this.gl=h;function p(A,x){if(!(A===l.width&&x===l.height)){if(l.width=A,l.height=x,!i){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]);i=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,i),h.bufferData(h.ARRAY_BUFFER,b,h.STATIC_DRAW),h.pixelStorei(h.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}h.viewport(0,0,l.width,l.height),a=[null,null]}}function c(A,x){let b=h.createFramebuffer();h.bindFramebuffer(h.FRAMEBUFFER,b);let w=h.createRenderbuffer();h.bindRenderbuffer(h.RENDERBUFFER,w);let I=h.createTexture();return h.bindTexture(h.TEXTURE_2D,I),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,A,x,0,h.RGBA,h.UNSIGNED_BYTE,null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,I,0),h.bindTexture(h.TEXTURE_2D,null),h.bindFramebuffer(h.FRAMEBUFFER,null),{fbo:b,texture:I}}function m(A){return a[A]=a[A]||c(l.width,l.height),a[A]}function f(A=0){if(!o)return;let x=null,b=null,w=!1;e===0?x=t:x=m(n).texture||null,e++,r&&!(A&d.INTERMEDIATE)?(b=null,w=e%2===0):(n=(n+1)%2,b=m(n).fbo||null),h.bindTexture(h.TEXTURE_2D,x),h.bindFramebuffer(h.FRAMEBUFFER,b),h.uniform1f(o.uniform.flipY,w?-1:1),h.drawArrays(h.TRIANGLES,0,6)}function g(A){if(u[A])return o=u[A],h.useProgram((o?o.id:null)||null),o;if(o=new qA(h,EC,A),!o)return se("filter: could not get webgl program"),null;let x=Float32Array.BYTES_PER_ELEMENT,b=4*x;return h.enableVertexAttribArray(o.attribute.pos),h.vertexAttribPointer(o.attribute.pos,2,h.FLOAT,!1,b,0*x),h.enableVertexAttribArray(o.attribute.uv),h.vertexAttribPointer(o.attribute.uv,2,h.FLOAT,!1,b,2*x),u[A]=o,o}let y={colorMatrix:A=>{let x=new Float32Array(A);x[4]/=255,x[9]/=255,x[14]/=255,x[19]/=255;let b=x[18]===1&&x[3]===0&&x[8]===0&&x[13]===0&&x[15]===0&&x[16]===0&&x[17]===0&&x[19]===0?$C:RC,w=g(b);!w||(h.uniform1fv(w.uniform.m,x),f())},brightness:A=>{let x=(A||0)+1;y.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},saturation:A=>{let x=(A||0)*2/3+1,b=(x-1)*-.5;y.colorMatrix([x,b,b,0,0,b,x,b,0,0,b,b,x,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:A=>{let x=(A||0)+1,b=-128*(x-1);y.colorMatrix([x,0,0,0,b,0,x,0,0,b,0,0,x,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:A=>{A=(A||0)/180*Math.PI;let x=Math.cos(A),b=Math.sin(A),w=.213,I=.715,T=.072;y.colorMatrix([w+x*(1-w)+b*-w,I+x*-I+b*-I,T+x*-T+b*(1-T),0,0,w+x*-w+b*.143,I+x*(1-I)+b*.14,T+x*-T+b*-.283,0,0,w+x*-w+b*-(1-w),I+x*-I+b*I,T+x*(1-T)+b*T,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:A=>{let x=new Float32Array(A),b=1/l.width,w=1/l.height,I=g(_C);!I||(h.uniform1fv(I.uniform.m,x),h.uniform2f(I.uniform.px,b,w),f())},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:A=>{let x=A||1;y.convolution.call(this,[0,-1*x,0,-1*x,1+4*x,-1*x,0,-1*x,0])},emboss:A=>{let x=A||1;y.convolution.call(this,[-2*x,-1*x,0,-1*x,1,1*x,0,1*x,2*x])},blur:A=>{let x=A/7/l.width,b=A/7/l.height,w=g(FC);!w||(h.uniform2f(w.uniform.px,0,b),f(d.INTERMEDIATE),h.uniform2f(w.uniform.px,x,0),f())},pixelate:A=>{let x=A/l.width,b=A/l.height,w=g(MC);!w||(h.uniform2f(w.uniform.size,x,b),f())}};this.add=function(A){let x=Array.prototype.slice.call(arguments,1),b=y[A];s.push({func:b,args:x})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(A){p(A.width,A.height),e=0,t||(t=h.createTexture()),h.bindTexture(h.TEXTURE_2D,t),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,A);for(let x=0;xc.data())),i=.99*Math.max(s[0][0],s[1][0],s[2][0]),o=[ce(r[0],n[0]),ce(r[1],n[1]),ce(r[2],n[2])],l=[ce(a[0],n[0]),ce(a[1],n[1]),ce(a[2],n[2])],u=[pe(i,l[0]),pe(i,l[1]),pe(i,l[2])],d=[L(o[0],u[0]),L(o[1],u[1]),L(o[2],u[2])],h=ur([d[0],d[1],d[2]],2),p=U(h,[1,t.shape[0],t.shape[1],3]);return te([...r,...n,...a,...o,...l,...u,...d,h,t]),p}var Um=3840,ut=null,er=null,Wd=null,Et,is={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function Zr(e,t){let r;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");r=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");r=document.createElement("canvas"),r.width=e,r.height=t}else typeof he.Canvas!="undefined"?r=new he.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(r=new globalThis.Canvas(e,t));return r}function Gm(e,t){let r=t||Zr(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),r}async function Vd(e,t,r=!0){if(!e)return t.debug&&se("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof nt)&&!(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 nt){let n=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)n=Kt(e,0);else if(e.shape[2]===4){let a=Fl(e,[0,0,0],[-1,-1,3]);n=Kt(a,0),te(a)}}else e.shape.length===4&&(e.shape[3]===3?n=Vr(e):e.shape[3]===4&&(n=_o(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let a=me(n,"float32");te(n),n=a}return{tensor:n,canvas:t.filter.return?er:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&se("input stream is not ready"),{tensor:null,canvas:ut};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,a=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!a)return t.debug&&se("cannot determine input dimensions"),{tensor:null,canvas:ut};let s=n,i=a;if(s>Um&&(s=Um,i=Math.trunc(s*a/n)),i>Um&&(i=Um,s=Math.trunc(i*n/a)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=n*((t.filter.height||0)/a)),(t.filter.height||0)>0?i=t.filter.height:(t.filter.width||0)>0&&(i=a*((t.filter.width||0)/n)),!s||!i)throw new Error("input error: cannot determine dimension");(!ut||(ut==null?void 0:ut.width)!==s||(ut==null?void 0:ut.height)!==i)&&(ut=Zr(s,i));let o=ut.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?o.putImageData(e,0,0):t.filter.flip&&typeof o.translate!="undefined"?(o.translate(n,0),o.scale(-1,1),o.drawImage(e,0,0,n,a,0,0,ut==null?void 0:ut.width,ut==null?void 0:ut.height),o.setTransform(1,0,0,1,0,0)):o.drawImage(e,0,0,n,a,0,0,ut==null?void 0:ut.width,ut==null?void 0:ut.height),(!er||ut.width!==er.width||(ut==null?void 0:ut.height)!==(er==null?void 0:er.height))&&(er=Zr(ut.width,ut.height)),t.filter.enabled&&he.webgl.supported?(Et||(Et=he.browser?new PC:null),he.filter=!!Et,!Et||!Et.add?(t.debug&&se("input process error: cannot initialize filters"),he.webgl.supported=!1,t.filter.enabled=!1,Gm(ut,er)):(Et.reset(),t.filter.brightness!==0&&Et.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Et.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Et.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Et.add("blur",t.filter.blur),t.filter.saturation!==0&&Et.add("saturation",t.filter.saturation),t.filter.hue!==0&&Et.add("hue",t.filter.hue),t.filter.negative&&Et.add("negative"),t.filter.sepia&&Et.add("sepia"),t.filter.vintage&&Et.add("brownie"),t.filter.sepia&&Et.add("sepia"),t.filter.kodachrome&&Et.add("kodachrome"),t.filter.technicolor&&Et.add("technicolor"),t.filter.polaroid&&Et.add("polaroid"),t.filter.pixelate!==0&&Et.add("pixelate",t.filter.pixelate),Et.get()>0?er=Et.apply(ut):er=Et.draw(ut))):(Gm(ut,er),Et&&(Et=null),he.filter=!!Et),!r)return{tensor:null,canvas:er};if(!er)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&&Ln)l=Ln?Ln.fromPixels(e):null;else{u=e.data.length/e.height/e.width;let p=new Uint8Array(e.data.buffer);l=ft(p,[e.height,e.width,u],"int32")}else if((!Wd||er.width!==Wd.width||er.height!==Wd.height)&&(Wd=Zr(er.width,er.height)),Ln&&he.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=Ln.fromPixels(er):(Wd=Gm(er),l=Ln.fromPixels(Wd));else{let m=Gm(er).getContext("2d").getImageData(0,0,s,i);u=m.data.length/s/i;let f=new Uint8Array(m.data.buffer);l=ft(f,[s,i,u])}if(u===4){let p=Fl(l,[0,0,0],[-1,-1,3]);te(l),l=p}if(!l)throw new Error("input error: cannot create tensor");let d=me(l,"float32"),h=t.filter.equalization?await Vm(d):Kt(d,0);return te([l,d]),{tensor:h,canvas:t.filter.return?er:null}}}async function OC(e,t){let r=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return r;if(!is.inputTensor)is.inputTensor=Vr(t);else if(is.inputTensor.shape[1]!==t.shape[1]||is.inputTensor.shape[2]!==t.shape[2])te(is.inputTensor),is.inputTensor=Vr(t);else{let n={};n.diff=ce(t,is.inputTensor),n.squared=L(n.diff,n.diff),n.sum=ke(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;te([is.inputTensor,n.diff,n.squared,n.sum]),is.inputTensor=Vr(t),r=s<=(e.cacheSensitivity||0)}return r}async function zC(e,t,r){let n={};if(!t||!r||t.shape.length!==4||t.shape.length!==r.shape.length)return e.debug||se("invalid input tensor or tensor shapes do not match:",t.shape,r.shape),0;if(t.shape[0]!==1||r.shape[0]!==1||t.shape[3]!==3||r.shape[3]!==3)return e.debug||se("input tensors must be of shape [1, height, width, 3]:",t.shape,r.shape),0;n.input1=Vr(t),n.input2=t.shape[1]!==r.shape[1]||t.shape[2]!==r.shape[2]?Ie.resizeBilinear(r,[t.shape[1],t.shape[2]]):Vr(r),n.diff=ce(n.input1,n.input2),n.squared=L(n.diff,n.diff),n.sum=ke(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return te([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var XA=class{constructor(){fe(this,"browser");fe(this,"node");fe(this,"worker");fe(this,"platform","");fe(this,"agent","");fe(this,"backends",[]);fe(this,"initial");fe(this,"filter");fe(this,"tfjs");fe(this,"offscreen");fe(this,"perfadd",!1);fe(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});fe(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});fe(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});fe(this,"cpu",{model:void 0,flags:[]});fe(this,"kernels",[]);fe(this,"Canvas");fe(this,"Image");fe(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:rc["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&&t[0]){let r=t[0].match(/\(([^()]+)\)/g);this.platform=r&&r[0]?r[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(Xt().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&Hr()==="wasm"&&(this.wasm.simd=await Z().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await Z().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=Zr(100,100),r=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof r!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(Hr()==="webgl"||Hr()==="humangl")){let n=Dn().gpgpu!=="undefined"?await Dn().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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=Fa(Hr()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},he=new XA;var os={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function m3e(e,t){return os.debug&&se("load model fetch:",e,t),fetch(e,t)}function DC(e){os.cacheModels=e.cacheModels,os.verbose=e.debug,os.modelBasePath=e.modelBasePath}async function Ge(e){let t=Gb(os.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let r=t.split("/"),n="indexeddb://"+r[r.length-1].replace(".json",""),a=await Cr.listModels(),s=os.cacheModels&&Object.keys(a).includes(n),i=typeof fetch=="undefined"?{}:{fetchFunc:(u,d)=>m3e(u,d)},o=new Vh(s?n:t,i),l=!1;try{o.findIOHandler(),os.debug&&se("model load handler:",o.handler);let u=await o.handler.load();o.loadSync(u),os.verbose&&se("load model:",o.modelUrl),l=!0}catch(u){se("error loading model:",t,u)}if(l&&os.cacheModels&&!s)try{let u=await o.save(n);se("model saved:",n,u)}catch(u){se("error saving model:",t,u)}return o}var KA="2.8.0";var C1={};vs(C1,{Models:()=>hc,load:()=>ib,reset:()=>S1,validate:()=>ob});var Jn,ZA=[],A3e=["white","black","asian","indian","other"],x3e=[15,23,28,35.5,45.5,55.5,65],LC=0,BC=0,YA=Number.MAX_SAFE_INTEGER;async function WC(e){return he.initial&&(Jn=null),Jn?e.debug&&se("cached model:",Jn.modelUrl):Jn=await Ge(e.face.gear),Jn}async function JA(e,t,r,n){var i,o;if(!Jn)return{age:0,gender:"unknown",genderScore:0,race:[]};let a=YA<(((i=t.face.gear)==null?void 0:i.skipFrames)||0),s=(((o=t.face.gear)==null?void 0:o.skipTime)||0)>oe()-BC;return t.skipAllowed&&s&&a&&LC===n&&ZA[r]?(YA++,ZA[r]):(YA=0,new Promise(async l=>{var y,A;if(!(Jn!=null&&Jn.inputs[0].shape))return;let u={},d=[[0,.1,.9,.9]];u.resize=Ie.cropAndResize(e,d,[0],[Jn.inputs[0].shape[2],Jn.inputs[0].shape[1]]);let h={age:0,gender:"unknown",genderScore:0,race:[]};(y=t.face.gear)!=null&&y.enabled&&([u.age,u.gender,u.race]=Jn.execute(u.resize,["age_output","gender_output","race_output"]));let p=await u.gender.data();h.gender=p[0]>p[1]?"male":"female",h.genderScore=Math.round(100*(p[0]>p[1]?p[0]:p[1]))/100;let c=await u.race.data();for(let x=0;x(((A=t.face.gear)==null?void 0:A.minConfidence)||.2)&&h.race.push({score:Math.round(100*c[x])/100,race:A3e[x]});h.race.sort((x,b)=>b.score-x.score);let f=Array.from(await u.age.data()).map((x,b)=>[x3e[b],x]).sort((x,b)=>b[1]-x[1]),g=f[0][0];for(let x=1;xte(u[x])),ZA[r]=h,LC=n,BC=oe(),l(h)}))}var Qe={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function UC(){Qe.tf255=Se(255,"float32"),Qe.tf1=Se(1,"float32"),Qe.tf2=Se(2,"float32"),Qe.tf05=Se(.5,"float32"),Qe.tf127=Se(127.5,"float32"),Qe.rgb=Nt([.2989,.587,.114],"float32")}var yn,jm=[],GC=0,jC=0,QA=Number.MAX_SAFE_INTEGER;async function HC(e){return he.initial&&(yn=null),yn?e.debug&&se("cached model:",yn.modelUrl):yn=await Ge(e.face.ssrnet.modelPathAge),yn}async function ex(e,t,r,n){var i,o,l,u;if(!yn)return{age:0};let a=QA<(((i=t.face.ssrnet)==null?void 0:i.skipFrames)||0),s=(((o=t.face.ssrnet)==null?void 0:o.skipTime)||0)>oe()-jC;return t.skipAllowed&&a&&s&&GC===n&&((l=jm[r])==null?void 0:l.age)&&((u=jm[r])==null?void 0:u.age)>0?(QA++,jm[r]):(QA=0,new Promise(async d=>{if(!(yn!=null&&yn.inputs)||!yn.inputs[0]||!yn.inputs[0].shape)return;let h={};h.resize=Ie.resizeBilinear(e,[yn.inputs[0].shape[2],yn.inputs[0].shape[1]],!1),h.enhance=L(h.resize,Qe.tf255);let p={age:0};if(t.face.ssrnet.enabled&&(h.age=yn.execute(h.enhance)),h.age){let c=await h.age.data();p.age=Math.trunc(10*c[0])/10}Object.keys(h).forEach(c=>te(h[c])),jm[r]=p,GC=n,jC=oe(),d(p)}))}var Qn,Hm=[],XC=0,KC=0,tx=Number.MAX_SAFE_INTEGER,rx=[.2989,.587,.114];async function ZC(e){return he.initial&&(Qn=null),Qn?e.debug&&se("cached model:",Qn.modelUrl):Qn=await Ge(e.face.ssrnet.modelPathGender),Qn}async function nx(e,t,r,n){var i,o,l,u;if(!Qn)return{gender:"unknown",genderScore:0};let a=tx<(((i=t.face.ssrnet)==null?void 0:i.skipFrames)||0),s=(((o=t.face.ssrnet)==null?void 0:o.skipTime)||0)>oe()-KC;return t.skipAllowed&&a&&s&&XC===n&&((l=Hm[r])==null?void 0:l.gender)&&((u=Hm[r])==null?void 0:u.genderScore)>0?(tx++,Hm[r]):(tx=0,new Promise(async d=>{if(!(Qn!=null&&Qn.inputs[0].shape))return;let h={};h.resize=Ie.resizeBilinear(e,[Qn.inputs[0].shape[2],Qn.inputs[0].shape[1]],!1),h.enhance=X(()=>{let[m,f,g]=Yt(h.resize,3,3),y=L(m,rx[0]),A=L(f,rx[1]),x=L(g,rx[2]),b=Pf([y,A,x]);return L(ce(b,Qe.tf05),2)});let p={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(h.gender=Qn.execute(h.enhance));let c=await h.gender.data();p.gender=c[0]>c[1]?"female":"male",p.genderScore=c[0]>c[1]?Math.trunc(100*c[0])/100:Math.trunc(100*c[1])/100,Object.keys(h).forEach(m=>te(h[m])),Hm[r]=p,XC=n,KC=oe(),d(p)}))}var Rr,qm=[],ax=Number.MAX_SAFE_INTEGER,JC=0,QC=0;async function eT(e){var t;return he.initial&&(Rr=null),Rr?e.debug&&se("cached model:",Rr.modelUrl):Rr=await Ge((t=e.face.antispoof)==null?void 0:t.modelPath),Rr}async function sx(e,t,r,n){var i,o;if(!Rr)return 0;let a=(((i=t.face.antispoof)==null?void 0:i.skipTime)||0)>oe()-QC,s=ax<(((o=t.face.antispoof)==null?void 0:o.skipFrames)||0);return t.skipAllowed&&a&&s&&JC===n&&qm[r]?(ax++,qm[r]):(ax=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[Rr!=null&&Rr.inputs[0].shape?Rr.inputs[0].shape[2]:0,Rr!=null&&Rr.inputs[0].shape?Rr.inputs[0].shape[1]:0],!1),d=Rr==null?void 0:Rr.execute(u),h=(await d.data())[0];qm[r]=Math.round(100*h)/100,JC=n,QC=oe(),te([u,d]),l(qm[r])}))}var ea={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]},ix={count:468,mouth:13,symmetryLine:[13,ea.midwayBetweenEyes[0]]},Wl={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},ox=[{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]}],ac=[[.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]],Vl=[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 v3e=[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],w3e=[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],k3e=[33,133,362,263,1,78,308],Swe=v3e.map(e=>ac[e]),Cwe=w3e.map(e=>ac[e]),Twe=k3e.map(e=>ac[e]);function Xi(e){let t=e.map(r=>r[0]);return t.push(e[e.length-1][1]),t}var I3e=[[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]],S3e=[[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]],C3e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],T3e=[[474,475],[475,476],[476,477],[477,474]],N3e=[[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]],E3e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],R3e=[[469,470],[470,471],[471,472],[472,469]],$3e=[[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]],Nwe={lips:Xi(I3e),leftEye:Xi(S3e),leftEyebrow:Xi(C3e),leftIris:Xi(T3e),rightEye:Xi(N3e),rightEyebrow:Xi(E3e),rightIris:Xi(R3e),faceOval:Xi($3e)};var Ud=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],Xm=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],Km=(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],Zm=(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],aT=(e,t)=>{let r=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:r,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},ux=(e,t,r)=>{let n=t.shape[1],a=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/a,e.endPoint[1]/n,e.endPoint[0]/a],i=Ie.cropAndResize(t,[s],[0],r),o=pe(i,Qe.tf255);return te(i),o},Ym=(e,t)=>{let r=Xm(e),n=Ud(e),a=[t*n[0]/2,t*n[1]/2];return{startPoint:[r[0]-a[0],r[1]-a[1]],endPoint:[r[0]+a[0],r[1]+a[1]],landmarks:e.landmarks,confidence:e.confidence}},Jm=e=>{let t=Xm(e),r=Ud(e),n=Math.max(...r)/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}},sT=e=>{let t=e.map(n=>n[0]),r=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...r)],endPoint:[Math.max(...t),Math.max(...r)],landmarks:e}},dx=[[1,0,0],[0,1,0],[0,0,1]],M3e=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),F3e=(e,t)=>M3e(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var rT=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ul=(e,t)=>{let r=0;for(let n=0;n{let r=[];for(let n=0;n{let r=[],n=e.length;for(let a=0;a{let r=Math.cos(e),n=Math.sin(e),a=[[r,-n,0],[n,r,0],[0,0,1]],s=rT(t[0],t[1]),i=nT(s,a),o=rT(-t[0],-t[1]);return nT(i,o)},P3e=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],r=[e[0][2],e[1][2]],n=[-Ul(t[0],r),-Ul(t[1],r)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},O3e=(e,t)=>[Ul(e,t[0]),Ul(e,t[1])];function oT(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},r=[];for(let n=0;n[s[0]/a*(c[0]-a/2),s[1]/a*(c[1]-a/2),c[2]||0]),o=r&&r!==0&&Math.abs(r)>.2,l=o?iT(r,[0,0]):dx,u=o?i.map(c=>[...O3e(c,l),c[2]]):i,d=o?P3e(n):dx,h=Xm(t),p=[Ul(h,d[0]),Ul(h,d[1])];return u.map(c=>[Math.trunc(c[0]+p[0]),Math.trunc(c[1]+p[1]),Math.trunc(c[2]||0)])}function uT(e,t,r,n){let a=t.landmarks.length>=ix.count?ix.symmetryLine:Wl.symmetryLine,s=0,i=dx,o;if(e&&he.kernels.includes("rotatewithoffset"))if(s=F3e(t.landmarks[a[0]],t.landmarks[a[1]]),s&&s!==0&&Math.abs(s)>.2){let u=Xm(t),d=[u[0]/r.shape[2],u[1]/r.shape[1]],h=Ie.rotateWithOffset(r,s,0,d);i=iT(-s,u),o=ux(t,h,[n,n]),te(h)}else o=ux(t,r,[n,n]);else o=ux(t,r,[n,n]);return[s,i,o]}var z3e=e=>{let t=e.map(n=>n[0]),r=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...r)+(Math.max(...r)-Math.min(...r))/2]},dT=(e,t)=>{let r=z3e(e),n=Ud(t);return{startPoint:[r[0]-n[0]/2,r[1]-n[1]/2],endPoint:[r[0]+n[0]/2,r[1]+n[1]/2]}};var pT=6,D3e=1.4,La,hT=null,Ki=0,sc=null,Gd=()=>Ki;async function cT(e){var t;return he.initial&&(La=null),La?e.debug&&se("cached model:",La.modelUrl):La=await Ge((t=e.face.detector)==null?void 0:t.modelPath),Ki=La.inputs[0].shape?La.inputs[0].shape[2]:0,sc=Se(Ki,"int32"),hT=ca(oT(Ki)),La}function L3e(e){let t={};t.boxStarts=_e(e,[0,1],[-1,2]),t.centers=le(t.boxStarts,hT),t.boxSizes=_e(e,[0,3],[-1,2]),t.boxSizesNormalized=pe(t.boxSizes,sc),t.centersNormalized=pe(t.centers,sc),t.halfBoxSize=pe(t.boxSizesNormalized,Qe.tf2),t.starts=ce(t.centersNormalized,t.halfBoxSize),t.ends=le(t.centersNormalized,t.halfBoxSize),t.startNormalized=L(t.starts,sc),t.endNormalized=L(t.ends,sc);let r=xd([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>te(t[n])),r}async function fT(e,t){var o,l,u,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let r={};r.resized=Ie.resizeBilinear(e,[Ki,Ki]),r.div=pe(r.resized,Qe.tf127),r.normalized=ce(r.div,Qe.tf05);let n=La==null?void 0:La.execute(r.normalized);if(Array.isArray(n)&&n.length>2){let h=n.sort((p,c)=>p.size-c.size);r.concat384=St([h[0],h[2]],2),r.concat512=St([h[1],h[3]],2),r.concat=St([r.concat512,r.concat384],1),r.batch=et(r.concat,0)}else Array.isArray(n)?r.batch=et(n[0]):r.batch=et(n);te(n),r.boxes=L3e(r.batch),r.logits=_e(r.batch,[0,0],[-1,1]),r.sigmoid=Tr(r.logits),r.scores=et(r.sigmoid),r.nms=await Ie.nonMaxSuppressionAsync(r.boxes,r.scores,((o=t.face.detector)==null?void 0:o.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((u=t.face.detector)==null?void 0:u.minConfidence)||0);let a=await r.nms.array(),s=[],i=await r.scores.data();for(let h=0;h(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let c={};c.bbox=_e(r.boxes,[a[h],0],[1,-1]),c.slice=_e(r.batch,[a[h],pT-1],[1,-1]),c.squeeze=et(c.slice),c.landmarks=U(c.squeeze,[pT,-1]);let m=await c.bbox.data(),f={startPoint:[m[0],m[1]],endPoint:[m[2],m[3]],landmarks:await c.landmarks.array(),confidence:p},g=aT(f,[(e.shape[2]||0)/Ki,(e.shape[1]||0)/Ki]),y=Ym(g,t.face.scale||D3e),A=Jm(y);s.push(A),Object.keys(c).forEach(x=>te(c[x]))}}return Object.keys(r).forEach(h=>te(r[h])),s}var Qm={};vs(Qm,{connected:()=>cx,kpt:()=>hx});var hx=["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"],cx={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 gT=224,B3e,W3e=5,e1=[8,16,32,32,32];async function yT(){let e=[],t=0;for(;tr.x)),y:Nt(e.map(r=>r.y))}}function ls(e,t=[1,1]){let r=[e.map(o=>o[0]),e.map(o=>o[1])],n=[Math.min(...r[0]),Math.min(...r[1])],a=[Math.max(...r[0]),Math.max(...r[1])],s=[n[0],n[1],a[0]-n[0],a[1]-n[1]],i=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:i}}function AT(e,t=[1,1]){let r=[e.map(u=>u[0]),e.map(u=>u[1])],n=[Math.min(...r[0]),Math.min(...r[1])],a=[Math.max(...r[0]),Math.max(...r[1])],s=[(n[0]+a[0])/2,(n[1]+a[1])/2],i=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+a[0],-s[1]+a[1]),o=[Math.trunc(s[0]-i),Math.trunc(s[1]-i),Math.trunc(2*i),Math.trunc(2*i)],l=[o[0]/t[0],o[1]/t[1],o[2]/t[0],o[3]/t[1]];return{box:o,boxRaw:l}}function t1(e,t){let r=[e[2]*t,e[3]*t];return[e[0]-(r[0]-e[2])/2,e[1]-(r[1]-e[3])/2,r[0],r[1]]}var vT={initial:!0},An={detector:null,landmarks:null},jd={detector:[224,224],landmarks:[256,256]},fx=Number.MAX_SAFE_INTEGER,U3e={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},n1=null,ic,Zi=[[0,0],[0,0],[0,0],[0,0]],xT=0,bT=e=>1-1/(1+Math.exp(e));async function wT(e){if(vT.initial&&(An.detector=null),!An.detector&&e.body.detector&&e.body.detector.modelPath){An.detector=await Ge(e.body.detector.modelPath);let t=Object.values(An.detector.modelSignature.inputs);jd.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,jd.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&An.detector&&se("cached model:",An.detector.modelUrl);return await yT(),An.detector}async function kT(e){if(vT.initial&&(An.landmarks=null),An.landmarks)e.debug&&se("cached model:",An.landmarks.modelUrl);else{An.landmarks=await Ge(e.body.modelPath);let t=Object.values(An.landmarks.modelSignature.inputs);jd.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,jd.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return An.landmarks}async function G3e(e,t){let r={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(ic&&(r.cropped=Ie.cropAndResize(e,[ic],[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],s=[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];Zi=[[0,0],a,s,[0,0]],r.pad=Xn(r.cropped||e,Zi),r.resize=Ie.resizeBilinear(r.pad,[t,t]),n=pe(r.resize,Qe.tf255)}else e.shape[1]!==t?(r.resize=Ie.resizeBilinear(r.cropped||e,[t,t]),n=pe(r.resize,Qe.tf255)):n=pe(r.cropped||e,Qe.tf255);return Object.keys(r).forEach(a=>te(r[a])),n}function j3e(e,t){for(let r of e)r.position=[Math.trunc(r.position[0]*(t[0]+Zi[2][0]+Zi[2][1])/t[0]-Zi[2][0]),Math.trunc(r.position[1]*(t[1]+Zi[1][0]+Zi[1][1])/t[1]-Zi[1][0]),r.position[2]],r.positionRaw=[r.position[0]/t[0],r.position[1]/t[1],2*r.position[2]/(t[0]+t[1])];if(ic)for(let r of e)r.positionRaw=[r.positionRaw[0]+ic[1],r.positionRaw[1]+ic[0],r.positionRaw[2]],r.position=[Math.trunc(r.positionRaw[0]*t[0]),Math.trunc(r.positionRaw[1]*t[1]),r.positionRaw[2]];return e}async function H3e(e){let t=e.find(o=>o.part==="leftPalm"),r=e.find(o=>o.part==="leftWrist"),n=e.find(o=>o.part==="leftIndex");t.position[2]=((r.position[2]||0)+(n.position[2]||0))/2;let a=e.find(o=>o.part==="rightPalm"),s=e.find(o=>o.part==="rightWrist"),i=e.find(o=>o.part==="rightIndex");a.position[2]=((s.position[2]||0)+(i.position[2]||0))/2}async function q3e(e,t,r){var m;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(m=An.landmarks)==null?void 0:m.execute(e,U3e.landmarks);let a=(await n.poseflag.data())[0],s=await n.ld.data(),i=await n.world.data();Object.keys(n).forEach(f=>te(n[f]));let o=[],l=5;for(let f=0;ff.position),h=ls(d,[r[0],r[1]]),p={};for(let[f,g]of Object.entries(cx)){let y=[];for(let A=0;Aw.part===g[A]),b=u.find(w=>w.part===g[A+1]);x&&b&&y.push([x.position,b.position])}p[f]=y}return{id:0,score:Math.trunc(100*a)/100,box:h.box,boxRaw:h.boxRaw,keypoints:u,annotations:p}}async function mx(e,t){let r=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>oe()-xT,a=fx<(t.body.skipFrames||0);if(t.skipAllowed&&n&&a&&n1!==null)fx++;else{let s={};s.landmarks=await G3e(e,256),n1=await q3e(s.landmarks,t,r),Object.keys(s).forEach(i=>te(s[i])),xT=oe(),fx=0}return n1?[n1]:[]}var Hd=[{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 us,Gl=0,gx=[],ST=0,yx=Number.MAX_SAFE_INTEGER;async function CT(e){if(he.initial&&(us=null),us)e.debug&&se("cached model:",us.modelUrl);else{us=await Ge(e.object.modelPath);let t=Object.values(us.modelSignature.inputs);Gl=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return us}async function X3e(e,t,r){if(!e)return[];let n={},a=[],s=await e.array();n.squeeze=et(e);let i=Yt(n.squeeze,6,1);n.stack=ur([i[1],i[0],i[3],i[2]],1),n.boxes=et(n.stack),n.scores=et(i[4]),n.classes=et(i[5]),te([e,...i]),n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.scores,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence||0);let o=await n.nms.data(),l=0;for(let u of Array.from(o)){let d=Math.trunc(100*s[0][u][4])/100,h=s[0][u][5],p=Hd[h].label,[c,m]=[s[0][u][0]/Gl,s[0][u][1]/Gl],f=[c,m,s[0][u][2]/Gl-c,s[0][u][3]/Gl-m],g=[Math.trunc(f[0]*t[0]),Math.trunc(f[1]*t[1]),Math.trunc(f[2]*t[0]),Math.trunc(f[3]*t[1])];a.push({id:l++,score:d,class:h,label:p,box:g,boxRaw:f})}return Object.keys(n).forEach(u=>te(n[u])),a}async function Ax(e,t){let r=(t.object.skipTime||0)>oe()-ST,n=yx<(t.object.skipFrames||0);return t.skipAllowed&&r&&n&&gx.length>0?(yx++,gx):(yx=0,new Promise(async a=>{let s=[e.shape[2]||0,e.shape[1]||0],i=Ie.resizeBilinear(e,[Gl,Gl]),o=t.object.enabled?us==null?void 0:us.execute(i,["tower_0/detections"]):null;ST=oe(),te(i);let l=await X3e(o,s,t);gx=l,a(l)}))}var a1={};vs(a1,{connected:()=>bx,kpt:()=>xx});var xx=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],bx={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $r,NT=0,Yr={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},vx=Number.MAX_SAFE_INTEGER;async function ET(e){return he.initial&&($r=null),$r?e.debug&&se("cached model:",$r.modelUrl):$r=await Ge(e.body.modelPath),$r}async function K3e(e,t){let[r,n]=e.shape,a=U(e,[n*r]),s=yr(a,0),i=(await s.data())[0];if(te([a,s]),i>t){let o=$n(a,0),l=wd(o,r),u=(await l.data())[0],d=pe(o,Se(r,"int32")),h=(await d.data())[0];return te([l,d]),[u,h,i]}return[0,0,i]}async function wx(e,t){let r=(t.body.skipTime||0)>oe()-NT,n=vx<(t.body.skipFrames||0);return t.skipAllowed&&r&&n&&Object.keys(Yr.keypoints).length>0?(vx++,[Yr]):(vx=0,new Promise(async a=>{var h;let s=X(()=>{if(!($r!=null&&$r.inputs[0].shape))return null;let p=Ie.resizeBilinear(e,[$r.inputs[0].shape[2],$r.inputs[0].shape[1]],!1),c=L(p,Qe.tf2);return ce(c,Qe.tf1)}),i;if(t.body.enabled&&(i=$r==null?void 0:$r.execute(s)),NT=oe(),te(s),i){Yr.keypoints.length=0;let p=i.squeeze();te(i);let c=p.unstack(2);te(p);for(let m=0;m(((h=t.body)==null?void 0:h.minConfidence)||0)&&Yr.keypoints.push({score:Math.round(100*y)/100,part:xx[m],positionRaw:[f/$r.inputs[0].shape[2],g/$r.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/$r.inputs[0].shape[2]),Math.round(e.shape[1]*g/$r.inputs[0].shape[1])]})}c.forEach(m=>te(m))}Yr.score=Yr.keypoints.reduce((p,c)=>c.score>p?c.score:p,0);let o=Yr.keypoints.map(p=>p.position[0]),l=Yr.keypoints.map(p=>p.position[1]);Yr.box=[Math.min(...o),Math.min(...l),Math.max(...o)-Math.min(...o),Math.max(...l)-Math.min(...l)];let u=Yr.keypoints.map(p=>p.positionRaw[0]),d=Yr.keypoints.map(p=>p.positionRaw[1]);Yr.boxRaw=[Math.min(...u),Math.min(...d),Math.max(...u)-Math.min(...u),Math.max(...d)-Math.min(...d)];for(let[p,c]of Object.entries(bx)){let m=[];for(let f=0;fA.part===c[f]),y=Yr.keypoints.find(A=>A.part===c[f+1]);g&&y&&g.score>(t.body.minConfidence||0)&&y.score>(t.body.minConfidence||0)&&m.push([g.position,y.position])}Yr.annotations[p]=m}a([Yr])}))}var Z3e=["angry","disgust","fear","happy","sad","surprise","neutral"],Wn,s1=[],$T=0,MT=0,kx=Number.MAX_SAFE_INTEGER;async function FT(e){var t;return he.initial&&(Wn=null),Wn?e.debug&&se("cached model:",Wn.modelUrl):Wn=await Ge((t=e.face.emotion)==null?void 0:t.modelPath),Wn}async function Ix(e,t,r,n){var i,o;if(!Wn)return[];let a=kx<(((i=t.face.emotion)==null?void 0:i.skipFrames)||0),s=(((o=t.face.emotion)==null?void 0:o.skipTime)||0)>oe()-MT;return t.skipAllowed&&s&&a&&$T===n&&s1[r]&&s1[r].length>0?(kx++,s1[r]):(kx=0,new Promise(async l=>{var d,h;let u=[];if((d=t.face.emotion)!=null&&d.enabled){let p={},c=Wn!=null&&Wn.inputs[0].shape?Wn.inputs[0].shape[2]:0;p.resize=Ie.resizeBilinear(e,[c,c],!1),p.channels=L(p.resize,Qe.rgb),p.grayscale=ke(p.channels,3,!0),p.grayscaleSub=ce(p.grayscale,Qe.tf05),p.grayscaleMul=L(p.grayscaleSub,Qe.tf2),p.emotion=Wn==null?void 0:Wn.execute(p.grayscaleMul),MT=oe();let m=await p.emotion.data();for(let f=0;f(((h=t.face.emotion)==null?void 0:h.minConfidence)||0)&&u.push({score:Math.min(.99,Math.trunc(100*m[f])/100),emotion:Z3e[f]});u.sort((f,g)=>g.score-f.score),Object.keys(p).forEach(f=>te(p[f]))}s1[r]=u,$T=n,l(u)}))}var xn,Sx=[],PT=0,OT=0,zT=Number.MAX_SAFE_INTEGER;async function DT(e){return he.initial&&(xn=null),xn?e.debug&&se("cached model:",xn.modelUrl):xn=await Ge(e.face.mobilefacenet.modelPath),xn}async function Cx(e,t,r,n){var i,o;if(!xn)return[];let a=zT<(((i=t.face.embedding)==null?void 0:i.skipFrames)||0),s=(((o=t.face.embedding)==null?void 0:o.skipTime)||0)>oe()-OT;return t.skipAllowed&&s&&a&&PT===n&&Sx[r]?(zT++,Sx[r]):new Promise(async l=>{var d;let u=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(xn==null?void 0:xn.inputs[0].shape)){let h={};h.crop=Ie.resizeBilinear(e,[xn.inputs[0].shape[2],xn.inputs[0].shape[1]],!1),h.data=xn==null?void 0:xn.execute(h.crop);let p=await h.data.data();u=Array.from(p)}Sx[r]=u,PT=n,OT=oe(),l(u)})}var ds,Yi=0,Y3e=2.3,Tx=ea.leftEyeLower0,Nx=ea.rightEyeLower0,qd={leftBounds:[Tx[0],Tx[Tx.length-1]],rightBounds:[Nx[0],Nx[Nx.length-1]]},Xd={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function UT(e){var t;return he.initial&&(ds=null),ds?e.debug&&se("cached model:",ds.modelUrl):ds=await Ge((t=e.face.iris)==null?void 0:t.modelPath),Yi=ds.inputs[0].shape?ds.inputs[0].shape[2]:0,Yi===-1&&(Yi=64),ds}function i1(e,t,r,n){for(let a=0;a{let t=e[qd.leftBounds[0]][2],r=e[qd.rightBounds[0]][2];return t-r},BT=(e,t,r,n,a,s=!1)=>{let i=Jm(Ym(sT([e[r],e[n]]),Y3e)),o=Ud(i),l=Ie.cropAndResize(t,[[i.startPoint[1]/a,i.startPoint[0]/a,i.endPoint[1]/a,i.endPoint[0]/a]],[0],[Yi,Yi]);if(s&&he.kernels.includes("flipleftright")){let u=Ie.flipLeftRight(l);te(l),l=u}return{box:i,boxSize:o,crop:l}},WT=(e,t,r,n=!1)=>{let a=[];for(let s=0;s{let n=e[ea[`${r}EyeUpper0`][Xd.upperCenter]][2],a=e[ea[`${r}EyeLower0`][Xd.lowerCenter]][2],s=(n+a)/2;return t.map((i,o)=>{let l=s;return o===2?l=n:o===4&&(l=a),[i[0],i[1],l]})};async function GT(e,t,r,n){if(!ds)return r.debug&&se("face mesh iris detection requested, but model is not loaded"),e;let{box:a,boxSize:s,crop:i}=BT(e,t,qd.leftBounds[0],qd.leftBounds[1],n,!0),{box:o,boxSize:l,crop:u}=BT(e,t,qd.rightBounds[0],qd.rightBounds[1],n,!0),d=St([i,u]);te(i),te(u);let h=ds.execute(d);te(d);let p=await h.data();te(h);let c=p.slice(0,Xd.numCoordinates*3),{rawCoords:m,iris:f}=WT(c,a,s,!0),g=p.slice(Xd.numCoordinates*3),{rawCoords:y,iris:A}=WT(g,o,l,!1),x=J3e(e);Math.abs(x)<30?(i1(e,m,"left",null),i1(e,y,"right",null)):x<1?i1(e,m,"left",["EyeUpper0","EyeLower0"]):i1(e,y,"right",["EyeUpper0","EyeLower0"]);let b=VT(e,f,"left"),w=VT(e,A,"right");return e.concat(b).concat(w)}var Q3e=[[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]],e5e=[[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]],t5e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],r5e=[[474,475],[475,476],[476,477],[477,474]],n5e=[[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]],a5e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],s5e=[[469,470],[470,471],[471,472],[472,469]],i5e=[[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 Ji(e){let t=e.map(r=>r[0]);return t.push(e[e.length-1][1]),t}var o5e={lips:Ji(Q3e),leftEye:Ji(e5e),leftEyebrow:Ji(t5e),leftIris:Ji(r5e),rightEye:Ji(n5e),rightEyebrow:Ji(a5e),rightIris:Ji(s5e),faceOval:Ji(i5e)},l5e=Object.entries(o5e).map(([e,t])=>t.map(r=>[r,e])).flat(),n8e=new Map(l5e),oc=[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],jl=[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],Hl=[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 qT(e,t){let r={lips:await t.filter(s=>s.size===160)[0].data(),irisL:await t.filter(s=>s.size===10)[0].data(),eyeL:await t.filter(s=>s.size===142)[0].data(),irisR:await t.filter(s=>s.size===10)[1].data(),eyeR:await t.filter(s=>s.size===142)[1].data()},n=jl.reduce((s,i)=>s+=e[i][2],0)/jl.length;for(let s=0;ss+=e[i][2],0)/Hl.length;for(let s=0;soe()-Ba.timestamp,n=Ba.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!r||!n||Ba.boxes.length===0?(Ba.boxes=await fT(e,t),Ba.timestamp=oe(),Ba.skipped=0):Ba.skipped++;let a=[],s=[],i=0;for(let A=0;AP.shape[P.shape.length-1]===1),R=T.find(P=>P.shape[P.shape.length-1]===1404),O=await E.data();I.faceScore=Math.round(100*O[0])/100;let $=U(R,[-1,3]),S=await $.array();if(I.faceScore<(((c=t.face.detector)==null?void 0:c.minConfidence)||1)){if(x.confidence=I.faceScore,(m=t.face.mesh)!=null&&m.keepInvalid){I.box=Km(x,e),I.boxRaw=Zm(x,e),I.score=I.boxScore,I.mesh=x.landmarks.map(P=>[(x.startPoint[0]+x.endPoint[0])/2+(x.endPoint[0]+x.startPoint[0])*P[0]/Gd(),(x.startPoint[1]+x.endPoint[1])/2+(x.endPoint[1]+x.startPoint[1])*P[1]/Gd()]),I.meshRaw=I.mesh.map(P=>[P[0]/(e.shape[2]||0),P[1]/(e.shape[1]||0),(P[2]||0)/ql]);for(let P of Object.keys(Wl))I.annotations[P]=[I.mesh[Wl[P]]]}}else{(f=t.face.attention)!=null&&f.enabled?S=await qT(S,T):(g=t.face.iris)!=null&&g.enabled&&(S=await GT(S,I.tensor,t,ql)),I.mesh=lT(S,x,b,w,ql),I.meshRaw=I.mesh.map(z=>[z[0]/(e.shape[2]||0),z[1]/(e.shape[1]||0),(z[2]||0)/ql]);for(let z of Object.keys(ea))I.annotations[z]=ea[z].map(j=>I.mesh[j]);I.score=I.faceScore;let P={...dT(I.mesh,x),confidence:x.confidence,landmarks:x.landmarks};I.box=Km(P,e),I.boxRaw=Zm(P,e),s.push(P)}te([...T,$])}else{I.box=Km(x,e),I.boxRaw=Zm(x,e),I.score=I.boxScore,I.mesh=x.landmarks.map(T=>[(x.startPoint[0]+x.endPoint[0])/2+(x.endPoint[0]+x.startPoint[0])*T[0]/Gd(),(x.startPoint[1]+x.endPoint[1])/2+(x.endPoint[1]+x.startPoint[1])*T[1]/Gd()]),I.meshRaw=I.mesh.map(T=>[T[0]/(e.shape[2]||0),T[1]/(e.shape[1]||0),(T[2]||0)/ql]);for(let T of Object.keys(Wl))I.annotations[T]=[I.mesh[Wl[T]]]}I.score>(((y=t.face.detector)==null?void 0:y.minConfidence)||1)?a.push(I):te(I.tensor)}return Ba.boxes=s,a}async function KT(e){var t,r,n,a,s,i;return he.initial&&(Mr=null),((r=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:r.enabled)&&(Mr==null?void 0:Mr.signature)&&Object.keys(((n=Mr==null?void 0:Mr.signature)==null?void 0:n.outputs)||{}).length<6&&(Mr=null),Mr?e.debug&&se("cached model:",Mr.modelUrl):(a=e.face.attention)!=null&&a.enabled?Mr=await Ge((s=e.face.attention)==null?void 0:s.modelPath):Mr=await Ge((i=e.face.mesh)==null?void 0:i.modelPath),ql=Mr.inputs[0].shape?Mr.inputs[0].shape[2]:0,Mr}var ZT=Vl,YT=ac;var bn,o1=[],JT=0,QT=0,Rx=Number.MAX_SAFE_INTEGER;async function eN(e){var t;return he.initial&&(bn=null),bn?e.debug&&se("cached model:",bn.modelUrl):bn=await Ge((t=e.face.description)==null?void 0:t.modelPath),bn}function $x(e){let t=e.image||e.tensor||e;if(!(bn!=null&&bn.inputs[0].shape))return t;let r=Ie.resizeBilinear(t,[bn.inputs[0].shape[2],bn.inputs[0].shape[1]],!1),n=L(r,Qe.tf255);return te(r),n}async function Mx(e,t,r,n){var i,o,l,u;if(!bn)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let a=Rx<(((i=t.face.description)==null?void 0:i.skipFrames)||0),s=(((o=t.face.description)==null?void 0:o.skipTime)||0)>oe()-JT;return t.skipAllowed&&a&&s&&QT===n&&((l=o1[r])==null?void 0:l.age)&&((u=o1[r])==null?void 0:u.age)>0?(Rx++,o1[r]):(Rx=0,new Promise(async d=>{var p,c;let h={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((p=t.face.description)!=null&&p.enabled){let m=$x(e),f=bn==null?void 0:bn.execute(m);JT=oe(),te(m);let y=await(await f.find(R=>R.shape[1]===1)).data(),A=Math.trunc(200*Math.abs(y[0]-.5))/100;A>(((c=t.face.description)==null?void 0:c.minConfidence)||0)&&(h.gender=y[0]<=.5?"female":"male",h.genderScore=Math.min(.99,A));let x=$n(f.find(R=>R.shape[1]===100),1),b=(await x.data())[0];te(x);let I=await f.find(R=>R.shape[1]===100).data();h.age=Math.round(I[b-1]>I[b+1]?10*b-100*I[b-1]:10*b+100*I[b+1])/10;let T=f.find(R=>R.shape[1]===1024),E=T?await T.data():[];h.descriptor=Array.from(E),f.forEach(R=>te(R))}o1[r]=h,QT=n,d(h)}))}function l1(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function lc(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function nN(e,t,r){let n=t.shape[1],a=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/a,e.endPoint[1]/n,e.endPoint[0]/a]];return Ie.cropAndResize(t,s,[0],r)}function aN(e,t){let r=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],a=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:r,endPoint:n,palmLandmarks:a,confidence:e.confidence}}function u1(e,t=1.5){let r=lc(e),n=l1(e),a=[t*n[0]/2,t*n[1]/2],s=[r[0]-a[0],r[1]-a[1]],i=[r[0]+a[0],r[1]+a[1]];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function d1(e){let t=lc(e),r=l1(e),a=Math.max(...r)/2,s=[t[0]-a,t[1]-a],i=[t[0]+a,t[1]+a];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function d5e(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function sN(e,t){let r=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return d5e(r)}var tN=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Qi(e,t){let r=0;for(let n=0;n[r.x,r.y]),this.anchorsTensor=ca(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=Nt([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Nt([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let r={};r.boxOffsets=_e(t,[0,0],[-1,2]),r.boxSizes=_e(t,[0,2],[-1,2]),r.div=pe(r.boxOffsets,this.inputSizeTensor),r.boxCenterPoints=le(r.div,this.anchorsTensor),r.halfBoxSizes=pe(r.boxSizes,this.doubleInputSizeTensor),r.sub=ce(r.boxCenterPoints,r.halfBoxSizes),r.startPoints=L(r.sub,this.inputSizeTensor),r.add=le(r.boxCenterPoints,r.halfBoxSizes),r.endPoints=L(r.add,this.inputSizeTensor);let n=xd([r.startPoints,r.endPoints],1);return Object.keys(r).forEach(a=>te(r[a])),n}normalizeLandmarks(t,r){let n={};n.reshape=U(t,[-1,7,2]),n.div=pe(n.reshape,this.inputSizeTensor),n.landmarks=le(n.div,this.anchors[r]);let a=L(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>te(n[s])),a}async predict(t,r){let n={};n.resize=Ie.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=pe(n.resize,Qe.tf127),n.image=ce(n.div,Qe.tf1),n.batched=this.model.execute(n.image),n.predictions=et(n.batched),n.slice=_e(n.predictions,[0,0],[-1,1]),n.sigmoid=Tr(n.slice),n.scores=et(n.sigmoid);let a=await n.scores.data();n.boxes=_e(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await Ie.nonMaxSuppressionAsync(n.norm,n.scores,3*r.hand.maxDetected,r.hand.iouThreshold,r.hand.minConfidence);let s=await n.nms.array(),i=[];for(let o of s){let l={};l.box=_e(n.norm,[o,0],[1,-1]),l.slice=_e(n.predictions,[o,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,o),l.palmLandmarks=U(l.norm,[-1,2]);let u=await l.box.data(),d=u.slice(0,2),h=u.slice(2,4),p=await l.palmLandmarks.array(),c={startPoint:d,endPoint:h,palmLandmarks:p,confidence:a[o]},m=aN(c,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);i.push(m),Object.keys(l).forEach(f=>te(l[f]))}return Object.keys(n).forEach(o=>te(n[o])),i}};var f5e=5,uN=1.65,dN=[0,5,9,13,17,1,2],m5e=0,g5e=2,pN=0,h1=class{constructor(t,r){fe(this,"handDetector");fe(this,"handPoseModel");fe(this,"inputSize");fe(this,"storedBoxes");fe(this,"skipped");fe(this,"detectedHands");this.handDetector=t,this.handPoseModel=r,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let r=t.map(i=>i[0]),n=t.map(i=>i[1]),a=[Math.min(...r),Math.min(...n)],s=[Math.max(...r),Math.max(...n)];return{startPoint:a,endPoint:s}}getBoxForPalmLandmarks(t,r){let n=t.map(s=>Px([...s,1],r)),a=this.calculateLandmarksBoundingBox(n);return u1(d1(a),f5e)}getBoxForHandLandmarks(t){let r=this.calculateLandmarksBoundingBox(t),n=u1(d1(r),uN);n.palmLandmarks=[];for(let a=0;a[i[0]*(c[0]-this.inputSize/2),i[1]*(c[1]-this.inputSize/2),i[2]*c[2]]),l=_x(n,[0,0]),u=o.map(c=>[...Px(c,l),c[2]]),d=iN(a),h=[...lc(r),1],p=[Qi(h,d[0]),Qi(h,d[1])];return u.map(c=>[Math.trunc(c[0]+p[0]),Math.trunc(c[1]+p[1]),Math.trunc(c[2])])}async estimateHands(t,r){let n=!1,a,s=(r.hand.skipTime||0)>oe()-pN,i=this.skipped<(r.hand.skipFrames||0);r.skipAllowed&&s&&i&&(a=await this.handDetector.predict(t,r),this.skipped=0),r.skipAllowed&&this.skipped++,a&&a.length>0&&(a.length!==this.detectedHands&&this.detectedHands!==r.hand.maxDetected||!r.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...a],this.storedBoxes.length>0&&(n=!0));let o=[];for(let l=0;l=r.hand.minConfidence/4){let w=U(x,[-1,3]),I=await w.array();te(x),te(w);let T=this.transformRawCoords(I,f,d,m),E=this.getBoxForHandLandmarks(T);this.storedBoxes[l]={...E,confidence:b};let R={landmarks:T,confidence:b,boxConfidence:u.confidence,fingerConfidence:b,box:{topLeft:E.startPoint,bottomRight:E.endPoint}};o.push(R)}else this.storedBoxes[l]=null;te(x)}else{let d=u1(d1(u),uN),h={confidence:u.confidence,boxConfidence:u.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};o.push(h)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=o.length,o.length>r.hand.maxDetected&&(o.length=r.hand.maxDetected),o}};var Jr={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=>Jr.nameMapping[e],getPoints:e=>Jr.pointsMapping[e]},to={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>to.nameMapping[e]},Bt={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=>Bt.nameMapping[e]},eo=class{constructor(t){fe(this,"name");fe(this,"curls");fe(this,"directions");fe(this,"weights");fe(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,r,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([r,n])}direction(t,r,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([r,n])}weight(t,r){this.weights[t]=r;let n=this.weights.reduce((a,s)=>a+s,0);this.weightsRelative=this.weights.map(a=>a*5/n)}matchAgainst(t,r){let n=0;for(let a in t){let s=t[a],i=this.curls[a];if(typeof i=="undefined"){n+=this.weightsRelative[a];continue}for(let[o,l]of i)if(s===o){n+=l*this.weightsRelative[a];break}}for(let a in r){let s=r[a],i=this.directions[a];if(typeof i=="undefined"){n+=this.weightsRelative[a];continue}for(let[o,l]of i)if(s===o){n+=l*this.weightsRelative[a];break}}return n/10}};var{thumb:wa,index:ps,middle:hs,ring:Xl,pinky:Kl}=Jr,{none:ka,half:A5e,full:Ia}=to,{verticalUp:Kd,verticalDown:A8e,horizontalLeft:Ox,horizontalRight:x5e,diagonalUpRight:b5e,diagonalUpLeft:Zd,diagonalDownRight:x8e,diagonalDownLeft:b8e}=Bt,ro=new eo("thumbs up");ro.curl(wa,ka,1);ro.direction(wa,Kd,1);ro.direction(wa,Zd,.25);ro.direction(wa,b5e,.25);for(let e of[Jr.index,Jr.middle,Jr.ring,Jr.pinky])ro.curl(e,Ia,1),ro.direction(e,Ox,1),ro.direction(e,x5e,1);var tr=new eo("victory");tr.curl(wa,A5e,.5);tr.curl(wa,ka,.5);tr.direction(wa,Kd,1);tr.direction(wa,Zd,1);tr.curl(ps,ka,1);tr.direction(ps,Kd,.75);tr.direction(ps,Zd,1);tr.curl(hs,ka,1);tr.direction(hs,Kd,1);tr.direction(hs,Zd,.75);tr.curl(Xl,Ia,1);tr.direction(Xl,Kd,.2);tr.direction(Xl,Zd,1);tr.direction(Xl,Ox,.2);tr.curl(Kl,Ia,1);tr.direction(Kl,Kd,.2);tr.direction(Kl,Zd,1);tr.direction(Kl,Ox,.2);tr.weight(ps,2);tr.weight(hs,2);var no=new eo("point");no.curl(wa,Ia,1);no.curl(ps,ka,.5);no.curl(hs,Ia,.5);no.curl(Xl,Ia,.5);no.curl(Kl,Ia,.5);no.weight(ps,2);no.weight(hs,2);var ao=new eo("middle finger");ao.curl(wa,ka,1);ao.curl(ps,Ia,.5);ao.curl(hs,Ia,.5);ao.curl(Xl,Ia,.5);ao.curl(Kl,Ia,.5);ao.weight(ps,2);ao.weight(hs,2);var Yd=new eo("open palm");Yd.curl(wa,ka,.75);Yd.curl(ps,ka,.75);Yd.curl(hs,ka,.75);Yd.curl(Xl,ka,.75);Yd.curl(Kl,ka,.75);var hN=[ro,tr,no,ao,Yd];var v5e=.7,Zl={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 cN(e,t,r,n){let a=(t-n)/(e-r),s=Math.atan(a)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function mN(e,t){if(!e||!t)return[0,0];let r=cN(e[0],e[1],t[0],t[1]);if(e.length===2)return r;let n=cN(e[1],e[2],t[1],t[2]);return[r,n]}function fN(e,t=1){let r=0,n=0,a=0;return e>=75&&e<=105?r=1*t:e>=25&&e<=155?n=1*t:a=1*t,[r,n,a]}function w5e(e,t,r){let n=e[0]-t[0],a=e[0]-r[0],s=t[0]-r[0],i=e[1]-t[1],o=e[1]-r[1],l=t[1]-r[1],u=e[2]-t[2],d=e[2]-r[2],h=t[2]-r[2],p=Math.sqrt(n*n+i*i+u*u),c=Math.sqrt(a*a+o*o+d*d),m=Math.sqrt(s*s+l*l+h*h),f=(m*m+p*p-c*c)/(2*m*p);f>1?f=1:f<-1&&(f=-1);let g=Math.acos(f);g=57.2958*g%180;let y;return g>Zl.NO_CURL_START_LIMIT?y=to.none:g>Zl.HALF_CURL_START_LIMIT?y=to.half:y=to.full,y}function gN(e,t,r,n){let a;return n===Math.abs(e)?e>0?a=Bt.horizontalLeft:a=Bt.horizontalRight:n===Math.abs(t)?t>0?a=Bt.horizontalLeft:a=Bt.horizontalRight:r>0?a=Bt.horizontalLeft:a=Bt.horizontalRight,a}function yN(e,t,r,n){let a;return n===Math.abs(e)?e<0?a=Bt.verticalDown:a=Bt.verticalUp:n===Math.abs(t)?t<0?a=Bt.verticalDown:a=Bt.verticalUp:r<0?a=Bt.verticalDown:a=Bt.verticalUp,a}function k5e(e,t,r,n,a,s,i,o){let l,u=yN(e,t,r,n),d=gN(a,s,i,o);return u===Bt.verticalUp?d===Bt.horizontalLeft?l=Bt.diagonalUpLeft:l=Bt.diagonalUpRight:d===Bt.horizontalLeft?l=Bt.diagonalDownLeft:l=Bt.diagonalDownRight,l}function I5e(e,t,r,n){let a=e[0]-t[0],s=e[0]-r[0],i=t[0]-r[0],o=e[1]-t[1],l=e[1]-r[1],u=t[1]-r[1],d=Math.max(Math.abs(a),Math.abs(s),Math.abs(i)),h=Math.max(Math.abs(o),Math.abs(l),Math.abs(u)),p=0,c=0,m=0,f=h/(d+1e-5);f>1.5?p+=Zl.DISTANCE_VOTE_POWER:f>.66?c+=Zl.DISTANCE_VOTE_POWER:m+=Zl.DISTANCE_VOTE_POWER;let g=Math.sqrt(a*a+o*o),y=Math.sqrt(s*s+l*l),A=Math.sqrt(i*i+u*u),x=Math.max(g,y,A),b=e[0],w=e[1],I=r[0],T=r[1];x===g?(I=r[0],T=r[1]):x===A&&(b=t[0],w=t[1]);let O=mN([b,w],[I,T]),$=fN(O,Zl.TOTAL_ANGLE_VOTE_POWER);p+=$[0],c+=$[1],m+=$[2];for(let P of n){let z=fN(P,Zl.SINGLE_ANGLE_VOTE_POWER);p+=z[0],c+=z[1],m+=z[2]}let S;return p===Math.max(p,c,m)?S=yN(l,o,u,h):m===Math.max(c,m)?S=gN(s,a,i,d):S=k5e(l,o,u,h,s,a,i,d),S}function AN(e){let t=[],r=[],n=[],a=[];if(!e)return{curls:n,directions:a};for(let s of Jr.all){let i=Jr.getPoints(s),o=[],l=[];for(let u of i){let d=e[u[0]],h=e[u[1]],p=mN(d,h),c=p[0],m=p[1];o.push(c),l.push(m)}t.push(o),r.push(l)}for(let s of Jr.all){let i=s===Jr.thumb?1:0,o=Jr.getPoints(s),l=e[o[i][0]],u=e[o[i+1][1]],d=e[o[3][1]],h=w5e(l,u,d),p=I5e(l,u,d,t[s].slice(i));n[s]=h,a[s]=p}return{curls:n,directions:a}}function c1(e){if(!e||e.length===0)return null;let t=AN(e),r={};for(let n of Jr.all)r[Jr.getName(n)]={curl:to.getName(t.curls[n]),direction:Bt.getName(t.directions[n])};return r}function xN(e){let t=[];if(!e||e.length===0)return t;let r=AN(e);for(let n of hN){let a=n.matchAgainst(r.curls,r.directions);a>=v5e&&t.push({name:n.name,confidence:a})}return t}var bN={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]},Jd,Qd,vN;async function Dx(e,t){let r=await vN.estimateHands(e,t);if(!r)return[];let n=[];for(let a=0;ar[a].landmarks[h]);let i=r[a].landmarks,o=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(i&&i.length>0){for(let d of i)d[0]o[2]&&(o[2]=d[0]),d[1]>o[3]&&(o[3]=d[1]);o[2]-=o[0],o[3]-=o[1],l=[o[0]/(e.shape[2]||0),o[1]/(e.shape[1]||0),o[2]/(e.shape[2]||0),o[3]/(e.shape[1]||0)]}else o=r[a].box?[Math.trunc(Math.max(0,r[a].box.topLeft[0])),Math.trunc(Math.max(0,r[a].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,r[a].box.bottomRight[0])-Math.max(0,r[a].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,r[a].box.bottomRight[1])-Math.max(0,r[a].box.topLeft[1]))]:[0,0,0,0],l=[r[a].box.topLeft[0]/(e.shape[2]||0),r[a].box.topLeft[1]/(e.shape[1]||0),(r[a].box.bottomRight[0]-r[a].box.topLeft[0])/(e.shape[2]||0),(r[a].box.bottomRight[1]-r[a].box.topLeft[1])/(e.shape[1]||0)];let u=c1(i);n.push({id:a,score:Math.round(100*r[a].confidence)/100,boxScore:Math.round(100*r[a].boxConfidence)/100,fingerScore:Math.round(100*r[a].fingerConfidence)/100,label:"hand",box:o,boxRaw:l,keypoints:i,annotations:s,landmarks:u})}return n}async function Lx(e){var r,n;he.initial&&(Jd=null,Qd=null),!Jd||!Qd?[Jd,Qd]=await Promise.all([e.hand.enabled?Ge((r=e.hand.detector)==null?void 0:r.modelPath):null,e.hand.landmarks?Ge((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&se("cached model:",Jd.modelUrl),e.debug&&se("cached model:",Qd.modelUrl));let t=new p1(Jd);return vN=new h1(t,Qd),[Jd,Qd]}var pr=[null,null],S5e=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],so=[[0,0],[0,0]],C5e=["hand","fist","pinch","point","face","tip","pinchtip"],kN=4,IN=1.6,T5e=512,N5e=1.4,f1=Number.MAX_SAFE_INTEGER,Bx=0,cs=[0,0],Ht={boxes:[],hands:[]},SN={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 CN(e){var t;if(he.initial&&(pr[0]=null),pr[0])e.debug&&se("cached model:",pr[0].modelUrl);else{m1(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),pr[0]=await Ge((t=e.hand.detector)==null?void 0:t.modelPath);let r=Object.values(pr[0].modelSignature.inputs);so[0][0]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[1].size):0,so[0][1]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[2].size):0}return pr[0]}async function TN(e){var t;if(he.initial&&(pr[1]=null),pr[1])e.debug&&se("cached model:",pr[1].modelUrl);else{pr[1]=await Ge((t=e.hand.skeleton)==null?void 0:t.modelPath);let r=Object.values(pr[1].modelSignature.inputs);so[1][0]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[1].size):0,so[1][1]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[2].size):0}return pr[1]}async function E5e(e,t){let r=[];if(!e||!pr[0])return r;let n={},a=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,T5e),i=Math.round(s*a/8)*8;n.resize=Ie.resizeBilinear(e,[s,i]),n.cast=me(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await pr[0].executeAsync(n.cast,S5e),n.boxes=et(n.rawBoxes,[0,2]),n.scores=et(n.rawScores,[0]);let o=an(n.scores,1);te(o[kN]),o.splice(kN,1),n.filtered=ur(o,1),te(o),n.max=yr(n.filtered,1),n.argmax=$n(n.filtered,1);let l=0;n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let u=await n.nms.data(),d=await n.max.data(),h=await n.argmax.data();for(let p of Array.from(u)){let c=_e(n.boxes,p,1),m=await c.data();te(c);let f=[m[1],m[0],m[3]-m[1],m[2]-m[0]],g=t1(f,N5e),y=[Math.trunc(f[0]*cs[0]),Math.trunc(f[1]*cs[1]),Math.trunc(f[2]*cs[0]),Math.trunc(f[3]*cs[1])],A=d[p],x=C5e[h[p]],b={id:l++,score:A,box:y,boxRaw:g,label:x};r.push(b)}return Object.keys(n).forEach(p=>te(n[p])),r.sort((p,c)=>c.score-p.score),r.length>(t.hand.maxDetected||1)&&(r.length=t.hand.maxDetected||1),r}async function Wx(e,t,r){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&&pr[1]&&r.hand.landmarks&&t.score>(r.hand.minConfidence||0)){let a={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];a.crop=Ie.cropAndResize(e,[s],[0],[so[1][0],so[1][1]],"bilinear"),a.div=pe(a.crop,Qe.tf255),[a.score,a.keypoints]=pr[1].execute(a.div,["Identity_1","Identity"]);let i=(await a.score.data())[0],o=(100-Math.trunc(100/(1+Math.exp(i))))/100;if(o>=(r.hand.minConfidence||0)){n.fingerScore=o,a.reshaped=U(a.keypoints,[-1,3]);let d=(await a.reshaped.array()).map(h=>[h[0]/so[1][1],h[1]/so[1][0],h[2]||0]).map(h=>[h[0]*t.boxRaw[2],h[1]*t.boxRaw[3],h[2]||0]);n.keypoints=d.map(h=>[cs[0]*(h[0]+t.boxRaw[0]),cs[1]*(h[1]+t.boxRaw[1]),h[2]||0]),n.landmarks=c1(n.keypoints);for(let h of Object.keys(SN))n.annotations[h]=SN[h].map(p=>n.landmarks&&n.keypoints[p]?n.keypoints[p]:null)}Object.keys(a).forEach(l=>te(a[l]))}return n}async function Vx(e,t){var a,s;if(!pr[0]||!pr[1]||!((a=pr[0])!=null&&a.inputs[0].shape)||!((s=pr[1])!=null&&s.inputs[0].shape))return[];cs=[e.shape[2]||0,e.shape[1]||0],f1++;let r=(t.hand.skipTime||0)>oe()-Bx,n=f1<(t.hand.skipFrames||0);return t.skipAllowed&&r&&n?Ht.hands:new Promise(async i=>{let o=3*(t.hand.skipTime||0)>oe()-Bx,l=f1<3*(t.hand.skipFrames||0);t.skipAllowed&&Ht.hands.length===t.hand.maxDetected?Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))):t.skipAllowed&&o&&l&&Ht.hands.length>0?Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))):(Ht.boxes=await E5e(e,t),Bx=oe(),Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))),f1=0);let u=[...Ht.boxes];if(Ht.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&h.box[3]/(e.shape[1]||1)>.05&&Ht.hands[d].fingerScore&&Ht.hands[d].fingerScore>(t.hand.minConfidence||0)){let p=t1(h.box,IN),c=t1(h.boxRaw,IN);Ht.boxes.push({...u[d],box:p,boxRaw:c})}}for(let d=0;doe()-RN,s=Ux<(((o=t.face.liveness)==null?void 0:o.skipFrames)||0);return t.skipAllowed&&a&&s&&EN===n&&g1[r]?(Ux++,g1[r]):(Ux=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[Fr!=null&&Fr.inputs[0].shape?Fr.inputs[0].shape[2]:0,Fr!=null&&Fr.inputs[0].shape?Fr.inputs[0].shape[1]:0],!1),d=Fr==null?void 0:Fr.execute(u),h=(await d.data())[0];g1[r]=Math.round(100*h)/100,EN=n,RN=oe(),te([u,d]),l(g1[r])}))}var uc={};vs(uc,{connected:()=>A1,horizontal:()=>jx,kpt:()=>y1,relative:()=>qx,vertical:()=>Hx});var y1=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],jx=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Hx=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],qx=[[["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 FN=.005,vn={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function Xx(e){for(let t of jx){let r=e.keypoints.findIndex(a=>a.part===t[0]),n=e.keypoints.findIndex(a=>a.part===t[1]);if(e.keypoints[r]&&e.keypoints[n]&&e.keypoints[r].position[0]a&&a.part===t[0]),n=e.keypoints.findIndex(a=>a&&a.part===t[1]);e.keypoints[r]&&e.keypoints[n]&&e.keypoints[r].position[1]u&&u.part===t[0]),a=e.keypoints.findIndex(u=>u&&u.part===t[1]),s=e.keypoints.findIndex(u=>u&&u.part===r[0]),i=e.keypoints.findIndex(u=>u&&u.part===r[1]);if(!e.keypoints[s]||!e.keypoints[i])continue;let o=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[i].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[a]?[Math.abs(e.keypoints[i].position[0]-e.keypoints[a].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[a].position[0])]:[0,0];if(o[0]>o[1]||l[0]>l[1]){let u=e.keypoints[n];e.keypoints[n]=e.keypoints[a],e.keypoints[a]=u}}}function _N(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]],r.pad=Xn(e,vn.padding),r.resize=Ie.resizeBilinear(r.pad,[t,t]);let n=me(r.resize,"int32");return Object.keys(r).forEach(a=>te(r[a])),n}function ON(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+vn.padding[2][0]+vn.padding[2][1])/t[0]-vn.padding[2][0],n.position[1]*(t[1]+vn.padding[1][0]+vn.padding[1][1])/t[1]-vn.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let r=ls(e.keypoints.map(n=>n.position),t);return e.box=r.box,e.boxRaw=r.boxRaw,e}var wn,x1=0,Kx=Number.MAX_SAFE_INTEGER,Yl={boxes:[],bodies:[],last:0};async function zN(e){return he.initial&&(wn=null),wn?e.debug&&se("cached model:",wn.modelUrl):(m1(["size"],e),wn=await Ge(e.body.modelPath)),x1=wn.inputs[0].shape?wn.inputs[0].shape[2]:0,x1<64&&(x1=256),wn}async function $5e(e,t,r){let n=e[0][0],a=[],s=0;for(let d=0;dt.body.minConfidence){let h=[n[d][1],n[d][0]];a.push({score:Math.round(100*s)/100,part:y1[d],positionRaw:h,position:[Math.round((r.shape[2]||0)*h[0]),Math.round((r.shape[1]||0)*h[1])]})}s=a.reduce((d,h)=>h.score>d?h.score:d,0);let i=[],o=ls(a.map(d=>d.position),[r.shape[2],r.shape[1]]),l={};for(let[d,h]of Object.entries(A1)){let p=[];for(let c=0;cg.part===h[c]),f=a.find(g=>g.part===h[c+1]);m&&f&&m.score>(t.body.minConfidence||0)&&f.score>(t.body.minConfidence||0)&&p.push([m.position,f.position])}l[d]=p}let u={id:0,score:s,box:o.box,boxRaw:o.boxRaw,keypoints:a,annotations:l};return Xx(u),i.push(u),i}async function M5e(e,t,r){let n=[];for(let a=0;at.body.minConfidence){let o=[];for(let h=0;h<17;h++){let p=s[3*h+2];if(p>t.body.minConfidence){let c=[s[3*h+1],s[3*h+0]];o.push({part:y1[h],score:Math.round(100*p)/100,positionRaw:c,position:[Math.round((r.shape[2]||0)*c[0]),Math.round((r.shape[1]||0)*c[1])]})}}let l=ls(o.map(h=>h.position),[r.shape[2],r.shape[1]]),u={};for(let[h,p]of Object.entries(A1)){let c=[];for(let m=0;my.part===p[m]),g=o.find(y=>y.part===p[m+1]);f&&g&&f.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&c.push([f.position,g.position])}u[h]=c}let d={id:a,score:i,box:l.box,boxRaw:l.boxRaw,keypoints:[...o],annotations:u};Xx(d),n.push(d)}}return n.sort((a,s)=>s.score-a.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function Zx(e,t){if(!wn||!(wn!=null&&wn.inputs[0].shape))return[];t.skipAllowed||(Yl.boxes.length=0),Kx++;let r=(t.body.skipTime||0)>oe()-Yl.last,n=Kx<(t.body.skipFrames||0);return t.skipAllowed&&r&&n?Yl.bodies:new Promise(async a=>{let s={};Kx=0,s.input=PN(e,x1),s.res=wn==null?void 0:wn.execute(s.input),Yl.last=oe();let i=await s.res.array();Yl.bodies=s.res.shape[2]===17?await $5e(i,t,e):await M5e(i,t,e);for(let o of Yl.bodies)ON(o,[e.shape[2]||1,e.shape[1]||1]),_N(o.keypoints);Object.keys(s).forEach(o=>te(s[o])),a(Yl.bodies)})}var ep,b1=[],LN=0,Yx=Number.MAX_SAFE_INTEGER,w1=0,v1=2.5;async function BN(e){if(!ep||he.initial){ep=await Ge(e.object.modelPath);let t=Object.values(ep.modelSignature.inputs);w1=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&se("cached model:",ep.modelUrl);return ep}async function F5e(e,t,r){let n=0,a=[];for(let l of[1,2,4])X(async()=>{let u=l*13,d=et(e.find(f=>f.shape[1]===u**2&&(f.shape[2]||0)===Hd.length)),h=et(e.find(f=>f.shape[1]===u**2&&(f.shape[2]||0)(r.object.minConfidence||0)&&g!==61){let A=(.5+Math.trunc(f%u))/u,x=(.5+Math.trunc(f/u))/u,b=c[f].map(S=>S*(u/l/w1)),[w,I]=[A-v1/l*b[0],x-v1/l*b[1]],[T,E]=[A+v1/l*b[2]-w,x+v1/l*b[3]-I],R=[w,I,T,E];R=R.map(S=>Math.max(0,Math.min(S,1)));let O=[R[0]*t[0],R[1]*t[1],R[2]*t[0],R[3]*t[1]],$={id:n++,score:Math.round(100*y)/100,class:g+1,label:Hd[g].label,box:O.map(S=>Math.trunc(S)),boxRaw:R};a.push($)}}});e.forEach(l=>te(l));let s=a.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),i=a.map(l=>l.score),o=[];if(s&&s.length>0){let l=await Ie.nonMaxSuppressionAsync(s,i,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence);o=await l.data(),te(l)}return a=a.filter((l,u)=>o.includes(u)).sort((l,u)=>u.score-l.score),a}async function Jx(e,t){let r=(t.object.skipTime||0)>oe()-LN,n=Yx<(t.object.skipFrames||0);return t.skipAllowed&&r&&n&&b1.length>0?(Yx++,b1):(Yx=0,!he.kernels.includes("mod")||!he.kernels.includes("sparsetodense")?b1:new Promise(async a=>{let s=[e.shape[2]||0,e.shape[1]||0],i=Ie.resizeBilinear(e,[w1,w1],!1),o=pe(i,Qe.tf255),l=o.transpose([0,3,1,2]);te(o),te(i);let u;t.object.enabled&&(u=ep.execute(l)),LN=oe(),te(l);let d=await F5e(u,s,t);b1=d,a(d)}))}var pc=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],_5e=pc.length,dc=pc.reduce((e,t,r)=>(e[t]=r,e),{}),P5e=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],G8e=P5e.map(([e,t])=>[dc[e],dc[t]]),VN=[["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 UN(e){let t=e.reduce(({maxX:r,maxY:n,minX:a,minY:s},{position:{x:i,y:o}})=>({maxX:Math.max(r,i),maxY:Math.max(n,o),minX:Math.min(a,i),minY:Math.min(s,o)}),{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 GN(e,[t,r],[n,a]){let s=t/n,i=r/a,o=(u,d)=>({id:d,score:u.score,boxRaw:[u.box[0]/a,u.box[1]/n,u.box[2]/a,u.box[3]/n],box:[Math.trunc(u.box[0]*i),Math.trunc(u.box[1]*s),Math.trunc(u.box[2]*i),Math.trunc(u.box[3]*s)],keypoints:u.keypoints.map(({score:h,part:p,position:c})=>({score:h,part:p,position:[Math.trunc(c.x*i),Math.trunc(c.y*s)],positionRaw:[c.x/n,c.y/n]})),annotations:{}});return e.map((u,d)=>o(u,d))}var k1=class{constructor(t,r){fe(this,"priorityQueue");fe(this,"numberOfElements");fe(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=r}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 r=2*t;if(rr?r:e}function jN(e,t,r,n){let a=r-e,s=n-t;return a*a+s*s}function rb(e,t){return{x:e.x+t.x,y:e.y+t.y}}var Sa,z5e=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],I1=1,tp=16,D5e=50**2;function HN(e,t,r,n,a,s,i=2){let o=y=>({y:s.get(y.y,y.x,e),x:s.get(y.y,y.x,s.shape[2]/2+e)}),l=(y,A,x)=>({y:tb(Math.round(y.y/tp),0,A-1),x:tb(Math.round(y.x/tp),0,x-1)}),[u,d]=n.shape,h=l(t.position,u,d),p=o(h),m=rb(t.position,p);for(let y=0;y[dc[p],dc[c]]),i=s.map(([,p])=>p),o=s.map(([p])=>p),l=t.shape[2],u=i.length,d=new Array(l),h=eb(e.part,tp,r);d[e.part.id]={score:e.score,part:pc[e.part.id],position:h};for(let p=u-1;p>=0;--p){let c=i[p],m=o[p];d[c]&&!d[m]&&(d[m]=HN(p,d[c],m,t,r,a))}for(let p=0;pt){o=!1;break}if(!o)break}return o}function W5e(e,t){let[r,n,a]=t.shape,s=new k1(r*n*a,({score:i})=>i);for(let i=0;i{var i;let s=(i=a[n])==null?void 0:i.position;return s?jN(r,t,s.y,s.x)<=D5e:!1})}function V5e(e,t){return t.reduce((n,{position:a,score:s},i)=>(qN(e,a,i)||(n+=s),n),0)/t.length}function U5e(e,t,r,n,a,s){let i=[],o=W5e(s,t);for(;i.lengthc.score>s);let h=V5e(i,d),p=UN(d);h>s&&i.push({keypoints:d,box:p,score:Math.round(100*h)/100})}return i}async function nb(e,t){let r=X(()=>{if(!Sa.inputs[0].shape)return[];let i=Ie.resizeBilinear(e,[Sa.inputs[0].shape[2],Sa.inputs[0].shape[1]]),o=ce(pe(me(i,"float32"),127.5),1),u=Sa.execute(o,z5e).map(d=>et(d,[0]));return u[1]=Tr(u[1]),u}),n=await Promise.all(r.map(i=>i.buffer()));for(let i of r)te(i);let a=await U5e(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return Sa.inputs[0].shape?GN(a,[e.shape[1],e.shape[2]],[Sa.inputs[0].shape[2],Sa.inputs[0].shape[1]]):[]}async function XN(e){return!Sa||he.initial?Sa=await Ge(e.body.modelPath):e.debug&&se("cached model:",Sa.modelUrl),Sa}var Wa,ab=!1;async function sb(e){return!Wa||he.initial?Wa=await Ge(e.segmentation.modelPath):e.debug&&se("cached model:",Wa.modelUrl),Wa}async function ZN(e,t,r){var f,g;if(ab)return{data:[],canvas:null,alpha:null};ab=!0,Wa||await sb(r);let n=await Vd(e,r),a=((f=n.tensor)==null?void 0:f.shape[2])||0,s=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let i={};i.resize=Ie.resizeBilinear(n.tensor,[Wa.inputs[0].shape?Wa.inputs[0].shape[1]:0,Wa.inputs[0].shape?Wa.inputs[0].shape[2]:0],!1),te(n.tensor),i.norm=pe(i.resize,Qe.tf255),i.res=Wa.execute(i.norm),i.squeeze=et(i.res,0),i.squeeze.shape[2]===2?(i.softmax=Id(i.squeeze),[i.bg,i.fg]=an(i.softmax,2),i.expand=Kt(i.fg,2),i.pad=Kt(i.expand,0),i.crop=Ie.cropAndResize(i.pad,[[0,0,.5,.5]],[0],[a,s]),i.data=et(i.crop,0)):i.data=Ie.resizeBilinear(i.squeeze,[s,a]);let o=Array.from(await i.data.data());if(he.node&&!he.Canvas&&typeof ImageData=="undefined")return r.debug&&se("canvas support missing"),Object.keys(i).forEach(y=>te(i[y])),{data:o,canvas:null,alpha:null};let l=Zr(a,s);Ln&&await Ln.toPixels(i.data,l);let u=l.getContext("2d");r.segmentation.blur&&r.segmentation.blur>0&&(u.filter=`blur(${r.segmentation.blur}px)`);let d=u.getImageData(0,0,a,s),h=Zr(a,s),p=h.getContext("2d");n.canvas&&p.drawImage(n.canvas,0,0),p.globalCompositeOperation="darken",r.segmentation.blur&&r.segmentation.blur>0&&(p.filter=`blur(${r.segmentation.blur}px)`),p.drawImage(l,0,0),p.globalCompositeOperation="source-over",p.filter="none";let c=p.getImageData(0,0,a,s);for(let y=0;yte(i[y])),ab=!1,{data:o,canvas:h,alpha:l}}var hc=class{constructor(){fe(this,"ssrnetage",null);fe(this,"gear",null);fe(this,"blazeposedetect",null);fe(this,"blazepose",null);fe(this,"centernet",null);fe(this,"efficientpose",null);fe(this,"mobilefacenet",null);fe(this,"emotion",null);fe(this,"facedetect",null);fe(this,"faceiris",null);fe(this,"facemesh",null);fe(this,"faceres",null);fe(this,"ssrnetgender",null);fe(this,"handpose",null);fe(this,"handskeleton",null);fe(this,"handtrack",null);fe(this,"liveness",null);fe(this,"movenet",null);fe(this,"nanodet",null);fe(this,"posenet",null);fe(this,"segmentation",null);fe(this,"antispoof",null)}};function S1(e){for(let t of Object.keys(e.models))e.models[t]=null}async function ib(e){var t,r,n,a,s,i,o,l,u,d,h,p,c,m,f,g,y,A,x,b,w,I,T,E,R,O,$,S,P,z,j;he.initial&&S1(e),e.config.hand.enabled&&(!e.models.handpose&&((r=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Lx(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((a=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:a.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Lx(e.config))),e.config.body.enabled&&!e.models.blazepose&&((i=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:i.includes("blazepose"))&&(e.models.blazepose=kT(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=wT(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(o=e.config.body)==null?void 0:o.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=ET(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(u=e.config.body)==null?void 0:u.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=zN(e.config)),e.config.body.enabled&&!e.models.posenet&&((p=(h=e.config.body)==null?void 0:h.modelPath)==null?void 0:p.includes("posenet"))&&(e.models.posenet=XN(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=cT(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=eT(e.config)),e.config.face.enabled&&((m=e.config.face.liveness)==null?void 0:m.enabled)&&!e.models.liveness&&(e.models.liveness=$N(e.config)),e.config.face.enabled&&((f=e.config.face.description)==null?void 0:f.enabled)&&!e.models.faceres&&(e.models.faceres=eN(e.config)),e.config.face.enabled&&((g=e.config.face.emotion)==null?void 0:g.enabled)&&!e.models.emotion&&(e.models.emotion=FT(e.config)),e.config.face.enabled&&((y=e.config.face.iris)==null?void 0:y.enabled)&&!((A=e.config.face.attention)!=null&&A.enabled)&&!e.models.faceiris&&(e.models.faceiris=UT(e.config)),e.config.face.enabled&&((x=e.config.face.mesh)==null?void 0:x.enabled)&&!e.models.facemesh&&(e.models.facemesh=KT(e.config)),e.config.face.enabled&&((b=e.config.face.gear)==null?void 0:b.enabled)&&!e.models.gear&&(e.models.gear=WC(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=HC(e.config)),e.config.face.enabled&&((I=e.config.face.ssrnet)==null?void 0:I.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=ZC(e.config)),e.config.face.enabled&&((T=e.config.face.mobilefacenet)==null?void 0:T.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=DT(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((R=(E=e.config.hand.detector)==null?void 0:E.modelPath)==null?void 0:R.includes("handtrack"))&&(e.models.handtrack=CN(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&(($=(O=e.config.hand.detector)==null?void 0:O.modelPath)==null?void 0:$.includes("handtrack"))&&(e.models.handskeleton=TN(e.config)),e.config.object.enabled&&!e.models.centernet&&((P=(S=e.config.object)==null?void 0:S.modelPath)==null?void 0:P.includes("centernet"))&&(e.models.centernet=CT(e.config)),e.config.object.enabled&&!e.models.nanodet&&((j=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:j.includes("nanodet"))&&(e.models.nanodet=BN(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=sb(e.config));for await(let K of Object.keys(e.models))e.models[K]&&typeof e.models[K]!="undefined"&&(e.models[K]=await e.models[K])}async function ob(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let r of Object.keys(e.models)){let n=e.models[r];if(!n)continue;let a=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let o of Object.values(s.graph.nodes)){let l=o.op.toLowerCase();a.includes(l)||a.push(l)}else!s&&e.config.debug&&se("model signature not determined:",r);let i=[];for(let o of a)!t.includes(o)&&!e.env.kernels.includes(o)&&!e.env.kernels.includes(o.replace("_",""))&&!e.env.kernels.includes(o.replace("native",""))&&!e.env.kernels.includes(o.replace("v2",""))&&i.push(o);e.config.debug&&i.length>0&&se("model validation failed:",r,i)}}var Rt={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 G5e(){let e=Rt.gl;!e||(Rt.extensions=e.getSupportedExtensions())}async function JN(e){var t;if(e.config.backend==="humangl"&&(Rt.name in Xt().registry&&(!Rt.gl||!Rt.gl.getParameter(Rt.gl.VERSION))&&(se("error: humangl backend invalid context"),S1(e)),!Vy(Rt.name))){try{Rt.canvas=await Zr(100,100)}catch(n){se("error: cannot create canvas:",n);return}try{if(Rt.gl=(t=Rt.canvas)==null?void 0:t.getContext("webgl2",Rt.webGLattr),!Rt.gl.getParameter(Rt.gl.VERSION).includes("2.0")){se("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Rt.canvas&&(Rt.canvas.addEventListener("webglcontextlost",async a=>{throw se("error: humangl:",a.type),se("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Rt.canvas.addEventListener("webglcontextrestored",a=>{se("error: humangl context restored:",a)}),Rt.canvas.addEventListener("webglcontextcreationerror",a=>{se("error: humangl context create:",a)}))}catch(n){se("error: cannot get WebGL context:",n);return}try{Mm(2,Rt.gl)}catch(n){se("error: cannot set WebGL context:",n);return}try{let n=new Cu(Rt.gl);El(Rt.name,()=>new Hh(n),Rt.priority)}catch(n){se("error: cannot register WebGL backend:",n);return}try{Fa("webgl").forEach(a=>{let s={...a,backendName:Rt.name};qn(s)})}catch(n){se("error: cannot update WebGL backend registration:",n);return}let r=Dn().getGPGPUContext?Dn().getGPGPUContext().gl:null;if(r)se(`humangl webgl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`);else{se("error: no current gl context:",r,Rt.gl);return}try{ba.set("WEBGL_VERSION",2)}catch(n){se("error: cannot set WebGL backend flags:",n);return}G5e(),se("backend registered:",Rt.name)}}function j5e(){if(!he.kernels.includes("mod")){let e={kernelName:"Mod",backendName:Hr(),kernelFunc:t=>X(()=>ce(t.inputs.a,L(pe(t.inputs.a,t.inputs.b),t.inputs.b)))};qn(e),he.kernels.push("mod")}if(!he.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:Hr(),kernelFunc:t=>X(()=>Sh(t.inputs.a/t.inputs.b)*t.inputs.b+wd(t.inputs.a,t.inputs.b))};qn(e),he.kernels.push("floormod")}}async function T1(e,t=!1){if(e.state="backend",t||he.initial||e.config.backend&&e.config.backend.length>0&&Hr()!==e.config.backend){let r=oe();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&se("running inside web worker"),he.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&se("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),he.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&se(`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")se("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let a=await navigator.gpu.requestAdapter();if(e.config.debug&&se("enumerated webgpu adapter:",a),!a)se("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let s="requestAdapterInfo"in a?await a.requestAdapterInfo():void 0;se("webgpu adapter info:",s)}}e.config.backend==="humangl"&&await JN(e);let n=Object.keys(Xt().registryFactory);if(e.config.debug&&se("available backends:",n),n.includes(e.config.backend)||(se(`error: backend ${e.config.backend} not found in registry`),e.config.backend=he.node?"tensorflow":"webgl",e.config.debug&&se(`override: setting backend ${e.config.backend}`)),e.config.debug&&se("setting backend:",e.config.backend),e.config.backend==="wasm"){try{Z().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(i){}if(e.config.debug&&se("wasm path:",e.config.wasmPath),typeof(Ue==null?void 0:Ue.setWasmPaths)!="undefined")await jA(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let a=await Z().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await Z().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&se(`wasm execution: ${a?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!a&&se("warning: wasm simd support is not enabled")}try{await Wy(e.config.backend),await Ad(),UC()}catch(a){return se("error: cannot set backend:",e.config.backend,a),!1}}if(Hr()==="humangl"&&(ba.set("CHECK_COMPUTATION_FOR_ERRORS",!1),ba.set("WEBGL_CPU_FORWARD",!0),ba.set("WEBGL_USE_SHAPES_UNIFORMS",!0),ba.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(se("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),ba.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),Dn().getGPGPUContext)){let n=await Dn().getGPGPUContext().gl;e.config.debug&&se(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}Hr(),Ly(),await Ad(),e.performance.initBackend=Math.trunc(oe()-r),e.config.backend=Hr(),await he.updateBackend(),j5e()}return!0}function m1(e,t){for(let r of e){let n={kernelName:r,backendName:t.backend,kernelFunc:()=>{t.debug&&se("kernelFunc",r,t.backend)}};qn(n)}he.kernels=Fa(Hr()).map(r=>r.kernelName.toLowerCase())}var fb={};vs(fb,{all:()=>cb,body:()=>np,canvas:()=>hb,face:()=>rp,gesture:()=>ip,hand:()=>ap,object:()=>sp,options:()=>_r,person:()=>pb});var Vn=e=>{if(!e)se("draw error: invalid canvas");else if(!e.getContext)se("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)se("draw error: cannot get canvas context");else return t}return null},Jl=e=>Math.round(e*180/Math.PI),fs=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let r=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${r[0]}, ${r[1]}, ${r[2]}, ${t.alpha})`};function ms(e,t,r,n,a){e.fillStyle=fs(n,a),e.beginPath(),e.arc(t,r,a.pointSize,0,2*Math.PI),e.fill()}function Va(e,t,r,n,a,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let i=(t+t+n)/2,o=(r+r+a)/2;e.ellipse(i,o,n/2,a/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,r),e.lineTo(t+n-s.roundRect,r),e.quadraticCurveTo(t+n,r,t+n,r+s.roundRect),e.lineTo(t+n,r+a-s.roundRect),e.quadraticCurveTo(t+n,r+a,t+n-s.roundRect,r+a),e.lineTo(t+s.roundRect,r+a),e.quadraticCurveTo(t,r+a,t,r+a-s.roundRect),e.lineTo(t,r+s.roundRect),e.quadraticCurveTo(t,r,t+s.roundRect,r),e.closePath();e.stroke()}function lb(e,t,r){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=fs(n[2],r),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),r.fillPolygons&&(e.closePath(),e.fill())}}function eE(e,t,r){if(!(t.length<2)){if(e.lineWidth=r.lineWidth,!r.useCurves||t.length<=2){lb(e,t,r);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(a=>`${Math.trunc(100*a.score)}% ${a.emotion}`);n.length>3&&(n.length=3),r.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&r.push(`roll: ${Jl(e.rotation.angle.roll)}\xB0 yaw:${Jl(e.rotation.angle.yaw)}\xB0 pitch:${Jl(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${Jl(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=dt.color;for(let n=r.length-1;n>=0;n--){let a=Math.max(e.box[0],0),s=n*dt.lineHeight+e.box[1];dt.shadowColor&&dt.shadowColor!==""&&(t.fillStyle=dt.shadowColor,t.fillText(r[n],a+5,s+16)),t.fillStyle=dt.labelColor,t.fillText(r[n],a+4,s+15)}}}function X5e(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=dt.useDepth?"rgba(255, 200, 255, 0.3)":dt.color,t.beginPath();let r=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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],r,n,0,0,2*Math.PI),t.stroke(),dt.fillPolygons&&(t.fillStyle=dt.useDepth?"rgba(255, 255, 200, 0.3)":dt.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=dt.useDepth?"rgba(255, 200, 255, 0.3)":dt.color,t.beginPath();let r=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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],r,n,0,0,2*Math.PI),t.stroke(),dt.fillPolygons&&(t.fillStyle=dt.useDepth?"rgba(255, 255, 200, 0.3)":dt.color,t.fill())}}function K5e(e,t){var r;if(dt.drawGaze&&((r=e.rotation)==null?void 0:r.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*Jl(e.rotation.angle.yaw)/90,a=e.box[1]+e.box[3]/2+e.box[2]*Jl(e.rotation.angle.pitch)/90,s=new Path2D(` +`;var HA=(e,t,r)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(a,s)=>(r[s]=0,a))},qA=class{constructor(t,r,n){fe(this,"uniform",{});fe(this,"attribute",{});fe(this,"gl");fe(this,"id");fe(this,"compile",(t,r)=>{let n=this.gl.createShader(r);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(se(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(se("filter: could not create shader"),null)});this.gl=t;let a=this.compile(r,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!a||!s)){if(!this.id){se("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,a),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){se(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),HA(r,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=this.gl.getAttribLocation(this.id,i);HA(r,"uniform",this.uniform),HA(n,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=this.gl.getUniformLocation(this.id,i)}}};function PC(){let e=0,t=null,r=!1,n=-1,a=[null,null],s=[],i=null,o=null,l=Zr(100,100),u={},d={INTERMEDIATE:1},h=l.getContext("webgl");if(!h){se("filter: cannot get webgl context");return}this.gl=h;function p(A,x){if(!(A===l.width&&x===l.height)){if(l.width=A,l.height=x,!i){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]);i=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,i),h.bufferData(h.ARRAY_BUFFER,b,h.STATIC_DRAW),h.pixelStorei(h.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}h.viewport(0,0,l.width,l.height),a=[null,null]}}function c(A,x){let b=h.createFramebuffer();h.bindFramebuffer(h.FRAMEBUFFER,b);let w=h.createRenderbuffer();h.bindRenderbuffer(h.RENDERBUFFER,w);let I=h.createTexture();return h.bindTexture(h.TEXTURE_2D,I),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,A,x,0,h.RGBA,h.UNSIGNED_BYTE,null),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,I,0),h.bindTexture(h.TEXTURE_2D,null),h.bindFramebuffer(h.FRAMEBUFFER,null),{fbo:b,texture:I}}function m(A){return a[A]=a[A]||c(l.width,l.height),a[A]}function f(A=0){if(!o)return;let x=null,b=null,w=!1;e===0?x=t:x=m(n).texture||null,e++,r&&!(A&d.INTERMEDIATE)?(b=null,w=e%2===0):(n=(n+1)%2,b=m(n).fbo||null),h.bindTexture(h.TEXTURE_2D,x),h.bindFramebuffer(h.FRAMEBUFFER,b),h.uniform1f(o.uniform.flipY,w?-1:1),h.drawArrays(h.TRIANGLES,0,6)}function g(A){if(u[A])return o=u[A],h.useProgram((o?o.id:null)||null),o;if(o=new qA(h,EC,A),!o)return se("filter: could not get webgl program"),null;let x=Float32Array.BYTES_PER_ELEMENT,b=4*x;return h.enableVertexAttribArray(o.attribute.pos),h.vertexAttribPointer(o.attribute.pos,2,h.FLOAT,!1,b,0*x),h.enableVertexAttribArray(o.attribute.uv),h.vertexAttribPointer(o.attribute.uv,2,h.FLOAT,!1,b,2*x),u[A]=o,o}let y={colorMatrix:A=>{let x=new Float32Array(A);x[4]/=255,x[9]/=255,x[14]/=255,x[19]/=255;let b=x[18]===1&&x[3]===0&&x[8]===0&&x[13]===0&&x[15]===0&&x[16]===0&&x[17]===0&&x[19]===0?$C:RC,w=g(b);!w||(h.uniform1fv(w.uniform.m,x),f())},brightness:A=>{let x=(A||0)+1;y.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},saturation:A=>{let x=(A||0)*2/3+1,b=(x-1)*-.5;y.colorMatrix([x,b,b,0,0,b,x,b,0,0,b,b,x,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:A=>{let x=(A||0)+1,b=-128*(x-1);y.colorMatrix([x,0,0,0,b,0,x,0,0,b,0,0,x,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:A=>{A=(A||0)/180*Math.PI;let x=Math.cos(A),b=Math.sin(A),w=.213,I=.715,T=.072;y.colorMatrix([w+x*(1-w)+b*-w,I+x*-I+b*-I,T+x*-T+b*(1-T),0,0,w+x*-w+b*.143,I+x*(1-I)+b*.14,T+x*-T+b*-.283,0,0,w+x*-w+b*-(1-w),I+x*-I+b*I,T+x*(1-T)+b*T,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:A=>{let x=new Float32Array(A),b=1/l.width,w=1/l.height,I=g(_C);!I||(h.uniform1fv(I.uniform.m,x),h.uniform2f(I.uniform.px,b,w),f())},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:A=>{let x=A||1;y.convolution.call(this,[0,-1*x,0,-1*x,1+4*x,-1*x,0,-1*x,0])},emboss:A=>{let x=A||1;y.convolution.call(this,[-2*x,-1*x,0,-1*x,1,1*x,0,1*x,2*x])},blur:A=>{let x=A/7/l.width,b=A/7/l.height,w=g(FC);!w||(h.uniform2f(w.uniform.px,0,b),f(d.INTERMEDIATE),h.uniform2f(w.uniform.px,x,0),f())},pixelate:A=>{let x=A/l.width,b=A/l.height,w=g(MC);!w||(h.uniform2f(w.uniform.size,x,b),f())}};this.add=function(A){let x=Array.prototype.slice.call(arguments,1),b=y[A];s.push({func:b,args:x})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(A){p(A.width,A.height),e=0,t||(t=h.createTexture()),h.bindTexture(h.TEXTURE_2D,t),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,A);for(let x=0;xc.data())),i=.99*Math.max(s[0][0],s[1][0],s[2][0]),o=[ce(r[0],n[0]),ce(r[1],n[1]),ce(r[2],n[2])],l=[ce(a[0],n[0]),ce(a[1],n[1]),ce(a[2],n[2])],u=[pe(i,l[0]),pe(i,l[1]),pe(i,l[2])],d=[L(o[0],u[0]),L(o[1],u[1]),L(o[2],u[2])],h=ur([d[0],d[1],d[2]],2),p=U(h,[1,t.shape[0],t.shape[1],3]);return te([...r,...n,...a,...o,...l,...u,...d,h,t]),p}var Um=3840,ut=null,er=null,Wd=null,Et,is={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function Zr(e,t){let r;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");r=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");r=document.createElement("canvas"),r.width=e,r.height=t}else typeof he.Canvas!="undefined"?r=new he.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(r=new globalThis.Canvas(e,t));return r}function Gm(e,t){let r=t||Zr(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),r}async function Vd(e,t,r=!0){if(!e)return t.debug&&se("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof nt)&&!(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 nt){let n=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)n=Kt(e,0);else if(e.shape[2]===4){let a=Fl(e,[0,0,0],[-1,-1,3]);n=Kt(a,0),te(a)}}else e.shape.length===4&&(e.shape[3]===3?n=Vr(e):e.shape[3]===4&&(n=_o(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let a=me(n,"float32");te(n),n=a}return{tensor:n,canvas:t.filter.return?er:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&se("input stream is not ready"),{tensor:null,canvas:ut};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,a=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!a)return t.debug&&se("cannot determine input dimensions"),{tensor:null,canvas:ut};let s=n,i=a;if(s>Um&&(s=Um,i=Math.trunc(s*a/n)),i>Um&&(i=Um,s=Math.trunc(i*n/a)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=n*((t.filter.height||0)/a)),(t.filter.height||0)>0?i=t.filter.height:(t.filter.width||0)>0&&(i=a*((t.filter.width||0)/n)),!s||!i)throw new Error("input error: cannot determine dimension");(!ut||(ut==null?void 0:ut.width)!==s||(ut==null?void 0:ut.height)!==i)&&(ut=Zr(s,i));let o=ut.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?o.putImageData(e,0,0):t.filter.flip&&typeof o.translate!="undefined"?(o.translate(n,0),o.scale(-1,1),o.drawImage(e,0,0,n,a,0,0,ut==null?void 0:ut.width,ut==null?void 0:ut.height),o.setTransform(1,0,0,1,0,0)):o.drawImage(e,0,0,n,a,0,0,ut==null?void 0:ut.width,ut==null?void 0:ut.height),(!er||ut.width!==er.width||(ut==null?void 0:ut.height)!==(er==null?void 0:er.height))&&(er=Zr(ut.width,ut.height)),t.filter.enabled&&he.webgl.supported?(Et||(Et=he.browser?new PC:null),he.filter=!!Et,!Et||!Et.add?(t.debug&&se("input process error: cannot initialize filters"),he.webgl.supported=!1,t.filter.enabled=!1,Gm(ut,er)):(Et.reset(),t.filter.brightness!==0&&Et.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Et.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Et.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Et.add("blur",t.filter.blur),t.filter.saturation!==0&&Et.add("saturation",t.filter.saturation),t.filter.hue!==0&&Et.add("hue",t.filter.hue),t.filter.negative&&Et.add("negative"),t.filter.sepia&&Et.add("sepia"),t.filter.vintage&&Et.add("brownie"),t.filter.sepia&&Et.add("sepia"),t.filter.kodachrome&&Et.add("kodachrome"),t.filter.technicolor&&Et.add("technicolor"),t.filter.polaroid&&Et.add("polaroid"),t.filter.pixelate!==0&&Et.add("pixelate",t.filter.pixelate),Et.get()>0?er=Et.apply(ut):er=Et.draw(ut))):(Gm(ut,er),Et&&(Et=null),he.filter=!!Et),!r)return{tensor:null,canvas:er};if(!er)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&&Ln)l=Ln?Ln.fromPixels(e):null;else{u=e.data.length/e.height/e.width;let p=new Uint8Array(e.data.buffer);l=ft(p,[e.height,e.width,u],"int32")}else if((!Wd||er.width!==Wd.width||er.height!==Wd.height)&&(Wd=Zr(er.width,er.height)),Ln&&he.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=Ln.fromPixels(er):(Wd=Gm(er),l=Ln.fromPixels(Wd));else{let m=Gm(er).getContext("2d").getImageData(0,0,s,i);u=m.data.length/s/i;let f=new Uint8Array(m.data.buffer);l=ft(f,[s,i,u])}if(u===4){let p=Fl(l,[0,0,0],[-1,-1,3]);te(l),l=p}if(!l)throw new Error("input error: cannot create tensor");let d=me(l,"float32"),h=t.filter.equalization?await Vm(d):Kt(d,0);return te([l,d]),{tensor:h,canvas:t.filter.return?er:null}}}async function OC(e,t){let r=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return r;if(!is.inputTensor)is.inputTensor=Vr(t);else if(is.inputTensor.shape[1]!==t.shape[1]||is.inputTensor.shape[2]!==t.shape[2])te(is.inputTensor),is.inputTensor=Vr(t);else{let n={};n.diff=ce(t,is.inputTensor),n.squared=L(n.diff,n.diff),n.sum=ke(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;te([is.inputTensor,n.diff,n.squared,n.sum]),is.inputTensor=Vr(t),r=s<=(e.cacheSensitivity||0)}return r}async function zC(e,t,r){let n={};if(!t||!r||t.shape.length!==4||t.shape.length!==r.shape.length)return e.debug||se("invalid input tensor or tensor shapes do not match:",t.shape,r.shape),0;if(t.shape[0]!==1||r.shape[0]!==1||t.shape[3]!==3||r.shape[3]!==3)return e.debug||se("input tensors must be of shape [1, height, width, 3]:",t.shape,r.shape),0;n.input1=Vr(t),n.input2=t.shape[1]!==r.shape[1]||t.shape[2]!==r.shape[2]?Ie.resizeBilinear(r,[t.shape[1],t.shape[2]]):Vr(r),n.diff=ce(n.input1,n.input2),n.squared=L(n.diff,n.diff),n.sum=ke(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return te([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var XA=class{constructor(){fe(this,"browser");fe(this,"node");fe(this,"worker");fe(this,"platform","");fe(this,"agent","");fe(this,"backends",[]);fe(this,"initial");fe(this,"filter");fe(this,"tfjs");fe(this,"offscreen");fe(this,"perfadd",!1);fe(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});fe(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});fe(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});fe(this,"cpu",{model:void 0,flags:[]});fe(this,"kernels",[]);fe(this,"Canvas");fe(this,"Image");fe(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:rc["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&&t[0]){let r=t[0].match(/\(([^()]+)\)/g);this.platform=r&&r[0]?r[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(Xt().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&Hr()==="wasm"&&(this.wasm.simd=await Z().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await Z().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=Zr(100,100),r=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof r!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(Hr()==="webgl"||Hr()==="humangl")){let n=Dn().gpgpu!=="undefined"?await Dn().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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=Fa(Hr()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},he=new XA;var os={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function m3e(e,t){return os.debug&&se("load model fetch:",e,t),fetch(e,t)}function DC(e){os.cacheModels=e.cacheModels,os.verbose=e.debug,os.modelBasePath=e.modelBasePath}async function Ge(e){let t=Gb(os.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let r=t.split("/"),n="indexeddb://"+r[r.length-1].replace(".json",""),a=await Cr.listModels(),s=os.cacheModels&&Object.keys(a).includes(n),i=typeof fetch=="undefined"?{}:{fetchFunc:(u,d)=>m3e(u,d)},o=new Vh(s?n:t,i),l=!1;try{o.findIOHandler(),os.debug&&se("model load handler:",o.handler);let u=await o.handler.load();o.loadSync(u),os.verbose&&se("load model:",o.modelUrl),l=!0}catch(u){se("error loading model:",t,u)}if(l&&os.cacheModels&&!s)try{let u=await o.save(n);se("model saved:",n,u)}catch(u){se("error saving model:",t,u)}return o}var KA="2.8.1";var C1={};vs(C1,{Models:()=>hc,load:()=>ib,reset:()=>S1,validate:()=>ob});var Jn,ZA=[],A3e=["white","black","asian","indian","other"],x3e=[15,23,28,35.5,45.5,55.5,65],LC=0,BC=0,YA=Number.MAX_SAFE_INTEGER;async function WC(e){return he.initial&&(Jn=null),Jn?e.debug&&se("cached model:",Jn.modelUrl):Jn=await Ge(e.face.gear),Jn}async function JA(e,t,r,n){var i,o;if(!Jn)return{age:0,gender:"unknown",genderScore:0,race:[]};let a=YA<(((i=t.face.gear)==null?void 0:i.skipFrames)||0),s=(((o=t.face.gear)==null?void 0:o.skipTime)||0)>oe()-BC;return t.skipAllowed&&s&&a&&LC===n&&ZA[r]?(YA++,ZA[r]):(YA=0,new Promise(async l=>{var y,A;if(!(Jn!=null&&Jn.inputs[0].shape))return;let u={},d=[[0,.1,.9,.9]];u.resize=Ie.cropAndResize(e,d,[0],[Jn.inputs[0].shape[2],Jn.inputs[0].shape[1]]);let h={age:0,gender:"unknown",genderScore:0,race:[]};(y=t.face.gear)!=null&&y.enabled&&([u.age,u.gender,u.race]=Jn.execute(u.resize,["age_output","gender_output","race_output"]));let p=await u.gender.data();h.gender=p[0]>p[1]?"male":"female",h.genderScore=Math.round(100*(p[0]>p[1]?p[0]:p[1]))/100;let c=await u.race.data();for(let x=0;x(((A=t.face.gear)==null?void 0:A.minConfidence)||.2)&&h.race.push({score:Math.round(100*c[x])/100,race:A3e[x]});h.race.sort((x,b)=>b.score-x.score);let f=Array.from(await u.age.data()).map((x,b)=>[x3e[b],x]).sort((x,b)=>b[1]-x[1]),g=f[0][0];for(let x=1;xte(u[x])),ZA[r]=h,LC=n,BC=oe(),l(h)}))}var Qe={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function UC(){Qe.tf255=Se(255,"float32"),Qe.tf1=Se(1,"float32"),Qe.tf2=Se(2,"float32"),Qe.tf05=Se(.5,"float32"),Qe.tf127=Se(127.5,"float32"),Qe.rgb=Nt([.2989,.587,.114],"float32")}var yn,jm=[],GC=0,jC=0,QA=Number.MAX_SAFE_INTEGER;async function HC(e){return he.initial&&(yn=null),yn?e.debug&&se("cached model:",yn.modelUrl):yn=await Ge(e.face.ssrnet.modelPathAge),yn}async function ex(e,t,r,n){var i,o,l,u;if(!yn)return{age:0};let a=QA<(((i=t.face.ssrnet)==null?void 0:i.skipFrames)||0),s=(((o=t.face.ssrnet)==null?void 0:o.skipTime)||0)>oe()-jC;return t.skipAllowed&&a&&s&&GC===n&&((l=jm[r])==null?void 0:l.age)&&((u=jm[r])==null?void 0:u.age)>0?(QA++,jm[r]):(QA=0,new Promise(async d=>{if(!(yn!=null&&yn.inputs)||!yn.inputs[0]||!yn.inputs[0].shape)return;let h={};h.resize=Ie.resizeBilinear(e,[yn.inputs[0].shape[2],yn.inputs[0].shape[1]],!1),h.enhance=L(h.resize,Qe.tf255);let p={age:0};if(t.face.ssrnet.enabled&&(h.age=yn.execute(h.enhance)),h.age){let c=await h.age.data();p.age=Math.trunc(10*c[0])/10}Object.keys(h).forEach(c=>te(h[c])),jm[r]=p,GC=n,jC=oe(),d(p)}))}var Qn,Hm=[],XC=0,KC=0,tx=Number.MAX_SAFE_INTEGER,rx=[.2989,.587,.114];async function ZC(e){return he.initial&&(Qn=null),Qn?e.debug&&se("cached model:",Qn.modelUrl):Qn=await Ge(e.face.ssrnet.modelPathGender),Qn}async function nx(e,t,r,n){var i,o,l,u;if(!Qn)return{gender:"unknown",genderScore:0};let a=tx<(((i=t.face.ssrnet)==null?void 0:i.skipFrames)||0),s=(((o=t.face.ssrnet)==null?void 0:o.skipTime)||0)>oe()-KC;return t.skipAllowed&&a&&s&&XC===n&&((l=Hm[r])==null?void 0:l.gender)&&((u=Hm[r])==null?void 0:u.genderScore)>0?(tx++,Hm[r]):(tx=0,new Promise(async d=>{if(!(Qn!=null&&Qn.inputs[0].shape))return;let h={};h.resize=Ie.resizeBilinear(e,[Qn.inputs[0].shape[2],Qn.inputs[0].shape[1]],!1),h.enhance=X(()=>{let[m,f,g]=Yt(h.resize,3,3),y=L(m,rx[0]),A=L(f,rx[1]),x=L(g,rx[2]),b=Pf([y,A,x]);return L(ce(b,Qe.tf05),2)});let p={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(h.gender=Qn.execute(h.enhance));let c=await h.gender.data();p.gender=c[0]>c[1]?"female":"male",p.genderScore=c[0]>c[1]?Math.trunc(100*c[0])/100:Math.trunc(100*c[1])/100,Object.keys(h).forEach(m=>te(h[m])),Hm[r]=p,XC=n,KC=oe(),d(p)}))}var Rr,qm=[],ax=Number.MAX_SAFE_INTEGER,JC=0,QC=0;async function eT(e){var t;return he.initial&&(Rr=null),Rr?e.debug&&se("cached model:",Rr.modelUrl):Rr=await Ge((t=e.face.antispoof)==null?void 0:t.modelPath),Rr}async function sx(e,t,r,n){var i,o;if(!Rr)return 0;let a=(((i=t.face.antispoof)==null?void 0:i.skipTime)||0)>oe()-QC,s=ax<(((o=t.face.antispoof)==null?void 0:o.skipFrames)||0);return t.skipAllowed&&a&&s&&JC===n&&qm[r]?(ax++,qm[r]):(ax=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[Rr!=null&&Rr.inputs[0].shape?Rr.inputs[0].shape[2]:0,Rr!=null&&Rr.inputs[0].shape?Rr.inputs[0].shape[1]:0],!1),d=Rr==null?void 0:Rr.execute(u),h=(await d.data())[0];qm[r]=Math.round(100*h)/100,JC=n,QC=oe(),te([u,d]),l(qm[r])}))}var ea={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]},ix={count:468,mouth:13,symmetryLine:[13,ea.midwayBetweenEyes[0]]},Wl={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},ox=[{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]}],ac=[[.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]],Vl=[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 v3e=[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],w3e=[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],k3e=[33,133,362,263,1,78,308],Swe=v3e.map(e=>ac[e]),Cwe=w3e.map(e=>ac[e]),Twe=k3e.map(e=>ac[e]);function Xi(e){let t=e.map(r=>r[0]);return t.push(e[e.length-1][1]),t}var I3e=[[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]],S3e=[[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]],C3e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],T3e=[[474,475],[475,476],[476,477],[477,474]],N3e=[[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]],E3e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],R3e=[[469,470],[470,471],[471,472],[472,469]],$3e=[[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]],Nwe={lips:Xi(I3e),leftEye:Xi(S3e),leftEyebrow:Xi(C3e),leftIris:Xi(T3e),rightEye:Xi(N3e),rightEyebrow:Xi(E3e),rightIris:Xi(R3e),faceOval:Xi($3e)};var Ud=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],Xm=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],Km=(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],Zm=(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],aT=(e,t)=>{let r=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:r,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},ux=(e,t,r)=>{let n=t.shape[1],a=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/a,e.endPoint[1]/n,e.endPoint[0]/a],i=Ie.cropAndResize(t,[s],[0],r),o=pe(i,Qe.tf255);return te(i),o},Ym=(e,t)=>{let r=Xm(e),n=Ud(e),a=[t*n[0]/2,t*n[1]/2];return{startPoint:[r[0]-a[0],r[1]-a[1]],endPoint:[r[0]+a[0],r[1]+a[1]],landmarks:e.landmarks,confidence:e.confidence}},Jm=e=>{let t=Xm(e),r=Ud(e),n=Math.max(...r)/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}},sT=e=>{let t=e.map(n=>n[0]),r=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...r)],endPoint:[Math.max(...t),Math.max(...r)],landmarks:e}},dx=[[1,0,0],[0,1,0],[0,0,1]],M3e=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),F3e=(e,t)=>M3e(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var rT=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ul=(e,t)=>{let r=0;for(let n=0;n{let r=[];for(let n=0;n{let r=[],n=e.length;for(let a=0;a{let r=Math.cos(e),n=Math.sin(e),a=[[r,-n,0],[n,r,0],[0,0,1]],s=rT(t[0],t[1]),i=nT(s,a),o=rT(-t[0],-t[1]);return nT(i,o)},P3e=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],r=[e[0][2],e[1][2]],n=[-Ul(t[0],r),-Ul(t[1],r)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},O3e=(e,t)=>[Ul(e,t[0]),Ul(e,t[1])];function oT(e){let t=e===192?{strides:[4],anchors:[1]}:{strides:[e/16,e/8],anchors:[2,6]},r=[];for(let n=0;n[s[0]/a*(c[0]-a/2),s[1]/a*(c[1]-a/2),c[2]||0]),o=r&&r!==0&&Math.abs(r)>.2,l=o?iT(r,[0,0]):dx,u=o?i.map(c=>[...O3e(c,l),c[2]]):i,d=o?P3e(n):dx,h=Xm(t),p=[Ul(h,d[0]),Ul(h,d[1])];return u.map(c=>[Math.trunc(c[0]+p[0]),Math.trunc(c[1]+p[1]),Math.trunc(c[2]||0)])}function uT(e,t,r,n){let a=t.landmarks.length>=ix.count?ix.symmetryLine:Wl.symmetryLine,s=0,i=dx,o;if(e&&he.kernels.includes("rotatewithoffset"))if(s=F3e(t.landmarks[a[0]],t.landmarks[a[1]]),s&&s!==0&&Math.abs(s)>.2){let u=Xm(t),d=[u[0]/r.shape[2],u[1]/r.shape[1]],h=Ie.rotateWithOffset(r,s,0,d);i=iT(-s,u),o=ux(t,h,[n,n]),te(h)}else o=ux(t,r,[n,n]);else o=ux(t,r,[n,n]);return[s,i,o]}var z3e=e=>{let t=e.map(n=>n[0]),r=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...r)+(Math.max(...r)-Math.min(...r))/2]},dT=(e,t)=>{let r=z3e(e),n=Ud(t);return{startPoint:[r[0]-n[0]/2,r[1]-n[1]/2],endPoint:[r[0]+n[0]/2,r[1]+n[1]/2]}};var pT=6,D3e=1.4,La,hT=null,Ki=0,sc=null,Gd=()=>Ki;async function cT(e){var t;return he.initial&&(La=null),La?e.debug&&se("cached model:",La.modelUrl):La=await Ge((t=e.face.detector)==null?void 0:t.modelPath),Ki=La.inputs[0].shape?La.inputs[0].shape[2]:0,sc=Se(Ki,"int32"),hT=ca(oT(Ki)),La}function L3e(e){let t={};t.boxStarts=_e(e,[0,1],[-1,2]),t.centers=le(t.boxStarts,hT),t.boxSizes=_e(e,[0,3],[-1,2]),t.boxSizesNormalized=pe(t.boxSizes,sc),t.centersNormalized=pe(t.centers,sc),t.halfBoxSize=pe(t.boxSizesNormalized,Qe.tf2),t.starts=ce(t.centersNormalized,t.halfBoxSize),t.ends=le(t.centersNormalized,t.halfBoxSize),t.startNormalized=L(t.starts,sc),t.endNormalized=L(t.ends,sc);let r=xd([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>te(t[n])),r}async function fT(e,t){var o,l,u,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let r={};r.resized=Ie.resizeBilinear(e,[Ki,Ki]),r.div=pe(r.resized,Qe.tf127),r.normalized=ce(r.div,Qe.tf05);let n=La==null?void 0:La.execute(r.normalized);if(Array.isArray(n)&&n.length>2){let h=n.sort((p,c)=>p.size-c.size);r.concat384=St([h[0],h[2]],2),r.concat512=St([h[1],h[3]],2),r.concat=St([r.concat512,r.concat384],1),r.batch=et(r.concat,0)}else Array.isArray(n)?r.batch=et(n[0]):r.batch=et(n);te(n),r.boxes=L3e(r.batch),r.logits=_e(r.batch,[0,0],[-1,1]),r.sigmoid=Tr(r.logits),r.scores=et(r.sigmoid),r.nms=await Ie.nonMaxSuppressionAsync(r.boxes,r.scores,((o=t.face.detector)==null?void 0:o.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((u=t.face.detector)==null?void 0:u.minConfidence)||0);let a=await r.nms.array(),s=[],i=await r.scores.data();for(let h=0;h(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let c={};c.bbox=_e(r.boxes,[a[h],0],[1,-1]),c.slice=_e(r.batch,[a[h],pT-1],[1,-1]),c.squeeze=et(c.slice),c.landmarks=U(c.squeeze,[pT,-1]);let m=await c.bbox.data(),f={startPoint:[m[0],m[1]],endPoint:[m[2],m[3]],landmarks:await c.landmarks.array(),confidence:p},g=aT(f,[(e.shape[2]||0)/Ki,(e.shape[1]||0)/Ki]),y=Ym(g,t.face.scale||D3e),A=Jm(y);s.push(A),Object.keys(c).forEach(x=>te(c[x]))}}return Object.keys(r).forEach(h=>te(r[h])),s}var Qm={};vs(Qm,{connected:()=>cx,kpt:()=>hx});var hx=["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"],cx={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 gT=224,B3e,W3e=5,e1=[8,16,32,32,32];async function yT(){let e=[],t=0;for(;tr.x)),y:Nt(e.map(r=>r.y))}}function ls(e,t=[1,1]){let r=[e.map(o=>o[0]),e.map(o=>o[1])],n=[Math.min(...r[0]),Math.min(...r[1])],a=[Math.max(...r[0]),Math.max(...r[1])],s=[n[0],n[1],a[0]-n[0],a[1]-n[1]],i=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:i}}function AT(e,t=[1,1]){let r=[e.map(u=>u[0]),e.map(u=>u[1])],n=[Math.min(...r[0]),Math.min(...r[1])],a=[Math.max(...r[0]),Math.max(...r[1])],s=[(n[0]+a[0])/2,(n[1]+a[1])/2],i=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+a[0],-s[1]+a[1]),o=[Math.trunc(s[0]-i),Math.trunc(s[1]-i),Math.trunc(2*i),Math.trunc(2*i)],l=[o[0]/t[0],o[1]/t[1],o[2]/t[0],o[3]/t[1]];return{box:o,boxRaw:l}}function t1(e,t){let r=[e[2]*t,e[3]*t];return[e[0]-(r[0]-e[2])/2,e[1]-(r[1]-e[3])/2,r[0],r[1]]}var vT={initial:!0},An={detector:null,landmarks:null},jd={detector:[224,224],landmarks:[256,256]},fx=Number.MAX_SAFE_INTEGER,U3e={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},n1=null,ic,Zi=[[0,0],[0,0],[0,0],[0,0]],xT=0,bT=e=>1-1/(1+Math.exp(e));async function wT(e){if(vT.initial&&(An.detector=null),!An.detector&&e.body.detector&&e.body.detector.modelPath){An.detector=await Ge(e.body.detector.modelPath);let t=Object.values(An.detector.modelSignature.inputs);jd.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,jd.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&An.detector&&se("cached model:",An.detector.modelUrl);return await yT(),An.detector}async function kT(e){if(vT.initial&&(An.landmarks=null),An.landmarks)e.debug&&se("cached model:",An.landmarks.modelUrl);else{An.landmarks=await Ge(e.body.modelPath);let t=Object.values(An.landmarks.modelSignature.inputs);jd.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,jd.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return An.landmarks}async function G3e(e,t){let r={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(ic&&(r.cropped=Ie.cropAndResize(e,[ic],[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],s=[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];Zi=[[0,0],a,s,[0,0]],r.pad=Xn(r.cropped||e,Zi),r.resize=Ie.resizeBilinear(r.pad,[t,t]),n=pe(r.resize,Qe.tf255)}else e.shape[1]!==t?(r.resize=Ie.resizeBilinear(r.cropped||e,[t,t]),n=pe(r.resize,Qe.tf255)):n=pe(r.cropped||e,Qe.tf255);return Object.keys(r).forEach(a=>te(r[a])),n}function j3e(e,t){for(let r of e)r.position=[Math.trunc(r.position[0]*(t[0]+Zi[2][0]+Zi[2][1])/t[0]-Zi[2][0]),Math.trunc(r.position[1]*(t[1]+Zi[1][0]+Zi[1][1])/t[1]-Zi[1][0]),r.position[2]],r.positionRaw=[r.position[0]/t[0],r.position[1]/t[1],2*r.position[2]/(t[0]+t[1])];if(ic)for(let r of e)r.positionRaw=[r.positionRaw[0]+ic[1],r.positionRaw[1]+ic[0],r.positionRaw[2]],r.position=[Math.trunc(r.positionRaw[0]*t[0]),Math.trunc(r.positionRaw[1]*t[1]),r.positionRaw[2]];return e}async function H3e(e){let t=e.find(o=>o.part==="leftPalm"),r=e.find(o=>o.part==="leftWrist"),n=e.find(o=>o.part==="leftIndex");t.position[2]=((r.position[2]||0)+(n.position[2]||0))/2;let a=e.find(o=>o.part==="rightPalm"),s=e.find(o=>o.part==="rightWrist"),i=e.find(o=>o.part==="rightIndex");a.position[2]=((s.position[2]||0)+(i.position[2]||0))/2}async function q3e(e,t,r){var m;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(m=An.landmarks)==null?void 0:m.execute(e,U3e.landmarks);let a=(await n.poseflag.data())[0],s=await n.ld.data(),i=await n.world.data();Object.keys(n).forEach(f=>te(n[f]));let o=[],l=5;for(let f=0;ff.position),h=ls(d,[r[0],r[1]]),p={};for(let[f,g]of Object.entries(cx)){let y=[];for(let A=0;Aw.part===g[A]),b=u.find(w=>w.part===g[A+1]);x&&b&&y.push([x.position,b.position])}p[f]=y}return{id:0,score:Math.trunc(100*a)/100,box:h.box,boxRaw:h.boxRaw,keypoints:u,annotations:p}}async function mx(e,t){let r=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>oe()-xT,a=fx<(t.body.skipFrames||0);if(t.skipAllowed&&n&&a&&n1!==null)fx++;else{let s={};s.landmarks=await G3e(e,256),n1=await q3e(s.landmarks,t,r),Object.keys(s).forEach(i=>te(s[i])),xT=oe(),fx=0}return n1?[n1]:[]}var Hd=[{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 us,Gl=0,gx=[],ST=0,yx=Number.MAX_SAFE_INTEGER;async function CT(e){if(he.initial&&(us=null),us)e.debug&&se("cached model:",us.modelUrl);else{us=await Ge(e.object.modelPath);let t=Object.values(us.modelSignature.inputs);Gl=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return us}async function X3e(e,t,r){if(!e)return[];let n={},a=[],s=await e.array();n.squeeze=et(e);let i=Yt(n.squeeze,6,1);n.stack=ur([i[1],i[0],i[3],i[2]],1),n.boxes=et(n.stack),n.scores=et(i[4]),n.classes=et(i[5]),te([e,...i]),n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.scores,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence||0);let o=await n.nms.data(),l=0;for(let u of Array.from(o)){let d=Math.trunc(100*s[0][u][4])/100,h=s[0][u][5],p=Hd[h].label,[c,m]=[s[0][u][0]/Gl,s[0][u][1]/Gl],f=[c,m,s[0][u][2]/Gl-c,s[0][u][3]/Gl-m],g=[Math.trunc(f[0]*t[0]),Math.trunc(f[1]*t[1]),Math.trunc(f[2]*t[0]),Math.trunc(f[3]*t[1])];a.push({id:l++,score:d,class:h,label:p,box:g,boxRaw:f})}return Object.keys(n).forEach(u=>te(n[u])),a}async function Ax(e,t){let r=(t.object.skipTime||0)>oe()-ST,n=yx<(t.object.skipFrames||0);return t.skipAllowed&&r&&n&&gx.length>0?(yx++,gx):(yx=0,new Promise(async a=>{let s=[e.shape[2]||0,e.shape[1]||0],i=Ie.resizeBilinear(e,[Gl,Gl]),o=t.object.enabled?us==null?void 0:us.execute(i,["tower_0/detections"]):null;ST=oe(),te(i);let l=await X3e(o,s,t);gx=l,a(l)}))}var a1={};vs(a1,{connected:()=>bx,kpt:()=>xx});var xx=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],bx={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var $r,NT=0,Yr={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},vx=Number.MAX_SAFE_INTEGER;async function ET(e){return he.initial&&($r=null),$r?e.debug&&se("cached model:",$r.modelUrl):$r=await Ge(e.body.modelPath),$r}async function K3e(e,t){let[r,n]=e.shape,a=U(e,[n*r]),s=yr(a,0),i=(await s.data())[0];if(te([a,s]),i>t){let o=$n(a,0),l=wd(o,r),u=(await l.data())[0],d=pe(o,Se(r,"int32")),h=(await d.data())[0];return te([l,d]),[u,h,i]}return[0,0,i]}async function wx(e,t){let r=(t.body.skipTime||0)>oe()-NT,n=vx<(t.body.skipFrames||0);return t.skipAllowed&&r&&n&&Object.keys(Yr.keypoints).length>0?(vx++,[Yr]):(vx=0,new Promise(async a=>{var h;let s=X(()=>{if(!($r!=null&&$r.inputs[0].shape))return null;let p=Ie.resizeBilinear(e,[$r.inputs[0].shape[2],$r.inputs[0].shape[1]],!1),c=L(p,Qe.tf2);return ce(c,Qe.tf1)}),i;if(t.body.enabled&&(i=$r==null?void 0:$r.execute(s)),NT=oe(),te(s),i){Yr.keypoints.length=0;let p=i.squeeze();te(i);let c=p.unstack(2);te(p);for(let m=0;m(((h=t.body)==null?void 0:h.minConfidence)||0)&&Yr.keypoints.push({score:Math.round(100*y)/100,part:xx[m],positionRaw:[f/$r.inputs[0].shape[2],g/$r.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/$r.inputs[0].shape[2]),Math.round(e.shape[1]*g/$r.inputs[0].shape[1])]})}c.forEach(m=>te(m))}Yr.score=Yr.keypoints.reduce((p,c)=>c.score>p?c.score:p,0);let o=Yr.keypoints.map(p=>p.position[0]),l=Yr.keypoints.map(p=>p.position[1]);Yr.box=[Math.min(...o),Math.min(...l),Math.max(...o)-Math.min(...o),Math.max(...l)-Math.min(...l)];let u=Yr.keypoints.map(p=>p.positionRaw[0]),d=Yr.keypoints.map(p=>p.positionRaw[1]);Yr.boxRaw=[Math.min(...u),Math.min(...d),Math.max(...u)-Math.min(...u),Math.max(...d)-Math.min(...d)];for(let[p,c]of Object.entries(bx)){let m=[];for(let f=0;fA.part===c[f]),y=Yr.keypoints.find(A=>A.part===c[f+1]);g&&y&&g.score>(t.body.minConfidence||0)&&y.score>(t.body.minConfidence||0)&&m.push([g.position,y.position])}Yr.annotations[p]=m}a([Yr])}))}var Z3e=["angry","disgust","fear","happy","sad","surprise","neutral"],Wn,s1=[],$T=0,MT=0,kx=Number.MAX_SAFE_INTEGER;async function FT(e){var t;return he.initial&&(Wn=null),Wn?e.debug&&se("cached model:",Wn.modelUrl):Wn=await Ge((t=e.face.emotion)==null?void 0:t.modelPath),Wn}async function Ix(e,t,r,n){var i,o;if(!Wn)return[];let a=kx<(((i=t.face.emotion)==null?void 0:i.skipFrames)||0),s=(((o=t.face.emotion)==null?void 0:o.skipTime)||0)>oe()-MT;return t.skipAllowed&&s&&a&&$T===n&&s1[r]&&s1[r].length>0?(kx++,s1[r]):(kx=0,new Promise(async l=>{var d,h;let u=[];if((d=t.face.emotion)!=null&&d.enabled){let p={},c=Wn!=null&&Wn.inputs[0].shape?Wn.inputs[0].shape[2]:0;p.resize=Ie.resizeBilinear(e,[c,c],!1),p.channels=L(p.resize,Qe.rgb),p.grayscale=ke(p.channels,3,!0),p.grayscaleSub=ce(p.grayscale,Qe.tf05),p.grayscaleMul=L(p.grayscaleSub,Qe.tf2),p.emotion=Wn==null?void 0:Wn.execute(p.grayscaleMul),MT=oe();let m=await p.emotion.data();for(let f=0;f(((h=t.face.emotion)==null?void 0:h.minConfidence)||0)&&u.push({score:Math.min(.99,Math.trunc(100*m[f])/100),emotion:Z3e[f]});u.sort((f,g)=>g.score-f.score),Object.keys(p).forEach(f=>te(p[f]))}s1[r]=u,$T=n,l(u)}))}var xn,Sx=[],PT=0,OT=0,zT=Number.MAX_SAFE_INTEGER;async function DT(e){return he.initial&&(xn=null),xn?e.debug&&se("cached model:",xn.modelUrl):xn=await Ge(e.face.mobilefacenet.modelPath),xn}async function Cx(e,t,r,n){var i,o;if(!xn)return[];let a=zT<(((i=t.face.embedding)==null?void 0:i.skipFrames)||0),s=(((o=t.face.embedding)==null?void 0:o.skipTime)||0)>oe()-OT;return t.skipAllowed&&s&&a&&PT===n&&Sx[r]?(zT++,Sx[r]):new Promise(async l=>{var d;let u=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(xn==null?void 0:xn.inputs[0].shape)){let h={};h.crop=Ie.resizeBilinear(e,[xn.inputs[0].shape[2],xn.inputs[0].shape[1]],!1),h.data=xn==null?void 0:xn.execute(h.crop);let p=await h.data.data();u=Array.from(p)}Sx[r]=u,PT=n,OT=oe(),l(u)})}var ds,Yi=0,Y3e=2.3,Tx=ea.leftEyeLower0,Nx=ea.rightEyeLower0,qd={leftBounds:[Tx[0],Tx[Tx.length-1]],rightBounds:[Nx[0],Nx[Nx.length-1]]},Xd={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function UT(e){var t;return he.initial&&(ds=null),ds?e.debug&&se("cached model:",ds.modelUrl):ds=await Ge((t=e.face.iris)==null?void 0:t.modelPath),Yi=ds.inputs[0].shape?ds.inputs[0].shape[2]:0,Yi===-1&&(Yi=64),ds}function i1(e,t,r,n){for(let a=0;a{let t=e[qd.leftBounds[0]][2],r=e[qd.rightBounds[0]][2];return t-r},BT=(e,t,r,n,a,s=!1)=>{let i=Jm(Ym(sT([e[r],e[n]]),Y3e)),o=Ud(i),l=Ie.cropAndResize(t,[[i.startPoint[1]/a,i.startPoint[0]/a,i.endPoint[1]/a,i.endPoint[0]/a]],[0],[Yi,Yi]);if(s&&he.kernels.includes("flipleftright")){let u=Ie.flipLeftRight(l);te(l),l=u}return{box:i,boxSize:o,crop:l}},WT=(e,t,r,n=!1)=>{let a=[];for(let s=0;s{let n=e[ea[`${r}EyeUpper0`][Xd.upperCenter]][2],a=e[ea[`${r}EyeLower0`][Xd.lowerCenter]][2],s=(n+a)/2;return t.map((i,o)=>{let l=s;return o===2?l=n:o===4&&(l=a),[i[0],i[1],l]})};async function GT(e,t,r,n){if(!ds)return r.debug&&se("face mesh iris detection requested, but model is not loaded"),e;let{box:a,boxSize:s,crop:i}=BT(e,t,qd.leftBounds[0],qd.leftBounds[1],n,!0),{box:o,boxSize:l,crop:u}=BT(e,t,qd.rightBounds[0],qd.rightBounds[1],n,!0),d=St([i,u]);te(i),te(u);let h=ds.execute(d);te(d);let p=await h.data();te(h);let c=p.slice(0,Xd.numCoordinates*3),{rawCoords:m,iris:f}=WT(c,a,s,!0),g=p.slice(Xd.numCoordinates*3),{rawCoords:y,iris:A}=WT(g,o,l,!1),x=J3e(e);Math.abs(x)<30?(i1(e,m,"left",null),i1(e,y,"right",null)):x<1?i1(e,m,"left",["EyeUpper0","EyeLower0"]):i1(e,y,"right",["EyeUpper0","EyeLower0"]);let b=VT(e,f,"left"),w=VT(e,A,"right");return e.concat(b).concat(w)}var Q3e=[[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]],e5e=[[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]],t5e=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],r5e=[[474,475],[475,476],[476,477],[477,474]],n5e=[[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]],a5e=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],s5e=[[469,470],[470,471],[471,472],[472,469]],i5e=[[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 Ji(e){let t=e.map(r=>r[0]);return t.push(e[e.length-1][1]),t}var o5e={lips:Ji(Q3e),leftEye:Ji(e5e),leftEyebrow:Ji(t5e),leftIris:Ji(r5e),rightEye:Ji(n5e),rightEyebrow:Ji(a5e),rightIris:Ji(s5e),faceOval:Ji(i5e)},l5e=Object.entries(o5e).map(([e,t])=>t.map(r=>[r,e])).flat(),n8e=new Map(l5e),oc=[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],jl=[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],Hl=[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 qT(e,t){let r={lips:await t.filter(s=>s.size===160)[0].data(),irisL:await t.filter(s=>s.size===10)[0].data(),eyeL:await t.filter(s=>s.size===142)[0].data(),irisR:await t.filter(s=>s.size===10)[1].data(),eyeR:await t.filter(s=>s.size===142)[1].data()},n=jl.reduce((s,i)=>s+=e[i][2],0)/jl.length;for(let s=0;ss+=e[i][2],0)/Hl.length;for(let s=0;soe()-Ba.timestamp,n=Ba.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!r||!n||Ba.boxes.length===0?(Ba.boxes=await fT(e,t),Ba.timestamp=oe(),Ba.skipped=0):Ba.skipped++;let a=[],s=[],i=0;for(let A=0;AP.shape[P.shape.length-1]===1),R=T.find(P=>P.shape[P.shape.length-1]===1404),O=await E.data();I.faceScore=Math.round(100*O[0])/100;let $=U(R,[-1,3]),S=await $.array();if(I.faceScore<(((c=t.face.detector)==null?void 0:c.minConfidence)||1)){if(x.confidence=I.faceScore,(m=t.face.mesh)!=null&&m.keepInvalid){I.box=Km(x,e),I.boxRaw=Zm(x,e),I.score=I.boxScore,I.mesh=x.landmarks.map(P=>[(x.startPoint[0]+x.endPoint[0])/2+(x.endPoint[0]+x.startPoint[0])*P[0]/Gd(),(x.startPoint[1]+x.endPoint[1])/2+(x.endPoint[1]+x.startPoint[1])*P[1]/Gd()]),I.meshRaw=I.mesh.map(P=>[P[0]/(e.shape[2]||0),P[1]/(e.shape[1]||0),(P[2]||0)/ql]);for(let P of Object.keys(Wl))I.annotations[P]=[I.mesh[Wl[P]]]}}else{(f=t.face.attention)!=null&&f.enabled?S=await qT(S,T):(g=t.face.iris)!=null&&g.enabled&&(S=await GT(S,I.tensor,t,ql)),I.mesh=lT(S,x,b,w,ql),I.meshRaw=I.mesh.map(z=>[z[0]/(e.shape[2]||0),z[1]/(e.shape[1]||0),(z[2]||0)/ql]);for(let z of Object.keys(ea))I.annotations[z]=ea[z].map(j=>I.mesh[j]);I.score=I.faceScore;let P={...dT(I.mesh,x),confidence:x.confidence,landmarks:x.landmarks};I.box=Km(P,e),I.boxRaw=Zm(P,e),s.push(P)}te([...T,$])}else{I.box=Km(x,e),I.boxRaw=Zm(x,e),I.score=I.boxScore,I.mesh=x.landmarks.map(T=>[(x.startPoint[0]+x.endPoint[0])/2+(x.endPoint[0]+x.startPoint[0])*T[0]/Gd(),(x.startPoint[1]+x.endPoint[1])/2+(x.endPoint[1]+x.startPoint[1])*T[1]/Gd()]),I.meshRaw=I.mesh.map(T=>[T[0]/(e.shape[2]||0),T[1]/(e.shape[1]||0),(T[2]||0)/ql]);for(let T of Object.keys(Wl))I.annotations[T]=[I.mesh[Wl[T]]]}I.score>(((y=t.face.detector)==null?void 0:y.minConfidence)||1)?a.push(I):te(I.tensor)}return Ba.boxes=s,a}async function KT(e){var t,r,n,a,s,i;return he.initial&&(Mr=null),((r=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:r.enabled)&&(Mr==null?void 0:Mr.signature)&&Object.keys(((n=Mr==null?void 0:Mr.signature)==null?void 0:n.outputs)||{}).length<6&&(Mr=null),Mr?e.debug&&se("cached model:",Mr.modelUrl):(a=e.face.attention)!=null&&a.enabled?Mr=await Ge((s=e.face.attention)==null?void 0:s.modelPath):Mr=await Ge((i=e.face.mesh)==null?void 0:i.modelPath),ql=Mr.inputs[0].shape?Mr.inputs[0].shape[2]:0,Mr}var ZT=Vl,YT=ac;var bn,o1=[],JT=0,QT=0,Rx=Number.MAX_SAFE_INTEGER;async function eN(e){var t;return he.initial&&(bn=null),bn?e.debug&&se("cached model:",bn.modelUrl):bn=await Ge((t=e.face.description)==null?void 0:t.modelPath),bn}function $x(e){let t=e.image||e.tensor||e;if(!(bn!=null&&bn.inputs[0].shape))return t;let r=Ie.resizeBilinear(t,[bn.inputs[0].shape[2],bn.inputs[0].shape[1]],!1),n=L(r,Qe.tf255);return te(r),n}async function Mx(e,t,r,n){var i,o,l,u;if(!bn)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let a=Rx<(((i=t.face.description)==null?void 0:i.skipFrames)||0),s=(((o=t.face.description)==null?void 0:o.skipTime)||0)>oe()-JT;return t.skipAllowed&&a&&s&&QT===n&&((l=o1[r])==null?void 0:l.age)&&((u=o1[r])==null?void 0:u.age)>0?(Rx++,o1[r]):(Rx=0,new Promise(async d=>{var p,c;let h={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((p=t.face.description)!=null&&p.enabled){let m=$x(e),f=bn==null?void 0:bn.execute(m);JT=oe(),te(m);let y=await(await f.find(R=>R.shape[1]===1)).data(),A=Math.trunc(200*Math.abs(y[0]-.5))/100;A>(((c=t.face.description)==null?void 0:c.minConfidence)||0)&&(h.gender=y[0]<=.5?"female":"male",h.genderScore=Math.min(.99,A));let x=$n(f.find(R=>R.shape[1]===100),1),b=(await x.data())[0];te(x);let I=await f.find(R=>R.shape[1]===100).data();h.age=Math.round(I[b-1]>I[b+1]?10*b-100*I[b-1]:10*b+100*I[b+1])/10;let T=f.find(R=>R.shape[1]===1024),E=T?await T.data():[];h.descriptor=Array.from(E),f.forEach(R=>te(R))}o1[r]=h,QT=n,d(h)}))}function l1(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function lc(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function nN(e,t,r){let n=t.shape[1],a=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/a,e.endPoint[1]/n,e.endPoint[0]/a]];return Ie.cropAndResize(t,s,[0],r)}function aN(e,t){let r=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],a=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:r,endPoint:n,palmLandmarks:a,confidence:e.confidence}}function u1(e,t=1.5){let r=lc(e),n=l1(e),a=[t*n[0]/2,t*n[1]/2],s=[r[0]-a[0],r[1]-a[1]],i=[r[0]+a[0],r[1]+a[1]];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function d1(e){let t=lc(e),r=l1(e),a=Math.max(...r)/2,s=[t[0]-a,t[1]-a],i=[t[0]+a,t[1]+a];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function d5e(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function sN(e,t){let r=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return d5e(r)}var tN=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Qi(e,t){let r=0;for(let n=0;n[r.x,r.y]),this.anchorsTensor=ca(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=Nt([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Nt([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let r={};r.boxOffsets=_e(t,[0,0],[-1,2]),r.boxSizes=_e(t,[0,2],[-1,2]),r.div=pe(r.boxOffsets,this.inputSizeTensor),r.boxCenterPoints=le(r.div,this.anchorsTensor),r.halfBoxSizes=pe(r.boxSizes,this.doubleInputSizeTensor),r.sub=ce(r.boxCenterPoints,r.halfBoxSizes),r.startPoints=L(r.sub,this.inputSizeTensor),r.add=le(r.boxCenterPoints,r.halfBoxSizes),r.endPoints=L(r.add,this.inputSizeTensor);let n=xd([r.startPoints,r.endPoints],1);return Object.keys(r).forEach(a=>te(r[a])),n}normalizeLandmarks(t,r){let n={};n.reshape=U(t,[-1,7,2]),n.div=pe(n.reshape,this.inputSizeTensor),n.landmarks=le(n.div,this.anchors[r]);let a=L(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>te(n[s])),a}async predict(t,r){let n={};n.resize=Ie.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=pe(n.resize,Qe.tf127),n.image=ce(n.div,Qe.tf1),n.batched=this.model.execute(n.image),n.predictions=et(n.batched),n.slice=_e(n.predictions,[0,0],[-1,1]),n.sigmoid=Tr(n.slice),n.scores=et(n.sigmoid);let a=await n.scores.data();n.boxes=_e(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await Ie.nonMaxSuppressionAsync(n.norm,n.scores,3*r.hand.maxDetected,r.hand.iouThreshold,r.hand.minConfidence);let s=await n.nms.array(),i=[];for(let o of s){let l={};l.box=_e(n.norm,[o,0],[1,-1]),l.slice=_e(n.predictions,[o,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,o),l.palmLandmarks=U(l.norm,[-1,2]);let u=await l.box.data(),d=u.slice(0,2),h=u.slice(2,4),p=await l.palmLandmarks.array(),c={startPoint:d,endPoint:h,palmLandmarks:p,confidence:a[o]},m=aN(c,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);i.push(m),Object.keys(l).forEach(f=>te(l[f]))}return Object.keys(n).forEach(o=>te(n[o])),i}};var f5e=5,uN=1.65,dN=[0,5,9,13,17,1,2],m5e=0,g5e=2,pN=0,h1=class{constructor(t,r){fe(this,"handDetector");fe(this,"handPoseModel");fe(this,"inputSize");fe(this,"storedBoxes");fe(this,"skipped");fe(this,"detectedHands");this.handDetector=t,this.handPoseModel=r,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let r=t.map(i=>i[0]),n=t.map(i=>i[1]),a=[Math.min(...r),Math.min(...n)],s=[Math.max(...r),Math.max(...n)];return{startPoint:a,endPoint:s}}getBoxForPalmLandmarks(t,r){let n=t.map(s=>Px([...s,1],r)),a=this.calculateLandmarksBoundingBox(n);return u1(d1(a),f5e)}getBoxForHandLandmarks(t){let r=this.calculateLandmarksBoundingBox(t),n=u1(d1(r),uN);n.palmLandmarks=[];for(let a=0;a[i[0]*(c[0]-this.inputSize/2),i[1]*(c[1]-this.inputSize/2),i[2]*c[2]]),l=_x(n,[0,0]),u=o.map(c=>[...Px(c,l),c[2]]),d=iN(a),h=[...lc(r),1],p=[Qi(h,d[0]),Qi(h,d[1])];return u.map(c=>[Math.trunc(c[0]+p[0]),Math.trunc(c[1]+p[1]),Math.trunc(c[2])])}async estimateHands(t,r){let n=!1,a,s=(r.hand.skipTime||0)>oe()-pN,i=this.skipped<(r.hand.skipFrames||0);r.skipAllowed&&s&&i&&(a=await this.handDetector.predict(t,r),this.skipped=0),r.skipAllowed&&this.skipped++,a&&a.length>0&&(a.length!==this.detectedHands&&this.detectedHands!==r.hand.maxDetected||!r.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...a],this.storedBoxes.length>0&&(n=!0));let o=[];for(let l=0;l=r.hand.minConfidence/4){let w=U(x,[-1,3]),I=await w.array();te(x),te(w);let T=this.transformRawCoords(I,f,d,m),E=this.getBoxForHandLandmarks(T);this.storedBoxes[l]={...E,confidence:b};let R={landmarks:T,confidence:b,boxConfidence:u.confidence,fingerConfidence:b,box:{topLeft:E.startPoint,bottomRight:E.endPoint}};o.push(R)}else this.storedBoxes[l]=null;te(x)}else{let d=u1(d1(u),uN),h={confidence:u.confidence,boxConfidence:u.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};o.push(h)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=o.length,o.length>r.hand.maxDetected&&(o.length=r.hand.maxDetected),o}};var Jr={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=>Jr.nameMapping[e],getPoints:e=>Jr.pointsMapping[e]},to={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>to.nameMapping[e]},Bt={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=>Bt.nameMapping[e]},eo=class{constructor(t){fe(this,"name");fe(this,"curls");fe(this,"directions");fe(this,"weights");fe(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,r,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([r,n])}direction(t,r,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([r,n])}weight(t,r){this.weights[t]=r;let n=this.weights.reduce((a,s)=>a+s,0);this.weightsRelative=this.weights.map(a=>a*5/n)}matchAgainst(t,r){let n=0;for(let a in t){let s=t[a],i=this.curls[a];if(typeof i=="undefined"){n+=this.weightsRelative[a];continue}for(let[o,l]of i)if(s===o){n+=l*this.weightsRelative[a];break}}for(let a in r){let s=r[a],i=this.directions[a];if(typeof i=="undefined"){n+=this.weightsRelative[a];continue}for(let[o,l]of i)if(s===o){n+=l*this.weightsRelative[a];break}}return n/10}};var{thumb:wa,index:ps,middle:hs,ring:Xl,pinky:Kl}=Jr,{none:ka,half:A5e,full:Ia}=to,{verticalUp:Kd,verticalDown:A8e,horizontalLeft:Ox,horizontalRight:x5e,diagonalUpRight:b5e,diagonalUpLeft:Zd,diagonalDownRight:x8e,diagonalDownLeft:b8e}=Bt,ro=new eo("thumbs up");ro.curl(wa,ka,1);ro.direction(wa,Kd,1);ro.direction(wa,Zd,.25);ro.direction(wa,b5e,.25);for(let e of[Jr.index,Jr.middle,Jr.ring,Jr.pinky])ro.curl(e,Ia,1),ro.direction(e,Ox,1),ro.direction(e,x5e,1);var tr=new eo("victory");tr.curl(wa,A5e,.5);tr.curl(wa,ka,.5);tr.direction(wa,Kd,1);tr.direction(wa,Zd,1);tr.curl(ps,ka,1);tr.direction(ps,Kd,.75);tr.direction(ps,Zd,1);tr.curl(hs,ka,1);tr.direction(hs,Kd,1);tr.direction(hs,Zd,.75);tr.curl(Xl,Ia,1);tr.direction(Xl,Kd,.2);tr.direction(Xl,Zd,1);tr.direction(Xl,Ox,.2);tr.curl(Kl,Ia,1);tr.direction(Kl,Kd,.2);tr.direction(Kl,Zd,1);tr.direction(Kl,Ox,.2);tr.weight(ps,2);tr.weight(hs,2);var no=new eo("point");no.curl(wa,Ia,1);no.curl(ps,ka,.5);no.curl(hs,Ia,.5);no.curl(Xl,Ia,.5);no.curl(Kl,Ia,.5);no.weight(ps,2);no.weight(hs,2);var ao=new eo("middle finger");ao.curl(wa,ka,1);ao.curl(ps,Ia,.5);ao.curl(hs,Ia,.5);ao.curl(Xl,Ia,.5);ao.curl(Kl,Ia,.5);ao.weight(ps,2);ao.weight(hs,2);var Yd=new eo("open palm");Yd.curl(wa,ka,.75);Yd.curl(ps,ka,.75);Yd.curl(hs,ka,.75);Yd.curl(Xl,ka,.75);Yd.curl(Kl,ka,.75);var hN=[ro,tr,no,ao,Yd];var v5e=.7,Zl={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 cN(e,t,r,n){let a=(t-n)/(e-r),s=Math.atan(a)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function mN(e,t){if(!e||!t)return[0,0];let r=cN(e[0],e[1],t[0],t[1]);if(e.length===2)return r;let n=cN(e[1],e[2],t[1],t[2]);return[r,n]}function fN(e,t=1){let r=0,n=0,a=0;return e>=75&&e<=105?r=1*t:e>=25&&e<=155?n=1*t:a=1*t,[r,n,a]}function w5e(e,t,r){let n=e[0]-t[0],a=e[0]-r[0],s=t[0]-r[0],i=e[1]-t[1],o=e[1]-r[1],l=t[1]-r[1],u=e[2]-t[2],d=e[2]-r[2],h=t[2]-r[2],p=Math.sqrt(n*n+i*i+u*u),c=Math.sqrt(a*a+o*o+d*d),m=Math.sqrt(s*s+l*l+h*h),f=(m*m+p*p-c*c)/(2*m*p);f>1?f=1:f<-1&&(f=-1);let g=Math.acos(f);g=57.2958*g%180;let y;return g>Zl.NO_CURL_START_LIMIT?y=to.none:g>Zl.HALF_CURL_START_LIMIT?y=to.half:y=to.full,y}function gN(e,t,r,n){let a;return n===Math.abs(e)?e>0?a=Bt.horizontalLeft:a=Bt.horizontalRight:n===Math.abs(t)?t>0?a=Bt.horizontalLeft:a=Bt.horizontalRight:r>0?a=Bt.horizontalLeft:a=Bt.horizontalRight,a}function yN(e,t,r,n){let a;return n===Math.abs(e)?e<0?a=Bt.verticalDown:a=Bt.verticalUp:n===Math.abs(t)?t<0?a=Bt.verticalDown:a=Bt.verticalUp:r<0?a=Bt.verticalDown:a=Bt.verticalUp,a}function k5e(e,t,r,n,a,s,i,o){let l,u=yN(e,t,r,n),d=gN(a,s,i,o);return u===Bt.verticalUp?d===Bt.horizontalLeft?l=Bt.diagonalUpLeft:l=Bt.diagonalUpRight:d===Bt.horizontalLeft?l=Bt.diagonalDownLeft:l=Bt.diagonalDownRight,l}function I5e(e,t,r,n){let a=e[0]-t[0],s=e[0]-r[0],i=t[0]-r[0],o=e[1]-t[1],l=e[1]-r[1],u=t[1]-r[1],d=Math.max(Math.abs(a),Math.abs(s),Math.abs(i)),h=Math.max(Math.abs(o),Math.abs(l),Math.abs(u)),p=0,c=0,m=0,f=h/(d+1e-5);f>1.5?p+=Zl.DISTANCE_VOTE_POWER:f>.66?c+=Zl.DISTANCE_VOTE_POWER:m+=Zl.DISTANCE_VOTE_POWER;let g=Math.sqrt(a*a+o*o),y=Math.sqrt(s*s+l*l),A=Math.sqrt(i*i+u*u),x=Math.max(g,y,A),b=e[0],w=e[1],I=r[0],T=r[1];x===g?(I=r[0],T=r[1]):x===A&&(b=t[0],w=t[1]);let O=mN([b,w],[I,T]),$=fN(O,Zl.TOTAL_ANGLE_VOTE_POWER);p+=$[0],c+=$[1],m+=$[2];for(let P of n){let z=fN(P,Zl.SINGLE_ANGLE_VOTE_POWER);p+=z[0],c+=z[1],m+=z[2]}let S;return p===Math.max(p,c,m)?S=yN(l,o,u,h):m===Math.max(c,m)?S=gN(s,a,i,d):S=k5e(l,o,u,h,s,a,i,d),S}function AN(e){let t=[],r=[],n=[],a=[];if(!e)return{curls:n,directions:a};for(let s of Jr.all){let i=Jr.getPoints(s),o=[],l=[];for(let u of i){let d=e[u[0]],h=e[u[1]],p=mN(d,h),c=p[0],m=p[1];o.push(c),l.push(m)}t.push(o),r.push(l)}for(let s of Jr.all){let i=s===Jr.thumb?1:0,o=Jr.getPoints(s),l=e[o[i][0]],u=e[o[i+1][1]],d=e[o[3][1]],h=w5e(l,u,d),p=I5e(l,u,d,t[s].slice(i));n[s]=h,a[s]=p}return{curls:n,directions:a}}function c1(e){if(!e||e.length===0)return null;let t=AN(e),r={};for(let n of Jr.all)r[Jr.getName(n)]={curl:to.getName(t.curls[n]),direction:Bt.getName(t.directions[n])};return r}function xN(e){let t=[];if(!e||e.length===0)return t;let r=AN(e);for(let n of hN){let a=n.matchAgainst(r.curls,r.directions);a>=v5e&&t.push({name:n.name,confidence:a})}return t}var bN={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]},Jd,Qd,vN;async function Dx(e,t){let r=await vN.estimateHands(e,t);if(!r)return[];let n=[];for(let a=0;ar[a].landmarks[h]);let i=r[a].landmarks,o=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(i&&i.length>0){for(let d of i)d[0]o[2]&&(o[2]=d[0]),d[1]>o[3]&&(o[3]=d[1]);o[2]-=o[0],o[3]-=o[1],l=[o[0]/(e.shape[2]||0),o[1]/(e.shape[1]||0),o[2]/(e.shape[2]||0),o[3]/(e.shape[1]||0)]}else o=r[a].box?[Math.trunc(Math.max(0,r[a].box.topLeft[0])),Math.trunc(Math.max(0,r[a].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,r[a].box.bottomRight[0])-Math.max(0,r[a].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,r[a].box.bottomRight[1])-Math.max(0,r[a].box.topLeft[1]))]:[0,0,0,0],l=[r[a].box.topLeft[0]/(e.shape[2]||0),r[a].box.topLeft[1]/(e.shape[1]||0),(r[a].box.bottomRight[0]-r[a].box.topLeft[0])/(e.shape[2]||0),(r[a].box.bottomRight[1]-r[a].box.topLeft[1])/(e.shape[1]||0)];let u=c1(i);n.push({id:a,score:Math.round(100*r[a].confidence)/100,boxScore:Math.round(100*r[a].boxConfidence)/100,fingerScore:Math.round(100*r[a].fingerConfidence)/100,label:"hand",box:o,boxRaw:l,keypoints:i,annotations:s,landmarks:u})}return n}async function Lx(e){var r,n;he.initial&&(Jd=null,Qd=null),!Jd||!Qd?[Jd,Qd]=await Promise.all([e.hand.enabled?Ge((r=e.hand.detector)==null?void 0:r.modelPath):null,e.hand.landmarks?Ge((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&se("cached model:",Jd.modelUrl),e.debug&&se("cached model:",Qd.modelUrl));let t=new p1(Jd);return vN=new h1(t,Qd),[Jd,Qd]}var pr=[null,null],S5e=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],so=[[0,0],[0,0]],C5e=["hand","fist","pinch","point","face","tip","pinchtip"],kN=4,IN=1.6,T5e=512,N5e=1.4,f1=Number.MAX_SAFE_INTEGER,Bx=0,cs=[0,0],Ht={boxes:[],hands:[]},SN={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 CN(e){var t;if(he.initial&&(pr[0]=null),pr[0])e.debug&&se("cached model:",pr[0].modelUrl);else{m1(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),pr[0]=await Ge((t=e.hand.detector)==null?void 0:t.modelPath);let r=Object.values(pr[0].modelSignature.inputs);so[0][0]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[1].size):0,so[0][1]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[2].size):0}return pr[0]}async function TN(e){var t;if(he.initial&&(pr[1]=null),pr[1])e.debug&&se("cached model:",pr[1].modelUrl);else{pr[1]=await Ge((t=e.hand.skeleton)==null?void 0:t.modelPath);let r=Object.values(pr[1].modelSignature.inputs);so[1][0]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[1].size):0,so[1][1]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[2].size):0}return pr[1]}async function E5e(e,t){let r=[];if(!e||!pr[0])return r;let n={},a=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,T5e),i=Math.round(s*a/8)*8;n.resize=Ie.resizeBilinear(e,[s,i]),n.cast=me(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await pr[0].executeAsync(n.cast,S5e),n.boxes=et(n.rawBoxes,[0,2]),n.scores=et(n.rawScores,[0]);let o=an(n.scores,1);te(o[kN]),o.splice(kN,1),n.filtered=ur(o,1),te(o),n.max=yr(n.filtered,1),n.argmax=$n(n.filtered,1);let l=0;n.nms=await Ie.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let u=await n.nms.data(),d=await n.max.data(),h=await n.argmax.data();for(let p of Array.from(u)){let c=_e(n.boxes,p,1),m=await c.data();te(c);let f=[m[1],m[0],m[3]-m[1],m[2]-m[0]],g=t1(f,N5e),y=[Math.trunc(f[0]*cs[0]),Math.trunc(f[1]*cs[1]),Math.trunc(f[2]*cs[0]),Math.trunc(f[3]*cs[1])],A=d[p],x=C5e[h[p]],b={id:l++,score:A,box:y,boxRaw:g,label:x};r.push(b)}return Object.keys(n).forEach(p=>te(n[p])),r.sort((p,c)=>c.score-p.score),r.length>(t.hand.maxDetected||1)&&(r.length=t.hand.maxDetected||1),r}async function Wx(e,t,r){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&&pr[1]&&r.hand.landmarks&&t.score>(r.hand.minConfidence||0)){let a={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];a.crop=Ie.cropAndResize(e,[s],[0],[so[1][0],so[1][1]],"bilinear"),a.div=pe(a.crop,Qe.tf255),[a.score,a.keypoints]=pr[1].execute(a.div,["Identity_1","Identity"]);let i=(await a.score.data())[0],o=(100-Math.trunc(100/(1+Math.exp(i))))/100;if(o>=(r.hand.minConfidence||0)){n.fingerScore=o,a.reshaped=U(a.keypoints,[-1,3]);let d=(await a.reshaped.array()).map(h=>[h[0]/so[1][1],h[1]/so[1][0],h[2]||0]).map(h=>[h[0]*t.boxRaw[2],h[1]*t.boxRaw[3],h[2]||0]);n.keypoints=d.map(h=>[cs[0]*(h[0]+t.boxRaw[0]),cs[1]*(h[1]+t.boxRaw[1]),h[2]||0]),n.landmarks=c1(n.keypoints);for(let h of Object.keys(SN))n.annotations[h]=SN[h].map(p=>n.landmarks&&n.keypoints[p]?n.keypoints[p]:null)}Object.keys(a).forEach(l=>te(a[l]))}return n}async function Vx(e,t){var a,s;if(!pr[0]||!pr[1]||!((a=pr[0])!=null&&a.inputs[0].shape)||!((s=pr[1])!=null&&s.inputs[0].shape))return[];cs=[e.shape[2]||0,e.shape[1]||0],f1++;let r=(t.hand.skipTime||0)>oe()-Bx,n=f1<(t.hand.skipFrames||0);return t.skipAllowed&&r&&n?Ht.hands:new Promise(async i=>{let o=3*(t.hand.skipTime||0)>oe()-Bx,l=f1<3*(t.hand.skipFrames||0);t.skipAllowed&&Ht.hands.length===t.hand.maxDetected?Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))):t.skipAllowed&&o&&l&&Ht.hands.length>0?Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))):(Ht.boxes=await E5e(e,t),Bx=oe(),Ht.hands=await Promise.all(Ht.boxes.map(d=>Wx(e,d,t))),f1=0);let u=[...Ht.boxes];if(Ht.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&h.box[3]/(e.shape[1]||1)>.05&&Ht.hands[d].fingerScore&&Ht.hands[d].fingerScore>(t.hand.minConfidence||0)){let p=t1(h.box,IN),c=t1(h.boxRaw,IN);Ht.boxes.push({...u[d],box:p,boxRaw:c})}}for(let d=0;doe()-RN,s=Ux<(((o=t.face.liveness)==null?void 0:o.skipFrames)||0);return t.skipAllowed&&a&&s&&EN===n&&g1[r]?(Ux++,g1[r]):(Ux=0,new Promise(async l=>{let u=Ie.resizeBilinear(e,[Fr!=null&&Fr.inputs[0].shape?Fr.inputs[0].shape[2]:0,Fr!=null&&Fr.inputs[0].shape?Fr.inputs[0].shape[1]:0],!1),d=Fr==null?void 0:Fr.execute(u),h=(await d.data())[0];g1[r]=Math.round(100*h)/100,EN=n,RN=oe(),te([u,d]),l(g1[r])}))}var uc={};vs(uc,{connected:()=>A1,horizontal:()=>jx,kpt:()=>y1,relative:()=>qx,vertical:()=>Hx});var y1=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],jx=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Hx=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],qx=[[["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 FN=.005,vn={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function Xx(e){for(let t of jx){let r=e.keypoints.findIndex(a=>a.part===t[0]),n=e.keypoints.findIndex(a=>a.part===t[1]);if(e.keypoints[r]&&e.keypoints[n]&&e.keypoints[r].position[0]a&&a.part===t[0]),n=e.keypoints.findIndex(a=>a&&a.part===t[1]);e.keypoints[r]&&e.keypoints[n]&&e.keypoints[r].position[1]u&&u.part===t[0]),a=e.keypoints.findIndex(u=>u&&u.part===t[1]),s=e.keypoints.findIndex(u=>u&&u.part===r[0]),i=e.keypoints.findIndex(u=>u&&u.part===r[1]);if(!e.keypoints[s]||!e.keypoints[i])continue;let o=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[i].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[a]?[Math.abs(e.keypoints[i].position[0]-e.keypoints[a].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[a].position[0])]:[0,0];if(o[0]>o[1]||l[0]>l[1]){let u=e.keypoints[n];e.keypoints[n]=e.keypoints[a],e.keypoints[a]=u}}}function _N(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]],r.pad=Xn(e,vn.padding),r.resize=Ie.resizeBilinear(r.pad,[t,t]);let n=me(r.resize,"int32");return Object.keys(r).forEach(a=>te(r[a])),n}function ON(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+vn.padding[2][0]+vn.padding[2][1])/t[0]-vn.padding[2][0],n.position[1]*(t[1]+vn.padding[1][0]+vn.padding[1][1])/t[1]-vn.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let r=ls(e.keypoints.map(n=>n.position),t);return e.box=r.box,e.boxRaw=r.boxRaw,e}var wn,x1=0,Kx=Number.MAX_SAFE_INTEGER,Yl={boxes:[],bodies:[],last:0};async function zN(e){return he.initial&&(wn=null),wn?e.debug&&se("cached model:",wn.modelUrl):(m1(["size"],e),wn=await Ge(e.body.modelPath)),x1=wn.inputs[0].shape?wn.inputs[0].shape[2]:0,x1<64&&(x1=256),wn}async function $5e(e,t,r){let n=e[0][0],a=[],s=0;for(let d=0;dt.body.minConfidence){let h=[n[d][1],n[d][0]];a.push({score:Math.round(100*s)/100,part:y1[d],positionRaw:h,position:[Math.round((r.shape[2]||0)*h[0]),Math.round((r.shape[1]||0)*h[1])]})}s=a.reduce((d,h)=>h.score>d?h.score:d,0);let i=[],o=ls(a.map(d=>d.position),[r.shape[2],r.shape[1]]),l={};for(let[d,h]of Object.entries(A1)){let p=[];for(let c=0;cg.part===h[c]),f=a.find(g=>g.part===h[c+1]);m&&f&&m.score>(t.body.minConfidence||0)&&f.score>(t.body.minConfidence||0)&&p.push([m.position,f.position])}l[d]=p}let u={id:0,score:s,box:o.box,boxRaw:o.boxRaw,keypoints:a,annotations:l};return Xx(u),i.push(u),i}async function M5e(e,t,r){let n=[];for(let a=0;at.body.minConfidence){let o=[];for(let h=0;h<17;h++){let p=s[3*h+2];if(p>t.body.minConfidence){let c=[s[3*h+1],s[3*h+0]];o.push({part:y1[h],score:Math.round(100*p)/100,positionRaw:c,position:[Math.round((r.shape[2]||0)*c[0]),Math.round((r.shape[1]||0)*c[1])]})}}let l=ls(o.map(h=>h.position),[r.shape[2],r.shape[1]]),u={};for(let[h,p]of Object.entries(A1)){let c=[];for(let m=0;my.part===p[m]),g=o.find(y=>y.part===p[m+1]);f&&g&&f.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&c.push([f.position,g.position])}u[h]=c}let d={id:a,score:i,box:l.box,boxRaw:l.boxRaw,keypoints:[...o],annotations:u};Xx(d),n.push(d)}}return n.sort((a,s)=>s.score-a.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function Zx(e,t){if(!wn||!(wn!=null&&wn.inputs[0].shape))return[];t.skipAllowed||(Yl.boxes.length=0),Kx++;let r=(t.body.skipTime||0)>oe()-Yl.last,n=Kx<(t.body.skipFrames||0);return t.skipAllowed&&r&&n?Yl.bodies:new Promise(async a=>{let s={};Kx=0,s.input=PN(e,x1),s.res=wn==null?void 0:wn.execute(s.input),Yl.last=oe();let i=await s.res.array();Yl.bodies=s.res.shape[2]===17?await $5e(i,t,e):await M5e(i,t,e);for(let o of Yl.bodies)ON(o,[e.shape[2]||1,e.shape[1]||1]),_N(o.keypoints);Object.keys(s).forEach(o=>te(s[o])),a(Yl.bodies)})}var ep,b1=[],LN=0,Yx=Number.MAX_SAFE_INTEGER,w1=0,v1=2.5;async function BN(e){if(!ep||he.initial){ep=await Ge(e.object.modelPath);let t=Object.values(ep.modelSignature.inputs);w1=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&se("cached model:",ep.modelUrl);return ep}async function F5e(e,t,r){let n=0,a=[];for(let l of[1,2,4])X(async()=>{let u=l*13,d=et(e.find(f=>f.shape[1]===u**2&&(f.shape[2]||0)===Hd.length)),h=et(e.find(f=>f.shape[1]===u**2&&(f.shape[2]||0)(r.object.minConfidence||0)&&g!==61){let A=(.5+Math.trunc(f%u))/u,x=(.5+Math.trunc(f/u))/u,b=c[f].map(S=>S*(u/l/w1)),[w,I]=[A-v1/l*b[0],x-v1/l*b[1]],[T,E]=[A+v1/l*b[2]-w,x+v1/l*b[3]-I],R=[w,I,T,E];R=R.map(S=>Math.max(0,Math.min(S,1)));let O=[R[0]*t[0],R[1]*t[1],R[2]*t[0],R[3]*t[1]],$={id:n++,score:Math.round(100*y)/100,class:g+1,label:Hd[g].label,box:O.map(S=>Math.trunc(S)),boxRaw:R};a.push($)}}});e.forEach(l=>te(l));let s=a.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),i=a.map(l=>l.score),o=[];if(s&&s.length>0){let l=await Ie.nonMaxSuppressionAsync(s,i,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence);o=await l.data(),te(l)}return a=a.filter((l,u)=>o.includes(u)).sort((l,u)=>u.score-l.score),a}async function Jx(e,t){let r=(t.object.skipTime||0)>oe()-LN,n=Yx<(t.object.skipFrames||0);return t.skipAllowed&&r&&n&&b1.length>0?(Yx++,b1):(Yx=0,!he.kernels.includes("mod")||!he.kernels.includes("sparsetodense")?b1:new Promise(async a=>{let s=[e.shape[2]||0,e.shape[1]||0],i=Ie.resizeBilinear(e,[w1,w1],!1),o=pe(i,Qe.tf255),l=o.transpose([0,3,1,2]);te(o),te(i);let u;t.object.enabled&&(u=ep.execute(l)),LN=oe(),te(l);let d=await F5e(u,s,t);b1=d,a(d)}))}var pc=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],_5e=pc.length,dc=pc.reduce((e,t,r)=>(e[t]=r,e),{}),P5e=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],G8e=P5e.map(([e,t])=>[dc[e],dc[t]]),VN=[["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 UN(e){let t=e.reduce(({maxX:r,maxY:n,minX:a,minY:s},{position:{x:i,y:o}})=>({maxX:Math.max(r,i),maxY:Math.max(n,o),minX:Math.min(a,i),minY:Math.min(s,o)}),{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 GN(e,[t,r],[n,a]){let s=t/n,i=r/a,o=(u,d)=>({id:d,score:u.score,boxRaw:[u.box[0]/a,u.box[1]/n,u.box[2]/a,u.box[3]/n],box:[Math.trunc(u.box[0]*i),Math.trunc(u.box[1]*s),Math.trunc(u.box[2]*i),Math.trunc(u.box[3]*s)],keypoints:u.keypoints.map(({score:h,part:p,position:c})=>({score:h,part:p,position:[Math.trunc(c.x*i),Math.trunc(c.y*s)],positionRaw:[c.x/n,c.y/n]})),annotations:{}});return e.map((u,d)=>o(u,d))}var k1=class{constructor(t,r){fe(this,"priorityQueue");fe(this,"numberOfElements");fe(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=r}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 r=2*t;if(rr?r:e}function jN(e,t,r,n){let a=r-e,s=n-t;return a*a+s*s}function rb(e,t){return{x:e.x+t.x,y:e.y+t.y}}var Sa,z5e=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],I1=1,tp=16,D5e=50**2;function HN(e,t,r,n,a,s,i=2){let o=y=>({y:s.get(y.y,y.x,e),x:s.get(y.y,y.x,s.shape[2]/2+e)}),l=(y,A,x)=>({y:tb(Math.round(y.y/tp),0,A-1),x:tb(Math.round(y.x/tp),0,x-1)}),[u,d]=n.shape,h=l(t.position,u,d),p=o(h),m=rb(t.position,p);for(let y=0;y[dc[p],dc[c]]),i=s.map(([,p])=>p),o=s.map(([p])=>p),l=t.shape[2],u=i.length,d=new Array(l),h=eb(e.part,tp,r);d[e.part.id]={score:e.score,part:pc[e.part.id],position:h};for(let p=u-1;p>=0;--p){let c=i[p],m=o[p];d[c]&&!d[m]&&(d[m]=HN(p,d[c],m,t,r,a))}for(let p=0;pt){o=!1;break}if(!o)break}return o}function W5e(e,t){let[r,n,a]=t.shape,s=new k1(r*n*a,({score:i})=>i);for(let i=0;i{var i;let s=(i=a[n])==null?void 0:i.position;return s?jN(r,t,s.y,s.x)<=D5e:!1})}function V5e(e,t){return t.reduce((n,{position:a,score:s},i)=>(qN(e,a,i)||(n+=s),n),0)/t.length}function U5e(e,t,r,n,a,s){let i=[],o=W5e(s,t);for(;i.lengthc.score>s);let h=V5e(i,d),p=UN(d);h>s&&i.push({keypoints:d,box:p,score:Math.round(100*h)/100})}return i}async function nb(e,t){let r=X(()=>{if(!Sa.inputs[0].shape)return[];let i=Ie.resizeBilinear(e,[Sa.inputs[0].shape[2],Sa.inputs[0].shape[1]]),o=ce(pe(me(i,"float32"),127.5),1),u=Sa.execute(o,z5e).map(d=>et(d,[0]));return u[1]=Tr(u[1]),u}),n=await Promise.all(r.map(i=>i.buffer()));for(let i of r)te(i);let a=await U5e(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return Sa.inputs[0].shape?GN(a,[e.shape[1],e.shape[2]],[Sa.inputs[0].shape[2],Sa.inputs[0].shape[1]]):[]}async function XN(e){return!Sa||he.initial?Sa=await Ge(e.body.modelPath):e.debug&&se("cached model:",Sa.modelUrl),Sa}var Wa,ab=!1;async function sb(e){return!Wa||he.initial?Wa=await Ge(e.segmentation.modelPath):e.debug&&se("cached model:",Wa.modelUrl),Wa}async function ZN(e,t,r){var f,g;if(ab)return{data:[],canvas:null,alpha:null};ab=!0,Wa||await sb(r);let n=await Vd(e,r),a=((f=n.tensor)==null?void 0:f.shape[2])||0,s=((g=n.tensor)==null?void 0:g.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let i={};i.resize=Ie.resizeBilinear(n.tensor,[Wa.inputs[0].shape?Wa.inputs[0].shape[1]:0,Wa.inputs[0].shape?Wa.inputs[0].shape[2]:0],!1),te(n.tensor),i.norm=pe(i.resize,Qe.tf255),i.res=Wa.execute(i.norm),i.squeeze=et(i.res,0),i.squeeze.shape[2]===2?(i.softmax=Id(i.squeeze),[i.bg,i.fg]=an(i.softmax,2),i.expand=Kt(i.fg,2),i.pad=Kt(i.expand,0),i.crop=Ie.cropAndResize(i.pad,[[0,0,.5,.5]],[0],[a,s]),i.data=et(i.crop,0)):i.data=Ie.resizeBilinear(i.squeeze,[s,a]);let o=Array.from(await i.data.data());if(he.node&&!he.Canvas&&typeof ImageData=="undefined")return r.debug&&se("canvas support missing"),Object.keys(i).forEach(y=>te(i[y])),{data:o,canvas:null,alpha:null};let l=Zr(a,s);Ln&&await Ln.toPixels(i.data,l);let u=l.getContext("2d");r.segmentation.blur&&r.segmentation.blur>0&&(u.filter=`blur(${r.segmentation.blur}px)`);let d=u.getImageData(0,0,a,s),h=Zr(a,s),p=h.getContext("2d");n.canvas&&p.drawImage(n.canvas,0,0),p.globalCompositeOperation="darken",r.segmentation.blur&&r.segmentation.blur>0&&(p.filter=`blur(${r.segmentation.blur}px)`),p.drawImage(l,0,0),p.globalCompositeOperation="source-over",p.filter="none";let c=p.getImageData(0,0,a,s);for(let y=0;yte(i[y])),ab=!1,{data:o,canvas:h,alpha:l}}var hc=class{constructor(){fe(this,"ssrnetage",null);fe(this,"gear",null);fe(this,"blazeposedetect",null);fe(this,"blazepose",null);fe(this,"centernet",null);fe(this,"efficientpose",null);fe(this,"mobilefacenet",null);fe(this,"emotion",null);fe(this,"facedetect",null);fe(this,"faceiris",null);fe(this,"facemesh",null);fe(this,"faceres",null);fe(this,"ssrnetgender",null);fe(this,"handpose",null);fe(this,"handskeleton",null);fe(this,"handtrack",null);fe(this,"liveness",null);fe(this,"movenet",null);fe(this,"nanodet",null);fe(this,"posenet",null);fe(this,"segmentation",null);fe(this,"antispoof",null)}};function S1(e){for(let t of Object.keys(e.models))e.models[t]=null}async function ib(e){var t,r,n,a,s,i,o,l,u,d,h,p,c,m,f,g,y,A,x,b,w,I,T,E,R,O,$,S,P,z,j;he.initial&&S1(e),e.config.hand.enabled&&(!e.models.handpose&&((r=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Lx(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((a=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:a.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Lx(e.config))),e.config.body.enabled&&!e.models.blazepose&&((i=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:i.includes("blazepose"))&&(e.models.blazepose=kT(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=wT(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(o=e.config.body)==null?void 0:o.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=ET(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(u=e.config.body)==null?void 0:u.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=zN(e.config)),e.config.body.enabled&&!e.models.posenet&&((p=(h=e.config.body)==null?void 0:h.modelPath)==null?void 0:p.includes("posenet"))&&(e.models.posenet=XN(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=cT(e.config)),e.config.face.enabled&&((c=e.config.face.antispoof)==null?void 0:c.enabled)&&!e.models.antispoof&&(e.models.antispoof=eT(e.config)),e.config.face.enabled&&((m=e.config.face.liveness)==null?void 0:m.enabled)&&!e.models.liveness&&(e.models.liveness=$N(e.config)),e.config.face.enabled&&((f=e.config.face.description)==null?void 0:f.enabled)&&!e.models.faceres&&(e.models.faceres=eN(e.config)),e.config.face.enabled&&((g=e.config.face.emotion)==null?void 0:g.enabled)&&!e.models.emotion&&(e.models.emotion=FT(e.config)),e.config.face.enabled&&((y=e.config.face.iris)==null?void 0:y.enabled)&&!((A=e.config.face.attention)!=null&&A.enabled)&&!e.models.faceiris&&(e.models.faceiris=UT(e.config)),e.config.face.enabled&&((x=e.config.face.mesh)==null?void 0:x.enabled)&&!e.models.facemesh&&(e.models.facemesh=KT(e.config)),e.config.face.enabled&&((b=e.config.face.gear)==null?void 0:b.enabled)&&!e.models.gear&&(e.models.gear=WC(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=HC(e.config)),e.config.face.enabled&&((I=e.config.face.ssrnet)==null?void 0:I.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=ZC(e.config)),e.config.face.enabled&&((T=e.config.face.mobilefacenet)==null?void 0:T.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=DT(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((R=(E=e.config.hand.detector)==null?void 0:E.modelPath)==null?void 0:R.includes("handtrack"))&&(e.models.handtrack=CN(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&(($=(O=e.config.hand.detector)==null?void 0:O.modelPath)==null?void 0:$.includes("handtrack"))&&(e.models.handskeleton=TN(e.config)),e.config.object.enabled&&!e.models.centernet&&((P=(S=e.config.object)==null?void 0:S.modelPath)==null?void 0:P.includes("centernet"))&&(e.models.centernet=CT(e.config)),e.config.object.enabled&&!e.models.nanodet&&((j=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:j.includes("nanodet"))&&(e.models.nanodet=BN(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=sb(e.config));for await(let K of Object.keys(e.models))e.models[K]&&typeof e.models[K]!="undefined"&&(e.models[K]=await e.models[K])}async function ob(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let r of Object.keys(e.models)){let n=e.models[r];if(!n)continue;let a=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let o of Object.values(s.graph.nodes)){let l=o.op.toLowerCase();a.includes(l)||a.push(l)}else!s&&e.config.debug&&se("model signature not determined:",r);let i=[];for(let o of a)!t.includes(o)&&!e.env.kernels.includes(o)&&!e.env.kernels.includes(o.replace("_",""))&&!e.env.kernels.includes(o.replace("native",""))&&!e.env.kernels.includes(o.replace("v2",""))&&i.push(o);e.config.debug&&i.length>0&&se("model validation failed:",r,i)}}var Rt={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 G5e(){let e=Rt.gl;!e||(Rt.extensions=e.getSupportedExtensions())}async function JN(e){var t;if(e.config.backend==="humangl"&&(Rt.name in Xt().registry&&(!Rt.gl||!Rt.gl.getParameter(Rt.gl.VERSION))&&(se("error: humangl backend invalid context"),S1(e)),!Vy(Rt.name))){try{Rt.canvas=await Zr(100,100)}catch(n){se("error: cannot create canvas:",n);return}try{if(Rt.gl=(t=Rt.canvas)==null?void 0:t.getContext("webgl2",Rt.webGLattr),!Rt.gl.getParameter(Rt.gl.VERSION).includes("2.0")){se("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}Rt.canvas&&(Rt.canvas.addEventListener("webglcontextlost",async a=>{throw se("error: humangl:",a.type),se("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),Rt.canvas.addEventListener("webglcontextrestored",a=>{se("error: humangl context restored:",a)}),Rt.canvas.addEventListener("webglcontextcreationerror",a=>{se("error: humangl context create:",a)}))}catch(n){se("error: cannot get WebGL context:",n);return}try{Mm(2,Rt.gl)}catch(n){se("error: cannot set WebGL context:",n);return}try{let n=new Cu(Rt.gl);El(Rt.name,()=>new Hh(n),Rt.priority)}catch(n){se("error: cannot register WebGL backend:",n);return}try{Fa("webgl").forEach(a=>{let s={...a,backendName:Rt.name};qn(s)})}catch(n){se("error: cannot update WebGL backend registration:",n);return}let r=Dn().getGPGPUContext?Dn().getGPGPUContext().gl:null;if(r)se(`humangl webgl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`);else{se("error: no current gl context:",r,Rt.gl);return}try{ba.set("WEBGL_VERSION",2)}catch(n){se("error: cannot set WebGL backend flags:",n);return}G5e(),se("backend registered:",Rt.name)}}function j5e(){if(!he.kernels.includes("mod")){let e={kernelName:"Mod",backendName:Hr(),kernelFunc:t=>X(()=>ce(t.inputs.a,L(pe(t.inputs.a,t.inputs.b),t.inputs.b)))};qn(e),he.kernels.push("mod")}if(!he.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:Hr(),kernelFunc:t=>X(()=>Sh(t.inputs.a/t.inputs.b)*t.inputs.b+wd(t.inputs.a,t.inputs.b))};qn(e),he.kernels.push("floormod")}}async function T1(e,t=!1){if(e.state="backend",t||he.initial||e.config.backend&&e.config.backend.length>0&&Hr()!==e.config.backend){let r=oe();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&se("running inside web worker"),he.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&se("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),he.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&se(`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")se("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let a=await navigator.gpu.requestAdapter();if(e.config.debug&&se("enumerated webgpu adapter:",a),!a)se("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let s="requestAdapterInfo"in a?await a.requestAdapterInfo():void 0;se("webgpu adapter info:",s)}}e.config.backend==="humangl"&&await JN(e);let n=Object.keys(Xt().registryFactory);if(e.config.debug&&se("available backends:",n),n.includes(e.config.backend)||(se(`error: backend ${e.config.backend} not found in registry`),e.config.backend=he.node?"tensorflow":"webgl",e.config.debug&&se(`override: setting backend ${e.config.backend}`)),e.config.debug&&se("setting backend:",e.config.backend),e.config.backend==="wasm"){try{Z().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(i){}if(e.config.debug&&se("wasm path:",e.config.wasmPath),typeof(Ue==null?void 0:Ue.setWasmPaths)!="undefined")await jA(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let a=await Z().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await Z().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&se(`wasm execution: ${a?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!a&&se("warning: wasm simd support is not enabled")}try{await Wy(e.config.backend),await Ad(),UC()}catch(a){return se("error: cannot set backend:",e.config.backend,a),!1}}if(Hr()==="humangl"&&(ba.set("CHECK_COMPUTATION_FOR_ERRORS",!1),ba.set("WEBGL_CPU_FORWARD",!0),ba.set("WEBGL_USE_SHAPES_UNIFORMS",!0),ba.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(se("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),ba.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),Dn().getGPGPUContext)){let n=await Dn().getGPGPUContext().gl;e.config.debug&&se(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}Hr(),Ly(),await Ad(),e.performance.initBackend=Math.trunc(oe()-r),e.config.backend=Hr(),await he.updateBackend(),j5e()}return!0}function m1(e,t){for(let r of e){let n={kernelName:r,backendName:t.backend,kernelFunc:()=>{t.debug&&se("kernelFunc",r,t.backend)}};qn(n)}he.kernels=Fa(Hr()).map(r=>r.kernelName.toLowerCase())}var fb={};vs(fb,{all:()=>cb,body:()=>np,canvas:()=>hb,face:()=>rp,gesture:()=>ip,hand:()=>ap,object:()=>sp,options:()=>_r,person:()=>pb});var Vn=e=>{if(!e)se("draw error: invalid canvas");else if(!e.getContext)se("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)se("draw error: cannot get canvas context");else return t}return null},Jl=e=>Math.round(e*180/Math.PI),fs=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let r=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${r[0]}, ${r[1]}, ${r[2]}, ${t.alpha})`};function ms(e,t,r,n,a){e.fillStyle=fs(n,a),e.beginPath(),e.arc(t,r,a.pointSize,0,2*Math.PI),e.fill()}function Va(e,t,r,n,a,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let i=(t+t+n)/2,o=(r+r+a)/2;e.ellipse(i,o,n/2,a/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,r),e.lineTo(t+n-s.roundRect,r),e.quadraticCurveTo(t+n,r,t+n,r+s.roundRect),e.lineTo(t+n,r+a-s.roundRect),e.quadraticCurveTo(t+n,r+a,t+n-s.roundRect,r+a),e.lineTo(t+s.roundRect,r+a),e.quadraticCurveTo(t,r+a,t,r+a-s.roundRect),e.lineTo(t,r+s.roundRect),e.quadraticCurveTo(t,r,t+s.roundRect,r),e.closePath();e.stroke()}function lb(e,t,r){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=fs(n[2],r),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),r.fillPolygons&&(e.closePath(),e.fill())}}function eE(e,t,r){if(!(t.length<2)){if(e.lineWidth=r.lineWidth,!r.useCurves||t.length<=2){lb(e,t,r);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(a=>`${Math.trunc(100*a.score)}% ${a.emotion}`);n.length>3&&(n.length=3),r.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&r.push(`roll: ${Jl(e.rotation.angle.roll)}\xB0 yaw:${Jl(e.rotation.angle.yaw)}\xB0 pitch:${Jl(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&r.push(`gaze: ${Jl(e.rotation.gaze.bearing)}\xB0`)),r.length===0&&r.push("face"),t.fillStyle=dt.color;for(let n=r.length-1;n>=0;n--){let a=Math.max(e.box[0],0),s=n*dt.lineHeight+e.box[1];dt.shadowColor&&dt.shadowColor!==""&&(t.fillStyle=dt.shadowColor,t.fillText(r[n],a+5,s+16)),t.fillStyle=dt.labelColor,t.fillText(r[n],a+4,s+15)}}}function X5e(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=dt.useDepth?"rgba(255, 200, 255, 0.3)":dt.color,t.beginPath();let r=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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],r,n,0,0,2*Math.PI),t.stroke(),dt.fillPolygons&&(t.fillStyle=dt.useDepth?"rgba(255, 255, 200, 0.3)":dt.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=dt.useDepth?"rgba(255, 200, 255, 0.3)":dt.color,t.beginPath();let r=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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],r,n,0,0,2*Math.PI),t.stroke(),dt.fillPolygons&&(t.fillStyle=dt.useDepth?"rgba(255, 255, 200, 0.3)":dt.color,t.fill())}}function K5e(e,t){var r;if(dt.drawGaze&&((r=e.rotation)==null?void 0:r.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*Jl(e.rotation.angle.yaw)/90,a=e.box[1]+e.box[3]/2+e.box[2]*Jl(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.node-gpu.js b/dist/human.node-gpu.js index 3bdaa8db..e0bc3cac 100644 --- a/dist/human.node-gpu.js +++ b/dist/human.node-gpu.js @@ -96,7 +96,7 @@ var tn=Object.create;var p2=Object.defineProperty;var on=Object.getOwnPropertyDe c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var z5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},S5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),z5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);z5(o,"uniform",this.uniform),z5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function gt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new S5(l,ft,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?pt:mt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(bt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ut);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var N2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function O2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>N2&&(A=N2,s=Math.trunc(A*r/n)),s>N2&&(s=N2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new gt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,O2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(O2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=O2(i0),i=N.browser.fromPixels(Ze));else{let u=O2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await I2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Pt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Mt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 C5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new C5;var L2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function Rt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=xt(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await L2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new L2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var j5="2.8.0";var y0=D(H());var P5={};Se(P5,{Models:()=>z2,load:()=>D1,reset:()=>g5,validate:()=>Z1});var W2=D(H());var H0,I5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],vt=0,Tt=0,N5=Number.MAX_SAFE_INTEGER;async function wt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function O5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=N5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-Tt;return t.skipAllowed&&A&&r&&vt===n&&I5[o]?(N5++,I5[o]):(N5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=W2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dW2.dispose(y[d])),I5[o]=l,vt=n,Tt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Et(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,F2=[],zt=0,St=0,L5=Number.MAX_SAFE_INTEGER;async function Ct(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function W5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=L5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-St;return t.skipAllowed&&r&&A&&zt===n&&((i=F2[o])==null?void 0:i.age)&&((y=F2[o])==null?void 0:y.age)>0?(L5++,F2[o]):(L5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),F2[o]=x,zt=n,St=h(),c(x)}))}var p0=D(H());var V0,G2=[],It=0,Nt=0,F5=Number.MAX_SAFE_INTEGER,G5=[.2989,.587,.114];async function Ot(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function B5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=F5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Nt;return t.skipAllowed&&r&&A&&It===n&&((i=G2[o])==null?void 0:i.gender)&&((y=G2[o])==null?void 0:y.genderScore)>0?(F5++,G2[o]):(F5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,G5[0]),b=p0.mul(m,G5[1]),d=p0.mul(M,G5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),G2[o]=x,It=n,Nt=h(),c(x)}))}var H2=D(H());var u0,B2=[],H5=Number.MAX_SAFE_INTEGER,Wt=0,Ft=0;async function Gt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function V5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Ft,A=H5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Wt===n&&B2[o]?(H5++,B2[o]):(H5=0,new Promise(async i=>{let y=H2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];B2[o]=Math.round(100*l)/100,Wt=n,Ft=h(),H2.dispose([y,c]),i(B2[o])}))}var O=D(H());var se=D(H());var D0={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]},D5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Z5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],V2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],D2=(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],Dt=(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}},q5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},X2=(e,t)=>{let o=V2(e),n=Ue(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}},q2=e=>{let t=V2(e),o=Ue(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}},Zt=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}},U5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Ht=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Ht(t[0],t[1]),s=Vt(A,r),a=Ht(-t[0],-t[1]);return Vt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function qt(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?Xt(o,[0,0]):U5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):U5,l=V2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Yt(e,t,o,n){let r=t.landmarks.length>=D5.count?D5.symmetryLine:Ce.symmetryLine,A=0,s=U5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=V2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=Xt(-A,y),a=q5(t,l,[n,n]),se.dispose(l)}else a=q5(t,o,[n,n]);else a=q5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Kt=(e,t)=>{let o=Bn(e),n=Ue(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 Jt=6,Hn=1.4,_0,Qt=null,he=0,M2=null,Ye=()=>he;async function _t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),Qt=O.tensor2d(qt(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,Qt),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function $t(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Jt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Jt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Dt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=X2(M,t.face.scale||Hn),b=q2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var U2={};Se(U2,{connected:()=>J5,kpt:()=>K5});var K5=["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"],J5={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=D(H()),t3=224,Dn,Zn=5,Y2=[8,16,32,32,32];async function o3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 n3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function K2(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 s3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},Q5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},Q2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],r3=0,A3=e=>1-1/(1+Math.exp(e));async function a3(e){if(s3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await o3(),S0.detector}async function i3(e){if(s3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(J5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function _5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-r3,r=Q5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&Q2!==null)Q5++;else{let A={};A.landmarks=await Un(e,256),Q2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),r3=h(),Q5=0}return Q2?[Q2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,$5=[],y3=0,e1=Number.MAX_SAFE_INTEGER;async function x3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function t1(e,t){let o=(t.object.skipTime||0)>h()-y3,n=e1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&$5.length>0?(e1++,$5):(e1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;y3=h(),R0.dispose(s);let i=await Qn(a,A,t);$5=i,r(i)}))}var _=D(H());var _2={};Se(_2,{connected:()=>n1,kpt:()=>o1});var o1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],n1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,d3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},r1=Number.MAX_SAFE_INTEGER;async function f3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function A1(e,t){let o=(t.body.skipTime||0)>h()-d3,n=r1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(r1++,[v0]):(r1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),d3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:o1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(n1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,$2=[],p3=0,u3=0,s1=Number.MAX_SAFE_INTEGER;async function h3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function a1(e,t,o,n){var s,a;if(!G0)return[];let r=s1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-u3;return t.skipAllowed&&A&&r&&p3===n&&$2[o]&&$2[o].length>0?(s1++,$2[o]):(s1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),u3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}$2[o]=y,p3=n,i(y)}))}var R3=D(H());var j0,i1=[],g3=0,P3=0,M3=Number.MAX_SAFE_INTEGER;async function v3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function l1(e,t,o,n){var s,a;if(!j0)return[];let r=M3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-P3;return t.skipAllowed&&A&&r&&g3===n&&i1[o]?(M3++,i1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=R3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}i1[o]=y,g3=n,P3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,y1=D0.leftEyeLower0,x1=D0.rightEyeLower0,Qe={leftBounds:[y1[0],y1[y1.length-1]],rightBounds:[x1[0],x1[x1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function z3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function e5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},w3=(e,t,o,n,r,A=!1)=>{let s=q2(X2(Zt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},k3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},E3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function S3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=w3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=w3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=k3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=k3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(e5(e,u,"left",null),e5(e,g,"right",null)):d<1?e5(e,u,"left",["EyeUpper0","EyeLower0"]):e5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=E3(e,m,"left"),S=E3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 I3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await $t(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Yt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await I2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await I3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await S3(K,w.tensor,t,We)),w.mesh=Ut(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Kt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=D2(V,e),w.boxRaw=Z2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function O3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var L3=je,W3=P2;var q0=D(H());var I0,t5=[],F3=0,G3=0,d1=Number.MAX_SAFE_INTEGER;async function B3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function f1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function m1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=d1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-F3;return t.skipAllowed&&r&&A&&G3===n&&((i=t5[o])==null?void 0:i.age)&&((y=t5[o])==null?void 0:y.age)>0?(d1++,t5[o]):(d1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=f1(e),m=I0==null?void 0:I0.execute(u);F3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}t5[o]=l,G3=n,c(l)}))}var W=D(H());var D3=D(H());function o5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Z3(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 D3.image.cropAndResize(t,A,[0],o)}function X3(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 n5(e,t=1.5){let o=T2(e),n=o5(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 r5(e){let t=T2(e),o=o5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function q3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var H3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=X3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,J3=1.65,Q3=[0,5,9,13,17,1,2],hr=0,br=2,_3=0,s5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>h1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return n5(r5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=n5(r5(o),J3);n.palmLandmarks=[];for(let r=0;r[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=u1(n,[0,0]),y=a.map(f=>[...h1(f,i),f[2]]),c=U3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-_3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=n5(r5(y),J3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:b1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,b1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,b1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,b1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var $3=[Te,l0,we,ke,o2];var vr=.7,Be={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 eo(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 oo(e,t){if(!e||!t)return[0,0];let o=eo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=eo(e[1],e[2],t[1],t[2]);return[o,n]}function to(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function no(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function ro(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=ro(e,t,o,n),c=no(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=oo([P,S],[w,j]),U=to(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=to(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=ro(i,a,y,l):u===Math.max(f,u)?K=no(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function Ao(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=oo(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function a5(e){if(!e||e.length===0)return null;let t=Ao(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function so(e){let t=[];if(!e||e.length===0)return t;let o=Ao(e);for(let n of $3){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var ao={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]},n2,r2,io;async function P1(e,t){let o=await io.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=a5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function M1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new A5(n2);return io=new s5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],yo=4,xo=1.6,Sr=512,Cr=1.4,i5=Number.MAX_SAFE_INTEGER,R1=0,ce=[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 fo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{l5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function mo(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[yo]),a.splice(yo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=K2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function v1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=a5(n.keypoints);for(let l of Object.keys(co))n.annotations[l]=co[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function T1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],i5++;let o=(t.hand.skipTime||0)>h()-R1,n=i5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-R1,i=i5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):(A0.boxes=await jr(e,t),R1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))),i5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=K2(l.box,xo),f=K2(l.boxRaw,xo);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-ho,A=w1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&uo===n&&y5[o]?(w1++,y5[o]):(w1=0,new Promise(async i=>{let y=x5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];y5[o]=Math.round(100*l)/100,uo=n,ho=h(),x5.dispose([y,c]),i(y5[o])}))}var To=D(H());var w2={};Se(w2,{connected:()=>d5,horizontal:()=>E1,kpt:()=>c5,relative:()=>S1,vertical:()=>z1});var c5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],E1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],z1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],d5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Po=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function C1(e){for(let t of E1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Mo(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function vo(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,f5=0,j1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function wo(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(l5(["size"],e),L0=await G(e.body.modelPath)),f5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,f5<64&&(f5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:c5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(d5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return C1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:c5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(d5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};C1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function I1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),j1++;let o=(t.body.skipTime||0)>h()-He.last,n=j1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};j1=0,A.input=Ro(e,f5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)vo(a,[e.shape[2]||1,e.shape[1]||1]),Mo(a.keypoints);Object.keys(A).forEach(a=>To.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,m5=[],Eo=0,N1=Number.MAX_SAFE_INTEGER,u5=0,p5=2.5;async function zo(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);u5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/u5)),[S,w]=[b-p5/i*P[0],d-p5/i*P[1]],[j,C]=[b+p5/i*P[2]-S,d+p5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function O1(e,t){let o=(t.object.skipTime||0)>h()-Eo,n=N1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&m5.length>0?(N1++,m5):(N1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?m5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[u5,u5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),Eo=h(),w0.dispose(i);let c=await Lr(y,A,t);m5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[t]]),Co=[["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 Io(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var h5=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 No(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function G1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],b5=1,s2=16,Hr=50**2;function Oo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:F1(Math.round(g.y/s2),0,b-1),x:F1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=G1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=W1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Oo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new h5(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?No(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Lo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=jo(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function B1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?Io(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Wo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,H1=!1;async function V1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Go(e,t,o){var m,M;if(H1)return{data:[],canvas:null,alpha:null};H1=!0,ee||await V1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),H1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function g5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function D1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&g5(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 M1(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 M1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=i3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=a3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=f3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=wo(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Wo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=_t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Gt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=bo(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=B3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=h3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=z3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=O3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=wt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ct(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Ot(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=v3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=fo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=mo(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=x3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=zo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=V1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function Z1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Ho(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),g5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function M5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Ho(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),Et()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function l5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var Q1={};Se(Q1,{all:()=>J1,body:()=>i2,canvas:()=>K1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>Y1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 X1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Do(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){X1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var z5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},S5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),z5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);z5(o,"uniform",this.uniform),z5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function gt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new S5(l,ft,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?pt:mt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(bt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ut);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var N2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function O2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>N2&&(A=N2,s=Math.trunc(A*r/n)),s>N2&&(s=N2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new gt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,O2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(O2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=O2(i0),i=N.browser.fromPixels(Ze));else{let u=O2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await I2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Pt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Mt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 C5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new C5;var L2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function Rt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=xt(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await L2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new L2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var j5="2.8.1";var y0=D(H());var P5={};Se(P5,{Models:()=>z2,load:()=>D1,reset:()=>g5,validate:()=>Z1});var W2=D(H());var H0,I5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],vt=0,Tt=0,N5=Number.MAX_SAFE_INTEGER;async function wt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function O5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=N5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-Tt;return t.skipAllowed&&A&&r&&vt===n&&I5[o]?(N5++,I5[o]):(N5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=W2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dW2.dispose(y[d])),I5[o]=l,vt=n,Tt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Et(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,F2=[],zt=0,St=0,L5=Number.MAX_SAFE_INTEGER;async function Ct(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function W5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=L5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-St;return t.skipAllowed&&r&&A&&zt===n&&((i=F2[o])==null?void 0:i.age)&&((y=F2[o])==null?void 0:y.age)>0?(L5++,F2[o]):(L5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),F2[o]=x,zt=n,St=h(),c(x)}))}var p0=D(H());var V0,G2=[],It=0,Nt=0,F5=Number.MAX_SAFE_INTEGER,G5=[.2989,.587,.114];async function Ot(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function B5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=F5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Nt;return t.skipAllowed&&r&&A&&It===n&&((i=G2[o])==null?void 0:i.gender)&&((y=G2[o])==null?void 0:y.genderScore)>0?(F5++,G2[o]):(F5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,G5[0]),b=p0.mul(m,G5[1]),d=p0.mul(M,G5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),G2[o]=x,It=n,Nt=h(),c(x)}))}var H2=D(H());var u0,B2=[],H5=Number.MAX_SAFE_INTEGER,Wt=0,Ft=0;async function Gt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function V5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Ft,A=H5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Wt===n&&B2[o]?(H5++,B2[o]):(H5=0,new Promise(async i=>{let y=H2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];B2[o]=Math.round(100*l)/100,Wt=n,Ft=h(),H2.dispose([y,c]),i(B2[o])}))}var O=D(H());var se=D(H());var D0={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]},D5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Z5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],V2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],D2=(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],Dt=(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}},q5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},X2=(e,t)=>{let o=V2(e),n=Ue(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}},q2=e=>{let t=V2(e),o=Ue(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}},Zt=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}},U5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Ht=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Ht(t[0],t[1]),s=Vt(A,r),a=Ht(-t[0],-t[1]);return Vt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function qt(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?Xt(o,[0,0]):U5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):U5,l=V2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Yt(e,t,o,n){let r=t.landmarks.length>=D5.count?D5.symmetryLine:Ce.symmetryLine,A=0,s=U5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=V2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=Xt(-A,y),a=q5(t,l,[n,n]),se.dispose(l)}else a=q5(t,o,[n,n]);else a=q5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Kt=(e,t)=>{let o=Bn(e),n=Ue(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 Jt=6,Hn=1.4,_0,Qt=null,he=0,M2=null,Ye=()=>he;async function _t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),Qt=O.tensor2d(qt(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,Qt),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function $t(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Jt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Jt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Dt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=X2(M,t.face.scale||Hn),b=q2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var U2={};Se(U2,{connected:()=>J5,kpt:()=>K5});var K5=["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"],J5={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=D(H()),t3=224,Dn,Zn=5,Y2=[8,16,32,32,32];async function o3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 n3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function K2(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 s3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},Q5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},Q2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],r3=0,A3=e=>1-1/(1+Math.exp(e));async function a3(e){if(s3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await o3(),S0.detector}async function i3(e){if(s3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(J5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function _5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-r3,r=Q5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&Q2!==null)Q5++;else{let A={};A.landmarks=await Un(e,256),Q2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),r3=h(),Q5=0}return Q2?[Q2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,$5=[],y3=0,e1=Number.MAX_SAFE_INTEGER;async function x3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function t1(e,t){let o=(t.object.skipTime||0)>h()-y3,n=e1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&$5.length>0?(e1++,$5):(e1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;y3=h(),R0.dispose(s);let i=await Qn(a,A,t);$5=i,r(i)}))}var _=D(H());var _2={};Se(_2,{connected:()=>n1,kpt:()=>o1});var o1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],n1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,d3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},r1=Number.MAX_SAFE_INTEGER;async function f3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function A1(e,t){let o=(t.body.skipTime||0)>h()-d3,n=r1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(r1++,[v0]):(r1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),d3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:o1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(n1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,$2=[],p3=0,u3=0,s1=Number.MAX_SAFE_INTEGER;async function h3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function a1(e,t,o,n){var s,a;if(!G0)return[];let r=s1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-u3;return t.skipAllowed&&A&&r&&p3===n&&$2[o]&&$2[o].length>0?(s1++,$2[o]):(s1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),u3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}$2[o]=y,p3=n,i(y)}))}var R3=D(H());var j0,i1=[],g3=0,P3=0,M3=Number.MAX_SAFE_INTEGER;async function v3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function l1(e,t,o,n){var s,a;if(!j0)return[];let r=M3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-P3;return t.skipAllowed&&A&&r&&g3===n&&i1[o]?(M3++,i1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=R3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}i1[o]=y,g3=n,P3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,y1=D0.leftEyeLower0,x1=D0.rightEyeLower0,Qe={leftBounds:[y1[0],y1[y1.length-1]],rightBounds:[x1[0],x1[x1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function z3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function e5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},w3=(e,t,o,n,r,A=!1)=>{let s=q2(X2(Zt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},k3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},E3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function S3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=w3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=w3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=k3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=k3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(e5(e,u,"left",null),e5(e,g,"right",null)):d<1?e5(e,u,"left",["EyeUpper0","EyeLower0"]):e5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=E3(e,m,"left"),S=E3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 I3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await $t(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Yt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await I2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await I3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await S3(K,w.tensor,t,We)),w.mesh=Ut(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Kt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=D2(V,e),w.boxRaw=Z2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function O3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var L3=je,W3=P2;var q0=D(H());var I0,t5=[],F3=0,G3=0,d1=Number.MAX_SAFE_INTEGER;async function B3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function f1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function m1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=d1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-F3;return t.skipAllowed&&r&&A&&G3===n&&((i=t5[o])==null?void 0:i.age)&&((y=t5[o])==null?void 0:y.age)>0?(d1++,t5[o]):(d1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=f1(e),m=I0==null?void 0:I0.execute(u);F3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}t5[o]=l,G3=n,c(l)}))}var W=D(H());var D3=D(H());function o5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Z3(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 D3.image.cropAndResize(t,A,[0],o)}function X3(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 n5(e,t=1.5){let o=T2(e),n=o5(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 r5(e){let t=T2(e),o=o5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function q3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var H3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=X3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,J3=1.65,Q3=[0,5,9,13,17,1,2],hr=0,br=2,_3=0,s5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>h1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return n5(r5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=n5(r5(o),J3);n.palmLandmarks=[];for(let r=0;r[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=u1(n,[0,0]),y=a.map(f=>[...h1(f,i),f[2]]),c=U3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-_3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=n5(r5(y),J3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:b1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,b1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,b1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,b1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var $3=[Te,l0,we,ke,o2];var vr=.7,Be={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 eo(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 oo(e,t){if(!e||!t)return[0,0];let o=eo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=eo(e[1],e[2],t[1],t[2]);return[o,n]}function to(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function no(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function ro(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=ro(e,t,o,n),c=no(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=oo([P,S],[w,j]),U=to(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=to(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=ro(i,a,y,l):u===Math.max(f,u)?K=no(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function Ao(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=oo(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function a5(e){if(!e||e.length===0)return null;let t=Ao(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function so(e){let t=[];if(!e||e.length===0)return t;let o=Ao(e);for(let n of $3){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var ao={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]},n2,r2,io;async function P1(e,t){let o=await io.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=a5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function M1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new A5(n2);return io=new s5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],yo=4,xo=1.6,Sr=512,Cr=1.4,i5=Number.MAX_SAFE_INTEGER,R1=0,ce=[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 fo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{l5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function mo(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[yo]),a.splice(yo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=K2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function v1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=a5(n.keypoints);for(let l of Object.keys(co))n.annotations[l]=co[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function T1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],i5++;let o=(t.hand.skipTime||0)>h()-R1,n=i5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-R1,i=i5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):(A0.boxes=await jr(e,t),R1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))),i5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=K2(l.box,xo),f=K2(l.boxRaw,xo);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-ho,A=w1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&uo===n&&y5[o]?(w1++,y5[o]):(w1=0,new Promise(async i=>{let y=x5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];y5[o]=Math.round(100*l)/100,uo=n,ho=h(),x5.dispose([y,c]),i(y5[o])}))}var To=D(H());var w2={};Se(w2,{connected:()=>d5,horizontal:()=>E1,kpt:()=>c5,relative:()=>S1,vertical:()=>z1});var c5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],E1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],z1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],d5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Po=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function C1(e){for(let t of E1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Mo(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function vo(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,f5=0,j1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function wo(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(l5(["size"],e),L0=await G(e.body.modelPath)),f5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,f5<64&&(f5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:c5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(d5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return C1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:c5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(d5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};C1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function I1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),j1++;let o=(t.body.skipTime||0)>h()-He.last,n=j1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};j1=0,A.input=Ro(e,f5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)vo(a,[e.shape[2]||1,e.shape[1]||1]),Mo(a.keypoints);Object.keys(A).forEach(a=>To.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,m5=[],Eo=0,N1=Number.MAX_SAFE_INTEGER,u5=0,p5=2.5;async function zo(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);u5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/u5)),[S,w]=[b-p5/i*P[0],d-p5/i*P[1]],[j,C]=[b+p5/i*P[2]-S,d+p5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function O1(e,t){let o=(t.object.skipTime||0)>h()-Eo,n=N1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&m5.length>0?(N1++,m5):(N1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?m5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[u5,u5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),Eo=h(),w0.dispose(i);let c=await Lr(y,A,t);m5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[t]]),Co=[["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 Io(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var h5=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 No(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function G1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],b5=1,s2=16,Hr=50**2;function Oo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:F1(Math.round(g.y/s2),0,b-1),x:F1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=G1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=W1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Oo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new h5(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?No(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Lo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=jo(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function B1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?Io(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Wo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,H1=!1;async function V1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Go(e,t,o){var m,M;if(H1)return{data:[],canvas:null,alpha:null};H1=!0,ee||await V1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),H1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function g5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function D1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&g5(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 M1(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 M1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=i3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=a3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=f3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=wo(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Wo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=_t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Gt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=bo(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=B3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=h3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=z3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=O3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=wt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ct(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Ot(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=v3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=fo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=mo(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=x3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=zo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=V1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function Z1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Ho(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),g5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function M5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Ho(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),Et()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function l5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var Q1={};Se(Q1,{all:()=>J1,body:()=>i2,canvas:()=>K1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>Y1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 X1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Do(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){X1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(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 0c271338..728fdc24 100644 --- a/dist/human.node-wasm.js +++ b/dist/human.node-wasm.js @@ -96,7 +96,7 @@ var on=Object.create;var p2=Object.defineProperty;var nn=Object.getOwnPropertyDe c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var S5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},C5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),S5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);S5(o,"uniform",this.uniform),S5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Pt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new C5(l,mt,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?ut:pt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(gt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(bt);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var O2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function L2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>O2&&(A=O2,s=Math.trunc(A*r/n)),s>O2&&(s=O2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new Pt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,L2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(L2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=L2(i0),i=N.browser.fromPixels(Ze));else{let u=L2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await N2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Mt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Rt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 j5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new j5;var W2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function vt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=ct(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await W2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new W2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var I5="2.8.0";var y0=D(H());var M5={};Se(M5,{Models:()=>z2,load:()=>Z1,reset:()=>P5,validate:()=>X1});var F2=D(H());var H0,N5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],Tt=0,wt=0,O5=Number.MAX_SAFE_INTEGER;async function kt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function L5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=O5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-wt;return t.skipAllowed&&A&&r&&Tt===n&&N5[o]?(O5++,N5[o]):(O5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=F2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dF2.dispose(y[d])),N5[o]=l,Tt=n,wt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function zt(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,G2=[],St=0,Ct=0,W5=Number.MAX_SAFE_INTEGER;async function jt(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function F5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=W5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Ct;return t.skipAllowed&&r&&A&&St===n&&((i=G2[o])==null?void 0:i.age)&&((y=G2[o])==null?void 0:y.age)>0?(W5++,G2[o]):(W5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),G2[o]=x,St=n,Ct=h(),c(x)}))}var p0=D(H());var V0,B2=[],Nt=0,Ot=0,G5=Number.MAX_SAFE_INTEGER,B5=[.2989,.587,.114];async function Lt(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function H5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=G5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Ot;return t.skipAllowed&&r&&A&&Nt===n&&((i=B2[o])==null?void 0:i.gender)&&((y=B2[o])==null?void 0:y.genderScore)>0?(G5++,B2[o]):(G5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,B5[0]),b=p0.mul(m,B5[1]),d=p0.mul(M,B5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),B2[o]=x,Nt=n,Ot=h(),c(x)}))}var V2=D(H());var u0,H2=[],V5=Number.MAX_SAFE_INTEGER,Ft=0,Gt=0;async function Bt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function D5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Gt,A=V5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ft===n&&H2[o]?(V5++,H2[o]):(V5=0,new Promise(async i=>{let y=V2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];H2[o]=Math.round(100*l)/100,Ft=n,Gt=h(),V2.dispose([y,c]),i(H2[o])}))}var O=D(H());var se=D(H());var D0={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]},Z5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},X5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],D2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],Z2=(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],X2=(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],Zt=(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}},U5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},q2=(e,t)=>{let o=D2(e),n=Ue(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}},U2=e=>{let t=D2(e),o=Ue(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}},Xt=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}},Y5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Vt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Vt(t[0],t[1]),s=Dt(A,r),a=Vt(-t[0],-t[1]);return Dt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function Ut(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?qt(o,[0,0]):Y5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):Y5,l=D2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Kt(e,t,o,n){let r=t.landmarks.length>=Z5.count?Z5.symmetryLine:Ce.symmetryLine,A=0,s=Y5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=D2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=qt(-A,y),a=U5(t,l,[n,n]),se.dispose(l)}else a=U5(t,o,[n,n]);else a=U5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Jt=(e,t)=>{let o=Bn(e),n=Ue(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 Qt=6,Hn=1.4,_0,_t=null,he=0,M2=null,Ye=()=>he;async function $t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),_t=O.tensor2d(Ut(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,_t),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function e3(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Qt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Qt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Zt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=q2(M,t.face.scale||Hn),b=U2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var Y2={};Se(Y2,{connected:()=>Q5,kpt:()=>J5});var J5=["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"],Q5={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=D(H()),o3=224,Dn,Zn=5,K2=[8,16,32,32,32];async function n3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 r3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function J2(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 a3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},_5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},_2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],A3=0,s3=e=>1-1/(1+Math.exp(e));async function i3(e){if(a3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await n3(),S0.detector}async function l3(e){if(a3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(Q5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function $5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-A3,r=_5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&_2!==null)_5++;else{let A={};A.landmarks=await Un(e,256),_2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),A3=h(),_5=0}return _2?[_2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,e1=[],x3=0,t1=Number.MAX_SAFE_INTEGER;async function c3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function o1(e,t){let o=(t.object.skipTime||0)>h()-x3,n=t1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&e1.length>0?(t1++,e1):(t1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;x3=h(),R0.dispose(s);let i=await Qn(a,A,t);e1=i,r(i)}))}var _=D(H());var $2={};Se($2,{connected:()=>r1,kpt:()=>n1});var n1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],r1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,f3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},A1=Number.MAX_SAFE_INTEGER;async function m3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function s1(e,t){let o=(t.body.skipTime||0)>h()-f3,n=A1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(A1++,[v0]):(A1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),f3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:n1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(r1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,e5=[],u3=0,h3=0,a1=Number.MAX_SAFE_INTEGER;async function b3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function i1(e,t,o,n){var s,a;if(!G0)return[];let r=a1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-h3;return t.skipAllowed&&A&&r&&u3===n&&e5[o]&&e5[o].length>0?(a1++,e5[o]):(a1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),h3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}e5[o]=y,u3=n,i(y)}))}var v3=D(H());var j0,l1=[],P3=0,M3=0,R3=Number.MAX_SAFE_INTEGER;async function T3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function y1(e,t,o,n){var s,a;if(!j0)return[];let r=R3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-M3;return t.skipAllowed&&A&&r&&P3===n&&l1[o]?(R3++,l1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=v3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}l1[o]=y,P3=n,M3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,x1=D0.leftEyeLower0,c1=D0.rightEyeLower0,Qe={leftBounds:[x1[0],x1[x1.length-1]],rightBounds:[c1[0],c1[c1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function S3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function t5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},k3=(e,t,o,n,r,A=!1)=>{let s=U2(q2(Xt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},E3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},z3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function C3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=k3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=k3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=E3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=E3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(t5(e,u,"left",null),t5(e,g,"right",null)):d<1?t5(e,u,"left",["EyeUpper0","EyeLower0"]):t5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=z3(e,m,"left"),S=z3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 N3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await e3(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Kt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await N2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=Z2(d,e),w.boxRaw=X2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await N3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await C3(K,w.tensor,t,We)),w.mesh=Yt(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Jt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=Z2(V,e),w.boxRaw=X2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=Z2(d,e),w.boxRaw=X2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function L3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var W3=je,F3=P2;var q0=D(H());var I0,o5=[],G3=0,B3=0,f1=Number.MAX_SAFE_INTEGER;async function H3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function m1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function p1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=f1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-G3;return t.skipAllowed&&r&&A&&B3===n&&((i=o5[o])==null?void 0:i.age)&&((y=o5[o])==null?void 0:y.age)>0?(f1++,o5[o]):(f1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=m1(e),m=I0==null?void 0:I0.execute(u);G3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}o5[o]=l,B3=n,c(l)}))}var W=D(H());var Z3=D(H());function n5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function X3(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 Z3.image.cropAndResize(t,A,[0],o)}function q3(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 r5(e,t=1.5){let o=T2(e),n=n5(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 A5(e){let t=T2(e),o=n5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function U3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var V3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=q3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,Q3=1.65,_3=[0,5,9,13,17,1,2],hr=0,br=2,$3=0,a5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>b1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return r5(A5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=r5(A5(o),Q3);n.palmLandmarks=[];for(let r=0;r<_3.length;r++)n.palmLandmarks.push(t[_3[r]].slice(0,2));return n}transformRawCoords(t,o,n,r){let A=n5(o),s=[A[0]/this.inputSize,A[1]/this.inputSize,(A[0]+A[1])/this.inputSize/2],a=t.map(f=>[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=h1(n,[0,0]),y=a.map(f=>[...b1(f,i),f[2]]),c=Y3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-$3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=r5(A5(y),Q3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:g1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,g1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,g1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,g1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var eo=[Te,l0,we,ke,o2];var vr=.7,Be={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 to(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 no(e,t){if(!e||!t)return[0,0];let o=to(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=to(e[1],e[2],t[1],t[2]);return[o,n]}function oo(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function ro(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function Ao(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=Ao(e,t,o,n),c=ro(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=no([P,S],[w,j]),U=oo(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=oo(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=Ao(i,a,y,l):u===Math.max(f,u)?K=ro(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function so(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=no(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function i5(e){if(!e||e.length===0)return null;let t=so(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function ao(e){let t=[];if(!e||e.length===0)return t;let o=so(e);for(let n of eo){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var io={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]},n2,r2,lo;async function M1(e,t){let o=await lo.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=i5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function R1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new s5(n2);return lo=new a5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],xo=4,co=1.6,Sr=512,Cr=1.4,l5=Number.MAX_SAFE_INTEGER,v1=0,ce=[0,0],A0={boxes:[],hands:[]},fo={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 mo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{y5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function po(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[xo]),a.splice(xo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=J2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function T1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=i5(n.keypoints);for(let l of Object.keys(fo))n.annotations[l]=fo[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function w1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],l5++;let o=(t.hand.skipTime||0)>h()-v1,n=l5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-v1,i=l5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))):(A0.boxes=await jr(e,t),v1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))),l5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=J2(l.box,co),f=J2(l.boxRaw,co);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-bo,A=k1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&ho===n&&x5[o]?(k1++,x5[o]):(k1=0,new Promise(async i=>{let y=c5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];x5[o]=Math.round(100*l)/100,ho=n,bo=h(),c5.dispose([y,c]),i(x5[o])}))}var wo=D(H());var w2={};Se(w2,{connected:()=>f5,horizontal:()=>z1,kpt:()=>d5,relative:()=>C1,vertical:()=>S1});var d5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],z1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],S1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],C1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],f5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Mo=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function j1(e){for(let t of z1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Ro(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function To(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,m5=0,I1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function ko(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(y5(["size"],e),L0=await G(e.body.modelPath)),m5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,m5<64&&(m5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:d5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(f5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return j1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:d5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(f5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};j1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function N1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),I1++;let o=(t.body.skipTime||0)>h()-He.last,n=I1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};I1=0,A.input=vo(e,m5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)To(a,[e.shape[2]||1,e.shape[1]||1]),Ro(a.keypoints);Object.keys(A).forEach(a=>wo.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,p5=[],zo=0,O1=Number.MAX_SAFE_INTEGER,h5=0,u5=2.5;async function So(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);h5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/h5)),[S,w]=[b-u5/i*P[0],d-u5/i*P[1]],[j,C]=[b+u5/i*P[2]-S,d+u5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function L1(e,t){let o=(t.object.skipTime||0)>h()-zo,n=O1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&p5.length>0?(O1++,p5):(O1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?p5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[h5,h5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),zo=h(),w0.dispose(i);let c=await Lr(y,A,t);p5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[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 Io(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 No(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var b5=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 Oo(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function B1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],g5=1,s2=16,Hr=50**2;function Lo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:G1(Math.round(g.y/s2),0,b-1),x:G1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=B1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=F1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Lo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new b5(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?Oo(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Wo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=Io(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function H1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?No(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Fo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,V1=!1;async function D1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Bo(e,t,o){var m,M;if(V1)return{data:[],canvas:null,alpha:null};V1=!0,ee||await D1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),V1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function P5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function Z1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&P5(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 R1(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 R1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=l3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=i3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=m3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=ko(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Fo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=$t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Bt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=go(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=H3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=b3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=S3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=L3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=kt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=jt(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Lt(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=T3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=mo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=po(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=c3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=So(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=D1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function X1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Vo(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),P5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function R5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Vo(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),zt()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function y5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var _1={};Se(_1,{all:()=>Q1,body:()=>i2,canvas:()=>J1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>K1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 q1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Zo(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){q1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var S5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},C5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),S5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);S5(o,"uniform",this.uniform),S5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function Pt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new C5(l,mt,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?ut:pt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(gt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(bt);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var O2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function L2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>O2&&(A=O2,s=Math.trunc(A*r/n)),s>O2&&(s=O2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new Pt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,L2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(L2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=L2(i0),i=N.browser.fromPixels(Ze));else{let u=L2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await N2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Mt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Rt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 j5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new j5;var W2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function vt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=ct(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await W2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new W2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var I5="2.8.1";var y0=D(H());var M5={};Se(M5,{Models:()=>z2,load:()=>Z1,reset:()=>P5,validate:()=>X1});var F2=D(H());var H0,N5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],Tt=0,wt=0,O5=Number.MAX_SAFE_INTEGER;async function kt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function L5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=O5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-wt;return t.skipAllowed&&A&&r&&Tt===n&&N5[o]?(O5++,N5[o]):(O5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=F2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dF2.dispose(y[d])),N5[o]=l,Tt=n,wt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function zt(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,G2=[],St=0,Ct=0,W5=Number.MAX_SAFE_INTEGER;async function jt(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function F5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=W5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Ct;return t.skipAllowed&&r&&A&&St===n&&((i=G2[o])==null?void 0:i.age)&&((y=G2[o])==null?void 0:y.age)>0?(W5++,G2[o]):(W5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),G2[o]=x,St=n,Ct=h(),c(x)}))}var p0=D(H());var V0,B2=[],Nt=0,Ot=0,G5=Number.MAX_SAFE_INTEGER,B5=[.2989,.587,.114];async function Lt(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function H5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=G5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Ot;return t.skipAllowed&&r&&A&&Nt===n&&((i=B2[o])==null?void 0:i.gender)&&((y=B2[o])==null?void 0:y.genderScore)>0?(G5++,B2[o]):(G5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,B5[0]),b=p0.mul(m,B5[1]),d=p0.mul(M,B5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),B2[o]=x,Nt=n,Ot=h(),c(x)}))}var V2=D(H());var u0,H2=[],V5=Number.MAX_SAFE_INTEGER,Ft=0,Gt=0;async function Bt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function D5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Gt,A=V5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Ft===n&&H2[o]?(V5++,H2[o]):(V5=0,new Promise(async i=>{let y=V2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];H2[o]=Math.round(100*l)/100,Ft=n,Gt=h(),V2.dispose([y,c]),i(H2[o])}))}var O=D(H());var se=D(H());var D0={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]},Z5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},X5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],D2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],Z2=(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],X2=(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],Zt=(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}},U5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},q2=(e,t)=>{let o=D2(e),n=Ue(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}},U2=e=>{let t=D2(e),o=Ue(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}},Xt=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}},Y5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Vt=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Vt(t[0],t[1]),s=Dt(A,r),a=Vt(-t[0],-t[1]);return Dt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function Ut(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?qt(o,[0,0]):Y5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):Y5,l=D2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Kt(e,t,o,n){let r=t.landmarks.length>=Z5.count?Z5.symmetryLine:Ce.symmetryLine,A=0,s=Y5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=D2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=qt(-A,y),a=U5(t,l,[n,n]),se.dispose(l)}else a=U5(t,o,[n,n]);else a=U5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Jt=(e,t)=>{let o=Bn(e),n=Ue(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 Qt=6,Hn=1.4,_0,_t=null,he=0,M2=null,Ye=()=>he;async function $t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),_t=O.tensor2d(Ut(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,_t),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function e3(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Qt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Qt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Zt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=q2(M,t.face.scale||Hn),b=U2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var Y2={};Se(Y2,{connected:()=>Q5,kpt:()=>J5});var J5=["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"],Q5={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=D(H()),o3=224,Dn,Zn=5,K2=[8,16,32,32,32];async function n3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 r3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function J2(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 a3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},_5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},_2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],A3=0,s3=e=>1-1/(1+Math.exp(e));async function i3(e){if(a3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await n3(),S0.detector}async function l3(e){if(a3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(Q5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function $5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-A3,r=_5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&_2!==null)_5++;else{let A={};A.landmarks=await Un(e,256),_2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),A3=h(),_5=0}return _2?[_2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,e1=[],x3=0,t1=Number.MAX_SAFE_INTEGER;async function c3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function o1(e,t){let o=(t.object.skipTime||0)>h()-x3,n=t1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&e1.length>0?(t1++,e1):(t1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;x3=h(),R0.dispose(s);let i=await Qn(a,A,t);e1=i,r(i)}))}var _=D(H());var $2={};Se($2,{connected:()=>r1,kpt:()=>n1});var n1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],r1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,f3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},A1=Number.MAX_SAFE_INTEGER;async function m3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function s1(e,t){let o=(t.body.skipTime||0)>h()-f3,n=A1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(A1++,[v0]):(A1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),f3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:n1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(r1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,e5=[],u3=0,h3=0,a1=Number.MAX_SAFE_INTEGER;async function b3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function i1(e,t,o,n){var s,a;if(!G0)return[];let r=a1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-h3;return t.skipAllowed&&A&&r&&u3===n&&e5[o]&&e5[o].length>0?(a1++,e5[o]):(a1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),h3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}e5[o]=y,u3=n,i(y)}))}var v3=D(H());var j0,l1=[],P3=0,M3=0,R3=Number.MAX_SAFE_INTEGER;async function T3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function y1(e,t,o,n){var s,a;if(!j0)return[];let r=R3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-M3;return t.skipAllowed&&A&&r&&P3===n&&l1[o]?(R3++,l1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=v3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}l1[o]=y,P3=n,M3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,x1=D0.leftEyeLower0,c1=D0.rightEyeLower0,Qe={leftBounds:[x1[0],x1[x1.length-1]],rightBounds:[c1[0],c1[c1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function S3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function t5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},k3=(e,t,o,n,r,A=!1)=>{let s=U2(q2(Xt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},E3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},z3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function C3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=k3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=k3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=E3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=E3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(t5(e,u,"left",null),t5(e,g,"right",null)):d<1?t5(e,u,"left",["EyeUpper0","EyeLower0"]):t5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=z3(e,m,"left"),S=z3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 N3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await e3(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Kt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await N2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=Z2(d,e),w.boxRaw=X2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await N3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await C3(K,w.tensor,t,We)),w.mesh=Yt(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Jt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=Z2(V,e),w.boxRaw=X2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=Z2(d,e),w.boxRaw=X2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function L3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var W3=je,F3=P2;var q0=D(H());var I0,o5=[],G3=0,B3=0,f1=Number.MAX_SAFE_INTEGER;async function H3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function m1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function p1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=f1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-G3;return t.skipAllowed&&r&&A&&B3===n&&((i=o5[o])==null?void 0:i.age)&&((y=o5[o])==null?void 0:y.age)>0?(f1++,o5[o]):(f1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=m1(e),m=I0==null?void 0:I0.execute(u);G3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}o5[o]=l,B3=n,c(l)}))}var W=D(H());var Z3=D(H());function n5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function X3(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 Z3.image.cropAndResize(t,A,[0],o)}function q3(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 r5(e,t=1.5){let o=T2(e),n=n5(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 A5(e){let t=T2(e),o=n5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function U3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var V3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=q3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,Q3=1.65,_3=[0,5,9,13,17,1,2],hr=0,br=2,$3=0,a5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>b1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return r5(A5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=r5(A5(o),Q3);n.palmLandmarks=[];for(let r=0;r<_3.length;r++)n.palmLandmarks.push(t[_3[r]].slice(0,2));return n}transformRawCoords(t,o,n,r){let A=n5(o),s=[A[0]/this.inputSize,A[1]/this.inputSize,(A[0]+A[1])/this.inputSize/2],a=t.map(f=>[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=h1(n,[0,0]),y=a.map(f=>[...b1(f,i),f[2]]),c=Y3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-$3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=r5(A5(y),Q3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:g1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,g1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,g1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,g1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var eo=[Te,l0,we,ke,o2];var vr=.7,Be={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 to(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 no(e,t){if(!e||!t)return[0,0];let o=to(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=to(e[1],e[2],t[1],t[2]);return[o,n]}function oo(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function ro(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function Ao(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=Ao(e,t,o,n),c=ro(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=no([P,S],[w,j]),U=oo(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=oo(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=Ao(i,a,y,l):u===Math.max(f,u)?K=ro(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function so(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=no(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function i5(e){if(!e||e.length===0)return null;let t=so(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function ao(e){let t=[];if(!e||e.length===0)return t;let o=so(e);for(let n of eo){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var io={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]},n2,r2,lo;async function M1(e,t){let o=await lo.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=i5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function R1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new s5(n2);return lo=new a5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],xo=4,co=1.6,Sr=512,Cr=1.4,l5=Number.MAX_SAFE_INTEGER,v1=0,ce=[0,0],A0={boxes:[],hands:[]},fo={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 mo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{y5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function po(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[xo]),a.splice(xo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=J2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function T1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=i5(n.keypoints);for(let l of Object.keys(fo))n.annotations[l]=fo[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function w1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],l5++;let o=(t.hand.skipTime||0)>h()-v1,n=l5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-v1,i=l5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))):(A0.boxes=await jr(e,t),v1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>T1(e,c,t))),l5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=J2(l.box,co),f=J2(l.boxRaw,co);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-bo,A=k1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&ho===n&&x5[o]?(k1++,x5[o]):(k1=0,new Promise(async i=>{let y=c5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];x5[o]=Math.round(100*l)/100,ho=n,bo=h(),c5.dispose([y,c]),i(x5[o])}))}var wo=D(H());var w2={};Se(w2,{connected:()=>f5,horizontal:()=>z1,kpt:()=>d5,relative:()=>C1,vertical:()=>S1});var d5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],z1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],S1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],C1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],f5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Mo=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function j1(e){for(let t of z1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Ro(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function To(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,m5=0,I1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function ko(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(y5(["size"],e),L0=await G(e.body.modelPath)),m5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,m5<64&&(m5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:d5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(f5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return j1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:d5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(f5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};j1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function N1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),I1++;let o=(t.body.skipTime||0)>h()-He.last,n=I1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};I1=0,A.input=vo(e,m5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)To(a,[e.shape[2]||1,e.shape[1]||1]),Ro(a.keypoints);Object.keys(A).forEach(a=>wo.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,p5=[],zo=0,O1=Number.MAX_SAFE_INTEGER,h5=0,u5=2.5;async function So(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);h5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/h5)),[S,w]=[b-u5/i*P[0],d-u5/i*P[1]],[j,C]=[b+u5/i*P[2]-S,d+u5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function L1(e,t){let o=(t.object.skipTime||0)>h()-zo,n=O1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&p5.length>0?(O1++,p5):(O1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?p5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[h5,h5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),zo=h(),w0.dispose(i);let c=await Lr(y,A,t);p5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[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 Io(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 No(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var b5=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 Oo(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function B1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],g5=1,s2=16,Hr=50**2;function Lo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:G1(Math.round(g.y/s2),0,b-1),x:G1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=B1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=F1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Lo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new b5(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?Oo(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Wo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=Io(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function H1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?No(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Fo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,V1=!1;async function D1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Bo(e,t,o){var m,M;if(V1)return{data:[],canvas:null,alpha:null};V1=!0,ee||await D1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),V1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function P5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function Z1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&P5(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 R1(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 R1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=l3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=i3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=m3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=ko(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Fo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=$t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Bt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=go(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=H3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=b3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=S3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=L3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=kt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=jt(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Lt(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=T3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=mo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=po(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=c3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=So(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=D1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function X1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Vo(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),P5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function R5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Vo(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),zt()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function y5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var _1={};Se(_1,{all:()=>Q1,body:()=>i2,canvas:()=>J1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>K1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 q1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Zo(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){q1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(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 d91f97cc..34155ee4 100644 --- a/dist/human.node.js +++ b/dist/human.node.js @@ -96,7 +96,7 @@ var tn=Object.create;var p2=Object.defineProperty;var on=Object.getOwnPropertyDe c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var z5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},S5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),z5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);z5(o,"uniform",this.uniform),z5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function gt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new S5(l,ft,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?pt:mt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(bt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ut);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var N2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function O2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>N2&&(A=N2,s=Math.trunc(A*r/n)),s>N2&&(s=N2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new gt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,O2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(O2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=O2(i0),i=N.browser.fromPixels(Ze));else{let u=O2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await I2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Pt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Mt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 C5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new C5;var L2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function Rt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=xt(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await L2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new L2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var j5="2.8.0";var y0=D(H());var P5={};Se(P5,{Models:()=>z2,load:()=>D1,reset:()=>g5,validate:()=>Z1});var W2=D(H());var H0,I5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],vt=0,Tt=0,N5=Number.MAX_SAFE_INTEGER;async function wt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function O5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=N5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-Tt;return t.skipAllowed&&A&&r&&vt===n&&I5[o]?(N5++,I5[o]):(N5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=W2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dW2.dispose(y[d])),I5[o]=l,vt=n,Tt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Et(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,F2=[],zt=0,St=0,L5=Number.MAX_SAFE_INTEGER;async function Ct(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function W5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=L5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-St;return t.skipAllowed&&r&&A&&zt===n&&((i=F2[o])==null?void 0:i.age)&&((y=F2[o])==null?void 0:y.age)>0?(L5++,F2[o]):(L5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),F2[o]=x,zt=n,St=h(),c(x)}))}var p0=D(H());var V0,G2=[],It=0,Nt=0,F5=Number.MAX_SAFE_INTEGER,G5=[.2989,.587,.114];async function Ot(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function B5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=F5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Nt;return t.skipAllowed&&r&&A&&It===n&&((i=G2[o])==null?void 0:i.gender)&&((y=G2[o])==null?void 0:y.genderScore)>0?(F5++,G2[o]):(F5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,G5[0]),b=p0.mul(m,G5[1]),d=p0.mul(M,G5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),G2[o]=x,It=n,Nt=h(),c(x)}))}var H2=D(H());var u0,B2=[],H5=Number.MAX_SAFE_INTEGER,Wt=0,Ft=0;async function Gt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function V5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Ft,A=H5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Wt===n&&B2[o]?(H5++,B2[o]):(H5=0,new Promise(async i=>{let y=H2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];B2[o]=Math.round(100*l)/100,Wt=n,Ft=h(),H2.dispose([y,c]),i(B2[o])}))}var O=D(H());var se=D(H());var D0={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]},D5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Z5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],V2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],D2=(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],Dt=(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}},q5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},X2=(e,t)=>{let o=V2(e),n=Ue(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}},q2=e=>{let t=V2(e),o=Ue(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}},Zt=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}},U5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Ht=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Ht(t[0],t[1]),s=Vt(A,r),a=Ht(-t[0],-t[1]);return Vt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function qt(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?Xt(o,[0,0]):U5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):U5,l=V2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Yt(e,t,o,n){let r=t.landmarks.length>=D5.count?D5.symmetryLine:Ce.symmetryLine,A=0,s=U5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=V2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=Xt(-A,y),a=q5(t,l,[n,n]),se.dispose(l)}else a=q5(t,o,[n,n]);else a=q5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Kt=(e,t)=>{let o=Bn(e),n=Ue(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 Jt=6,Hn=1.4,_0,Qt=null,he=0,M2=null,Ye=()=>he;async function _t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),Qt=O.tensor2d(qt(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,Qt),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function $t(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Jt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Jt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Dt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=X2(M,t.face.scale||Hn),b=q2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var U2={};Se(U2,{connected:()=>J5,kpt:()=>K5});var K5=["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"],J5={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=D(H()),t3=224,Dn,Zn=5,Y2=[8,16,32,32,32];async function o3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 n3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function K2(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 s3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},Q5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},Q2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],r3=0,A3=e=>1-1/(1+Math.exp(e));async function a3(e){if(s3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await o3(),S0.detector}async function i3(e){if(s3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(J5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function _5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-r3,r=Q5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&Q2!==null)Q5++;else{let A={};A.landmarks=await Un(e,256),Q2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),r3=h(),Q5=0}return Q2?[Q2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,$5=[],y3=0,e1=Number.MAX_SAFE_INTEGER;async function x3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function t1(e,t){let o=(t.object.skipTime||0)>h()-y3,n=e1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&$5.length>0?(e1++,$5):(e1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;y3=h(),R0.dispose(s);let i=await Qn(a,A,t);$5=i,r(i)}))}var _=D(H());var _2={};Se(_2,{connected:()=>n1,kpt:()=>o1});var o1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],n1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,d3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},r1=Number.MAX_SAFE_INTEGER;async function f3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function A1(e,t){let o=(t.body.skipTime||0)>h()-d3,n=r1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(r1++,[v0]):(r1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),d3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:o1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(n1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,$2=[],p3=0,u3=0,s1=Number.MAX_SAFE_INTEGER;async function h3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function a1(e,t,o,n){var s,a;if(!G0)return[];let r=s1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-u3;return t.skipAllowed&&A&&r&&p3===n&&$2[o]&&$2[o].length>0?(s1++,$2[o]):(s1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),u3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}$2[o]=y,p3=n,i(y)}))}var R3=D(H());var j0,i1=[],g3=0,P3=0,M3=Number.MAX_SAFE_INTEGER;async function v3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function l1(e,t,o,n){var s,a;if(!j0)return[];let r=M3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-P3;return t.skipAllowed&&A&&r&&g3===n&&i1[o]?(M3++,i1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=R3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}i1[o]=y,g3=n,P3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,y1=D0.leftEyeLower0,x1=D0.rightEyeLower0,Qe={leftBounds:[y1[0],y1[y1.length-1]],rightBounds:[x1[0],x1[x1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function z3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function e5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},w3=(e,t,o,n,r,A=!1)=>{let s=q2(X2(Zt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},k3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},E3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function S3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=w3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=w3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=k3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=k3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(e5(e,u,"left",null),e5(e,g,"right",null)):d<1?e5(e,u,"left",["EyeUpper0","EyeLower0"]):e5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=E3(e,m,"left"),S=E3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 I3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await $t(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Yt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await I2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await I3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await S3(K,w.tensor,t,We)),w.mesh=Ut(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Kt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=D2(V,e),w.boxRaw=Z2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function O3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var L3=je,W3=P2;var q0=D(H());var I0,t5=[],F3=0,G3=0,d1=Number.MAX_SAFE_INTEGER;async function B3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function f1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function m1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=d1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-F3;return t.skipAllowed&&r&&A&&G3===n&&((i=t5[o])==null?void 0:i.age)&&((y=t5[o])==null?void 0:y.age)>0?(d1++,t5[o]):(d1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=f1(e),m=I0==null?void 0:I0.execute(u);F3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}t5[o]=l,G3=n,c(l)}))}var W=D(H());var D3=D(H());function o5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Z3(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 D3.image.cropAndResize(t,A,[0],o)}function X3(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 n5(e,t=1.5){let o=T2(e),n=o5(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 r5(e){let t=T2(e),o=o5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function q3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var H3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=X3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,J3=1.65,Q3=[0,5,9,13,17,1,2],hr=0,br=2,_3=0,s5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>h1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return n5(r5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=n5(r5(o),J3);n.palmLandmarks=[];for(let r=0;r[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=u1(n,[0,0]),y=a.map(f=>[...h1(f,i),f[2]]),c=U3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-_3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=n5(r5(y),J3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:b1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,b1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,b1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,b1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var $3=[Te,l0,we,ke,o2];var vr=.7,Be={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 eo(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 oo(e,t){if(!e||!t)return[0,0];let o=eo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=eo(e[1],e[2],t[1],t[2]);return[o,n]}function to(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function no(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function ro(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=ro(e,t,o,n),c=no(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=oo([P,S],[w,j]),U=to(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=to(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=ro(i,a,y,l):u===Math.max(f,u)?K=no(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function Ao(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=oo(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function a5(e){if(!e||e.length===0)return null;let t=Ao(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function so(e){let t=[];if(!e||e.length===0)return t;let o=Ao(e);for(let n of $3){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var ao={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]},n2,r2,io;async function P1(e,t){let o=await io.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=a5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function M1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new A5(n2);return io=new s5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],yo=4,xo=1.6,Sr=512,Cr=1.4,i5=Number.MAX_SAFE_INTEGER,R1=0,ce=[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 fo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{l5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function mo(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[yo]),a.splice(yo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=K2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function v1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=a5(n.keypoints);for(let l of Object.keys(co))n.annotations[l]=co[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function T1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],i5++;let o=(t.hand.skipTime||0)>h()-R1,n=i5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-R1,i=i5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):(A0.boxes=await jr(e,t),R1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))),i5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=K2(l.box,xo),f=K2(l.boxRaw,xo);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-ho,A=w1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&uo===n&&y5[o]?(w1++,y5[o]):(w1=0,new Promise(async i=>{let y=x5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];y5[o]=Math.round(100*l)/100,uo=n,ho=h(),x5.dispose([y,c]),i(y5[o])}))}var To=D(H());var w2={};Se(w2,{connected:()=>d5,horizontal:()=>E1,kpt:()=>c5,relative:()=>S1,vertical:()=>z1});var c5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],E1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],z1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],d5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Po=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function C1(e){for(let t of E1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Mo(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function vo(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,f5=0,j1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function wo(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(l5(["size"],e),L0=await G(e.body.modelPath)),f5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,f5<64&&(f5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:c5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(d5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return C1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:c5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(d5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};C1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function I1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),j1++;let o=(t.body.skipTime||0)>h()-He.last,n=j1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};j1=0,A.input=Ro(e,f5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)vo(a,[e.shape[2]||1,e.shape[1]||1]),Mo(a.keypoints);Object.keys(A).forEach(a=>To.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,m5=[],Eo=0,N1=Number.MAX_SAFE_INTEGER,u5=0,p5=2.5;async function zo(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);u5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/u5)),[S,w]=[b-p5/i*P[0],d-p5/i*P[1]],[j,C]=[b+p5/i*P[2]-S,d+p5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function O1(e,t){let o=(t.object.skipTime||0)>h()-Eo,n=N1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&m5.length>0?(N1++,m5):(N1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?m5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[u5,u5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),Eo=h(),w0.dispose(i);let c=await Lr(y,A,t);m5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[t]]),Co=[["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 Io(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var h5=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 No(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function G1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],b5=1,s2=16,Hr=50**2;function Oo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:F1(Math.round(g.y/s2),0,b-1),x:F1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=G1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=W1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Oo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new h5(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?No(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Lo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=jo(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function B1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?Io(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Wo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,H1=!1;async function V1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Go(e,t,o){var m,M;if(H1)return{data:[],canvas:null,alpha:null};H1=!0,ee||await V1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),H1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function g5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function D1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&g5(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 M1(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 M1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=i3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=a3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=f3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=wo(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Wo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=_t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Gt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=bo(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=B3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=h3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=z3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=O3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=wt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ct(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Ot(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=v3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=fo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=mo(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=x3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=zo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=V1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function Z1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Ho(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),g5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function M5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Ho(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),Et()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function l5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var Q1={};Se(Q1,{all:()=>J1,body:()=>i2,canvas:()=>K1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>Y1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 X1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Do(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){X1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(e.rotation.angle.pitch)/90,A=new Path2D(` +`;var z5=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,A)=>(o[A]=0,r))},S5=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:(p(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(p("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){p("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)){p(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),z5(o,"attribute",this.attribute);for(let s in this.attribute)this.attribute[s]=this.gl.getAttribLocation(this.id,s);z5(o,"uniform",this.uniform),z5(n,"uniform",this.uniform);for(let s in this.uniform)this.uniform[s]=this.gl.getUniformLocation(this.id,s)}}};function gt(){let e=0,t=null,o=!1,n=-1,r=[null,null],A=[],s=null,a=null,i=M0(100,100),y={},c={INTERMEDIATE:1},l=i.getContext("webgl");if(!l){p("filter: cannot get webgl context");return}this.gl=l;function x(b,d){if(!(b===i.width&&d===i.height)){if(i.width=b,i.height=d,!s){let P=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=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,s),l.bufferData(l.ARRAY_BUFFER,P,l.STATIC_DRAW),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}l.viewport(0,0,i.width,i.height),r=[null,null]}}function f(b,d){let P=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,P);let S=l.createRenderbuffer();l.bindRenderbuffer(l.RENDERBUFFER,S);let w=l.createTexture();return l.bindTexture(l.TEXTURE_2D,w),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,b,d,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,w,0),l.bindTexture(l.TEXTURE_2D,null),l.bindFramebuffer(l.FRAMEBUFFER,null),{fbo:P,texture:w}}function u(b){return r[b]=r[b]||f(i.width,i.height),r[b]}function m(b=0){if(!a)return;let d=null,P=null,S=!1;e===0?d=t:d=u(n).texture||null,e++,o&&!(b&c.INTERMEDIATE)?(P=null,S=e%2===0):(n=(n+1)%2,P=u(n).fbo||null),l.bindTexture(l.TEXTURE_2D,d),l.bindFramebuffer(l.FRAMEBUFFER,P),l.uniform1f(a.uniform.flipY,S?-1:1),l.drawArrays(l.TRIANGLES,0,6)}function M(b){if(y[b])return a=y[b],l.useProgram((a?a.id:null)||null),a;if(a=new S5(l,ft,b),!a)return p("filter: could not get webgl program"),null;let d=Float32Array.BYTES_PER_ELEMENT,P=4*d;return l.enableVertexAttribArray(a.attribute.pos),l.vertexAttribPointer(a.attribute.pos,2,l.FLOAT,!1,P,0*d),l.enableVertexAttribArray(a.attribute.uv),l.vertexAttribPointer(a.attribute.uv,2,l.FLOAT,!1,P,2*d),y[b]=a,a}let g={colorMatrix:b=>{let d=new Float32Array(b);d[4]/=255,d[9]/=255,d[14]/=255,d[19]/=255;let P=d[18]===1&&d[3]===0&&d[8]===0&&d[13]===0&&d[15]===0&&d[16]===0&&d[17]===0&&d[19]===0?pt:mt,S=M(P);!S||(l.uniform1fv(S.uniform.m,d),m())},brightness:b=>{let d=(b||0)+1;g.colorMatrix([d,0,0,0,0,0,d,0,0,0,0,0,d,0,0,0,0,0,1,0])},saturation:b=>{let d=(b||0)*2/3+1,P=(d-1)*-.5;g.colorMatrix([d,P,P,0,0,P,d,P,0,0,P,P,d,0,0,0,0,0,1,0])},desaturate:()=>{g.saturation(-1)},contrast:b=>{let d=(b||0)+1,P=-128*(d-1);g.colorMatrix([d,0,0,0,P,0,d,0,0,P,0,0,d,0,P,0,0,0,1,0])},negative:()=>{g.contrast(-2)},hue:b=>{b=(b||0)/180*Math.PI;let d=Math.cos(b),P=Math.sin(b),S=.213,w=.715,j=.072;g.colorMatrix([S+d*(1-S)+P*-S,w+d*-w+P*-w,j+d*-j+P*(1-j),0,0,S+d*-S+P*.143,w+d*(1-w)+P*.14,j+d*-j+P*-.283,0,0,S+d*-S+P*-(1-S),w+d*-w+P*w,j+d*(1-j)+P*j,0,0,0,0,0,1,0])},desaturateLuminance:()=>{g.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:()=>{g.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.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:()=>{g.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:b=>{let d=new Float32Array(b),P=1/i.width,S=1/i.height,w=M(bt);!w||(l.uniform1fv(w.uniform.m,d),l.uniform2f(w.uniform.px,P,S),m())},detectEdges:()=>{g.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{g.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{g.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:b=>{let d=b||1;g.convolution.call(this,[0,-1*d,0,-1*d,1+4*d,-1*d,0,-1*d,0])},emboss:b=>{let d=b||1;g.convolution.call(this,[-2*d,-1*d,0,-1*d,1,1*d,0,1*d,2*d])},blur:b=>{let d=b/7/i.width,P=b/7/i.height,S=M(ht);!S||(l.uniform2f(S.uniform.px,0,P),m(c.INTERMEDIATE),l.uniform2f(S.uniform.px,d,0),m())},pixelate:b=>{let d=b/i.width,P=b/i.height,S=M(ut);!S||(l.uniform2f(S.uniform.size,d,P),m())}};this.add=function(b){let d=Array.prototype.slice.call(arguments,1),P=g[b];A.push({func:P,args:d})},this.reset=function(){A=[]},this.get=function(){return A},this.apply=function(b){x(b.width,b.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,b);for(let d=0;df.data())),s=.99*Math.max(A[0][0],A[1][0],A[2][0]),a=[Z.sub(o[0],n[0]),Z.sub(o[1],n[1]),Z.sub(o[2],n[2])],i=[Z.sub(r[0],n[0]),Z.sub(r[1],n[1]),Z.sub(r[2],n[2])],y=[Z.div(s,i[0]),Z.div(s,i[1]),Z.div(s,i[2])],c=[Z.mul(a[0],y[0]),Z.mul(a[1],y[1]),Z.mul(a[2],y[2])],l=Z.stack([c[0],c[1],c[2]],2),x=Z.reshape(l,[1,t.shape[0],t.shape[1],3]);return Z.dispose([...o,...n,...r,...a,...i,...y,...c,l,t]),x}var N2=3840,X=null,i0=null,Ze=null,e0,re={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function M0(e,t){let o;if(v.browser)if(v.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 v.Canvas!="undefined"?o=new v.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function O2(e,t){let o=t||M0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function Xe(e,t,o=!0){if(!e)return t.debug&&p("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof N.Tensor)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof v.Canvas!="undefined"&&e instanceof v.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 n=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)n=N.expandDims(e,0);else if(e.shape[2]===4){let r=N.slice3d(e,[0,0,0],[-1,-1,3]);n=N.expandDims(r,0),N.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=N.clone(e):e.shape[3]===4&&(n=N.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=N.cast(n,"float32");N.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?i0:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&p("input stream is not ready"),{tensor:null,canvas:X};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&&p("cannot determine input dimensions"),{tensor:null,canvas:X};let A=n,s=r;if(A>N2&&(A=N2,s=Math.trunc(A*r/n)),s>N2&&(s=N2,A=Math.trunc(s*n/r)),(t.filter.width||0)>0?A=t.filter.width:(t.filter.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");(!X||(X==null?void 0:X.width)!==A||(X==null?void 0:X.height)!==s)&&(X=M0(A,s));let a=X.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,X==null?void 0:X.width,X==null?void 0:X.height),a.setTransform(1,0,0,1,0,0)):a.drawImage(e,0,0,n,r,0,0,X==null?void 0:X.width,X==null?void 0:X.height),(!i0||X.width!==i0.width||(X==null?void 0:X.height)!==(i0==null?void 0:i0.height))&&(i0=M0(X.width,X.height)),t.filter.enabled&&v.webgl.supported?(e0||(e0=v.browser?new gt:null),v.filter=!!e0,!e0||!e0.add?(t.debug&&p("input process error: cannot initialize filters"),v.webgl.supported=!1,t.filter.enabled=!1,O2(X,i0)):(e0.reset(),t.filter.brightness!==0&&e0.add("brightness",t.filter.brightness),t.filter.contrast!==0&&e0.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&e0.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&e0.add("blur",t.filter.blur),t.filter.saturation!==0&&e0.add("saturation",t.filter.saturation),t.filter.hue!==0&&e0.add("hue",t.filter.hue),t.filter.negative&&e0.add("negative"),t.filter.sepia&&e0.add("sepia"),t.filter.vintage&&e0.add("brownie"),t.filter.sepia&&e0.add("sepia"),t.filter.kodachrome&&e0.add("kodachrome"),t.filter.technicolor&&e0.add("technicolor"),t.filter.polaroid&&e0.add("polaroid"),t.filter.pixelate!==0&&e0.add("pixelate",t.filter.pixelate),e0.get()>0?i0=e0.apply(X):i0=e0.draw(X))):(O2(X,i0),e0&&(e0=null),v.filter=!!e0),!o)return{tensor:null,canvas:i0};if(!i0)throw new Error("canvas error: cannot create output");let i,y=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(v.browser&&N.browser)i=N.browser?N.browser.fromPixels(e):null;else{y=e.data.length/e.height/e.width;let x=new Uint8Array(e.data.buffer);i=N.tensor(x,[e.height,e.width,y],"int32")}else if((!Ze||i0.width!==Ze.width||i0.height!==Ze.height)&&(Ze=M0(i0.width,i0.height)),N.browser&&v.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?i=N.browser.fromPixels(i0):(Ze=O2(i0),i=N.browser.fromPixels(Ze));else{let u=O2(i0).getContext("2d").getImageData(0,0,A,s);y=u.data.length/A/s;let m=new Uint8Array(u.data.buffer);i=N.tensor(m,[A,s,y])}if(y===4){let x=N.slice3d(i,[0,0,0],[-1,-1,3]);N.dispose(i),i=x}if(!i)throw new Error("input error: cannot create tensor");let c=N.cast(i,"float32"),l=t.filter.equalization?await I2(c):N.expandDims(c,0);return N.dispose([i,c]),{tensor:l,canvas:t.filter.return?i0:null}}}async function Pt(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(!re.inputTensor)re.inputTensor=N.clone(t);else if(re.inputTensor.shape[1]!==t.shape[1]||re.inputTensor.shape[2]!==t.shape[2])N.dispose(re.inputTensor),re.inputTensor=N.clone(t);else{let n={};n.diff=N.sub(t,re.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([re.inputTensor,n.diff,n.squared,n.sum]),re.inputTensor=N.clone(t),o=A<=(e.cacheSensitivity||0)}return o}async function Mt(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||p("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||p("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 C5=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,"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:m0.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&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&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(m0.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&m0.getBackend()==="wasm"&&(this.wasm.simd=await m0.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await m0.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=M0(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&&(m0.getBackend()==="webgl"||m0.getBackend()==="humangl")){let n=m0.backend().gpgpu!=="undefined"?await m0.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{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=m0.getKernelsForBackend(m0.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},v=new C5;var L2=D(H()),Ae={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function hn(e,t){return Ae.debug&&p("load model fetch:",e,t),fetch(e,t)}function Rt(e){Ae.cacheModels=e.cacheModels,Ae.verbose=e.debug,Ae.modelBasePath=e.modelBasePath}async function G(e){let t=xt(Ae.modelBasePath,e||"");t.toLowerCase().endsWith(".json")||(t+=".json");let o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await L2.io.listModels(),A=Ae.cacheModels&&Object.keys(r).includes(n),s=typeof fetch=="undefined"?{}:{fetchFunc:(y,c)=>hn(y,c)},a=new L2.GraphModel(A?n:t,s),i=!1;try{a.findIOHandler(),Ae.debug&&p("model load handler:",a.handler);let y=await a.handler.load();a.loadSync(y),Ae.verbose&&p("load model:",a.modelUrl),i=!0}catch(y){p("error loading model:",t,y)}if(i&&Ae.cacheModels&&!A)try{let y=await a.save(n);p("model saved:",n,y)}catch(y){p("error saving model:",t,y)}return a}var Q0=D(H());var j5="2.8.1";var y0=D(H());var P5={};Se(P5,{Models:()=>z2,load:()=>D1,reset:()=>g5,validate:()=>Z1});var W2=D(H());var H0,I5=[],Pn=["white","black","asian","indian","other"],Mn=[15,23,28,35.5,45.5,55.5,65],vt=0,Tt=0,N5=Number.MAX_SAFE_INTEGER;async function wt(e){return v.initial&&(H0=null),H0?e.debug&&p("cached model:",H0.modelUrl):H0=await G(e.face.gear),H0}async function O5(e,t,o,n){var s,a;if(!H0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=N5<(((s=t.face.gear)==null?void 0:s.skipFrames)||0),A=(((a=t.face.gear)==null?void 0:a.skipTime)||0)>h()-Tt;return t.skipAllowed&&A&&r&&vt===n&&I5[o]?(N5++,I5[o]):(N5=0,new Promise(async i=>{var g,b;if(!(H0!=null&&H0.inputs[0].shape))return;let y={},c=[[0,.1,.9,.9]];y.resize=W2.image.cropAndResize(e,c,[0],[H0.inputs[0].shape[2],H0.inputs[0].shape[1]]);let l={age:0,gender:"unknown",genderScore:0,race:[]};(g=t.face.gear)!=null&&g.enabled&&([y.age,y.gender,y.race]=H0.execute(y.resize,["age_output","gender_output","race_output"]));let x=await y.gender.data();l.gender=x[0]>x[1]?"male":"female",l.genderScore=Math.round(100*(x[0]>x[1]?x[0]:x[1]))/100;let f=await y.race.data();for(let d=0;d(((b=t.face.gear)==null?void 0:b.minConfidence)||.2)&&l.race.push({score:Math.round(100*f[d])/100,race:Pn[d]});l.race.sort((d,P)=>P.score-d.score);let m=Array.from(await y.age.data()).map((d,P)=>[Mn[P],d]).sort((d,P)=>P[1]-d[1]),M=m[0][0];for(let d=1;dW2.dispose(y[d])),I5[o]=l,vt=n,Tt=h(),i(l)}))}var qe=D(H());var pe=D(H()),B={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Et(){B.tf255=pe.scalar(255,"float32"),B.tf1=pe.scalar(1,"float32"),B.tf2=pe.scalar(2,"float32"),B.tf05=pe.scalar(.5,"float32"),B.tf127=pe.scalar(127.5,"float32"),B.rgb=pe.tensor1d([.2989,.587,.114],"float32")}var E0,F2=[],zt=0,St=0,L5=Number.MAX_SAFE_INTEGER;async function Ct(e){return v.initial&&(E0=null),E0?e.debug&&p("cached model:",E0.modelUrl):E0=await G(e.face.ssrnet.modelPathAge),E0}async function W5(e,t,o,n){var s,a,i,y;if(!E0)return{age:0};let r=L5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-St;return t.skipAllowed&&r&&A&&zt===n&&((i=F2[o])==null?void 0:i.age)&&((y=F2[o])==null?void 0:y.age)>0?(L5++,F2[o]):(L5=0,new Promise(async c=>{if(!(E0!=null&&E0.inputs)||!E0.inputs[0]||!E0.inputs[0].shape)return;let l={};l.resize=qe.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]],!1),l.enhance=qe.mul(l.resize,B.tf255);let x={age:0};if(t.face.ssrnet.enabled&&(l.age=E0.execute(l.enhance)),l.age){let f=await l.age.data();x.age=Math.trunc(10*f[0])/10}Object.keys(l).forEach(f=>qe.dispose(l[f])),F2[o]=x,zt=n,St=h(),c(x)}))}var p0=D(H());var V0,G2=[],It=0,Nt=0,F5=Number.MAX_SAFE_INTEGER,G5=[.2989,.587,.114];async function Ot(e){return v.initial&&(V0=null),V0?e.debug&&p("cached model:",V0.modelUrl):V0=await G(e.face.ssrnet.modelPathGender),V0}async function B5(e,t,o,n){var s,a,i,y;if(!V0)return{gender:"unknown",genderScore:0};let r=F5<(((s=t.face.ssrnet)==null?void 0:s.skipFrames)||0),A=(((a=t.face.ssrnet)==null?void 0:a.skipTime)||0)>h()-Nt;return t.skipAllowed&&r&&A&&It===n&&((i=G2[o])==null?void 0:i.gender)&&((y=G2[o])==null?void 0:y.genderScore)>0?(F5++,G2[o]):(F5=0,new Promise(async c=>{if(!(V0!=null&&V0.inputs[0].shape))return;let l={};l.resize=p0.image.resizeBilinear(e,[V0.inputs[0].shape[2],V0.inputs[0].shape[1]],!1),l.enhance=p0.tidy(()=>{let[u,m,M]=p0.split(l.resize,3,3),g=p0.mul(u,G5[0]),b=p0.mul(m,G5[1]),d=p0.mul(M,G5[2]),P=p0.addN([g,b,d]);return p0.mul(p0.sub(P,B.tf05),2)});let x={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(l.gender=V0.execute(l.enhance));let f=await l.gender.data();x.gender=f[0]>f[1]?"female":"male",x.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(l).forEach(u=>p0.dispose(l[u])),G2[o]=x,It=n,Nt=h(),c(x)}))}var H2=D(H());var u0,B2=[],H5=Number.MAX_SAFE_INTEGER,Wt=0,Ft=0;async function Gt(e){var t;return v.initial&&(u0=null),u0?e.debug&&p("cached model:",u0.modelUrl):u0=await G((t=e.face.antispoof)==null?void 0:t.modelPath),u0}async function V5(e,t,o,n){var s,a;if(!u0)return 0;let r=(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)>h()-Ft,A=H5<(((a=t.face.antispoof)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&Wt===n&&B2[o]?(H5++,B2[o]):(H5=0,new Promise(async i=>{let y=H2.image.resizeBilinear(e,[u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[2]:0,u0!=null&&u0.inputs[0].shape?u0.inputs[0].shape[1]:0],!1),c=u0==null?void 0:u0.execute(y),l=(await c.data())[0];B2[o]=Math.round(100*l)/100,Wt=n,Ft=h(),H2.dispose([y,c]),i(B2[o])}))}var O=D(H());var se=D(H());var D0={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]},D5={count:468,mouth:13,symmetryLine:[13,D0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Z5=[{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]],je=[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 vn=[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],Tn=[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],wn=[33,133,362,263,1,78,308],DA=vn.map(e=>P2[e]),ZA=Tn.map(e=>P2[e]),XA=wn.map(e=>P2[e]);function ue(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var kn=[[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]],En=[[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]],zn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Sn=[[474,475],[475,476],[476,477],[477,474]],Cn=[[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]],jn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],In=[[469,470],[470,471],[471,472],[472,469]],Nn=[[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]],qA={lips:ue(kn),leftEye:ue(En),leftEyebrow:ue(zn),leftIris:ue(Sn),rightEye:ue(Cn),rightEyebrow:ue(jn),rightIris:ue(In),faceOval:ue(Nn)};var Ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],V2=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],D2=(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],Dt=(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}},q5=(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=se.image.cropAndResize(t,[A],[0],o),a=se.div(s,B.tf255);return se.dispose(s),a},X2=(e,t)=>{let o=V2(e),n=Ue(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}},q2=e=>{let t=V2(e),o=Ue(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}},Zt=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}},U5=[[1,0,0],[0,1,0],[0,0,1]],On=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ln=(e,t)=>On(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Ht=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ie=(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=Ht(t[0],t[1]),s=Vt(A,r),a=Ht(-t[0],-t[1]);return Vt(s,a)},Fn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-Ie(t[0],o),-Ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Gn=(e,t)=>[Ie(e,t[0]),Ie(e,t[1])];function qt(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*(f[0]-r/2),A[1]/r*(f[1]-r/2),f[2]||0]),a=o&&o!==0&&Math.abs(o)>.2,i=a?Xt(o,[0,0]):U5,y=a?s.map(f=>[...Gn(f,i),f[2]]):s,c=a?Fn(n):U5,l=V2(t),x=[Ie(l,c[0]),Ie(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2]||0)])}function Yt(e,t,o,n){let r=t.landmarks.length>=D5.count?D5.symmetryLine:Ce.symmetryLine,A=0,s=U5,a;if(e&&v.kernels.includes("rotatewithoffset"))if(A=Ln(t.landmarks[r[0]],t.landmarks[r[1]]),A&&A!==0&&Math.abs(A)>.2){let y=V2(t),c=[y[0]/o.shape[2],y[1]/o.shape[1]],l=se.image.rotateWithOffset(o,A,0,c);s=Xt(-A,y),a=q5(t,l,[n,n]),se.dispose(l)}else a=q5(t,o,[n,n]);else a=q5(t,o,[n,n]);return[A,s,a]}var Bn=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]},Kt=(e,t)=>{let o=Bn(e),n=Ue(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 Jt=6,Hn=1.4,_0,Qt=null,he=0,M2=null,Ye=()=>he;async function _t(e){var t;return v.initial&&(_0=null),_0?e.debug&&p("cached model:",_0.modelUrl):_0=await G((t=e.face.detector)==null?void 0:t.modelPath),he=_0.inputs[0].shape?_0.inputs[0].shape[2]:0,M2=O.scalar(he,"int32"),Qt=O.tensor2d(qt(he)),_0}function Vn(e){let t={};t.boxStarts=O.slice(e,[0,1],[-1,2]),t.centers=O.add(t.boxStarts,Qt),t.boxSizes=O.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=O.div(t.boxSizes,M2),t.centersNormalized=O.div(t.centers,M2),t.halfBoxSize=O.div(t.boxSizesNormalized,B.tf2),t.starts=O.sub(t.centersNormalized,t.halfBoxSize),t.ends=O.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=O.mul(t.starts,M2),t.endNormalized=O.mul(t.ends,M2);let o=O.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>O.dispose(t[n])),o}async function $t(e,t){var a,i,y,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=O.image.resizeBilinear(e,[he,he]),o.div=O.div(o.resized,B.tf127),o.normalized=O.sub(o.div,B.tf05);let n=_0==null?void 0:_0.execute(o.normalized);if(Array.isArray(n)&&n.length>2){let l=n.sort((x,f)=>x.size-f.size);o.concat384=O.concat([l[0],l[2]],2),o.concat512=O.concat([l[1],l[3]],2),o.concat=O.concat([o.concat512,o.concat384],1),o.batch=O.squeeze(o.concat,0)}else Array.isArray(n)?o.batch=O.squeeze(n[0]):o.batch=O.squeeze(n);O.dispose(n),o.boxes=Vn(o.batch),o.logits=O.slice(o.batch,[0,0],[-1,1]),o.sigmoid=O.sigmoid(o.logits),o.scores=O.squeeze(o.sigmoid),o.nms=await O.image.nonMaxSuppressionAsync(o.boxes,o.scores,((a=t.face.detector)==null?void 0:a.maxDetected)||0,((i=t.face.detector)==null?void 0:i.iouThreshold)||0,((y=t.face.detector)==null?void 0:y.minConfidence)||0);let r=await o.nms.array(),A=[],s=await o.scores.data();for(let l=0;l(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let f={};f.bbox=O.slice(o.boxes,[r[l],0],[1,-1]),f.slice=O.slice(o.batch,[r[l],Jt-1],[1,-1]),f.squeeze=O.squeeze(f.slice),f.landmarks=O.reshape(f.squeeze,[Jt,-1]);let u=await f.bbox.data(),m={startPoint:[u[0],u[1]],endPoint:[u[2],u[3]],landmarks:await f.landmarks.array(),confidence:x},M=Dt(m,[(e.shape[2]||0)/he,(e.shape[1]||0)/he]),g=X2(M,t.face.scale||Hn),b=q2(g);A.push(b),Object.keys(f).forEach(d=>O.dispose(f[d]))}}return Object.keys(o).forEach(l=>O.dispose(o[l])),A}var C0=D(H());var U2={};Se(U2,{connected:()=>J5,kpt:()=>K5});var K5=["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"],J5={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=D(H()),t3=224,Dn,Zn=5,Y2=[8,16,32,32,32];async function o3(){let e=[],t=0;for(;to.x)),y:z0.tensor1d(e.map(o=>o.y))}}function ae(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 n3(e,t=[1,1]){let o=[e.map(y=>y[0]),e.map(y=>y[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)],i=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:i}}function K2(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 s3={initial:!0},S0={detector:null,landmarks:null},Ke={detector:[224,224],landmarks:[256,256]},Q5=Number.MAX_SAFE_INTEGER,qn={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},Q2=null,R2,be=[[0,0],[0,0],[0,0],[0,0]],r3=0,A3=e=>1-1/(1+Math.exp(e));async function a3(e){if(s3.initial&&(S0.detector=null),!S0.detector&&e.body.detector&&e.body.detector.modelPath){S0.detector=await G(e.body.detector.modelPath);let t=Object.values(S0.detector.modelSignature.inputs);Ke.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&S0.detector&&p("cached model:",S0.detector.modelUrl);return await o3(),S0.detector}async function i3(e){if(s3.initial&&(S0.landmarks=null),S0.landmarks)e.debug&&p("cached model:",S0.landmarks.modelUrl);else{S0.landmarks=await G(e.body.modelPath);let t=Object.values(S0.landmarks.modelSignature.inputs);Ke.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Ke.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return S0.landmarks}async function Un(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(R2&&(o.cropped=C0.image.cropAndResize(e,[R2],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[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];be=[[0,0],r,A,[0,0]],o.pad=C0.pad(o.cropped||e,be),o.resize=C0.image.resizeBilinear(o.pad,[t,t]),n=C0.div(o.resize,B.tf255)}else e.shape[1]!==t?(o.resize=C0.image.resizeBilinear(o.cropped||e,[t,t]),n=C0.div(o.resize,B.tf255)):n=C0.div(o.cropped||e,B.tf255);return Object.keys(o).forEach(r=>C0.dispose(o[r])),n}function Yn(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+be[2][0]+be[2][1])/t[0]-be[2][0]),Math.trunc(o.position[1]*(t[1]+be[1][0]+be[1][1])/t[1]-be[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(R2)for(let o of e)o.positionRaw=[o.positionRaw[0]+R2[1],o.positionRaw[1]+R2[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}async function Kn(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 Jn(e,t,o){var u;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(u=S0.landmarks)==null?void 0:u.execute(e,qn.landmarks);let r=(await n.poseflag.data())[0],A=await n.ld.data(),s=await n.world.data();Object.keys(n).forEach(m=>C0.dispose(n[m]));let a=[],i=5;for(let m=0;mm.position),l=ae(c,[o[0],o[1]]),x={};for(let[m,M]of Object.entries(J5)){let g=[];for(let b=0;bS.part===M[b]),P=y.find(S=>S.part===M[b+1]);d&&P&&g.push([d.position,P.position])}x[m]=g}return{id:0,score:Math.trunc(100*r)/100,box:l.box,boxRaw:l.boxRaw,keypoints:y,annotations:x}}async function _5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>h()-r3,r=Q5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&Q2!==null)Q5++;else{let A={};A.landmarks=await Un(e,256),Q2=await Jn(A.landmarks,t,o),Object.keys(A).forEach(s=>C0.dispose(A[s])),r3=h(),Q5=0}return Q2?[Q2]:[]}var R0=D(H());var Je=[{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 ie,Ne=0,$5=[],y3=0,e1=Number.MAX_SAFE_INTEGER;async function x3(e){if(v.initial&&(ie=null),ie)e.debug&&p("cached model:",ie.modelUrl);else{ie=await G(e.object.modelPath);let t=Object.values(ie.modelSignature.inputs);Ne=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return ie}async function Qn(e,t,o){if(!e)return[];let n={},r=[],A=await e.array();n.squeeze=R0.squeeze(e);let s=R0.split(n.squeeze,6,1);n.stack=R0.stack([s[1],s[0],s[3],s[2]],1),n.boxes=R0.squeeze(n.stack),n.scores=R0.squeeze(s[4]),n.classes=R0.squeeze(s[5]),R0.dispose([e,...s]),n.nms=await R0.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let a=await n.nms.data(),i=0;for(let y of Array.from(a)){let c=Math.trunc(100*A[0][y][4])/100,l=A[0][y][5],x=Je[l].label,[f,u]=[A[0][y][0]/Ne,A[0][y][1]/Ne],m=[f,u,A[0][y][2]/Ne-f,A[0][y][3]/Ne-u],M=[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:i++,score:c,class:l,label:x,box:M,boxRaw:m})}return Object.keys(n).forEach(y=>R0.dispose(n[y])),r}async function t1(e,t){let o=(t.object.skipTime||0)>h()-y3,n=e1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&$5.length>0?(e1++,$5):(e1=0,new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=R0.image.resizeBilinear(e,[Ne,Ne]),a=t.object.enabled?ie==null?void 0:ie.execute(s,["tower_0/detections"]):null;y3=h(),R0.dispose(s);let i=await Qn(a,A,t);$5=i,r(i)}))}var _=D(H());var _2={};Se(_2,{connected:()=>n1,kpt:()=>o1});var o1=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],n1={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var h0,d3=0,v0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},r1=Number.MAX_SAFE_INTEGER;async function f3(e){return v.initial&&(h0=null),h0?e.debug&&p("cached model:",h0.modelUrl):h0=await G(e.body.modelPath),h0}async function _n(e,t){let[o,n]=e.shape,r=_.reshape(e,[n*o]),A=_.max(r,0),s=(await A.data())[0];if(_.dispose([r,A]),s>t){let a=_.argMax(r,0),i=_.mod(a,o),y=(await i.data())[0],c=_.div(a,_.scalar(o,"int32")),l=(await c.data())[0];return _.dispose([i,c]),[y,l,s]}return[0,0,s]}async function A1(e,t){let o=(t.body.skipTime||0)>h()-d3,n=r1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(v0.keypoints).length>0?(r1++,[v0]):(r1=0,new Promise(async r=>{var l;let A=_.tidy(()=>{if(!(h0!=null&&h0.inputs[0].shape))return null;let x=_.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),f=_.mul(x,B.tf2);return _.sub(f,B.tf1)}),s;if(t.body.enabled&&(s=h0==null?void 0:h0.execute(A)),d3=h(),_.dispose(A),s){v0.keypoints.length=0;let x=s.squeeze();_.dispose(s);let f=x.unstack(2);_.dispose(x);for(let u=0;u(((l=t.body)==null?void 0:l.minConfidence)||0)&&v0.keypoints.push({score:Math.round(100*g)/100,part:o1[u],positionRaw:[m/h0.inputs[0].shape[2],M/h0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/h0.inputs[0].shape[2]),Math.round(e.shape[1]*M/h0.inputs[0].shape[1])]})}f.forEach(u=>_.dispose(u))}v0.score=v0.keypoints.reduce((x,f)=>f.score>x?f.score:x,0);let a=v0.keypoints.map(x=>x.position[0]),i=v0.keypoints.map(x=>x.position[1]);v0.box=[Math.min(...a),Math.min(...i),Math.max(...a)-Math.min(...a),Math.max(...i)-Math.min(...i)];let y=v0.keypoints.map(x=>x.positionRaw[0]),c=v0.keypoints.map(x=>x.positionRaw[1]);v0.boxRaw=[Math.min(...y),Math.min(...c),Math.max(...y)-Math.min(...y),Math.max(...c)-Math.min(...c)];for(let[x,f]of Object.entries(n1)){let u=[];for(let m=0;mb.part===f[m]),g=v0.keypoints.find(b=>b.part===f[m+1]);M&&g&&M.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&u.push([M.position,g.position])}v0.annotations[x]=u}r([v0])}))}var Z0=D(H());var $n=["angry","disgust","fear","happy","sad","surprise","neutral"],G0,$2=[],p3=0,u3=0,s1=Number.MAX_SAFE_INTEGER;async function h3(e){var t;return v.initial&&(G0=null),G0?e.debug&&p("cached model:",G0.modelUrl):G0=await G((t=e.face.emotion)==null?void 0:t.modelPath),G0}async function a1(e,t,o,n){var s,a;if(!G0)return[];let r=s1<(((s=t.face.emotion)==null?void 0:s.skipFrames)||0),A=(((a=t.face.emotion)==null?void 0:a.skipTime)||0)>h()-u3;return t.skipAllowed&&A&&r&&p3===n&&$2[o]&&$2[o].length>0?(s1++,$2[o]):(s1=0,new Promise(async i=>{var c,l;let y=[];if((c=t.face.emotion)!=null&&c.enabled){let x={},f=G0!=null&&G0.inputs[0].shape?G0.inputs[0].shape[2]:0;x.resize=Z0.image.resizeBilinear(e,[f,f],!1),x.channels=Z0.mul(x.resize,B.rgb),x.grayscale=Z0.sum(x.channels,3,!0),x.grayscaleSub=Z0.sub(x.grayscale,B.tf05),x.grayscaleMul=Z0.mul(x.grayscaleSub,B.tf2),x.emotion=G0==null?void 0:G0.execute(x.grayscaleMul),u3=h();let u=await x.emotion.data();for(let m=0;m(((l=t.face.emotion)==null?void 0:l.minConfidence)||0)&&y.push({score:Math.min(.99,Math.trunc(100*u[m])/100),emotion:$n[m]});y.sort((m,M)=>M.score-m.score),Object.keys(x).forEach(m=>Z0.dispose(x[m]))}$2[o]=y,p3=n,i(y)}))}var R3=D(H());var j0,i1=[],g3=0,P3=0,M3=Number.MAX_SAFE_INTEGER;async function v3(e){return v.initial&&(j0=null),j0?e.debug&&p("cached model:",j0.modelUrl):j0=await G(e.face.mobilefacenet.modelPath),j0}async function l1(e,t,o,n){var s,a;if(!j0)return[];let r=M3<(((s=t.face.embedding)==null?void 0:s.skipFrames)||0),A=(((a=t.face.embedding)==null?void 0:a.skipTime)||0)>h()-P3;return t.skipAllowed&&A&&r&&g3===n&&i1[o]?(M3++,i1[o]):new Promise(async i=>{var c;let y=[];if(((c=t.face.embedding)==null?void 0:c.enabled)&&(j0==null?void 0:j0.inputs[0].shape)){let l={};l.crop=R3.image.resizeBilinear(e,[j0.inputs[0].shape[2],j0.inputs[0].shape[1]],!1),l.data=j0==null?void 0:j0.execute(l.crop);let x=await l.data.data();y=Array.from(x)}i1[o]=y,g3=n,P3=h(),i(y)})}var $e=D(H());var X0=D(H());var le,ge=0,er=2.3,y1=D0.leftEyeLower0,x1=D0.rightEyeLower0,Qe={leftBounds:[y1[0],y1[y1.length-1]],rightBounds:[x1[0],x1[x1.length-1]]},_e={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function z3(e){var t;return v.initial&&(le=null),le?e.debug&&p("cached model:",le.modelUrl):le=await G((t=e.face.iris)==null?void 0:t.modelPath),ge=le.inputs[0].shape?le.inputs[0].shape[2]:0,ge===-1&&(ge=64),le}function e5(e,t,o,n){for(let r=0;r{let t=e[Qe.leftBounds[0]][2],o=e[Qe.rightBounds[0]][2];return t-o},w3=(e,t,o,n,r,A=!1)=>{let s=q2(X2(Zt([e[o],e[n]]),er)),a=Ue(s),i=X0.image.cropAndResize(t,[[s.startPoint[1]/r,s.startPoint[0]/r,s.endPoint[1]/r,s.endPoint[0]/r]],[0],[ge,ge]);if(A&&v.kernels.includes("flipleftright")){let y=X0.image.flipLeftRight(i);X0.dispose(i),i=y}return{box:s,boxSize:a,crop:i}},k3=(e,t,o,n=!1)=>{let r=[];for(let A=0;A<_e.numCoordinates;A++){let s=e[A*3],a=e[A*3+1],i=e[A*3+2];r.push([(n?1-s/ge:s/ge)*o[0]+t.startPoint[0],a/ge*o[1]+t.startPoint[1],i])}return{rawCoords:r,iris:r.slice(_e.index)}},E3=(e,t,o)=>{let n=e[D0[`${o}EyeUpper0`][_e.upperCenter]][2],r=e[D0[`${o}EyeLower0`][_e.lowerCenter]][2],A=(n+r)/2;return t.map((s,a)=>{let i=A;return a===2?i=n:a===4&&(i=r),[s[0],s[1],i]})};async function S3(e,t,o,n){if(!le)return o.debug&&p("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:A,crop:s}=w3(e,t,Qe.leftBounds[0],Qe.leftBounds[1],n,!0),{box:a,boxSize:i,crop:y}=w3(e,t,Qe.rightBounds[0],Qe.rightBounds[1],n,!0),c=X0.concat([s,y]);X0.dispose(s),X0.dispose(y);let l=le.execute(c);X0.dispose(c);let x=await l.data();X0.dispose(l);let f=x.slice(0,_e.numCoordinates*3),{rawCoords:u,iris:m}=k3(f,r,A,!0),M=x.slice(_e.numCoordinates*3),{rawCoords:g,iris:b}=k3(M,a,i,!1),d=tr(e);Math.abs(d)<30?(e5(e,u,"left",null),e5(e,g,"right",null)):d<1?e5(e,u,"left",["EyeUpper0","EyeLower0"]):e5(e,g,"right",["EyeUpper0","EyeLower0"]);let P=E3(e,m,"left"),S=E3(e,b,"right");return e.concat(P).concat(S)}var or=[[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]],nr=[[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]],rr=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ar=[[474,475],[475,476],[476,477],[477,474]],sr=[[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]],ar=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ir=[[469,470],[470,471],[471,472],[472,469]],lr=[[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 yr={lips:Pe(or),leftEye:Pe(nr),leftEyebrow:Pe(rr),leftIris:Pe(Ar),rightEye:Pe(sr),rightEyebrow:Pe(ar),rightIris:Pe(ir),faceOval:Pe(lr)},xr=Object.entries(yr).map(([e,t])=>t.map(o=>[o,e])).flat(),P7=new Map(xr),v2=[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],Oe=[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],Le=[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 I3(e,t){let o={lips:await t.filter(A=>A.size===160)[0].data(),irisL:await t.filter(A=>A.size===10)[0].data(),eyeL:await t.filter(A=>A.size===142)[0].data(),irisR:await t.filter(A=>A.size===10)[1].data(),eyeR:await t.filter(A=>A.size===142)[1].data()},n=Oe.reduce((A,s)=>A+=e[s][2],0)/Oe.length;for(let A=0;AA+=e[s][2],0)/Le.length;for(let A=0;Ah()-$0.timestamp,n=$0.skipped<(((i=t.face.detector)==null?void 0:i.skipFrames)||0);!t.skipAllowed||!o||!n||$0.boxes.length===0?($0.boxes=await $t(e,t),$0.timestamp=h(),$0.skipped=0):$0.skipped++;let r=[],A=[],s=0;for(let b=0;b<$0.boxes.length;b++){let d=$0.boxes[b],P=0,S,w={id:s++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if([P,S,w.tensor]=Yt((y=t.face.detector)==null?void 0:y.rotation,d,e,(c=t.face.mesh)!=null&&c.enabled?We:Ye()),(l=t==null?void 0:t.filter)!=null&&l.equalization){let j=await I2(w.tensor);$e.dispose(w.tensor),w.tensor=j}if(w.boxScore=Math.round(100*d.confidence)/100,(x=t.face.mesh)!=null&&x.enabled)if(!b0)t.debug&&p("face mesh detection requested, but model is not loaded");else{let j=b0.execute(w.tensor),C=j.find(V=>V.shape[V.shape.length-1]===1),F=j.find(V=>V.shape[V.shape.length-1]===1404),Q=await C.data();w.faceScore=Math.round(100*Q[0])/100;let U=$e.reshape(F,[-1,3]),K=await U.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1)){if(d.confidence=w.faceScore,(u=t.face.mesh)!=null&&u.keepInvalid){w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(V=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*V[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*V[1]/Ye()]),w.meshRaw=w.mesh.map(V=>[V[0]/(e.shape[2]||0),V[1]/(e.shape[1]||0),(V[2]||0)/We]);for(let V of Object.keys(Ce))w.annotations[V]=[w.mesh[Ce[V]]]}}else{(m=t.face.attention)!=null&&m.enabled?K=await I3(K,j):(M=t.face.iris)!=null&&M.enabled&&(K=await S3(K,w.tensor,t,We)),w.mesh=Ut(K,d,P,S,We),w.meshRaw=w.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/We]);for(let E of Object.keys(D0))w.annotations[E]=D0[E].map(W0=>w.mesh[W0]);w.score=w.faceScore;let V={...Kt(w.mesh,d),confidence:d.confidence,landmarks:d.landmarks};w.box=D2(V,e),w.boxRaw=Z2(V,e),A.push(V)}$e.dispose([...j,U])}else{w.box=D2(d,e),w.boxRaw=Z2(d,e),w.score=w.boxScore,w.mesh=d.landmarks.map(j=>[(d.startPoint[0]+d.endPoint[0])/2+(d.endPoint[0]+d.startPoint[0])*j[0]/Ye(),(d.startPoint[1]+d.endPoint[1])/2+(d.endPoint[1]+d.startPoint[1])*j[1]/Ye()]),w.meshRaw=w.mesh.map(j=>[j[0]/(e.shape[2]||0),j[1]/(e.shape[1]||0),(j[2]||0)/We]);for(let j of Object.keys(Ce))w.annotations[j]=[w.mesh[Ce[j]]]}w.score>(((g=t.face.detector)==null?void 0:g.minConfidence)||1)?r.push(w):$e.dispose(w.tensor)}return $0.boxes=A,r}async function O3(e){var t,o,n,r,A,s;return v.initial&&(b0=null),((o=(t=e==null?void 0:e.face)==null?void 0:t.attention)==null?void 0:o.enabled)&&(b0==null?void 0:b0.signature)&&Object.keys(((n=b0==null?void 0:b0.signature)==null?void 0:n.outputs)||{}).length<6&&(b0=null),b0?e.debug&&p("cached model:",b0.modelUrl):(r=e.face.attention)!=null&&r.enabled?b0=await G((A=e.face.attention)==null?void 0:A.modelPath):b0=await G((s=e.face.mesh)==null?void 0:s.modelPath),We=b0.inputs[0].shape?b0.inputs[0].shape[2]:0,b0}var L3=je,W3=P2;var q0=D(H());var I0,t5=[],F3=0,G3=0,d1=Number.MAX_SAFE_INTEGER;async function B3(e){var t;return v.initial&&(I0=null),I0?e.debug&&p("cached model:",I0.modelUrl):I0=await G((t=e.face.description)==null?void 0:t.modelPath),I0}function f1(e){let t=e.image||e.tensor||e;if(!(I0!=null&&I0.inputs[0].shape))return t;let o=q0.image.resizeBilinear(t,[I0.inputs[0].shape[2],I0.inputs[0].shape[1]],!1),n=q0.mul(o,B.tf255);return q0.dispose(o),n}async function m1(e,t,o,n){var s,a,i,y;if(!I0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=d1<(((s=t.face.description)==null?void 0:s.skipFrames)||0),A=(((a=t.face.description)==null?void 0:a.skipTime)||0)>h()-F3;return t.skipAllowed&&r&&A&&G3===n&&((i=t5[o])==null?void 0:i.age)&&((y=t5[o])==null?void 0:y.age)>0?(d1++,t5[o]):(d1=0,new Promise(async c=>{var x,f;let l={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((x=t.face.description)!=null&&x.enabled){let u=f1(e),m=I0==null?void 0:I0.execute(u);F3=h(),q0.dispose(u);let g=await(await m.find(F=>F.shape[1]===1)).data(),b=Math.trunc(200*Math.abs(g[0]-.5))/100;b>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(l.gender=g[0]<=.5?"female":"male",l.genderScore=Math.min(.99,b));let d=q0.argMax(m.find(F=>F.shape[1]===100),1),P=(await d.data())[0];q0.dispose(d);let w=await m.find(F=>F.shape[1]===100).data();l.age=Math.round(w[P-1]>w[P+1]?10*P-100*w[P-1]:10*P+100*w[P+1])/10;let j=m.find(F=>F.shape[1]===1024),C=j?await j.data():[];l.descriptor=Array.from(C),m.forEach(F=>q0.dispose(F))}t5[o]=l,G3=n,c(l)}))}var W=D(H());var D3=D(H());function o5(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function T2(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Z3(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 D3.image.cropAndResize(t,A,[0],o)}function X3(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 n5(e,t=1.5){let o=T2(e),n=o5(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 r5(e){let t=T2(e),o=o5(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 dr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function q3(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return dr(o)}var H3=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Me(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=W.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=W.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=W.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=W.slice(t,[0,0],[-1,2]),o.boxSizes=W.slice(t,[0,2],[-1,2]),o.div=W.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=W.add(o.div,this.anchorsTensor),o.halfBoxSizes=W.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=W.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=W.mul(o.sub,this.inputSizeTensor),o.add=W.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=W.mul(o.add,this.inputSizeTensor);let n=W.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>W.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=W.reshape(t,[-1,7,2]),n.div=W.div(n.reshape,this.inputSizeTensor),n.landmarks=W.add(n.div,this.anchors[o]);let r=W.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(A=>W.dispose(n[A])),r}async predict(t,o){let n={};n.resize=W.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=W.div(n.resize,B.tf127),n.image=W.sub(n.div,B.tf1),n.batched=this.model.execute(n.image),n.predictions=W.squeeze(n.batched),n.slice=W.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=W.sigmoid(n.slice),n.scores=W.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=W.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await W.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let A=await n.nms.array(),s=[];for(let a of A){let i={};i.box=W.slice(n.norm,[a,0],[1,-1]),i.slice=W.slice(n.predictions,[a,5],[1,14]),i.norm=this.normalizeLandmarks(i.slice,a),i.palmLandmarks=W.reshape(i.norm,[-1,2]);let y=await i.box.data(),c=y.slice(0,2),l=y.slice(2,4),x=await i.palmLandmarks.array(),f={startPoint:c,endPoint:l,palmLandmarks:x,confidence:r[a]},u=X3(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);s.push(u),Object.keys(i).forEach(m=>W.dispose(i[m]))}return Object.keys(n).forEach(a=>W.dispose(n[a])),s}};var N0=D(H());var ur=5,J3=1.65,Q3=[0,5,9,13,17,1,2],hr=0,br=2,_3=0,s5=class{constructor(t,o){T(this,"handDetector");T(this,"handPoseModel");T(this,"inputSize");T(this,"storedBoxes");T(this,"skipped");T(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[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=>h1([...A,1],o)),r=this.calculateLandmarksBoundingBox(n);return n5(r5(r),ur)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=n5(r5(o),J3);n.palmLandmarks=[];for(let r=0;r[s[0]*(f[0]-this.inputSize/2),s[1]*(f[1]-this.inputSize/2),s[2]*f[2]]),i=u1(n,[0,0]),y=a.map(f=>[...h1(f,i),f[2]]),c=U3(r),l=[...T2(o),1],x=[Me(l,c[0]),Me(l,c[1])];return y.map(f=>[Math.trunc(f[0]+x[0]),Math.trunc(f[1]+x[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,A=(o.hand.skipTime||0)>h()-_3,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 i=0;i=o.hand.minConfidence/4){let S=N0.reshape(d,[-1,3]),w=await S.array();N0.dispose(d),N0.dispose(S);let j=this.transformRawCoords(w,m,c,u),C=this.getBoxForHandLandmarks(j);this.storedBoxes[i]={...C,confidence:P};let F={landmarks:j,confidence:P,boxConfidence:y.confidence,fingerConfidence:P,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};a.push(F)}else this.storedBoxes[i]=null;N0.dispose(d)}else{let c=n5(r5(y),J3),l={confidence:y.confidence,boxConfidence:y.confidence,fingerConfidence:0,box:{topLeft:c.startPoint,bottomRight:c.endPoint},landmarks:[]};a.push(l)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=a.length,a.length>o.hand.maxDetected&&(a.length=o.hand.maxDetected),a}};var T0={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=>T0.nameMapping[e],getPoints:e=>T0.pointsMapping[e]},ve={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>ve.nameMapping[e]},o0={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=>o0.nameMapping[e]},Re=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,i]of s)if(A===a){n+=i*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,i]of s)if(A===a){n+=i*this.weightsRelative[r];break}}return n/10}};var{thumb:U0,index:ye,middle:xe,ring:Fe,pinky:Ge}=T0,{none:Y0,half:Pr,full:K0}=ve,{verticalUp:e2,verticalDown:L7,horizontalLeft:b1,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:t2,diagonalDownRight:W7,diagonalDownLeft:F7}=o0,Te=new Re("thumbs up");Te.curl(U0,Y0,1);Te.direction(U0,e2,1);Te.direction(U0,t2,.25);Te.direction(U0,Rr,.25);for(let e of[T0.index,T0.middle,T0.ring,T0.pinky])Te.curl(e,K0,1),Te.direction(e,b1,1),Te.direction(e,Mr,1);var l0=new Re("victory");l0.curl(U0,Pr,.5);l0.curl(U0,Y0,.5);l0.direction(U0,e2,1);l0.direction(U0,t2,1);l0.curl(ye,Y0,1);l0.direction(ye,e2,.75);l0.direction(ye,t2,1);l0.curl(xe,Y0,1);l0.direction(xe,e2,1);l0.direction(xe,t2,.75);l0.curl(Fe,K0,1);l0.direction(Fe,e2,.2);l0.direction(Fe,t2,1);l0.direction(Fe,b1,.2);l0.curl(Ge,K0,1);l0.direction(Ge,e2,.2);l0.direction(Ge,t2,1);l0.direction(Ge,b1,.2);l0.weight(ye,2);l0.weight(xe,2);var we=new Re("point");we.curl(U0,K0,1);we.curl(ye,Y0,.5);we.curl(xe,K0,.5);we.curl(Fe,K0,.5);we.curl(Ge,K0,.5);we.weight(ye,2);we.weight(xe,2);var ke=new Re("middle finger");ke.curl(U0,Y0,1);ke.curl(ye,K0,.5);ke.curl(xe,K0,.5);ke.curl(Fe,K0,.5);ke.curl(Ge,K0,.5);ke.weight(ye,2);ke.weight(xe,2);var o2=new Re("open palm");o2.curl(U0,Y0,.75);o2.curl(ye,Y0,.75);o2.curl(xe,Y0,.75);o2.curl(Fe,Y0,.75);o2.curl(Ge,Y0,.75);var $3=[Te,l0,we,ke,o2];var vr=.7,Be={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 eo(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 oo(e,t){if(!e||!t)return[0,0];let o=eo(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=eo(e[1],e[2],t[1],t[2]);return[o,n]}function to(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 Tr(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],i=t[1]-o[1],y=e[2]-t[2],c=e[2]-o[2],l=t[2]-o[2],x=Math.sqrt(n*n+s*s+y*y),f=Math.sqrt(r*r+a*a+c*c),u=Math.sqrt(A*A+i*i+l*l),m=(u*u+x*x-f*f)/(2*u*x);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let g;return M>Be.NO_CURL_START_LIMIT?g=ve.none:M>Be.HALF_CURL_START_LIMIT?g=ve.half:g=ve.full,g}function no(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=o0.horizontalLeft:r=o0.horizontalRight:n===Math.abs(t)?t>0?r=o0.horizontalLeft:r=o0.horizontalRight:o>0?r=o0.horizontalLeft:r=o0.horizontalRight,r}function ro(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=o0.verticalDown:r=o0.verticalUp:n===Math.abs(t)?t<0?r=o0.verticalDown:r=o0.verticalUp:o<0?r=o0.verticalDown:r=o0.verticalUp,r}function wr(e,t,o,n,r,A,s,a){let i,y=ro(e,t,o,n),c=no(r,A,s,a);return y===o0.verticalUp?c===o0.horizontalLeft?i=o0.diagonalUpLeft:i=o0.diagonalUpRight:c===o0.horizontalLeft?i=o0.diagonalDownLeft:i=o0.diagonalDownRight,i}function kr(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],i=e[1]-o[1],y=t[1]-o[1],c=Math.max(Math.abs(r),Math.abs(A),Math.abs(s)),l=Math.max(Math.abs(a),Math.abs(i),Math.abs(y)),x=0,f=0,u=0,m=l/(c+1e-5);m>1.5?x+=Be.DISTANCE_VOTE_POWER:m>.66?f+=Be.DISTANCE_VOTE_POWER:u+=Be.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+a*a),g=Math.sqrt(A*A+i*i),b=Math.sqrt(s*s+y*y),d=Math.max(M,g,b),P=e[0],S=e[1],w=o[0],j=o[1];d===M?(w=o[0],j=o[1]):d===b&&(P=t[0],S=t[1]);let Q=oo([P,S],[w,j]),U=to(Q,Be.TOTAL_ANGLE_VOTE_POWER);x+=U[0],f+=U[1],u+=U[2];for(let V of n){let E=to(V,Be.SINGLE_ANGLE_VOTE_POWER);x+=E[0],f+=E[1],u+=E[2]}let K;return x===Math.max(x,f,u)?K=ro(i,a,y,l):u===Math.max(f,u)?K=no(A,r,s,c):K=wr(i,a,y,l,A,r,s,c),K}function Ao(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let A of T0.all){let s=T0.getPoints(A),a=[],i=[];for(let y of s){let c=e[y[0]],l=e[y[1]],x=oo(c,l),f=x[0],u=x[1];a.push(f),i.push(u)}t.push(a),o.push(i)}for(let A of T0.all){let s=A===T0.thumb?1:0,a=T0.getPoints(A),i=e[a[s][0]],y=e[a[s+1][1]],c=e[a[3][1]],l=Tr(i,y,c),x=kr(i,y,c,t[A].slice(s));n[A]=l,r[A]=x}return{curls:n,directions:r}}function a5(e){if(!e||e.length===0)return null;let t=Ao(e),o={};for(let n of T0.all)o[T0.getName(n)]={curl:ve.getName(t.curls[n]),direction:o0.getName(t.directions[n])};return o}function so(e){let t=[];if(!e||e.length===0)return t;let o=Ao(e);for(let n of $3){let r=n.matchAgainst(o.curls,o.directions);r>=vr&&t.push({name:n.name,confidence:r})}return t}var ao={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]},n2,r2,io;async function P1(e,t){let o=await io.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[l]);let s=o[r].landmarks,a=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],i=[0,0,0,0];if(s&&s.length>0){for(let c of s)c[0]a[2]&&(a[2]=c[0]),c[1]>a[3]&&(a[3]=c[1]);a[2]-=a[0],a[3]-=a[1],i=[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],i=[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 y=a5(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:i,keypoints:s,annotations:A,landmarks:y})}return n}async function M1(e){var o,n;v.initial&&(n2=null,r2=null),!n2||!r2?[n2,r2]=await Promise.all([e.hand.enabled?G((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?G((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&p("cached model:",n2.modelUrl),e.debug&&p("cached model:",r2.modelUrl));let t=new A5(n2);return io=new s5(t,r2),[n2,r2]}var J=D(H());var c0=[null,null],Er=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Ee=[[0,0],[0,0]],zr=["hand","fist","pinch","point","face","tip","pinchtip"],yo=4,xo=1.6,Sr=512,Cr=1.4,i5=Number.MAX_SAFE_INTEGER,R1=0,ce=[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 fo(e){var t;if(v.initial&&(c0[0]=null),c0[0])e.debug&&p("cached model:",c0[0].modelUrl);else{l5(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),c0[0]=await G((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(c0[0].modelSignature.inputs);Ee[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[0]}async function mo(e){var t;if(v.initial&&(c0[1]=null),c0[1])e.debug&&p("cached model:",c0[1].modelUrl);else{c0[1]=await G((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(c0[1].modelSignature.inputs);Ee[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Ee[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return c0[1]}async function jr(e,t){let o=[];if(!e||!c0[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,Sr),s=Math.round(A*r/8)*8;n.resize=J.image.resizeBilinear(e,[A,s]),n.cast=J.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await c0[0].executeAsync(n.cast,Er),n.boxes=J.squeeze(n.rawBoxes,[0,2]),n.scores=J.squeeze(n.rawScores,[0]);let a=J.unstack(n.scores,1);J.dispose(a[yo]),a.splice(yo,1),n.filtered=J.stack(a,1),J.dispose(a),n.max=J.max(n.filtered,1),n.argmax=J.argMax(n.filtered,1);let i=0;n.nms=await J.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let y=await n.nms.data(),c=await n.max.data(),l=await n.argmax.data();for(let x of Array.from(y)){let f=J.slice(n.boxes,x,1),u=await f.data();J.dispose(f);let m=[u[1],u[0],u[3]-u[1],u[2]-u[0]],M=K2(m,Cr),g=[Math.trunc(m[0]*ce[0]),Math.trunc(m[1]*ce[1]),Math.trunc(m[2]*ce[0]),Math.trunc(m[3]*ce[1])],b=c[x],d=zr[l[x]],P={id:i++,score:b,box:g,boxRaw:M,label:d};o.push(P)}return Object.keys(n).forEach(x=>J.dispose(n[x])),o.sort((x,f)=>f.score-x.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function v1(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&&c0[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=J.image.cropAndResize(e,[A],[0],[Ee[1][0],Ee[1][1]],"bilinear"),r.div=J.div(r.crop,B.tf255),[r.score,r.keypoints]=c0[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=J.reshape(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(l=>[l[0]/Ee[1][1],l[1]/Ee[1][0],l[2]||0]).map(l=>[l[0]*t.boxRaw[2],l[1]*t.boxRaw[3],l[2]||0]);n.keypoints=c.map(l=>[ce[0]*(l[0]+t.boxRaw[0]),ce[1]*(l[1]+t.boxRaw[1]),l[2]||0]),n.landmarks=a5(n.keypoints);for(let l of Object.keys(co))n.annotations[l]=co[l].map(x=>n.landmarks&&n.keypoints[x]?n.keypoints[x]:null)}Object.keys(r).forEach(i=>J.dispose(r[i]))}return n}async function T1(e,t){var r,A;if(!c0[0]||!c0[1]||!((r=c0[0])!=null&&r.inputs[0].shape)||!((A=c0[1])!=null&&A.inputs[0].shape))return[];ce=[e.shape[2]||0,e.shape[1]||0],i5++;let o=(t.hand.skipTime||0)>h()-R1,n=i5<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?A0.hands:new Promise(async s=>{let a=3*(t.hand.skipTime||0)>h()-R1,i=i5<3*(t.hand.skipFrames||0);t.skipAllowed&&A0.hands.length===t.hand.maxDetected?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):t.skipAllowed&&a&&i&&A0.hands.length>0?A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))):(A0.boxes=await jr(e,t),R1=h(),A0.hands=await Promise.all(A0.boxes.map(c=>v1(e,c,t))),i5=0);let y=[...A0.boxes];if(A0.boxes.length=0,t.cacheSensitivity>0)for(let c=0;c.05&&l.box[3]/(e.shape[1]||1)>.05&&A0.hands[c].fingerScore&&A0.hands[c].fingerScore>(t.hand.minConfidence||0)){let x=K2(l.box,xo),f=K2(l.boxRaw,xo);A0.boxes.push({...y[c],box:x,boxRaw:f})}}for(let c=0;ch()-ho,A=w1<(((a=t.face.liveness)==null?void 0:a.skipFrames)||0);return t.skipAllowed&&r&&A&&uo===n&&y5[o]?(w1++,y5[o]):(w1=0,new Promise(async i=>{let y=x5.image.resizeBilinear(e,[g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[2]:0,g0!=null&&g0.inputs[0].shape?g0.inputs[0].shape[1]:0],!1),c=g0==null?void 0:g0.execute(y),l=(await c.data())[0];y5[o]=Math.round(100*l)/100,uo=n,ho=h(),x5.dispose([y,c]),i(y5[o])}))}var To=D(H());var w2={};Se(w2,{connected:()=>d5,horizontal:()=>E1,kpt:()=>c5,relative:()=>S1,vertical:()=>z1});var c5=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],E1=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],z1=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],S1=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],d5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var ze=D(H()),Po=.005,O0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function C1(e){for(let t of E1){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]y&&y.part===t[0]),r=e.keypoints.findIndex(y=>y&&y.part===t[1]),A=e.keypoints.findIndex(y=>y&&y.part===o[0]),s=e.keypoints.findIndex(y=>y&&y.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],i=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]||i[0]>i[1]){let y=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=y}}}function Mo(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=ze.pad(e,O0.padding),o.resize=ze.image.resizeBilinear(o.pad,[t,t]);let n=ze.cast(o.resize,"int32");return Object.keys(o).forEach(r=>ze.dispose(o[r])),n}function vo(e,t){e.keypoints=e.keypoints.filter(n=>n&&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=ae(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var L0,f5=0,j1=Number.MAX_SAFE_INTEGER,He={boxes:[],bodies:[],last:0};async function wo(e){return v.initial&&(L0=null),L0?e.debug&&p("cached model:",L0.modelUrl):(l5(["size"],e),L0=await G(e.body.modelPath)),f5=L0.inputs[0].shape?L0.inputs[0].shape[2]:0,f5<64&&(f5=256),L0}async function Nr(e,t,o){let n=e[0][0],r=[],A=0;for(let c=0;ct.body.minConfidence){let l=[n[c][1],n[c][0]];r.push({score:Math.round(100*A)/100,part:c5[c],positionRaw:l,position:[Math.round((o.shape[2]||0)*l[0]),Math.round((o.shape[1]||0)*l[1])]})}A=r.reduce((c,l)=>l.score>c?l.score:c,0);let s=[],a=ae(r.map(c=>c.position),[o.shape[2],o.shape[1]]),i={};for(let[c,l]of Object.entries(d5)){let x=[];for(let f=0;fM.part===l[f]),m=r.find(M=>M.part===l[f+1]);u&&m&&u.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&x.push([u.position,m.position])}i[c]=x}let y={id:0,score:A,box:a.box,boxRaw:a.boxRaw,keypoints:r,annotations:i};return C1(y),s.push(y),s}async function Or(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let a=[];for(let l=0;l<17;l++){let x=A[3*l+2];if(x>t.body.minConfidence){let f=[A[3*l+1],A[3*l+0]];a.push({part:c5[l],score:Math.round(100*x)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let i=ae(a.map(l=>l.position),[o.shape[2],o.shape[1]]),y={};for(let[l,x]of Object.entries(d5)){let f=[];for(let u=0;ug.part===x[u]),M=a.find(g=>g.part===x[u+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}y[l]=f}let c={id:r,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:[...a],annotations:y};C1(c),n.push(c)}}return n.sort((r,A)=>A.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function I1(e,t){if(!L0||!(L0!=null&&L0.inputs[0].shape))return[];t.skipAllowed||(He.boxes.length=0),j1++;let o=(t.body.skipTime||0)>h()-He.last,n=j1<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?He.bodies:new Promise(async r=>{let A={};j1=0,A.input=Ro(e,f5),A.res=L0==null?void 0:L0.execute(A.input),He.last=h();let s=await A.res.array();He.bodies=A.res.shape[2]===17?await Nr(s,t,e):await Or(s,t,e);for(let a of He.bodies)vo(a,[e.shape[2]||1,e.shape[1]||1]),Mo(a.keypoints);Object.keys(A).forEach(a=>To.dispose(A[a])),r(He.bodies)})}var w0=D(H());var A2,m5=[],Eo=0,N1=Number.MAX_SAFE_INTEGER,u5=0,p5=2.5;async function zo(e){if(!A2||v.initial){A2=await G(e.object.modelPath);let t=Object.values(A2.modelSignature.inputs);u5=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&p("cached model:",A2.modelUrl);return A2}async function Lr(e,t,o){let n=0,r=[];for(let i of[1,2,4])w0.tidy(async()=>{let y=i*13,c=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)===Je.length)),l=w0.squeeze(e.find(m=>m.shape[1]===y**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let b=(.5+Math.trunc(m%y))/y,d=(.5+Math.trunc(m/y))/y,P=f[m].map(K=>K*(y/i/u5)),[S,w]=[b-p5/i*P[0],d-p5/i*P[1]],[j,C]=[b+p5/i*P[2]-S,d+p5/i*P[3]-w],F=[S,w,j,C];F=F.map(K=>Math.max(0,Math.min(K,1)));let Q=[F[0]*t[0],F[1]*t[1],F[2]*t[0],F[3]*t[1]],U={id:n++,score:Math.round(100*g)/100,class:M+1,label:Je[M].label,box:Q.map(K=>Math.trunc(K)),boxRaw:F};r.push(U)}}});e.forEach(i=>w0.dispose(i));let A=r.map(i=>[i.boxRaw[1],i.boxRaw[0],i.boxRaw[3],i.boxRaw[2]]),s=r.map(i=>i.score),a=[];if(A&&A.length>0){let i=await w0.image.nonMaxSuppressionAsync(A,s,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);a=await i.data(),w0.dispose(i)}return r=r.filter((i,y)=>a.includes(y)).sort((i,y)=>y.score-i.score),r}async function O1(e,t){let o=(t.object.skipTime||0)>h()-Eo,n=N1<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&m5.length>0?(N1++,m5):(N1=0,!v.kernels.includes("mod")||!v.kernels.includes("sparsetodense")?m5:new Promise(async r=>{let A=[e.shape[2]||0,e.shape[1]||0],s=w0.image.resizeBilinear(e,[u5,u5],!1),a=w0.div(s,B.tf255),i=a.transpose([0,3,1,2]);w0.dispose(a),w0.dispose(s);let y;t.object.enabled&&(y=A2.execute(i)),Eo=h(),w0.dispose(i);let c=await Lr(y,A,t);m5=c,r(c)}))}var k0=D(H());var E2=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Wr=E2.length,k2=E2.reduce((e,t,o)=>(e[t]=o,e),{}),Fr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],i4=Fr.map(([e,t])=>[k2[e],k2[t]]),Co=[["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 Io(e,[t,o],[n,r]){let A=t/n,s=o/r,a=(y,c)=>({id:c,score:y.score,boxRaw:[y.box[0]/r,y.box[1]/n,y.box[2]/r,y.box[3]/n],box:[Math.trunc(y.box[0]*s),Math.trunc(y.box[1]*A),Math.trunc(y.box[2]*s),Math.trunc(y.box[3]*A)],keypoints:y.keypoints.map(({score:l,part:x,position:f})=>({score:l,part:x,position:[Math.trunc(f.x*s),Math.trunc(f.y*A)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((y,c)=>a(y,c))}var h5=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 No(e,t,o,n){let r=o-e,A=n-t;return r*r+A*A}function G1(e,t){return{x:e.x+t.x,y:e.y+t.y}}var J0,Br=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],b5=1,s2=16,Hr=50**2;function Oo(e,t,o,n,r,A,s=2){let a=g=>({y:A.get(g.y,g.x,e),x:A.get(g.y,g.x,A.shape[2]/2+e)}),i=(g,b,d)=>({y:F1(Math.round(g.y/s2),0,b-1),x:F1(Math.round(g.x/s2),0,d-1)}),[y,c]=n.shape,l=i(t.position,y,c),x=a(l),u=G1(t.position,x);for(let g=0;g[k2[x],k2[f]]),s=A.map(([,x])=>x),a=A.map(([x])=>x),i=t.shape[2],y=s.length,c=new Array(i),l=W1(e.part,s2,o);c[e.part.id]={score:e.score,part:E2[e.part.id],position:l};for(let x=y-1;x>=0;--x){let f=s[x],u=a[x];c[f]&&!c[u]&&(c[u]=Oo(x,c[f],u,t,o,r))}for(let x=0;xt){a=!1;break}if(!a)break}return a}function Zr(e,t){let[o,n,r]=t.shape,A=new h5(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?No(o,t,A.y,A.x)<=Hr:!1})}function Xr(e,t){return t.reduce((n,{position:r,score:A},s)=>(Lo(e,r,s)||(n+=A),n),0)/t.length}function qr(e,t,o,n,r,A){let s=[],a=Zr(A,t);for(;s.lengthf.score>A);let l=Xr(s,c),x=jo(c);l>A&&s.push({keypoints:c,box:x,score:Math.round(100*l)/100})}return s}async function B1(e,t){let o=k0.tidy(()=>{if(!J0.inputs[0].shape)return[];let s=k0.image.resizeBilinear(e,[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]),a=k0.sub(k0.div(k0.cast(s,"float32"),127.5),1),y=J0.execute(a,Br).map(c=>k0.squeeze(c,[0]));return y[1]=k0.sigmoid(y[1]),y}),n=await Promise.all(o.map(s=>s.buffer()));for(let s of o)k0.dispose(s);let r=await qr(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return J0.inputs[0].shape?Io(r,[e.shape[1],e.shape[2]],[J0.inputs[0].shape[2],J0.inputs[0].shape[1]]):[]}async function Wo(e){return!J0||v.initial?J0=await G(e.body.modelPath):e.debug&&p("cached model:",J0.modelUrl),J0}var n0=D(H());var ee,H1=!1;async function V1(e){return!ee||v.initial?ee=await G(e.segmentation.modelPath):e.debug&&p("cached model:",ee.modelUrl),ee}async function Go(e,t,o){var m,M;if(H1)return{data:[],canvas:null,alpha:null};H1=!0,ee||await V1(o);let n=await Xe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,A=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let s={};s.resize=n0.image.resizeBilinear(n.tensor,[ee.inputs[0].shape?ee.inputs[0].shape[1]:0,ee.inputs[0].shape?ee.inputs[0].shape[2]:0],!1),n0.dispose(n.tensor),s.norm=n0.div(s.resize,B.tf255),s.res=ee.execute(s.norm),s.squeeze=n0.squeeze(s.res,0),s.squeeze.shape[2]===2?(s.softmax=n0.softmax(s.squeeze),[s.bg,s.fg]=n0.unstack(s.softmax,2),s.expand=n0.expandDims(s.fg,2),s.pad=n0.expandDims(s.expand,0),s.crop=n0.image.cropAndResize(s.pad,[[0,0,.5,.5]],[0],[r,A]),s.data=n0.squeeze(s.crop,0)):s.data=n0.image.resizeBilinear(s.squeeze,[A,r]);let a=Array.from(await s.data.data());if(v.node&&!v.Canvas&&typeof ImageData=="undefined")return o.debug&&p("canvas support missing"),Object.keys(s).forEach(g=>n0.dispose(s[g])),{data:a,canvas:null,alpha:null};let i=M0(r,A);n0.browser&&await n0.browser.toPixels(s.data,i);let y=i.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(y.filter=`blur(${o.segmentation.blur}px)`);let c=y.getImageData(0,0,r,A),l=M0(r,A),x=l.getContext("2d");n.canvas&&x.drawImage(n.canvas,0,0),x.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`),x.drawImage(i,0,0),x.globalCompositeOperation="source-over",x.filter="none";let f=x.getImageData(0,0,r,A);for(let g=0;gn0.dispose(s[g])),H1=!1,{data:a,canvas:l,alpha:i}}var z2=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,"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)}};function g5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function D1(e){var t,o,n,r,A,s,a,i,y,c,l,x,f,u,m,M,g,b,d,P,S,w,j,C,F,Q,U,K,V,E,W0;v.initial&&g5(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 M1(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 M1(e.config))),e.config.body.enabled&&!e.models.blazepose&&((s=(A=e.config.body)==null?void 0:A.modelPath)==null?void 0:s.includes("blazepose"))&&(e.models.blazepose=i3(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=a3(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((i=(a=e.config.body)==null?void 0:a.modelPath)==null?void 0:i.includes("efficientpose"))&&(e.models.efficientpose=f3(e.config)),e.config.body.enabled&&!e.models.movenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("movenet"))&&(e.models.movenet=wo(e.config)),e.config.body.enabled&&!e.models.posenet&&((x=(l=e.config.body)==null?void 0:l.modelPath)==null?void 0:x.includes("posenet"))&&(e.models.posenet=Wo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=_t(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Gt(e.config)),e.config.face.enabled&&((u=e.config.face.liveness)==null?void 0:u.enabled)&&!e.models.liveness&&(e.models.liveness=bo(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=B3(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=h3(e.config)),e.config.face.enabled&&((g=e.config.face.iris)==null?void 0:g.enabled)&&!((b=e.config.face.attention)!=null&&b.enabled)&&!e.models.faceiris&&(e.models.faceiris=z3(e.config)),e.config.face.enabled&&((d=e.config.face.mesh)==null?void 0:d.enabled)&&!e.models.facemesh&&(e.models.facemesh=O3(e.config)),e.config.face.enabled&&((P=e.config.face.gear)==null?void 0:P.enabled)&&!e.models.gear&&(e.models.gear=wt(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Ct(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Ot(e.config)),e.config.face.enabled&&((j=e.config.face.mobilefacenet)==null?void 0:j.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=v3(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((F=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handtrack=fo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((U=(Q=e.config.hand.detector)==null?void 0:Q.modelPath)==null?void 0:U.includes("handtrack"))&&(e.models.handskeleton=mo(e.config)),e.config.object.enabled&&!e.models.centernet&&((V=(K=e.config.object)==null?void 0:K.modelPath)==null?void 0:V.includes("centernet"))&&(e.models.centernet=x3(e.config)),e.config.object.enabled&&!e.models.nanodet&&((W0=(E=e.config.object)==null?void 0:E.modelPath)==null?void 0:W0.includes("nanodet"))&&(e.models.nanodet=zo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=V1(e.config));for await(let F0 of Object.keys(e.models))e.models[F0]&&typeof e.models[F0]!="undefined"&&(e.models[F0]=await e.models[F0])}async function Z1(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],A=n==null?void 0:n.executor;if(A&&A.graph.nodes)for(let a of Object.values(A.graph.nodes)){let i=a.op.toLowerCase();r.includes(i)||r.push(i)}else!A&&e.config.debug&&p("model signature not determined:",o);let s=[];for(let a of r)!t.includes(a)&&!e.env.kernels.includes(a)&&!e.env.kernels.includes(a.replace("_",""))&&!e.env.kernels.includes(a.replace("native",""))&&!e.env.kernels.includes(a.replace("v2",""))&&s.push(a);e.config.debug&&s.length>0&&p("model validation failed:",o,s)}}var t0={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 Ur(){let e=t0.gl;!e||(t0.extensions=e.getSupportedExtensions())}async function Ho(e){var t;if(e.config.backend==="humangl"&&(t0.name in y0.engine().registry&&(!t0.gl||!t0.gl.getParameter(t0.gl.VERSION))&&(p("error: humangl backend invalid context"),g5(e)),!y0.findBackend(t0.name))){try{t0.canvas=await M0(100,100)}catch(n){p("error: cannot create canvas:",n);return}try{if(t0.gl=(t=t0.canvas)==null?void 0:t.getContext("webgl2",t0.webGLattr),!t0.gl.getParameter(t0.gl.VERSION).includes("2.0")){p("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}t0.canvas&&(t0.canvas.addEventListener("webglcontextlost",async r=>{throw p("error: humangl:",r.type),p("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),t0.canvas.addEventListener("webglcontextrestored",r=>{p("error: humangl context restored:",r)}),t0.canvas.addEventListener("webglcontextcreationerror",r=>{p("error: humangl context create:",r)}))}catch(n){p("error: cannot get WebGL context:",n);return}try{y0.setWebGLContext(2,t0.gl)}catch(n){p("error: cannot set WebGL context:",n);return}try{let n=new y0.GPGPUContext(t0.gl);y0.registerBackend(t0.name,()=>new y0.MathBackendWebGL(n),t0.priority)}catch(n){p("error: cannot register WebGL backend:",n);return}try{y0.getKernelsForBackend("webgl").forEach(r=>{let A={...r,backendName:t0.name};y0.registerKernel(A)})}catch(n){p("error: cannot update WebGL backend registration:",n);return}let o=y0.backend().getGPGPUContext?y0.backend().getGPGPUContext().gl:null;if(o)p(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{p("error: no current gl context:",o,t0.gl);return}try{y0.ENV.set("WEBGL_VERSION",2)}catch(n){p("error: cannot set WebGL backend flags:",n);return}Ur(),p("backend registered:",t0.name)}}var I=D(H());function Yr(){if(!v.kernels.includes("mod")){let e={kernelName:"Mod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.sub(t.inputs.a,I.mul(I.div(t.inputs.a,t.inputs.b),t.inputs.b)))};I.registerKernel(e),v.kernels.push("mod")}if(!v.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:I.getBackend(),kernelFunc:t=>I.tidy(()=>I.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+I.mod(t.inputs.a,t.inputs.b))};I.registerKernel(e),v.kernels.push("floormod")}}async function M5(e,t=!1){if(e.state="backend",t||v.initial||e.config.backend&&e.config.backend.length>0&&I.getBackend()!==e.config.backend){let o=h();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&p("running inside web worker"),v.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&p("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),v.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&p(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),v.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")p("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();if(e.config.debug&&p("enumerated webgpu adapter:",r),!r)p("override: backend set to webgpu but browser reports no available gpu"),e.config.backend="humangl";else{let A="requestAdapterInfo"in r?await r.requestAdapterInfo():void 0;p("webgpu adapter info:",A)}}e.config.backend==="humangl"&&await Ho(e);let n=Object.keys(I.engine().registryFactory);if(e.config.debug&&p("available backends:",n),n.includes(e.config.backend)||(p(`error: backend ${e.config.backend} not found in registry`),e.config.backend=v.node?"tensorflow":"webgl",e.config.debug&&p(`override: setting backend ${e.config.backend}`)),e.config.debug&&p("setting backend:",e.config.backend),e.config.backend==="wasm"){try{I.env().set("CANVAS2D_WILL_READ_FREQUENTLY",!0)}catch(s){}if(e.config.debug&&p("wasm path:",e.config.wasmPath),typeof(I==null?void 0:I.setWasmPaths)!="undefined")await I.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=await I.env().getAsync("WASM_HAS_SIMD_SUPPORT"),A=await I.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&p(`wasm execution: ${r?"SIMD":"no SIMD"} ${A?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&p("warning: wasm simd support is not enabled")}try{await I.setBackend(e.config.backend),await I.ready(),Et()}catch(r){return p("error: cannot set backend:",e.config.backend,r),!1}}if(I.getBackend()==="humangl"&&(I.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),I.ENV.set("WEBGL_CPU_FORWARD",!0),I.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),I.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(p("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),I.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),I.backend().getGPGPUContext)){let n=await I.backend().getGPGPUContext().gl;e.config.debug&&p(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}I.getBackend(),I.enableProdMode(),await I.ready(),e.performance.initBackend=Math.trunc(h()-o),e.config.backend=I.getBackend(),await v.updateBackend(),Yr()}return!0}function l5(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&p("kernelFunc",o,t.backend)}};I.registerKernel(n)}v.kernels=I.getKernelsForBackend(I.getBackend()).map(o=>o.kernelName.toLowerCase())}var Q1={};Se(Q1,{all:()=>J1,body:()=>i2,canvas:()=>K1,face:()=>a2,gesture:()=>x2,hand:()=>l2,object:()=>y2,options:()=>P0,person:()=>Y1});var B0=e=>{if(!e)p("draw error: invalid canvas");else if(!e.getContext)p("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)p("draw error: cannot get canvas context");else return t}return null},Ve=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 te(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 X1(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],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function Do(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){X1(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${Ve(e.rotation.angle.roll)}\xB0 yaw:${Ve(e.rotation.angle.yaw)}\xB0 pitch:${Ve(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${Ve(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=q.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),A=n*q.lineHeight+e.box[1];q.shadowColor&&q.shadowColor!==""&&(t.fillStyle=q.shadowColor,t.fillText(o[n],r+5,A+16)),t.fillStyle=q.labelColor,t.fillText(o[n],r+4,A+15)}}}function Qr(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=q.useDepth?"rgba(255, 200, 255, 0.3)":q.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=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,n,0,0,2*Math.PI),t.stroke(),q.fillPolygons&&(t.fillStyle=q.useDepth?"rgba(255, 255, 200, 0.3)":q.color,t.fill())}}function _r(e,t){var o;if(q.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]*Ve(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*Ve(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 57834a58..0bd239f4 100644 --- a/test/build.log +++ b/test/build.log @@ -1,24 +1,24 @@ -2022-06-02 10:37:20 INFO:  Application: {"name":"@vladmandic/human","version":"2.8.0"} -2022-06-02 10:37:20 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} -2022-06-02 10:37:20 INFO:  Toolchain: {"build":"0.7.3","esbuild":"0.14.42","typescript":"4.7.2","typedoc":"0.22.17","eslint":"8.16.0"} -2022-06-02 10:37:20 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} -2022-06-02 10:37:20 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":595} -2022-06-02 10:37:20 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":73,"inputBytes":642827,"outputBytes":300685} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":599} -2022-06-02 10:37:20 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":73,"inputBytes":642831,"outputBytes":300689} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":651} -2022-06-02 10:37:20 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":73,"inputBytes":642883,"outputBytes":300739} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1069,"outputBytes":358} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1032,"outputBytes":583} -2022-06-02 10:37:20 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":73,"inputBytes":642815,"outputBytes":299595} -2022-06-02 10:37:20 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1353524} -2022-06-02 10:37:21 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":73,"inputBytes":1995756,"outputBytes":1652193} -2022-06-02 10:37:21 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":73,"inputBytes":1995756,"outputBytes":2139052} -2022-06-02 10:37:25 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":116} -2022-06-02 10:37:27 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":73,"generated":true} -2022-06-02 10:37:27 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6054,"outputBytes":2989} -2022-06-02 10:37:27 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15174,"outputBytes":7820} -2022-06-02 10:37:35 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":106,"errors":0,"warnings":0} -2022-06-02 10:37:35 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} -2022-06-02 10:37:35 INFO:  Done... +2022-06-08 08:51:09 INFO:  Application: {"name":"@vladmandic/human","version":"2.8.1"} +2022-06-08 08:51:09 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} +2022-06-08 08:51:09 INFO:  Toolchain: {"build":"0.7.3","esbuild":"0.14.43","typescript":"4.7.3","typedoc":"0.22.17","eslint":"8.17.0"} +2022-06-08 08:51:09 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} +2022-06-08 08:51:09 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":595} +2022-06-08 08:51:09 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":73,"inputBytes":642827,"outputBytes":300685} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":599} +2022-06-08 08:51:09 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":73,"inputBytes":642831,"outputBytes":300689} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":651} +2022-06-08 08:51:09 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":73,"inputBytes":642883,"outputBytes":300739} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1069,"outputBytes":358} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1032,"outputBytes":583} +2022-06-08 08:51:09 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":73,"inputBytes":642815,"outputBytes":299595} +2022-06-08 08:51:09 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1353524} +2022-06-08 08:51:09 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":73,"inputBytes":1995756,"outputBytes":1652193} +2022-06-08 08:51:10 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":73,"inputBytes":1995756,"outputBytes":2139052} +2022-06-08 08:51:15 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":116} +2022-06-08 08:51:17 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":73,"generated":true} +2022-06-08 08:51:17 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6054,"outputBytes":2989} +2022-06-08 08:51:17 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15174,"outputBytes":7820} +2022-06-08 08:51:26 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":106,"errors":0,"warnings":0} +2022-06-08 08:51:26 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} +2022-06-08 08:51:26 INFO:  Done... diff --git a/test/test-node-wasm.js b/test/test-node-wasm.js index 4c961bef..9d787436 100644 --- a/test/test-node-wasm.js +++ b/test/test-node-wasm.js @@ -13,8 +13,8 @@ const config = { cacheSensitivity: 0, modelBasePath: 'https://vladmandic.github.io/human/models/', backend: 'wasm', - // wasmPath: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/', - wasmPath: `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`, + wasmPath: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/', + // wasmPath: `cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`, debug: false, async: false, face: { diff --git a/test/test.log b/test/test.log index 7713516c..578739ef 100644 --- a/test/test.log +++ b/test/test.log @@ -1,684 +1,684 @@ -2022-06-02 10:37:47 INFO:  @vladmandic/human version 2.8.0 -2022-06-02 10:37:47 INFO:  User: vlado Platform: linux Arch: x64 Node: v18.1.0 -2022-06-02 10:37:47 INFO:  tests: ["test-node.js","test-node-gpu.js","test-node-wasm.js"] -2022-06-02 10:37:47 INFO:  demos: ["../demo/nodejs/node.js","../demo/nodejs/node-canvas.js","../demo/nodejs/node-env.js","../demo/nodejs/node-event.js","../demo/nodejs/node-multiprocess.js"] -2022-06-02 10:37:47 INFO:  -2022-06-02 10:37:47 INFO:  test-node.js start -2022-06-02 10:37:47 INFO:  test-node.js test: configuration validation -2022-06-02 10:37:47 STATE: test-node.js passed: configuration default validation [] -2022-06-02 10:37:47 STATE: test-node.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-06-02 10:37:47 INFO:  test-node.js test: model load -2022-06-02 10:37:47 STATE: test-node.js passed: models loaded 22 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":"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-06-02 10:37:47 INFO:  test-node.js test: warmup -2022-06-02 10:37:47 STATE: test-node.js passed: create human -2022-06-02 10:37:47 INFO:  test-node.js human version: 2.8.0 -2022-06-02 10:37:47 INFO:  test-node.js platform: linux x64 agent: NodeJS v18.1.0 -2022-06-02 10:37:47 INFO:  test-node.js tfjs version: 3.18.0 -2022-06-02 10:37:47 INFO:  test-node.js tensorflow binding version: 2.7.0-dev20211101 -2022-06-02 10:37:47 STATE: test-node.js passed: set backend: tensorflow -2022-06-02 10:37:47 STATE: test-node.js tensors 1921 -2022-06-02 10:37:47 STATE: test-node.js passed: load models -2022-06-02 10:37:47 STATE: test-node.js result: defined models: 22 loaded models: 12 -2022-06-02 10:37:47 STATE: test-node.js passed: warmup: none default -2022-06-02 10:37:47 DATA:  test-node.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-06-02 10:37:47 DATA:  test-node.js result: performance: load: null total: null -2022-06-02 10:37:47 STATE: test-node.js passed: warmup none result match -2022-06-02 10:37:47 STATE: test-node.js event: image -2022-06-02 10:37:48 STATE: test-node.js event: detect -2022-06-02 10:37:48 STATE: test-node.js event: warmup -2022-06-02 10:37:48 STATE: test-node.js passed: warmup: face default -2022-06-02 10:37:48 DATA:  test-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-06-02 10:37:48 DATA:  test-node.js result: performance: load: null total: 354 -2022-06-02 10:37:48 STATE: test-node.js passed: warmup face result match -2022-06-02 10:37:48 STATE: test-node.js event: image -2022-06-02 10:37:48 STATE: test-node.js event: detect -2022-06-02 10:37:48 STATE: test-node.js event: warmup -2022-06-02 10:37:48 STATE: test-node.js passed: warmup: body default -2022-06-02 10:37:48 DATA:  test-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-06-02 10:37:48 DATA:  test-node.js result: performance: load: null total: 260 -2022-06-02 10:37:48 STATE: test-node.js passed: warmup body result match -2022-06-02 10:37:48 STATE: test-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-06-02 10:37:48 INFO:  test-node.js test: details verification -2022-06-02 10:37:48 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:48 STATE: test-node.js event: image -2022-06-02 10:37:48 STATE: test-node.js event: detect -2022-06-02 10:37:48 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:48 DATA:  test-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-06-02 10:37:48 DATA:  test-node.js result: performance: load: null total: 239 -2022-06-02 10:37:48 STATE: test-node.js passed: details face length 1 -2022-06-02 10:37:48 STATE: test-node.js passed: details face score 1 0.93 1 -2022-06-02 10:37:48 STATE: test-node.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-06-02 10:37:48 STATE: test-node.js passed: details face arrays 4 478 1024 -2022-06-02 10:37:48 STATE: test-node.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-06-02 10:37:48 STATE: test-node.js passed: details face anti-spoofing 0.79 -2022-06-02 10:37:48 STATE: test-node.js passed: details face liveness 0.83 -2022-06-02 10:37:48 STATE: test-node.js passed: details body length 1 -2022-06-02 10:37:48 STATE: test-node.js passed: details body 0.92 17 6 -2022-06-02 10:37:48 STATE: test-node.js passed: details hand length 1 -2022-06-02 10:37:48 STATE: test-node.js passed: details hand 0.51 0.73 point -2022-06-02 10:37:48 STATE: test-node.js passed: details hand arrays 21 5 7 -2022-06-02 10:37:48 STATE: test-node.js passed: details gesture length 7 -2022-06-02 10:37:48 STATE: test-node.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-06-02 10:37:48 STATE: test-node.js passed: details object length 1 -2022-06-02 10:37:48 STATE: test-node.js passed: details object 0.72 person -2022-06-02 10:37:48 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} -2022-06-02 10:37:48 STATE: test-node.js event: image -2022-06-02 10:37:49 STATE: test-node.js event: detect -2022-06-02 10:37:49 STATE: test-node.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-06-02 10:37:49 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} -2022-06-02 10:37:49 STATE: test-node.js event: image -2022-06-02 10:37:49 STATE: test-node.js event: detect -2022-06-02 10:37:49 STATE: test-node.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-06-02 10:37:49 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:49 STATE: test-node.js event: image -2022-06-02 10:37:50 STATE: test-node.js event: detect -2022-06-02 10:37:50 STATE: test-node.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-06-02 10:37:50 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:50 STATE: test-node.js event: image -2022-06-02 10:37:50 STATE: test-node.js event: detect -2022-06-02 10:37:50 STATE: test-node.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-06-02 10:37:50 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-06-02 10:37:50 STATE: test-node.js event: image -2022-06-02 10:37:50 STATE: test-node.js event: detect -2022-06-02 10:37:50 STATE: test-node.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-06-02 10:37:50 INFO:  test-node.js test default -2022-06-02 10:37:51 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:51 STATE: test-node.js event: image -2022-06-02 10:37:51 STATE: test-node.js event: detect -2022-06-02 10:37:51 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:51 DATA:  test-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-06-02 10:37:51 DATA:  test-node.js result: performance: load: null total: 217 -2022-06-02 10:37:51 STATE: test-node.js passed: default result face match 1 female 0.97 -2022-06-02 10:37:51 INFO:  test-node.js test sync -2022-06-02 10:37:51 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:51 STATE: test-node.js event: image -2022-06-02 10:37:51 STATE: test-node.js event: detect -2022-06-02 10:37:51 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:51 DATA:  test-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-06-02 10:37:51 DATA:  test-node.js result: performance: load: null total: 236 -2022-06-02 10:37:51 STATE: test-node.js passed: default sync 1 female 0.97 -2022-06-02 10:37:51 INFO:  test-node.js test: image process -2022-06-02 10:37:51 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:51 STATE: test-node.js passed: image input null [1,256,256,3] -2022-06-02 10:37:51 INFO:  test-node.js test: image null -2022-06-02 10:37:51 STATE: test-node.js passed: invalid input could not convert input to tensor -2022-06-02 10:37:51 INFO:  test-node.js test face similarity -2022-06-02 10:37:51 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:51 STATE: test-node.js event: image -2022-06-02 10:37:51 STATE: test-node.js event: detect -2022-06-02 10:37:51 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:37:51 DATA:  test-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-06-02 10:37:51 DATA:  test-node.js result: performance: load: null total: 213 -2022-06-02 10:37:52 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:52 STATE: test-node.js event: image -2022-06-02 10:37:52 STATE: test-node.js event: detect -2022-06-02 10:37:52 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:52 DATA:  test-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-06-02 10:37:52 DATA:  test-node.js result: performance: load: null total: 215 -2022-06-02 10:37:52 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:52 STATE: test-node.js event: image -2022-06-02 10:37:52 STATE: test-node.js event: detect -2022-06-02 10:37:52 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:52 DATA:  test-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-06-02 10:37:52 DATA:  test-node.js result: performance: load: null total: 195 -2022-06-02 10:37:52 STATE: test-node.js passed: face descriptor -2022-06-02 10:37:52 STATE: test-node.js passed: face similarity {"similarity":[1,0.44727452329649126,0.5567935850640406],"descriptors":[1024,1024,1024]} -2022-06-02 10:37:52 INFO:  test-node.js test face matching -2022-06-02 10:37:52 STATE: test-node.js passed: face database 40 -2022-06-02 10:37:52 STATE: test-node.js passed: face match {"first":{"index":4,"similarity":0.7827852615252829}} {"second":{"index":4,"similarity":0.5002052633015844}} {"third":{"index":4,"similarity":0.5401587887998899}} -2022-06-02 10:37:52 INFO:  test-node.js test object -2022-06-02 10:37:52 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:52 STATE: test-node.js event: image -2022-06-02 10:37:52 STATE: test-node.js event: detect -2022-06-02 10:37:52 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:52 DATA:  test-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-06-02 10:37:52 DATA:  test-node.js result: performance: load: null total: 215 -2022-06-02 10:37:52 STATE: test-node.js passed: object result match -2022-06-02 10:37:52 INFO:  test-node.js test sensitive -2022-06-02 10:37:53 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:53 STATE: test-node.js event: image -2022-06-02 10:37:53 STATE: test-node.js event: detect -2022-06-02 10:37:53 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:53 DATA:  test-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:37:53 DATA:  test-node.js result: performance: load: null total: 233 -2022-06-02 10:37:53 STATE: test-node.js passed: sensitive result match -2022-06-02 10:37:53 STATE: test-node.js passed: sensitive face result match -2022-06-02 10:37:53 STATE: test-node.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] -2022-06-02 10:37:53 STATE: test-node.js passed: sensitive body result match -2022-06-02 10:37:53 STATE: test-node.js passed: sensitive hand result match -2022-06-02 10:37:53 INFO:  test-node.js test detectors -2022-06-02 10:37:53 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:53 STATE: test-node.js event: image -2022-06-02 10:37:53 STATE: test-node.js event: detect -2022-06-02 10:37:53 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:53 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:37:53 DATA:  test-node.js result: performance: load: null total: 167 -2022-06-02 10:37:53 STATE: test-node.js passed: detector result face match -2022-06-02 10:37:53 STATE: test-node.js passed: detector result hand match -2022-06-02 10:37:53 INFO:  test-node.js test: multi-instance -2022-06-02 10:37:53 STATE: test-node.js event: image -2022-06-02 10:37:53 STATE: test-node.js event: detect -2022-06-02 10:37:53 STATE: test-node.js passed: detect: random default -2022-06-02 10:37:53 DATA:  test-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.07,"keypoints":15} -2022-06-02 10:37:53 DATA:  test-node.js result: performance: load: null total: 149 -2022-06-02 10:37:53 INFO:  test-node.js test: first instance -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:54 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:54 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:37:54 DATA:  test-node.js result: performance: load: null total: 148 -2022-06-02 10:37:54 INFO:  test-node.js test: second instance -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:54 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:54 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:37:54 DATA:  test-node.js result: performance: load: null total: 145 -2022-06-02 10:37:54 INFO:  test-node.js test: concurrent -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:54 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:55 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:55 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} -2022-06-02 10:37:55 STATE: test-node.js event: image -2022-06-02 10:37:55 STATE: test-node.js event: image -2022-06-02 10:37:55 STATE: test-node.js event: image -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1417 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1417 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1538 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1538 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1538 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1538 -2022-06-02 10:37:56 STATE: test-node.js event: detect -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1283 -2022-06-02 10:37:56 STATE: test-node.js event: detect -2022-06-02 10:37:56 STATE: test-node.js event: detect -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1283 -2022-06-02 10:37:56 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:37:56 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:37:56 DATA:  test-node.js result: performance: load: null total: 1283 -2022-06-02 10:37:56 INFO:  test-node.js test: monkey-patch -2022-06-02 10:37:56 STATE: test-node.js event: image -2022-06-02 10:37:56 STATE: test-node.js event: detect -2022-06-02 10:37:56 STATE: test-node.js passed: monkey patch -2022-06-02 10:37:56 STATE: test-node.js passed: segmentation [65536] -2022-06-02 10:37:56 STATE: test-node.js passeed: equal usage -2022-06-02 10:37:56 INFO:  test-node.js test: input compare -2022-06-02 10:37:56 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:37:56 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} -2022-06-02 10:37:56 STATE: test-node.js passed: image compare 0 23.275441687091504 -2022-06-02 10:37:56 INFO:  test-node.js events: {"image":21,"detect":21,"warmup":2} -2022-06-02 10:37:56 INFO:  test-node.js tensors 1927 -2022-06-02 10:37:56 INFO:  test-node.js test complete: 9338 ms -2022-06-02 10:37:56 INFO:  -2022-06-02 10:37:56 INFO:  test-node-gpu.js start -2022-06-02 10:37:57 INFO:  test-node-gpu.js test: configuration validation -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: configuration default validation [] -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-06-02 10:37:57 INFO:  test-node-gpu.js test: model load -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: models loaded 22 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":"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-06-02 10:37:57 INFO:  test-node-gpu.js test: warmup -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: create human -2022-06-02 10:37:57 INFO:  test-node-gpu.js human version: 2.8.0 -2022-06-02 10:37:57 INFO:  test-node-gpu.js platform: linux x64 agent: NodeJS v18.1.0 -2022-06-02 10:37:57 INFO:  test-node-gpu.js tfjs version: 3.18.0 -2022-06-02 10:37:57 INFO:  test-node-gpu.js tensorflow binding version: 2.7.0-dev20211101 -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: set backend: tensorflow -2022-06-02 10:37:57 STATE: test-node-gpu.js tensors 1921 -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: load models -2022-06-02 10:37:57 STATE: test-node-gpu.js result: defined models: 22 loaded models: 12 -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: warmup: none default -2022-06-02 10:37:57 DATA:  test-node-gpu.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-06-02 10:37:57 DATA:  test-node-gpu.js result: performance: load: null total: null -2022-06-02 10:37:57 STATE: test-node-gpu.js passed: warmup none result match -2022-06-02 10:37:58 STATE: test-node-gpu.js event: image -2022-06-02 10:38:00 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:00 STATE: test-node-gpu.js event: warmup -2022-06-02 10:38:00 STATE: test-node-gpu.js passed: warmup: face default -2022-06-02 10:38:00 DATA:  test-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-06-02 10:38:00 DATA:  test-node-gpu.js result: performance: load: null total: 2264 -2022-06-02 10:38:00 STATE: test-node-gpu.js passed: warmup face result match -2022-06-02 10:38:00 STATE: test-node-gpu.js event: image -2022-06-02 10:38:00 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:00 STATE: test-node-gpu.js event: warmup -2022-06-02 10:38:00 STATE: test-node-gpu.js passed: warmup: body default -2022-06-02 10:38:00 DATA:  test-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-06-02 10:38:00 DATA:  test-node-gpu.js result: performance: load: null total: 201 -2022-06-02 10:38:00 STATE: test-node-gpu.js passed: warmup body result match -2022-06-02 10:38:00 STATE: test-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-06-02 10:38:00 INFO:  test-node-gpu.js test: details verification -2022-06-02 10:38:00 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:00 STATE: test-node-gpu.js event: image -2022-06-02 10:38:01 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:01 DATA:  test-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-06-02 10:38:01 DATA:  test-node-gpu.js result: performance: load: null total: 258 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face length 1 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face score 1 0.93 1 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face arrays 4 478 1024 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face anti-spoofing 0.79 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details face liveness 0.83 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details body length 1 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details body 0.92 17 6 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details hand length 1 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details hand 0.51 0.73 point -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details hand arrays 21 5 7 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details gesture length 7 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details object length 1 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: details object 0.72 person -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} -2022-06-02 10:38:01 STATE: test-node-gpu.js event: image -2022-06-02 10:38:01 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-06-02 10:38:01 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} -2022-06-02 10:38:01 STATE: test-node-gpu.js event: image -2022-06-02 10:38:02 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:02 STATE: test-node-gpu.js event: image -2022-06-02 10:38:02 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:02 STATE: test-node-gpu.js event: image -2022-06-02 10:38:02 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-06-02 10:38:02 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-06-02 10:38:02 STATE: test-node-gpu.js event: image -2022-06-02 10:38:03 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-06-02 10:38:03 INFO:  test-node-gpu.js test default -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:03 STATE: test-node-gpu.js event: image -2022-06-02 10:38:03 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:03 DATA:  test-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-06-02 10:38:03 DATA:  test-node-gpu.js result: performance: load: null total: 192 -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: default result face match 1 female 0.97 -2022-06-02 10:38:03 INFO:  test-node-gpu.js test sync -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:03 STATE: test-node-gpu.js event: image -2022-06-02 10:38:03 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:03 DATA:  test-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-06-02 10:38:03 DATA:  test-node-gpu.js result: performance: load: null total: 191 -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: default sync 1 female 0.97 -2022-06-02 10:38:03 INFO:  test-node-gpu.js test: image process -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: image input null [1,256,256,3] -2022-06-02 10:38:03 INFO:  test-node-gpu.js test: image null -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: invalid input could not convert input to tensor -2022-06-02 10:38:03 INFO:  test-node-gpu.js test face similarity -2022-06-02 10:38:03 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:03 STATE: test-node-gpu.js event: image -2022-06-02 10:38:04 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:04 DATA:  test-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-06-02 10:38:04 DATA:  test-node-gpu.js result: performance: load: null total: 184 -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:04 STATE: test-node-gpu.js event: image -2022-06-02 10:38:04 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:04 DATA:  test-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-06-02 10:38:04 DATA:  test-node-gpu.js result: performance: load: null total: 191 -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:04 STATE: test-node-gpu.js event: image -2022-06-02 10:38:04 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:04 DATA:  test-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-06-02 10:38:04 DATA:  test-node-gpu.js result: performance: load: null total: 208 -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: face descriptor -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: face similarity {"similarity":[1,0.447238756461232,0.556914029877052],"descriptors":[1024,1024,1024]} -2022-06-02 10:38:04 INFO:  test-node-gpu.js test face matching -2022-06-02 10:38:04 STATE: test-node-gpu.js passed: face database 40 -2022-06-02 10:38:04 STATE: test-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-06-02 10:38:04 INFO:  test-node-gpu.js test object -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:05 STATE: test-node-gpu.js event: image -2022-06-02 10:38:05 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:05 DATA:  test-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-06-02 10:38:05 DATA:  test-node-gpu.js result: performance: load: null total: 226 -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: object result match -2022-06-02 10:38:05 INFO:  test-node-gpu.js test sensitive -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:05 STATE: test-node-gpu.js event: image -2022-06-02 10:38:05 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:05 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:05 DATA:  test-node-gpu.js result: performance: load: null total: 222 -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: sensitive result match -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: sensitive face result match -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: sensitive body result match -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: sensitive hand result match -2022-06-02 10:38:05 INFO:  test-node-gpu.js test detectors -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:05 STATE: test-node-gpu.js event: image -2022-06-02 10:38:05 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:05 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:05 DATA:  test-node-gpu.js result: performance: load: null total: 94 -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: detector result face match -2022-06-02 10:38:05 STATE: test-node-gpu.js passed: detector result hand match -2022-06-02 10:38:05 INFO:  test-node-gpu.js test: multi-instance -2022-06-02 10:38:05 STATE: test-node-gpu.js event: image -2022-06-02 10:38:06 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: detect: random default -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.06,"keypoints":15} -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: performance: load: null total: 102 -2022-06-02 10:38:06 INFO:  test-node-gpu.js test: first instance -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: performance: load: null total: 91 -2022-06-02 10:38:06 INFO:  test-node-gpu.js test: second instance -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:06 DATA:  test-node-gpu.js result: performance: load: null total: 82 -2022-06-02 10:38:06 INFO:  test-node-gpu.js test: concurrent -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:06 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} -2022-06-02 10:38:07 STATE: test-node-gpu.js event: image -2022-06-02 10:38:07 STATE: test-node-gpu.js event: image -2022-06-02 10:38:07 STATE: test-node-gpu.js event: image -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 945 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 945 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 999 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 999 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 999 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 999 -2022-06-02 10:38:07 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 752 -2022-06-02 10:38:07 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:07 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 753 -2022-06-02 10:38:07 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:07 DATA:  test-node-gpu.js result: performance: load: null total: 753 -2022-06-02 10:38:07 INFO:  test-node-gpu.js test: monkey-patch -2022-06-02 10:38:07 STATE: test-node-gpu.js event: image -2022-06-02 10:38:08 STATE: test-node-gpu.js event: detect -2022-06-02 10:38:08 STATE: test-node-gpu.js passed: monkey patch -2022-06-02 10:38:08 STATE: test-node-gpu.js passed: segmentation [65536] -2022-06-02 10:38:08 STATE: test-node-gpu.js passeed: equal usage -2022-06-02 10:38:08 INFO:  test-node-gpu.js test: input compare -2022-06-02 10:38:08 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} -2022-06-02 10:38:08 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} -2022-06-02 10:38:08 STATE: test-node-gpu.js passed: image compare 0 23.275441687091504 -2022-06-02 10:38:08 INFO:  test-node-gpu.js events: {"image":21,"detect":21,"warmup":2} -2022-06-02 10:38:08 INFO:  test-node-gpu.js tensors 1927 -2022-06-02 10:38:08 INFO:  test-node-gpu.js test complete: 10665 ms -2022-06-02 10:38:08 INFO:  -2022-06-02 10:38:08 INFO:  test-node-wasm.js start -2022-06-02 10:38:09 STATE: test-node-wasm.js passed: model server: https://vladmandic.github.io/human/models/ -2022-06-02 10:38:09 INFO:  test-node-wasm.js test: configuration validation -2022-06-02 10:38:09 STATE: test-node-wasm.js passed: configuration default validation [] -2022-06-02 10:38:09 STATE: test-node-wasm.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] -2022-06-02 10:38:09 INFO:  test-node-wasm.js test: model load -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: models loaded 22 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":"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-06-02 10:38:10 INFO:  test-node-wasm.js test: warmup -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: create human -2022-06-02 10:38:10 INFO:  test-node-wasm.js human version: 2.8.0 -2022-06-02 10:38:10 INFO:  test-node-wasm.js platform: linux x64 agent: NodeJS v18.1.0 -2022-06-02 10:38:10 INFO:  test-node-wasm.js tfjs version: 3.18.0 -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: set backend: wasm -2022-06-02 10:38:10 STATE: test-node-wasm.js tensors 1921 -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: load models -2022-06-02 10:38:10 STATE: test-node-wasm.js result: defined models: 22 loaded models: 12 -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: warmup: none default -2022-06-02 10:38:10 DATA:  test-node-wasm.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} -2022-06-02 10:38:10 DATA:  test-node-wasm.js result: performance: load: null total: null -2022-06-02 10:38:10 STATE: test-node-wasm.js passed: warmup none result match -2022-06-02 10:38:10 STATE: test-node-wasm.js event: image -2022-06-02 10:38:11 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:11 STATE: test-node-wasm.js event: warmup -2022-06-02 10:38:11 STATE: test-node-wasm.js passed: warmup: face default -2022-06-02 10:38:11 DATA:  test-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-06-02 10:38:11 DATA:  test-node-wasm.js result: performance: load: null total: 552 -2022-06-02 10:38:11 STATE: test-node-wasm.js passed: warmup face result match -2022-06-02 10:38:11 STATE: test-node-wasm.js event: image -2022-06-02 10:38:11 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:11 STATE: test-node-wasm.js event: warmup -2022-06-02 10:38:11 STATE: test-node-wasm.js passed: warmup: body default -2022-06-02 10:38:11 DATA:  test-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-06-02 10:38:11 DATA:  test-node-wasm.js result: performance: load: null total: 427 -2022-06-02 10:38:11 STATE: test-node-wasm.js passed: warmup body result match -2022-06-02 10:38:11 STATE: test-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-06-02 10:38:11 INFO:  test-node-wasm.js test: details verification -2022-06-02 10:38:11 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:11 STATE: test-node-wasm.js event: image -2022-06-02 10:38:12 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:12 DATA:  test-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-06-02 10:38:12 DATA:  test-node-wasm.js result: performance: load: null total: 355 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face length 1 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face score 1 0.93 1 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face age/gender 23.7 female 0.97 85.47 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face arrays 4 478 1024 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face anti-spoofing 0.79 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details face liveness 0.83 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details body length 1 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details body 0.92 17 6 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details hand length 1 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details hand 0.51 0.73 point -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details hand arrays 21 5 7 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details gesture length 7 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details gesture first {"face":0,"gesture":"facing right"} -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details object length 1 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: details object 0.72 person -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1413675264} -2022-06-02 10:38:12 STATE: test-node-wasm.js event: image -2022-06-02 10:38:12 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: float32 -2022-06-02 10:38:12 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1413675264} -2022-06-02 10:38:13 STATE: test-node-wasm.js event: image -2022-06-02 10:38:13 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:13 STATE: test-node-wasm.js passed: tensor shape: [1200,1200,4] dtype: float32 -2022-06-02 10:38:13 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:13 STATE: test-node-wasm.js event: image -2022-06-02 10:38:14 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:14 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,3] dtype: float32 -2022-06-02 10:38:14 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:14 STATE: test-node-wasm.js event: image -2022-06-02 10:38:14 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:14 STATE: test-node-wasm.js passed: tensor shape: [1200,1200,3] dtype: float32 -2022-06-02 10:38:14 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} -2022-06-02 10:38:14 STATE: test-node-wasm.js event: image -2022-06-02 10:38:15 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:15 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: int32 -2022-06-02 10:38:15 INFO:  test-node-wasm.js test default -2022-06-02 10:38:15 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:15 STATE: test-node-wasm.js event: image -2022-06-02 10:38:15 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:15 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:15 DATA:  test-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-06-02 10:38:15 DATA:  test-node-wasm.js result: performance: load: null total: 376 -2022-06-02 10:38:15 STATE: test-node-wasm.js passed: default result face match 1 female 0.97 -2022-06-02 10:38:15 INFO:  test-node-wasm.js test sync -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:16 STATE: test-node-wasm.js event: image -2022-06-02 10:38:16 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:16 DATA:  test-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-06-02 10:38:16 DATA:  test-node-wasm.js result: performance: load: null total: 360 -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: default sync 1 female 0.97 -2022-06-02 10:38:16 INFO:  test-node-wasm.js test: image process -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: image input null [1,256,256,3] -2022-06-02 10:38:16 INFO:  test-node-wasm.js test: image null -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: invalid input could not convert input to tensor -2022-06-02 10:38:16 INFO:  test-node-wasm.js test face similarity -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:16 STATE: test-node-wasm.js event: image -2022-06-02 10:38:16 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:16 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:16 DATA:  test-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-06-02 10:38:16 DATA:  test-node-wasm.js result: performance: load: null total: 342 -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:17 STATE: test-node-wasm.js event: image -2022-06-02 10:38:17 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:17 DATA:  test-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-06-02 10:38:17 DATA:  test-node-wasm.js result: performance: load: null total: 352 -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:17 STATE: test-node-wasm.js event: image -2022-06-02 10:38:17 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:17 DATA:  test-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-06-02 10:38:17 DATA:  test-node-wasm.js result: performance: load: null total: 332 -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: face descriptor -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: face similarity {"similarity":[1,0.5266119940661309,0.4858842904087851],"descriptors":[1024,1024,1024]} -2022-06-02 10:38:17 INFO:  test-node-wasm.js test face matching -2022-06-02 10:38:17 STATE: test-node-wasm.js passed: face database 40 -2022-06-02 10:38:17 STATE: test-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-06-02 10:38:17 INFO:  test-node-wasm.js test object -2022-06-02 10:38:18 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:18 STATE: test-node-wasm.js event: image -2022-06-02 10:38:18 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:18 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:18 DATA:  test-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-06-02 10:38:18 DATA:  test-node-wasm.js result: performance: load: null total: 376 -2022-06-02 10:38:18 STATE: test-node-wasm.js passed: object result match -2022-06-02 10:38:18 INFO:  test-node-wasm.js test sensitive -2022-06-02 10:38:18 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:18 STATE: test-node-wasm.js event: image -2022-06-02 10:38:19 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: performance: load: null total: 400 -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: sensitive result match -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: sensitive face result match -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: sensitive face emotion result [{"score":0.46,"emotion":"neutral"},{"score":0.24,"emotion":"fear"},{"score":0.17,"emotion":"sad"}] -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: sensitive body result match -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: sensitive hand result match -2022-06-02 10:38:19 INFO:  test-node-wasm.js test detectors -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:19 STATE: test-node-wasm.js event: image -2022-06-02 10:38:19 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: performance: load: null total: 265 -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: detector result face match -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: detector result hand match -2022-06-02 10:38:19 INFO:  test-node-wasm.js test: multi-instance -2022-06-02 10:38:19 STATE: test-node-wasm.js event: image -2022-06-02 10:38:19 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: detect: random default -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.07,"keypoints":15} -2022-06-02 10:38:19 DATA:  test-node-wasm.js result: performance: load: null total: 232 -2022-06-02 10:38:19 INFO:  test-node-wasm.js test: first instance -2022-06-02 10:38:19 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:20 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:20 DATA:  test-node-wasm.js result: performance: load: null total: 254 -2022-06-02 10:38:20 INFO:  test-node-wasm.js test: second instance -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:20 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:20 DATA:  test-node-wasm.js result: performance: load: null total: 229 -2022-06-02 10:38:20 INFO:  test-node-wasm.js test: concurrent -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:20 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:21 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} -2022-06-02 10:38:21 STATE: test-node-wasm.js event: image -2022-06-02 10:38:21 STATE: test-node-wasm.js event: image -2022-06-02 10:38:21 STATE: test-node-wasm.js event: image -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2190 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2190 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2419 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2419 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2419 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2419 -2022-06-02 10:38:23 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2088 -2022-06-02 10:38:23 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:23 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2088 -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} -2022-06-02 10:38:23 DATA:  test-node-wasm.js result: performance: load: null total: 2088 -2022-06-02 10:38:23 INFO:  test-node-wasm.js test: monkey-patch -2022-06-02 10:38:23 STATE: test-node-wasm.js event: image -2022-06-02 10:38:23 STATE: test-node-wasm.js event: detect -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: monkey patch -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: segmentation [65536] -2022-06-02 10:38:23 STATE: test-node-wasm.js passeed: equal usage -2022-06-02 10:38:23 INFO:  test-node-wasm.js test: input compare -2022-06-02 10:38:23 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} -2022-06-02 10:38:24 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} -2022-06-02 10:38:24 STATE: test-node-wasm.js passed: image compare 0 23.280073018790848 -2022-06-02 10:38:24 INFO:  test-node-wasm.js events: {"image":21,"detect":21,"warmup":2} -2022-06-02 10:38:24 INFO:  test-node-wasm.js tensors 1929 -2022-06-02 10:38:24 INFO:  test-node-wasm.js test complete: 14643 ms -2022-06-02 10:38:24 INFO:  all tests complete -2022-06-02 10:38:24 INFO:  failed: {"count":0,"messages":[]} -2022-06-02 10:38:24 INFO:  status: {"test":"test-node.js","passed":101,"failed":0} -2022-06-02 10:38:24 INFO:  status: {"test":"test-node-gpu.js","passed":101,"failed":0} -2022-06-02 10:38:24 INFO:  status: {"test":"test-node-wasm.js","passed":102,"failed":0} +2022-06-08 08:51:32 INFO:  @vladmandic/human version 2.8.1 +2022-06-08 08:51:32 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.15.0 +2022-06-08 08:51:32 INFO:  tests: ["test-node.js","test-node-gpu.js","test-node-wasm.js"] +2022-06-08 08:51:32 INFO:  demos: ["../demo/nodejs/node.js","../demo/nodejs/node-canvas.js","../demo/nodejs/node-env.js","../demo/nodejs/node-event.js","../demo/nodejs/node-multiprocess.js"] +2022-06-08 08:51:32 INFO:  +2022-06-08 08:51:32 INFO:  test-node.js start +2022-06-08 08:51:32 INFO:  test-node.js test: configuration validation +2022-06-08 08:51:32 STATE: test-node.js passed: configuration default validation [] +2022-06-08 08:51:32 STATE: test-node.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-06-08 08:51:32 INFO:  test-node.js test: model load +2022-06-08 08:51:32 STATE: test-node.js passed: models loaded 22 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":"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-06-08 08:51:32 INFO:  test-node.js test: warmup +2022-06-08 08:51:32 STATE: test-node.js passed: create human +2022-06-08 08:51:32 INFO:  test-node.js human version: 2.8.1 +2022-06-08 08:51:32 INFO:  test-node.js platform: linux x64 agent: NodeJS v16.15.0 +2022-06-08 08:51:32 INFO:  test-node.js tfjs version: 3.18.0 +2022-06-08 08:51:32 INFO:  test-node.js tensorflow binding version: 2.7.0-dev20211101 +2022-06-08 08:51:32 STATE: test-node.js passed: set backend: tensorflow +2022-06-08 08:51:32 STATE: test-node.js tensors 1921 +2022-06-08 08:51:32 STATE: test-node.js passed: load models +2022-06-08 08:51:32 STATE: test-node.js result: defined models: 22 loaded models: 12 +2022-06-08 08:51:32 STATE: test-node.js passed: warmup: none default +2022-06-08 08:51:32 DATA:  test-node.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-06-08 08:51:32 DATA:  test-node.js result: performance: load: null total: null +2022-06-08 08:51:32 STATE: test-node.js passed: warmup none result match +2022-06-08 08:51:32 STATE: test-node.js event: image +2022-06-08 08:51:32 STATE: test-node.js event: detect +2022-06-08 08:51:32 STATE: test-node.js event: warmup +2022-06-08 08:51:32 STATE: test-node.js passed: warmup: face default +2022-06-08 08:51:32 DATA:  test-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-06-08 08:51:32 DATA:  test-node.js result: performance: load: null total: 325 +2022-06-08 08:51:32 STATE: test-node.js passed: warmup face result match +2022-06-08 08:51:32 STATE: test-node.js event: image +2022-06-08 08:51:33 STATE: test-node.js event: detect +2022-06-08 08:51:33 STATE: test-node.js event: warmup +2022-06-08 08:51:33 STATE: test-node.js passed: warmup: body default +2022-06-08 08:51:33 DATA:  test-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-06-08 08:51:33 DATA:  test-node.js result: performance: load: null total: 246 +2022-06-08 08:51:33 STATE: test-node.js passed: warmup body result match +2022-06-08 08:51:33 STATE: test-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-06-08 08:51:33 INFO:  test-node.js test: details verification +2022-06-08 08:51:33 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:33 STATE: test-node.js event: image +2022-06-08 08:51:33 STATE: test-node.js event: detect +2022-06-08 08:51:33 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:33 DATA:  test-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-06-08 08:51:33 DATA:  test-node.js result: performance: load: null total: 232 +2022-06-08 08:51:33 STATE: test-node.js passed: details face length 1 +2022-06-08 08:51:33 STATE: test-node.js passed: details face score 1 0.93 1 +2022-06-08 08:51:33 STATE: test-node.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-06-08 08:51:33 STATE: test-node.js passed: details face arrays 4 478 1024 +2022-06-08 08:51:33 STATE: test-node.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-06-08 08:51:33 STATE: test-node.js passed: details face anti-spoofing 0.79 +2022-06-08 08:51:33 STATE: test-node.js passed: details face liveness 0.83 +2022-06-08 08:51:33 STATE: test-node.js passed: details body length 1 +2022-06-08 08:51:33 STATE: test-node.js passed: details body 0.92 17 6 +2022-06-08 08:51:33 STATE: test-node.js passed: details hand length 1 +2022-06-08 08:51:33 STATE: test-node.js passed: details hand 0.51 0.73 point +2022-06-08 08:51:33 STATE: test-node.js passed: details hand arrays 21 5 7 +2022-06-08 08:51:33 STATE: test-node.js passed: details gesture length 7 +2022-06-08 08:51:33 STATE: test-node.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-06-08 08:51:33 STATE: test-node.js passed: details object length 1 +2022-06-08 08:51:33 STATE: test-node.js passed: details object 0.72 person +2022-06-08 08:51:33 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} +2022-06-08 08:51:33 STATE: test-node.js event: image +2022-06-08 08:51:33 STATE: test-node.js event: detect +2022-06-08 08:51:33 STATE: test-node.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-06-08 08:51:34 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} +2022-06-08 08:51:34 STATE: test-node.js event: image +2022-06-08 08:51:34 STATE: test-node.js event: detect +2022-06-08 08:51:34 STATE: test-node.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-06-08 08:51:34 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:34 STATE: test-node.js event: image +2022-06-08 08:51:34 STATE: test-node.js event: detect +2022-06-08 08:51:34 STATE: test-node.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-06-08 08:51:34 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:34 STATE: test-node.js event: image +2022-06-08 08:51:35 STATE: test-node.js event: detect +2022-06-08 08:51:35 STATE: test-node.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-06-08 08:51:35 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-06-08 08:51:35 STATE: test-node.js event: image +2022-06-08 08:51:35 STATE: test-node.js event: detect +2022-06-08 08:51:35 STATE: test-node.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-06-08 08:51:35 INFO:  test-node.js test default +2022-06-08 08:51:35 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:35 STATE: test-node.js event: image +2022-06-08 08:51:35 STATE: test-node.js event: detect +2022-06-08 08:51:35 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:35 DATA:  test-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-06-08 08:51:35 DATA:  test-node.js result: performance: load: null total: 211 +2022-06-08 08:51:35 STATE: test-node.js passed: default result face match 1 female 0.97 +2022-06-08 08:51:35 INFO:  test-node.js test sync +2022-06-08 08:51:36 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:36 STATE: test-node.js event: image +2022-06-08 08:51:36 STATE: test-node.js event: detect +2022-06-08 08:51:36 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:36 DATA:  test-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-06-08 08:51:36 DATA:  test-node.js result: performance: load: null total: 206 +2022-06-08 08:51:36 STATE: test-node.js passed: default sync 1 female 0.97 +2022-06-08 08:51:36 INFO:  test-node.js test: image process +2022-06-08 08:51:36 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:36 STATE: test-node.js passed: image input null [1,256,256,3] +2022-06-08 08:51:36 INFO:  test-node.js test: image null +2022-06-08 08:51:36 STATE: test-node.js passed: invalid input could not convert input to tensor +2022-06-08 08:51:36 INFO:  test-node.js test face similarity +2022-06-08 08:51:36 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:36 STATE: test-node.js event: image +2022-06-08 08:51:36 STATE: test-node.js event: detect +2022-06-08 08:51:36 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:36 DATA:  test-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-06-08 08:51:36 DATA:  test-node.js result: performance: load: null total: 198 +2022-06-08 08:51:36 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:36 STATE: test-node.js event: image +2022-06-08 08:51:36 STATE: test-node.js event: detect +2022-06-08 08:51:36 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:36 DATA:  test-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-06-08 08:51:36 DATA:  test-node.js result: performance: load: null total: 203 +2022-06-08 08:51:36 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:36 STATE: test-node.js event: image +2022-06-08 08:51:37 STATE: test-node.js event: detect +2022-06-08 08:51:37 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:37 DATA:  test-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-06-08 08:51:37 DATA:  test-node.js result: performance: load: null total: 183 +2022-06-08 08:51:37 STATE: test-node.js passed: face descriptor +2022-06-08 08:51:37 STATE: test-node.js passed: face similarity {"similarity":[1,0.44727452329649126,0.5567935850640406],"descriptors":[1024,1024,1024]} +2022-06-08 08:51:37 INFO:  test-node.js test face matching +2022-06-08 08:51:37 STATE: test-node.js passed: face database 40 +2022-06-08 08:51:37 STATE: test-node.js passed: face match {"first":{"index":4,"similarity":0.7827852615252829}} {"second":{"index":4,"similarity":0.5002052633015844}} {"third":{"index":4,"similarity":0.5401587887998899}} +2022-06-08 08:51:37 INFO:  test-node.js test object +2022-06-08 08:51:37 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:37 STATE: test-node.js event: image +2022-06-08 08:51:37 STATE: test-node.js event: detect +2022-06-08 08:51:37 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:37 DATA:  test-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-06-08 08:51:37 DATA:  test-node.js result: performance: load: null total: 203 +2022-06-08 08:51:37 STATE: test-node.js passed: object result match +2022-06-08 08:51:37 INFO:  test-node.js test sensitive +2022-06-08 08:51:37 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:37 STATE: test-node.js event: image +2022-06-08 08:51:37 STATE: test-node.js event: detect +2022-06-08 08:51:37 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:37 DATA:  test-node.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:37 DATA:  test-node.js result: performance: load: null total: 218 +2022-06-08 08:51:37 STATE: test-node.js passed: sensitive result match +2022-06-08 08:51:37 STATE: test-node.js passed: sensitive face result match +2022-06-08 08:51:37 STATE: test-node.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] +2022-06-08 08:51:37 STATE: test-node.js passed: sensitive body result match +2022-06-08 08:51:37 STATE: test-node.js passed: sensitive hand result match +2022-06-08 08:51:37 INFO:  test-node.js test detectors +2022-06-08 08:51:38 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:38 STATE: test-node.js event: image +2022-06-08 08:51:38 STATE: test-node.js event: detect +2022-06-08 08:51:38 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:38 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:38 DATA:  test-node.js result: performance: load: null total: 137 +2022-06-08 08:51:38 STATE: test-node.js passed: detector result face match +2022-06-08 08:51:38 STATE: test-node.js passed: detector result hand match +2022-06-08 08:51:38 INFO:  test-node.js test: multi-instance +2022-06-08 08:51:38 STATE: test-node.js event: image +2022-06-08 08:51:38 STATE: test-node.js event: detect +2022-06-08 08:51:38 STATE: test-node.js passed: detect: random default +2022-06-08 08:51:38 DATA:  test-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.07,"keypoints":15} +2022-06-08 08:51:38 DATA:  test-node.js result: performance: load: null total: 130 +2022-06-08 08:51:38 INFO:  test-node.js test: first instance +2022-06-08 08:51:38 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:38 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:38 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:38 DATA:  test-node.js result: performance: load: null total: 135 +2022-06-08 08:51:38 INFO:  test-node.js test: second instance +2022-06-08 08:51:38 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:38 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:38 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:38 DATA:  test-node.js result: performance: load: null total: 130 +2022-06-08 08:51:38 INFO:  test-node.js test: concurrent +2022-06-08 08:51:38 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:38 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:39 STATE: test-node.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289024} +2022-06-08 08:51:39 STATE: test-node.js event: image +2022-06-08 08:51:39 STATE: test-node.js event: image +2022-06-08 08:51:39 STATE: test-node.js event: image +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1364 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1364 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1485 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1485 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1485 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1485 +2022-06-08 08:51:40 STATE: test-node.js event: detect +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1239 +2022-06-08 08:51:40 STATE: test-node.js event: detect +2022-06-08 08:51:40 STATE: test-node.js event: detect +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1239 +2022-06-08 08:51:40 STATE: test-node.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:40 DATA:  test-node.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:40 DATA:  test-node.js result: performance: load: null total: 1239 +2022-06-08 08:51:40 INFO:  test-node.js test: monkey-patch +2022-06-08 08:51:40 STATE: test-node.js event: image +2022-06-08 08:51:40 STATE: test-node.js event: detect +2022-06-08 08:51:40 STATE: test-node.js passed: monkey patch +2022-06-08 08:51:40 STATE: test-node.js passed: segmentation [65536] +2022-06-08 08:51:40 STATE: test-node.js passeed: equal usage +2022-06-08 08:51:40 INFO:  test-node.js test: input compare +2022-06-08 08:51:41 STATE: test-node.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:41 STATE: test-node.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796864} +2022-06-08 08:51:41 STATE: test-node.js passed: image compare 0 23.275441687091504 +2022-06-08 08:51:41 INFO:  test-node.js events: {"image":21,"detect":21,"warmup":2} +2022-06-08 08:51:41 INFO:  test-node.js tensors 1927 +2022-06-08 08:51:41 INFO:  test-node.js test complete: 8781 ms +2022-06-08 08:51:41 INFO:  +2022-06-08 08:51:41 INFO:  test-node-gpu.js start +2022-06-08 08:51:42 INFO:  test-node-gpu.js test: configuration validation +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: configuration default validation [] +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-06-08 08:51:42 INFO:  test-node-gpu.js test: model load +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: models loaded 22 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":"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-06-08 08:51:42 INFO:  test-node-gpu.js test: warmup +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: create human +2022-06-08 08:51:42 INFO:  test-node-gpu.js human version: 2.8.1 +2022-06-08 08:51:42 INFO:  test-node-gpu.js platform: linux x64 agent: NodeJS v16.15.0 +2022-06-08 08:51:42 INFO:  test-node-gpu.js tfjs version: 3.18.0 +2022-06-08 08:51:42 INFO:  test-node-gpu.js tensorflow binding version: 2.7.0-dev20211101 +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: set backend: tensorflow +2022-06-08 08:51:42 STATE: test-node-gpu.js tensors 1921 +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: load models +2022-06-08 08:51:42 STATE: test-node-gpu.js result: defined models: 22 loaded models: 12 +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: warmup: none default +2022-06-08 08:51:42 DATA:  test-node-gpu.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-06-08 08:51:42 DATA:  test-node-gpu.js result: performance: load: null total: null +2022-06-08 08:51:42 STATE: test-node-gpu.js passed: warmup none result match +2022-06-08 08:51:42 STATE: test-node-gpu.js event: image +2022-06-08 08:51:44 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:44 STATE: test-node-gpu.js event: warmup +2022-06-08 08:51:44 STATE: test-node-gpu.js passed: warmup: face default +2022-06-08 08:51:44 DATA:  test-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-06-08 08:51:44 DATA:  test-node-gpu.js result: performance: load: null total: 2137 +2022-06-08 08:51:44 STATE: test-node-gpu.js passed: warmup face result match +2022-06-08 08:51:44 STATE: test-node-gpu.js event: image +2022-06-08 08:51:44 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:44 STATE: test-node-gpu.js event: warmup +2022-06-08 08:51:44 STATE: test-node-gpu.js passed: warmup: body default +2022-06-08 08:51:44 DATA:  test-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-06-08 08:51:44 DATA:  test-node-gpu.js result: performance: load: null total: 223 +2022-06-08 08:51:44 STATE: test-node-gpu.js passed: warmup body result match +2022-06-08 08:51:44 STATE: test-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-06-08 08:51:44 INFO:  test-node-gpu.js test: details verification +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:45 STATE: test-node-gpu.js event: image +2022-06-08 08:51:45 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:45 DATA:  test-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-06-08 08:51:45 DATA:  test-node-gpu.js result: performance: load: null total: 172 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face length 1 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face score 1 0.93 1 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face arrays 4 478 1024 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face anti-spoofing 0.79 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details face liveness 0.83 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details body length 1 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details body 0.92 17 6 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details hand length 1 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details hand 0.51 0.73 point +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details hand arrays 21 5 7 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details gesture length 7 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details object length 1 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: details object 0.72 person +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996928} +2022-06-08 08:51:45 STATE: test-node-gpu.js event: image +2022-06-08 08:51:45 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-06-08 08:51:45 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1371996928} +2022-06-08 08:51:45 STATE: test-node-gpu.js event: image +2022-06-08 08:51:46 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:46 STATE: test-node-gpu.js event: image +2022-06-08 08:51:46 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:46 STATE: test-node-gpu.js event: image +2022-06-08 08:51:46 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-06-08 08:51:46 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-06-08 08:51:46 STATE: test-node-gpu.js event: image +2022-06-08 08:51:47 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-06-08 08:51:47 INFO:  test-node-gpu.js test default +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:47 STATE: test-node-gpu.js event: image +2022-06-08 08:51:47 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:47 DATA:  test-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-06-08 08:51:47 DATA:  test-node-gpu.js result: performance: load: null total: 140 +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: default result face match 1 female 0.97 +2022-06-08 08:51:47 INFO:  test-node-gpu.js test sync +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:47 STATE: test-node-gpu.js event: image +2022-06-08 08:51:47 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:47 DATA:  test-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-06-08 08:51:47 DATA:  test-node-gpu.js result: performance: load: null total: 186 +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: default sync 1 female 0.97 +2022-06-08 08:51:47 INFO:  test-node-gpu.js test: image process +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: image input null [1,256,256,3] +2022-06-08 08:51:47 INFO:  test-node-gpu.js test: image null +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: invalid input could not convert input to tensor +2022-06-08 08:51:47 INFO:  test-node-gpu.js test face similarity +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:47 STATE: test-node-gpu.js event: image +2022-06-08 08:51:47 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:47 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:47 DATA:  test-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-06-08 08:51:47 DATA:  test-node-gpu.js result: performance: load: null total: 138 +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:48 STATE: test-node-gpu.js event: image +2022-06-08 08:51:48 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:48 DATA:  test-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-06-08 08:51:48 DATA:  test-node-gpu.js result: performance: load: null total: 153 +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:48 STATE: test-node-gpu.js event: image +2022-06-08 08:51:48 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:48 DATA:  test-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-06-08 08:51:48 DATA:  test-node-gpu.js result: performance: load: null total: 186 +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: face descriptor +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: face similarity {"similarity":[1,0.447238756461232,0.556914029877052],"descriptors":[1024,1024,1024]} +2022-06-08 08:51:48 INFO:  test-node-gpu.js test face matching +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: face database 40 +2022-06-08 08:51:48 STATE: test-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-06-08 08:51:48 INFO:  test-node-gpu.js test object +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:48 STATE: test-node-gpu.js event: image +2022-06-08 08:51:48 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:48 DATA:  test-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-06-08 08:51:48 DATA:  test-node-gpu.js result: performance: load: null total: 212 +2022-06-08 08:51:48 STATE: test-node-gpu.js passed: object result match +2022-06-08 08:51:48 INFO:  test-node-gpu.js test sensitive +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:49 STATE: test-node-gpu.js event: image +2022-06-08 08:51:49 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 2 gesture: 9 object: 1 person: 1 {"score":1,"age":23.7,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: performance: load: null total: 211 +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: sensitive result match +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: sensitive face result match +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: sensitive face emotion result [{"score":0.59,"emotion":"angry"},{"score":0.29,"emotion":"fear"}] +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: sensitive body result match +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: sensitive hand result match +2022-06-08 08:51:49 INFO:  test-node-gpu.js test detectors +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:49 STATE: test-node-gpu.js event: image +2022-06-08 08:51:49 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: performance: load: null total: 139 +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: detector result face match +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: detector result hand match +2022-06-08 08:51:49 INFO:  test-node-gpu.js test: multi-instance +2022-06-08 08:51:49 STATE: test-node-gpu.js event: image +2022-06-08 08:51:49 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: detect: random default +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.06,"keypoints":15} +2022-06-08 08:51:49 DATA:  test-node-gpu.js result: performance: load: null total: 102 +2022-06-08 08:51:49 INFO:  test-node-gpu.js test: first instance +2022-06-08 08:51:49 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:50 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:50 DATA:  test-node-gpu.js result: performance: load: null total: 89 +2022-06-08 08:51:50 INFO:  test-node-gpu.js test: second instance +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:50 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:50 DATA:  test-node-gpu.js result: performance: load: null total: 70 +2022-06-08 08:51:50 INFO:  test-node-gpu.js test: concurrent +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:50 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151289056} +2022-06-08 08:51:51 STATE: test-node-gpu.js event: image +2022-06-08 08:51:51 STATE: test-node-gpu.js event: image +2022-06-08 08:51:51 STATE: test-node-gpu.js event: image +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 865 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 865 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 934 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 934 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 934 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 934 +2022-06-08 08:51:51 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 684 +2022-06-08 08:51:51 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:51 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 685 +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:51:51 DATA:  test-node-gpu.js result: performance: load: null total: 685 +2022-06-08 08:51:51 INFO:  test-node-gpu.js test: monkey-patch +2022-06-08 08:51:51 STATE: test-node-gpu.js event: image +2022-06-08 08:51:51 STATE: test-node-gpu.js event: detect +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: monkey patch +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: segmentation [65536] +2022-06-08 08:51:51 STATE: test-node-gpu.js passeed: equal usage +2022-06-08 08:51:51 INFO:  test-node-gpu.js test: input compare +2022-06-08 08:51:51 STATE: test-node-gpu.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34696120} +2022-06-08 08:51:52 STATE: test-node-gpu.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1004796928} +2022-06-08 08:51:52 STATE: test-node-gpu.js passed: image compare 0 23.275441687091504 +2022-06-08 08:51:52 INFO:  test-node-gpu.js events: {"image":21,"detect":21,"warmup":2} +2022-06-08 08:51:52 INFO:  test-node-gpu.js tensors 1927 +2022-06-08 08:51:52 INFO:  test-node-gpu.js test complete: 10102 ms +2022-06-08 08:51:52 INFO:  +2022-06-08 08:51:52 INFO:  test-node-wasm.js start +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: model server: https://vladmandic.github.io/human/models/ +2022-06-08 08:51:53 INFO:  test-node-wasm.js test: configuration validation +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: configuration default validation [] +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: configuration invalid validation [{"reason":"unknown property","where":"config.invalid = true"}] +2022-06-08 08:51:53 INFO:  test-node-wasm.js test: model load +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: models loaded 22 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":"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-06-08 08:51:53 INFO:  test-node-wasm.js test: warmup +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: create human +2022-06-08 08:51:53 INFO:  test-node-wasm.js human version: 2.8.1 +2022-06-08 08:51:53 INFO:  test-node-wasm.js platform: linux x64 agent: NodeJS v16.15.0 +2022-06-08 08:51:53 INFO:  test-node-wasm.js tfjs version: 3.18.0 +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: set backend: wasm +2022-06-08 08:51:53 STATE: test-node-wasm.js tensors 1921 +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: load models +2022-06-08 08:51:53 STATE: test-node-wasm.js result: defined models: 22 loaded models: 12 +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: warmup: none default +2022-06-08 08:51:53 DATA:  test-node-wasm.js result: face: 0 body: 0 hand: 0 gesture: 0 object: 0 person: 0 {} {} {} +2022-06-08 08:51:53 DATA:  test-node-wasm.js result: performance: load: null total: null +2022-06-08 08:51:53 STATE: test-node-wasm.js passed: warmup none result match +2022-06-08 08:51:53 STATE: test-node-wasm.js event: image +2022-06-08 08:51:54 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:54 STATE: test-node-wasm.js event: warmup +2022-06-08 08:51:54 STATE: test-node-wasm.js passed: warmup: face default +2022-06-08 08:51:54 DATA:  test-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-06-08 08:51:54 DATA:  test-node-wasm.js result: performance: load: null total: 466 +2022-06-08 08:51:54 STATE: test-node-wasm.js passed: warmup face result match +2022-06-08 08:51:54 STATE: test-node-wasm.js event: image +2022-06-08 08:51:54 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:54 STATE: test-node-wasm.js event: warmup +2022-06-08 08:51:54 STATE: test-node-wasm.js passed: warmup: body default +2022-06-08 08:51:54 DATA:  test-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-06-08 08:51:54 DATA:  test-node-wasm.js result: performance: load: null total: 366 +2022-06-08 08:51:54 STATE: test-node-wasm.js passed: warmup body result match +2022-06-08 08:51:54 STATE: test-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-06-08 08:51:54 INFO:  test-node-wasm.js test: details verification +2022-06-08 08:51:54 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:54 STATE: test-node-wasm.js event: image +2022-06-08 08:51:55 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:55 DATA:  test-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-06-08 08:51:55 DATA:  test-node-wasm.js result: performance: load: null total: 357 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face length 1 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face score 1 0.93 1 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face age/gender 23.7 female 0.97 85.47 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face arrays 4 478 1024 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face emotion 2 {"score":0.59,"emotion":"angry"} +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face anti-spoofing 0.79 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details face liveness 0.83 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details body length 1 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details body 0.92 17 6 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details hand length 1 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details hand 0.51 0.73 point +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details hand arrays 21 5 7 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details gesture length 7 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details gesture first {"face":0,"gesture":"facing right"} +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details object length 1 +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: details object 0.72 person +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1413675264} +2022-06-08 08:51:55 STATE: test-node-wasm.js event: image +2022-06-08 08:51:55 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:55 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: float32 +2022-06-08 08:51:56 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,4] {"checksum":1413675264} +2022-06-08 08:51:56 STATE: test-node-wasm.js event: image +2022-06-08 08:51:56 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:56 STATE: test-node-wasm.js passed: tensor shape: [1200,1200,4] dtype: float32 +2022-06-08 08:51:56 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:56 STATE: test-node-wasm.js event: image +2022-06-08 08:51:56 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:56 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,3] dtype: float32 +2022-06-08 08:51:57 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:57 STATE: test-node-wasm.js event: image +2022-06-08 08:51:57 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:57 STATE: test-node-wasm.js passed: tensor shape: [1200,1200,3] dtype: float32 +2022-06-08 08:51:57 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,4] {"checksum":1371996871} +2022-06-08 08:51:57 STATE: test-node-wasm.js event: image +2022-06-08 08:51:58 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:58 STATE: test-node-wasm.js passed: tensor shape: [1,1200,1200,4] dtype: int32 +2022-06-08 08:51:58 INFO:  test-node-wasm.js test default +2022-06-08 08:51:58 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:58 STATE: test-node-wasm.js event: image +2022-06-08 08:51:58 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:58 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:58 DATA:  test-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-06-08 08:51:58 DATA:  test-node-wasm.js result: performance: load: null total: 323 +2022-06-08 08:51:58 STATE: test-node-wasm.js passed: default result face match 1 female 0.97 +2022-06-08 08:51:58 INFO:  test-node-wasm.js test sync +2022-06-08 08:51:58 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:58 STATE: test-node-wasm.js event: image +2022-06-08 08:51:59 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:51:59 DATA:  test-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-06-08 08:51:59 DATA:  test-node-wasm.js result: performance: load: null total: 357 +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: default sync 1 female 0.97 +2022-06-08 08:51:59 INFO:  test-node-wasm.js test: image process +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: image input null [1,256,256,3] +2022-06-08 08:51:59 INFO:  test-node-wasm.js test: image null +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: invalid input could not convert input to tensor +2022-06-08 08:51:59 INFO:  test-node-wasm.js test face similarity +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:51:59 STATE: test-node-wasm.js event: image +2022-06-08 08:51:59 STATE: test-node-wasm.js event: detect +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:51:59 DATA:  test-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-06-08 08:51:59 DATA:  test-node-wasm.js result: performance: load: null total: 292 +2022-06-08 08:51:59 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:51:59 STATE: test-node-wasm.js event: image +2022-06-08 08:52:00 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:00 DATA:  test-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-06-08 08:52:00 DATA:  test-node-wasm.js result: performance: load: null total: 345 +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:00 STATE: test-node-wasm.js event: image +2022-06-08 08:52:00 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:00 DATA:  test-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-06-08 08:52:00 DATA:  test-node-wasm.js result: performance: load: null total: 312 +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: face descriptor +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: face similarity {"similarity":[1,0.5266119940661309,0.4858842904087851],"descriptors":[1024,1024,1024]} +2022-06-08 08:52:00 INFO:  test-node-wasm.js test face matching +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: face database 40 +2022-06-08 08:52:00 STATE: test-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-06-08 08:52:00 INFO:  test-node-wasm.js test object +2022-06-08 08:52:00 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:00 STATE: test-node-wasm.js event: image +2022-06-08 08:52:01 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:01 DATA:  test-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-06-08 08:52:01 DATA:  test-node-wasm.js result: performance: load: null total: 373 +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: object result match +2022-06-08 08:52:01 INFO:  test-node-wasm.js test sensitive +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:01 STATE: test-node-wasm.js event: image +2022-06-08 08:52:01 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:01 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 2 gesture: 10 object: 1 person: 1 {"score":1,"age":29.6,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:52:01 DATA:  test-node-wasm.js result: performance: load: null total: 369 +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: sensitive result match +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: sensitive face result match +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: sensitive face emotion result [{"score":0.46,"emotion":"neutral"},{"score":0.24,"emotion":"fear"},{"score":0.17,"emotion":"sad"}] +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: sensitive body result match +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: sensitive hand result match +2022-06-08 08:52:01 INFO:  test-node-wasm.js test detectors +2022-06-08 08:52:01 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:01 STATE: test-node-wasm.js event: image +2022-06-08 08:52:02 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: performance: load: null total: 242 +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: detector result face match +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: detector result hand match +2022-06-08 08:52:02 INFO:  test-node-wasm.js test: multi-instance +2022-06-08 08:52:02 STATE: test-node-wasm.js event: image +2022-06-08 08:52:02 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: detect: random default +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0.07,"keypoints":15} +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: performance: load: null total: 226 +2022-06-08 08:52:02 INFO:  test-node-wasm.js test: first instance +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:52:02 DATA:  test-node-wasm.js result: performance: load: null total: 244 +2022-06-08 08:52:02 INFO:  test-node-wasm.js test: second instance +2022-06-08 08:52:02 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:03 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:52:03 DATA:  test-node-wasm.js result: performance: load: null total: 238 +2022-06-08 08:52:03 INFO:  test-node-wasm.js test: concurrent +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:03 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:52:04 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:04 STATE: test-node-wasm.js passed: load image: samples/in/ai-upper.jpg [1,720,688,3] {"checksum":151155104} +2022-06-08 08:52:04 STATE: test-node-wasm.js event: image +2022-06-08 08:52:04 STATE: test-node-wasm.js event: image +2022-06-08 08:52:04 STATE: test-node-wasm.js event: image +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2511 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2511 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2747 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2747 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2747 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2747 +2022-06-08 08:52:06 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-upper.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 0 gesture: 0 object: 1 person: 1 {"score":0.96} {"score":0.71,"class":"person"} {"score":0.75,"keypoints":16} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2448 +2022-06-08 08:52:06 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:06 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-face.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 2 object: 1 person: 1 {"score":0.91} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2448 +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: detect: samples/in/ai-body.jpg default +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: face: 1 body: 1 hand: 1 gesture: 0 object: 1 person: 1 {"score":0.93} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17} +2022-06-08 08:52:06 DATA:  test-node-wasm.js result: performance: load: null total: 2448 +2022-06-08 08:52:06 INFO:  test-node-wasm.js test: monkey-patch +2022-06-08 08:52:06 STATE: test-node-wasm.js event: image +2022-06-08 08:52:06 STATE: test-node-wasm.js event: detect +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: monkey patch +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: segmentation [65536] +2022-06-08 08:52:06 STATE: test-node-wasm.js passeed: equal usage +2022-06-08 08:52:06 INFO:  test-node-wasm.js test: input compare +2022-06-08 08:52:06 STATE: test-node-wasm.js passed: load image: samples/in/ai-face.jpg [1,256,256,3] {"checksum":34697856} +2022-06-08 08:52:07 STATE: test-node-wasm.js passed: load image: samples/in/ai-body.jpg [1,1200,1200,3] {"checksum":1038921856} +2022-06-08 08:52:07 STATE: test-node-wasm.js passed: image compare 0 23.280073018790848 +2022-06-08 08:52:07 INFO:  test-node-wasm.js events: {"image":21,"detect":21,"warmup":2} +2022-06-08 08:52:07 INFO:  test-node-wasm.js tensors 1929 +2022-06-08 08:52:07 INFO:  test-node-wasm.js test complete: 13925 ms +2022-06-08 08:52:07 INFO:  all tests complete +2022-06-08 08:52:07 INFO:  failed: {"count":0,"messages":[]} +2022-06-08 08:52:07 INFO:  status: {"test":"test-node.js","passed":101,"failed":0} +2022-06-08 08:52:07 INFO:  status: {"test":"test-node-gpu.js","passed":101,"failed":0} +2022-06-08 08:52:07 INFO:  status: {"test":"test-node-wasm.js","passed":102,"failed":0} diff --git a/typedoc/classes/Env.html b/typedoc/classes/Env.html index 00bcfa91..9f581519 100644 --- a/typedoc/classes/Env.html +++ b/typedoc/classes/Env.html @@ -1,4 +1,4 @@ -Env | @vladmandic/human - v2.8.0
Options
All
  • Public
  • Public/Protected
  • All
Menu
+Env | @vladmandic/human - v2.8.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Env class that holds detected capabilities

Hierarchy

  • Env

Index

Constructors

Properties

Canvas: undefined

MonkeyPatch for Canvas

diff --git a/typedoc/classes/GraphModel.html b/typedoc/classes/GraphModel.html index 2686e97a..97b73cac 100644 --- a/typedoc/classes/GraphModel.html +++ b/typedoc/classes/GraphModel.html @@ -1,4 +1,4 @@ -GraphModel | @vladmandic/human - v2.8.0
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GraphModel<ModelURL>

+GraphModel | @vladmandic/human - v2.8.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GraphModel<ModelURL>

A tf.GraphModel is a directed, acyclic graph built from a SavedModel GraphDef and allows inference execution.

A tf.GraphModel can only be created by loading from a model converted from diff --git a/typedoc/classes/Human.html b/typedoc/classes/Human.html index c620d73b..211aa2a5 100644 --- a/typedoc/classes/Human.html +++ b/typedoc/classes/Human.html @@ -1,4 +1,4 @@ -Human | @vladmandic/human - v2.8.0

Options
All
  • Public
  • Public/Protected
  • All
Menu
+Human | @vladmandic/human - v2.8.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Human* library main class

All methods and properties are available only as members of Human class