diff --git a/CHANGELOG.md b/CHANGELOG.md index 19d931e2..f3318c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # @vladmandic/human -Version: **2.0.3** +Version: **2.1.1** Description: **Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gesture Recognition** Author: **Vladimir Mandic ** @@ -9,7 +9,7 @@ Repository: **** ## Changelog -### **HEAD -> main** 2021/07/29 mandic00@live.com +### **2.1.1** 2021/07/29 mandic00@live.com ### **origin/main** 2021/07/19 marcogodoy@untitled.cl diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index 3a256f90..cb9979a0 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -730,5 +730,5 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var de="2.0.3";var T0,k0,I0,d0,c0,P0,e5,N0,t5,o5,n5,r5,a2=class{constructor(e){K(this,T0,void 0);K(this,k0,void 0);K(this,I0,void 0);K(this,d0,void 0);K(this,c0,void 0);K(this,P0,void 0);this.analyze=(...e)=>{if(!C(this,k0))return;let t=this.tf.engine().state.numTensors,n=C(this,T0);_(this,T0,t);let o=t-n;o!==0&&g(...e,o)};K(this,e5,e=>{if(!C(this,I0))return null;if(!e)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(e instanceof r.Tensor))return"input must be a tensor";try{this.tf.getBackend()}catch(t){return"backend not loaded"}return null});K(this,N0,async(e=!1)=>{var t;if(this.config.backend&&this.config.backend.length>0&&e||this.tf.getBackend()!==this.config.backend){let n=N();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&g("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&g("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&g("wasm path:",this.config.wasmPath),typeof((t=this.tf)==null?void 0:t.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let o=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),x=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&g(`wasm execution: ${o?"SIMD":"no SIMD"} ${x?"multithreaded":"singlethreaded"}`),this.config.debug&&!o&&g("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&dA();try{await this.tf.setBackend(this.config.backend)}catch(o){g("error: cannot set backend:",this.config.backend,o)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let o=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&g(`gl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(N()-n)}});this.next=e=>le(e||this.result);K(this,t5,async e=>{if(this.config.cacheSensitivity===0)return!1;let t=32,n=e.resizeBilinear([Math.trunc(e.shape[1]/t),Math.trunc(e.shape[2]/t)]),o=n.dataSync(),x=0;for(let y=0;y10*this.config.cacheSensitivity?0:a),i});K(this,o5,async()=>{let e=(o,x="application/octet-stream")=>fetch(`data:${x};base64,${o}`).then(a=>a.blob()),t,n;switch(this.config.warmup){case"face":t=await e($0);break;case"full":t=await e(A5);break;default:t=null}if(t){let o=await createImageBitmap(t);n=await this.detect(o,this.config),o.close()}return n});K(this,n5,async()=>new Promise(e=>{let t,n=0;switch(this.config.warmup){case"face":n=256,t="data:image/jpeg;base64,"+$0;break;case"full":case"body":n=1200,t="data:image/jpeg;base64,"+A5;break;default:t=null}let o=new Image;o.onload=async()=>{let x=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(n,n):document.createElement("canvas");x.width=o.naturalWidth,x.height=o.naturalHeight;let a=x.getContext("2d");a==null||a.drawImage(o,0,0);let i=await this.detect(x,this.config);e(i)},t?o.src=t:e(null)}));K(this,r5,async()=>{let e=o=>Buffer.from(o,"base64"),t;if(this.config.warmup==="face"&&(t=e($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(t=e(A5)),!t)return null;let n;if(typeof r.node!="undefined"){let o=r.node.decodeJpeg(t),x=o.expandDims(0);this.tf.dispose(o),n=await this.detect(x,this.config),this.tf.dispose(x)}else this.config.debug&&g("Warmup tfjs-node not loaded");return n});this.config=q(yA,e||{}),this.tf=r,this.draw=aA,this.version=de,this.state="idle",_(this,T0,0),_(this,k0,!1),_(this,I0,!1),_(this,d0,!0),_(this,P0,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=t=>l0(t,this.config),this.faceTriangulation=zA,this.faceUVMap=EA,this.sysinfo=lA(),_(this,c0,1)}similarity(e,t){return p5(e,t)}segmentation(e,t){return $A(e,t,this.config)}enhance(e){return b5(e)}match(e,t,n=0){return jA(e,t,n)}async load(e){this.state="load";let t=N();e&&(this.config=q(this.config,e)),C(this,d0)&&(this.config.debug&&g(`version: ${this.version}`),this.config.debug&&g(`tfjs version: ${this.tf.version_core}`),this.config.debug&&g("platform:",this.sysinfo.platform),this.config.debug&&g("agent:",this.sysinfo.agent),await C(this,N0).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&g("configuration:",this.config),this.config.debug&&g("tf flags:",this.tf.ENV.flags))),await Ae(this),C(this,d0)&&(this.config.debug&&g("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),_(this,d0,!1));let n=Math.trunc(N()-t);n>(this.performance.load||0)&&(this.performance.load=n)}async detect(e,t){return new Promise(async n=>{this.state="config";let o,x;this.config=q(this.config,t),this.state="check";let a=C(this,e5).call(this,e);a&&(g(a,e),n({error:a}));let i=N();await C(this,N0).call(this),await this.load(),o=N();let y=l0(e,this.config);if(this.performance.image=Math.trunc(N()-o),this.analyze("Get Image:"),this.config.segmentation.enabled&&y&&y.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",o=N(),await oA(y),x=Math.trunc(N()-o),x>0&&(this.performance.segmentation=x),y.canvas&&(y.tensor.dispose(),y=l0(y.canvas,this.config)),this.analyze("End Segmentation:")),!y||!y.tensor){g("could not convert input to tensor"),n({error:"could not convert input to tensor"});return}o=N(),this.config.skipFrame=await C(this,t5).call(this,y.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(N()-o),this.analyze("Check Changed:");let s,d,l,f;this.config.async?(s=this.config.face.enabled?nA(this,y.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",o=N(),s=this.config.face.enabled?await nA(this,y.tensor):[],x=Math.trunc(N()-o),x>0&&(this.performance.face=x)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?S5(y.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?d=this.config.body.enabled?Z5(y.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?d=this.config.body.enabled?C5(y.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(d=this.config.body.enabled?J5(y.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",o=N(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await S5(y.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?d=this.config.body.enabled?await Z5(y.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?d=this.config.body.enabled?await C5(y.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(d=this.config.body.enabled?await J5(y.tensor,this.config):[]),x=Math.trunc(N()-o),x>0&&(this.performance.body=x)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(l=this.config.hand.enabled?H5(y.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",o=N(),l=this.config.hand.enabled?await H5(y.tensor,this.config):[],x=Math.trunc(N()-o),x>0&&(this.performance.hand=x)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?f=this.config.object.enabled?Q5(y.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(f=this.config.object.enabled?eA(y.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",o=N(),this.config.object.modelPath.includes("nanodet")?f=this.config.object.enabled?await Q5(y.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(f=this.config.object.enabled?await eA(y.tensor,this.config):[]),x=Math.trunc(N()-o),x>0&&(this.performance.object=x)),this.analyze("End Object:"),this.config.async&&([s,d,l,f]=await Promise.all([s,d,l,f]));let u=[];this.config.gesture.enabled&&(o=N(),u=[...te(s),...ee(d),...ne(l),...oe(s)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(N()-o)),this.performance.total=Math.trunc(N()-i),this.state="idle",this.result={face:s,body:d,hand:l,gesture:u,object:f,performance:this.performance,canvas:y.canvas,timestamp:Date.now(),get persons(){var v;return ye(s,d,l,u,(v=y==null?void 0:y.tensor)==null?void 0:v.shape)}},r.dispose(y.tensor),n(this.result)})}async warmup(e){let t=N();if(e&&(this.config=q(this.config,e)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let n;typeof createImageBitmap=="function"?n=await C(this,o5).call(this):typeof Image!="undefined"?n=await C(this,n5).call(this):n=await C(this,r5).call(this);let o=N();return this.config.debug&&g("Warmup",this.config.warmup,Math.round(o-t),"ms",n),n}};T0=new WeakMap,k0=new WeakMap,I0=new WeakMap,d0=new WeakMap,c0=new WeakMap,P0=new WeakMap,e5=new WeakMap,N0=new WeakMap,t5=new WeakMap,o5=new WeakMap,n5=new WeakMap,r5=new WeakMap;export{a2 as Human,a2 as default}; +2Q==`;var de="2.1.1";var T0,k0,I0,d0,c0,P0,e5,N0,t5,o5,n5,r5,a2=class{constructor(e){K(this,T0,void 0);K(this,k0,void 0);K(this,I0,void 0);K(this,d0,void 0);K(this,c0,void 0);K(this,P0,void 0);this.analyze=(...e)=>{if(!C(this,k0))return;let t=this.tf.engine().state.numTensors,n=C(this,T0);_(this,T0,t);let o=t-n;o!==0&&g(...e,o)};K(this,e5,e=>{if(!C(this,I0))return null;if(!e)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(e instanceof r.Tensor))return"input must be a tensor";try{this.tf.getBackend()}catch(t){return"backend not loaded"}return null});K(this,N0,async(e=!1)=>{var t;if(this.config.backend&&this.config.backend.length>0&&e||this.tf.getBackend()!==this.config.backend){let n=N();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&g("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&g("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&g("wasm path:",this.config.wasmPath),typeof((t=this.tf)==null?void 0:t.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let o=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),x=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&g(`wasm execution: ${o?"SIMD":"no SIMD"} ${x?"multithreaded":"singlethreaded"}`),this.config.debug&&!o&&g("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&dA();try{await this.tf.setBackend(this.config.backend)}catch(o){g("error: cannot set backend:",this.config.backend,o)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let o=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&g(`gl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(N()-n)}});this.next=e=>le(e||this.result);K(this,t5,async e=>{if(this.config.cacheSensitivity===0)return!1;let t=32,n=e.resizeBilinear([Math.trunc(e.shape[1]/t),Math.trunc(e.shape[2]/t)]),o=n.dataSync(),x=0;for(let y=0;y10*this.config.cacheSensitivity?0:a),i});K(this,o5,async()=>{let e=(o,x="application/octet-stream")=>fetch(`data:${x};base64,${o}`).then(a=>a.blob()),t,n;switch(this.config.warmup){case"face":t=await e($0);break;case"full":t=await e(A5);break;default:t=null}if(t){let o=await createImageBitmap(t);n=await this.detect(o,this.config),o.close()}return n});K(this,n5,async()=>new Promise(e=>{let t,n=0;switch(this.config.warmup){case"face":n=256,t="data:image/jpeg;base64,"+$0;break;case"full":case"body":n=1200,t="data:image/jpeg;base64,"+A5;break;default:t=null}let o=new Image;o.onload=async()=>{let x=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(n,n):document.createElement("canvas");x.width=o.naturalWidth,x.height=o.naturalHeight;let a=x.getContext("2d");a==null||a.drawImage(o,0,0);let i=await this.detect(x,this.config);e(i)},t?o.src=t:e(null)}));K(this,r5,async()=>{let e=o=>Buffer.from(o,"base64"),t;if(this.config.warmup==="face"&&(t=e($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(t=e(A5)),!t)return null;let n;if(typeof r.node!="undefined"){let o=r.node.decodeJpeg(t),x=o.expandDims(0);this.tf.dispose(o),n=await this.detect(x,this.config),this.tf.dispose(x)}else this.config.debug&&g("Warmup tfjs-node not loaded");return n});this.config=q(yA,e||{}),this.tf=r,this.draw=aA,this.version=de,this.state="idle",_(this,T0,0),_(this,k0,!1),_(this,I0,!1),_(this,d0,!0),_(this,P0,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=t=>l0(t,this.config),this.faceTriangulation=zA,this.faceUVMap=EA,this.sysinfo=lA(),_(this,c0,1)}similarity(e,t){return p5(e,t)}segmentation(e,t){return $A(e,t,this.config)}enhance(e){return b5(e)}match(e,t,n=0){return jA(e,t,n)}async load(e){this.state="load";let t=N();e&&(this.config=q(this.config,e)),C(this,d0)&&(this.config.debug&&g(`version: ${this.version}`),this.config.debug&&g(`tfjs version: ${this.tf.version_core}`),this.config.debug&&g("platform:",this.sysinfo.platform),this.config.debug&&g("agent:",this.sysinfo.agent),await C(this,N0).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&g("configuration:",this.config),this.config.debug&&g("tf flags:",this.tf.ENV.flags))),await Ae(this),C(this,d0)&&(this.config.debug&&g("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),_(this,d0,!1));let n=Math.trunc(N()-t);n>(this.performance.load||0)&&(this.performance.load=n)}async detect(e,t){return new Promise(async n=>{this.state="config";let o,x;this.config=q(this.config,t),this.state="check";let a=C(this,e5).call(this,e);a&&(g(a,e),n({error:a}));let i=N();await C(this,N0).call(this),await this.load(),o=N();let y=l0(e,this.config);if(this.performance.image=Math.trunc(N()-o),this.analyze("Get Image:"),this.config.segmentation.enabled&&y&&y.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",o=N(),await oA(y),x=Math.trunc(N()-o),x>0&&(this.performance.segmentation=x),y.canvas&&(y.tensor.dispose(),y=l0(y.canvas,this.config)),this.analyze("End Segmentation:")),!y||!y.tensor){g("could not convert input to tensor"),n({error:"could not convert input to tensor"});return}o=N(),this.config.skipFrame=await C(this,t5).call(this,y.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(N()-o),this.analyze("Check Changed:");let s,d,l,f;this.config.async?(s=this.config.face.enabled?nA(this,y.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",o=N(),s=this.config.face.enabled?await nA(this,y.tensor):[],x=Math.trunc(N()-o),x>0&&(this.performance.face=x)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?S5(y.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?d=this.config.body.enabled?Z5(y.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?d=this.config.body.enabled?C5(y.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(d=this.config.body.enabled?J5(y.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",o=N(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await S5(y.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?d=this.config.body.enabled?await Z5(y.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?d=this.config.body.enabled?await C5(y.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(d=this.config.body.enabled?await J5(y.tensor,this.config):[]),x=Math.trunc(N()-o),x>0&&(this.performance.body=x)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(l=this.config.hand.enabled?H5(y.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",o=N(),l=this.config.hand.enabled?await H5(y.tensor,this.config):[],x=Math.trunc(N()-o),x>0&&(this.performance.hand=x)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?f=this.config.object.enabled?Q5(y.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(f=this.config.object.enabled?eA(y.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",o=N(),this.config.object.modelPath.includes("nanodet")?f=this.config.object.enabled?await Q5(y.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(f=this.config.object.enabled?await eA(y.tensor,this.config):[]),x=Math.trunc(N()-o),x>0&&(this.performance.object=x)),this.analyze("End Object:"),this.config.async&&([s,d,l,f]=await Promise.all([s,d,l,f]));let u=[];this.config.gesture.enabled&&(o=N(),u=[...te(s),...ee(d),...ne(l),...oe(s)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(N()-o)),this.performance.total=Math.trunc(N()-i),this.state="idle",this.result={face:s,body:d,hand:l,gesture:u,object:f,performance:this.performance,canvas:y.canvas,timestamp:Date.now(),get persons(){var v;return ye(s,d,l,u,(v=y==null?void 0:y.tensor)==null?void 0:v.shape)}},r.dispose(y.tensor),n(this.result)})}async warmup(e){let t=N();if(e&&(this.config=q(this.config,e)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let n;typeof createImageBitmap=="function"?n=await C(this,o5).call(this):typeof Image!="undefined"?n=await C(this,n5).call(this):n=await C(this,r5).call(this);let o=N();return this.config.debug&&g("Warmup",this.config.warmup,Math.round(o-t),"ms",n),n}};T0=new WeakMap,k0=new WeakMap,I0=new WeakMap,d0=new WeakMap,c0=new WeakMap,P0=new WeakMap,e5=new WeakMap,N0=new WeakMap,t5=new WeakMap,o5=new WeakMap,n5=new WeakMap,r5=new WeakMap;export{a2 as Human,a2 as default}; //# sourceMappingURL=human.esm-nobundle.js.map diff --git a/dist/human.esm.js b/dist/human.esm.js index 9b2433f0..edca5c49 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -5358,7 +5358,7 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var rR="2.0.3";var _u,Th,Nh,wi,ki,Du,A0,Ch,x0,b0,v0,w0,_we=class{constructor(t){wr(this,_u,void 0);wr(this,Th,void 0);wr(this,Nh,void 0);wr(this,wi,void 0);wr(this,ki,void 0);wr(this,Du,void 0);this.analyze=(...t)=>{if(!Dn(this,Th))return;let n=this.tf.engine().state.numTensors,r=Dn(this,_u);es(this,_u,n);let s=n-r;s!==0&&fe(...t,s)};wr(this,A0,t=>{if(!Dn(this,Nh))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof It))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});wr(this,Ch,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let r=nt();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&fe("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&fe("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&fe("wasm path:",this.config.wasmPath),typeof((n=this.tf)==null?void 0:n.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let s=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&fe(`wasm execution: ${s?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),this.config.debug&&!s&&fe("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&r$();try{await this.tf.setBackend(this.config.backend)}catch(s){fe("error: cannot set backend:",this.config.backend,s)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(fe("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let s=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&fe(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(nt()-r)}});this.next=t=>nR(t||this.result);wr(this,x0,async t=>{if(this.config.cacheSensitivity===0)return!1;let n=32,r=t.resizeBilinear([Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),s=r.dataSync(),a=0;for(let l=0;l10*this.config.cacheSensitivity?0:o),i});wr(this,b0,async()=>{let t=(s,a="application/octet-stream")=>fetch(`data:${a};base64,${s}`).then(o=>o.blob()),n,r;switch(this.config.warmup){case"face":n=await t(g0);break;case"full":n=await t(y0);break;default:n=null}if(n){let s=await createImageBitmap(n);r=await this.detect(s,this.config),s.close()}return r});wr(this,v0,async()=>new Promise(t=>{let n,r=0;switch(this.config.warmup){case"face":r=256,n="data:image/jpeg;base64,"+g0;break;case"full":case"body":r=1200,n="data:image/jpeg;base64,"+y0;break;default:n=null}let s=new Image;s.onload=async()=>{let a=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(r,r):document.createElement("canvas");a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");o==null||o.drawImage(s,0,0);let i=await this.detect(a,this.config);t(i)},n?s.src=n:t(null)}));wr(this,w0,async()=>{let t=s=>Buffer.from(s,"base64"),n;if(this.config.warmup==="face"&&(n=t(g0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(y0)),!n)return null;let r;if(typeof void 0!="undefined"){let s=(void 0).decodeJpeg(n),a=s.expandDims(0);this.tf.dispose(s),r=await this.detect(a,this.config),this.tf.dispose(a)}else this.config.debug&&fe("Warmup tfjs-node not loaded");return r});this.config=Fn(w3,t||{}),this.tf=Ah,this.draw=o3,this.version=rR,this.state="idle",es(this,_u,0),es(this,Th,!1),es(this,Nh,!1),es(this,wi,!0),es(this,Du,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=n=>vi(n,this.config),this.faceTriangulation=g$,this.faceUVMap=y$,this.sysinfo=k3(),es(this,ki,1)}similarity(t,n){return yb(t,n)}segmentation(t,n){return H$(t,n,this.config)}enhance(t){return Ab(t)}match(t,n,r=0){return x$(t,n,r)}async load(t){this.state="load";let n=nt();t&&(this.config=Fn(this.config,t)),Dn(this,wi)&&(this.config.debug&&fe(`version: ${this.version}`),this.config.debug&&fe(`tfjs version: ${this.tf.version_core}`),this.config.debug&&fe("platform:",this.sysinfo.platform),this.config.debug&&fe("agent:",this.sysinfo.agent),await Dn(this,Ch).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&fe("configuration:",this.config),this.config.debug&&fe("tf flags:",this.tf.ENV.flags))),await G$(this),Dn(this,wi)&&(this.config.debug&&fe("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),es(this,wi,!1));let r=Math.trunc(nt()-n);r>(this.performance.load||0)&&(this.performance.load=r)}async detect(t,n){return new Promise(async r=>{this.state="config";let s,a;this.config=Fn(this.config,n),this.state="check";let o=Dn(this,A0).call(this,t);o&&(fe(o,t),r({error:o}));let i=nt();await Dn(this,Ch).call(this),await this.load(),s=nt();let l=vi(t,this.config);if(this.performance.image=Math.trunc(nt()-s),this.analyze("Get Image:"),this.config.segmentation.enabled&&l&&l.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",s=nt(),await n3(l),a=Math.trunc(nt()-s),a>0&&(this.performance.segmentation=a),l.canvas&&(l.tensor.dispose(),l=vi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l||!l.tensor){fe("could not convert input to tensor"),r({error:"could not convert input to tensor"});return}s=nt(),this.config.skipFrame=await Dn(this,x0).call(this,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(nt()-s),this.analyze("Check Changed:");let u,c,d,h;this.config.async?(u=this.config.face.enabled?r3(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",s=nt(),u=this.config.face.enabled?await r3(this,l.tensor):[],a=Math.trunc(nt()-s),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?Eb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?Pb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?Wb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?jb(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",s=nt(),this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?await Eb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?await Pb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?await Wb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?await jb(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?Mb(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",s=nt(),d=this.config.hand.enabled?await Mb(l.tensor,this.config):[],a=Math.trunc(nt()-s),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?Zb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?e3(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",s=nt(),this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?await Zb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?await e3(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,h]=await Promise.all([u,c,d,h]));let p=[];this.config.gesture.enabled&&(s=nt(),p=[...q$(u),...j$(c),...X$(d),...K$(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(nt()-s)),this.performance.total=Math.trunc(nt()-i),this.state="idle",this.result={face:u,body:c,hand:d,gesture:p,object:h,performance:this.performance,canvas:l.canvas,timestamp:Date.now(),get persons(){var f;return tR(u,c,d,p,(f=l==null?void 0:l.tensor)==null?void 0:f.shape)}},We(l.tensor),r(this.result)})}async warmup(t){let n=nt();if(t&&(this.config=Fn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let r;typeof createImageBitmap=="function"?r=await Dn(this,b0).call(this):typeof Image!="undefined"?r=await Dn(this,v0).call(this):r=await Dn(this,w0).call(this);let s=nt();return this.config.debug&&fe("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};_u=new WeakMap,Th=new WeakMap,Nh=new WeakMap,wi=new WeakMap,ki=new WeakMap,Du=new WeakMap,A0=new WeakMap,Ch=new WeakMap,x0=new WeakMap,b0=new WeakMap,v0=new WeakMap,w0=new WeakMap;export{_we as Human,_we as default}; +2Q==`;var rR="2.1.1";var _u,Th,Nh,wi,ki,Du,A0,Ch,x0,b0,v0,w0,_we=class{constructor(t){wr(this,_u,void 0);wr(this,Th,void 0);wr(this,Nh,void 0);wr(this,wi,void 0);wr(this,ki,void 0);wr(this,Du,void 0);this.analyze=(...t)=>{if(!Dn(this,Th))return;let n=this.tf.engine().state.numTensors,r=Dn(this,_u);es(this,_u,n);let s=n-r;s!==0&&fe(...t,s)};wr(this,A0,t=>{if(!Dn(this,Nh))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof It))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});wr(this,Ch,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let r=nt();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&fe("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&fe("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&fe("wasm path:",this.config.wasmPath),typeof((n=this.tf)==null?void 0:n.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let s=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&fe(`wasm execution: ${s?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),this.config.debug&&!s&&fe("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&r$();try{await this.tf.setBackend(this.config.backend)}catch(s){fe("error: cannot set backend:",this.config.backend,s)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(fe("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let s=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&fe(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(nt()-r)}});this.next=t=>nR(t||this.result);wr(this,x0,async t=>{if(this.config.cacheSensitivity===0)return!1;let n=32,r=t.resizeBilinear([Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),s=r.dataSync(),a=0;for(let l=0;l10*this.config.cacheSensitivity?0:o),i});wr(this,b0,async()=>{let t=(s,a="application/octet-stream")=>fetch(`data:${a};base64,${s}`).then(o=>o.blob()),n,r;switch(this.config.warmup){case"face":n=await t(g0);break;case"full":n=await t(y0);break;default:n=null}if(n){let s=await createImageBitmap(n);r=await this.detect(s,this.config),s.close()}return r});wr(this,v0,async()=>new Promise(t=>{let n,r=0;switch(this.config.warmup){case"face":r=256,n="data:image/jpeg;base64,"+g0;break;case"full":case"body":r=1200,n="data:image/jpeg;base64,"+y0;break;default:n=null}let s=new Image;s.onload=async()=>{let a=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(r,r):document.createElement("canvas");a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");o==null||o.drawImage(s,0,0);let i=await this.detect(a,this.config);t(i)},n?s.src=n:t(null)}));wr(this,w0,async()=>{let t=s=>Buffer.from(s,"base64"),n;if(this.config.warmup==="face"&&(n=t(g0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(y0)),!n)return null;let r;if(typeof void 0!="undefined"){let s=(void 0).decodeJpeg(n),a=s.expandDims(0);this.tf.dispose(s),r=await this.detect(a,this.config),this.tf.dispose(a)}else this.config.debug&&fe("Warmup tfjs-node not loaded");return r});this.config=Fn(w3,t||{}),this.tf=Ah,this.draw=o3,this.version=rR,this.state="idle",es(this,_u,0),es(this,Th,!1),es(this,Nh,!1),es(this,wi,!0),es(this,Du,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=n=>vi(n,this.config),this.faceTriangulation=g$,this.faceUVMap=y$,this.sysinfo=k3(),es(this,ki,1)}similarity(t,n){return yb(t,n)}segmentation(t,n){return H$(t,n,this.config)}enhance(t){return Ab(t)}match(t,n,r=0){return x$(t,n,r)}async load(t){this.state="load";let n=nt();t&&(this.config=Fn(this.config,t)),Dn(this,wi)&&(this.config.debug&&fe(`version: ${this.version}`),this.config.debug&&fe(`tfjs version: ${this.tf.version_core}`),this.config.debug&&fe("platform:",this.sysinfo.platform),this.config.debug&&fe("agent:",this.sysinfo.agent),await Dn(this,Ch).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&fe("configuration:",this.config),this.config.debug&&fe("tf flags:",this.tf.ENV.flags))),await G$(this),Dn(this,wi)&&(this.config.debug&&fe("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),es(this,wi,!1));let r=Math.trunc(nt()-n);r>(this.performance.load||0)&&(this.performance.load=r)}async detect(t,n){return new Promise(async r=>{this.state="config";let s,a;this.config=Fn(this.config,n),this.state="check";let o=Dn(this,A0).call(this,t);o&&(fe(o,t),r({error:o}));let i=nt();await Dn(this,Ch).call(this),await this.load(),s=nt();let l=vi(t,this.config);if(this.performance.image=Math.trunc(nt()-s),this.analyze("Get Image:"),this.config.segmentation.enabled&&l&&l.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",s=nt(),await n3(l),a=Math.trunc(nt()-s),a>0&&(this.performance.segmentation=a),l.canvas&&(l.tensor.dispose(),l=vi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l||!l.tensor){fe("could not convert input to tensor"),r({error:"could not convert input to tensor"});return}s=nt(),this.config.skipFrame=await Dn(this,x0).call(this,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(nt()-s),this.analyze("Check Changed:");let u,c,d,h;this.config.async?(u=this.config.face.enabled?r3(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",s=nt(),u=this.config.face.enabled?await r3(this,l.tensor):[],a=Math.trunc(nt()-s),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?Eb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?Pb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?Wb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?jb(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",s=nt(),this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?await Eb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?await Pb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?await Wb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?await jb(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?Mb(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",s=nt(),d=this.config.hand.enabled?await Mb(l.tensor,this.config):[],a=Math.trunc(nt()-s),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?Zb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?e3(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",s=nt(),this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?await Zb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?await e3(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,h]=await Promise.all([u,c,d,h]));let p=[];this.config.gesture.enabled&&(s=nt(),p=[...q$(u),...j$(c),...X$(d),...K$(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(nt()-s)),this.performance.total=Math.trunc(nt()-i),this.state="idle",this.result={face:u,body:c,hand:d,gesture:p,object:h,performance:this.performance,canvas:l.canvas,timestamp:Date.now(),get persons(){var f;return tR(u,c,d,p,(f=l==null?void 0:l.tensor)==null?void 0:f.shape)}},We(l.tensor),r(this.result)})}async warmup(t){let n=nt();if(t&&(this.config=Fn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let r;typeof createImageBitmap=="function"?r=await Dn(this,b0).call(this):typeof Image!="undefined"?r=await Dn(this,v0).call(this):r=await Dn(this,w0).call(this);let s=nt();return this.config.debug&&fe("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};_u=new WeakMap,Th=new WeakMap,Nh=new WeakMap,wi=new WeakMap,ki=new WeakMap,Du=new WeakMap,A0=new WeakMap,Ch=new WeakMap,x0=new WeakMap,b0=new WeakMap,v0=new WeakMap,w0=new WeakMap;export{_we as Human,_we as default}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/dist/human.js b/dist/human.js index 5a0ebdce..510503b5 100644 --- a/dist/human.js +++ b/dist/human.js @@ -5358,7 +5358,7 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var rR="2.0.3";var _u,Th,Nh,wi,ki,Du,A0,Ch,x0,b0,v0,w0,sR=class{constructor(t){wr(this,_u,void 0);wr(this,Th,void 0);wr(this,Nh,void 0);wr(this,wi,void 0);wr(this,ki,void 0);wr(this,Du,void 0);this.analyze=(...t)=>{if(!Dn(this,Th))return;let n=this.tf.engine().state.numTensors,r=Dn(this,_u);es(this,_u,n);let s=n-r;s!==0&&fe(...t,s)};wr(this,A0,t=>{if(!Dn(this,Nh))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof It))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});wr(this,Ch,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let r=nt();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&fe("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&fe("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&fe("wasm path:",this.config.wasmPath),typeof((n=this.tf)==null?void 0:n.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let s=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&fe(`wasm execution: ${s?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),this.config.debug&&!s&&fe("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&r$();try{await this.tf.setBackend(this.config.backend)}catch(s){fe("error: cannot set backend:",this.config.backend,s)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(fe("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let s=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&fe(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(nt()-r)}});this.next=t=>nR(t||this.result);wr(this,x0,async t=>{if(this.config.cacheSensitivity===0)return!1;let n=32,r=t.resizeBilinear([Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),s=r.dataSync(),a=0;for(let l=0;l10*this.config.cacheSensitivity?0:o),i});wr(this,b0,async()=>{let t=(s,a="application/octet-stream")=>fetch(`data:${a};base64,${s}`).then(o=>o.blob()),n,r;switch(this.config.warmup){case"face":n=await t(g0);break;case"full":n=await t(y0);break;default:n=null}if(n){let s=await createImageBitmap(n);r=await this.detect(s,this.config),s.close()}return r});wr(this,v0,async()=>new Promise(t=>{let n,r=0;switch(this.config.warmup){case"face":r=256,n="data:image/jpeg;base64,"+g0;break;case"full":case"body":r=1200,n="data:image/jpeg;base64,"+y0;break;default:n=null}let s=new Image;s.onload=async()=>{let a=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(r,r):document.createElement("canvas");a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");o==null||o.drawImage(s,0,0);let i=await this.detect(a,this.config);t(i)},n?s.src=n:t(null)}));wr(this,w0,async()=>{let t=s=>Buffer.from(s,"base64"),n;if(this.config.warmup==="face"&&(n=t(g0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(y0)),!n)return null;let r;if(typeof void 0!="undefined"){let s=(void 0).decodeJpeg(n),a=s.expandDims(0);this.tf.dispose(s),r=await this.detect(a,this.config),this.tf.dispose(a)}else this.config.debug&&fe("Warmup tfjs-node not loaded");return r});this.config=Fn(w3,t||{}),this.tf=Ah,this.draw=i3,this.version=rR,this.state="idle",es(this,_u,0),es(this,Th,!1),es(this,Nh,!1),es(this,wi,!0),es(this,Du,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=n=>vi(n,this.config),this.faceTriangulation=g$,this.faceUVMap=y$,this.sysinfo=k3(),es(this,ki,1)}similarity(t,n){return Ab(t,n)}segmentation(t,n){return H$(t,n,this.config)}enhance(t){return xb(t)}match(t,n,r=0){return x$(t,n,r)}async load(t){this.state="load";let n=nt();t&&(this.config=Fn(this.config,t)),Dn(this,wi)&&(this.config.debug&&fe(`version: ${this.version}`),this.config.debug&&fe(`tfjs version: ${this.tf.version_core}`),this.config.debug&&fe("platform:",this.sysinfo.platform),this.config.debug&&fe("agent:",this.sysinfo.agent),await Dn(this,Ch).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&fe("configuration:",this.config),this.config.debug&&fe("tf flags:",this.tf.ENV.flags))),await G$(this),Dn(this,wi)&&(this.config.debug&&fe("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),es(this,wi,!1));let r=Math.trunc(nt()-n);r>(this.performance.load||0)&&(this.performance.load=r)}async detect(t,n){return new Promise(async r=>{this.state="config";let s,a;this.config=Fn(this.config,n),this.state="check";let o=Dn(this,A0).call(this,t);o&&(fe(o,t),r({error:o}));let i=nt();await Dn(this,Ch).call(this),await this.load(),s=nt();let l=vi(t,this.config);if(this.performance.image=Math.trunc(nt()-s),this.analyze("Get Image:"),this.config.segmentation.enabled&&l&&l.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",s=nt(),await r3(l),a=Math.trunc(nt()-s),a>0&&(this.performance.segmentation=a),l.canvas&&(l.tensor.dispose(),l=vi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l||!l.tensor){fe("could not convert input to tensor"),r({error:"could not convert input to tensor"});return}s=nt(),this.config.skipFrame=await Dn(this,x0).call(this,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(nt()-s),this.analyze("Check Changed:");let u,c,d,h;this.config.async?(u=this.config.face.enabled?s3(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",s=nt(),u=this.config.face.enabled?await s3(this,l.tensor):[],a=Math.trunc(nt()-s),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?$b(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?qb(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",s=nt(),this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?await $b(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?await zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?await Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?await qb(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?Ob(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",s=nt(),d=this.config.hand.enabled?await Ob(l.tensor,this.config):[],a=Math.trunc(nt()-s),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?Yb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?t3(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",s=nt(),this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?await Yb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?await t3(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,h]=await Promise.all([u,c,d,h]));let p=[];this.config.gesture.enabled&&(s=nt(),p=[...q$(u),...j$(c),...X$(d),...K$(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(nt()-s)),this.performance.total=Math.trunc(nt()-i),this.state="idle",this.result={face:u,body:c,hand:d,gesture:p,object:h,performance:this.performance,canvas:l.canvas,timestamp:Date.now(),get persons(){var f;return tR(u,c,d,p,(f=l==null?void 0:l.tensor)==null?void 0:f.shape)}},We(l.tensor),r(this.result)})}async warmup(t){let n=nt();if(t&&(this.config=Fn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let r;typeof createImageBitmap=="function"?r=await Dn(this,b0).call(this):typeof Image!="undefined"?r=await Dn(this,v0).call(this):r=await Dn(this,w0).call(this);let s=nt();return this.config.debug&&fe("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};_u=new WeakMap,Th=new WeakMap,Nh=new WeakMap,wi=new WeakMap,ki=new WeakMap,Du=new WeakMap,A0=new WeakMap,Ch=new WeakMap,x0=new WeakMap,b0=new WeakMap,v0=new WeakMap,w0=new WeakMap;return Dwe;})(); +2Q==`;var rR="2.1.1";var _u,Th,Nh,wi,ki,Du,A0,Ch,x0,b0,v0,w0,sR=class{constructor(t){wr(this,_u,void 0);wr(this,Th,void 0);wr(this,Nh,void 0);wr(this,wi,void 0);wr(this,ki,void 0);wr(this,Du,void 0);this.analyze=(...t)=>{if(!Dn(this,Th))return;let n=this.tf.engine().state.numTensors,r=Dn(this,_u);es(this,_u,n);let s=n-r;s!==0&&fe(...t,s)};wr(this,A0,t=>{if(!Dn(this,Nh))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof It))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});wr(this,Ch,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let r=nt();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&fe("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&fe("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&fe("wasm path:",this.config.wasmPath),typeof((n=this.tf)==null?void 0:n.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let s=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&fe(`wasm execution: ${s?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),this.config.debug&&!s&&fe("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&r$();try{await this.tf.setBackend(this.config.backend)}catch(s){fe("error: cannot set backend:",this.config.backend,s)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(fe("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let s=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&fe(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(nt()-r)}});this.next=t=>nR(t||this.result);wr(this,x0,async t=>{if(this.config.cacheSensitivity===0)return!1;let n=32,r=t.resizeBilinear([Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),s=r.dataSync(),a=0;for(let l=0;l10*this.config.cacheSensitivity?0:o),i});wr(this,b0,async()=>{let t=(s,a="application/octet-stream")=>fetch(`data:${a};base64,${s}`).then(o=>o.blob()),n,r;switch(this.config.warmup){case"face":n=await t(g0);break;case"full":n=await t(y0);break;default:n=null}if(n){let s=await createImageBitmap(n);r=await this.detect(s,this.config),s.close()}return r});wr(this,v0,async()=>new Promise(t=>{let n,r=0;switch(this.config.warmup){case"face":r=256,n="data:image/jpeg;base64,"+g0;break;case"full":case"body":r=1200,n="data:image/jpeg;base64,"+y0;break;default:n=null}let s=new Image;s.onload=async()=>{let a=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(r,r):document.createElement("canvas");a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");o==null||o.drawImage(s,0,0);let i=await this.detect(a,this.config);t(i)},n?s.src=n:t(null)}));wr(this,w0,async()=>{let t=s=>Buffer.from(s,"base64"),n;if(this.config.warmup==="face"&&(n=t(g0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(y0)),!n)return null;let r;if(typeof void 0!="undefined"){let s=(void 0).decodeJpeg(n),a=s.expandDims(0);this.tf.dispose(s),r=await this.detect(a,this.config),this.tf.dispose(a)}else this.config.debug&&fe("Warmup tfjs-node not loaded");return r});this.config=Fn(w3,t||{}),this.tf=Ah,this.draw=i3,this.version=rR,this.state="idle",es(this,_u,0),es(this,Th,!1),es(this,Nh,!1),es(this,wi,!0),es(this,Du,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=n=>vi(n,this.config),this.faceTriangulation=g$,this.faceUVMap=y$,this.sysinfo=k3(),es(this,ki,1)}similarity(t,n){return Ab(t,n)}segmentation(t,n){return H$(t,n,this.config)}enhance(t){return xb(t)}match(t,n,r=0){return x$(t,n,r)}async load(t){this.state="load";let n=nt();t&&(this.config=Fn(this.config,t)),Dn(this,wi)&&(this.config.debug&&fe(`version: ${this.version}`),this.config.debug&&fe(`tfjs version: ${this.tf.version_core}`),this.config.debug&&fe("platform:",this.sysinfo.platform),this.config.debug&&fe("agent:",this.sysinfo.agent),await Dn(this,Ch).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&fe("configuration:",this.config),this.config.debug&&fe("tf flags:",this.tf.ENV.flags))),await G$(this),Dn(this,wi)&&(this.config.debug&&fe("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),es(this,wi,!1));let r=Math.trunc(nt()-n);r>(this.performance.load||0)&&(this.performance.load=r)}async detect(t,n){return new Promise(async r=>{this.state="config";let s,a;this.config=Fn(this.config,n),this.state="check";let o=Dn(this,A0).call(this,t);o&&(fe(o,t),r({error:o}));let i=nt();await Dn(this,Ch).call(this),await this.load(),s=nt();let l=vi(t,this.config);if(this.performance.image=Math.trunc(nt()-s),this.analyze("Get Image:"),this.config.segmentation.enabled&&l&&l.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",s=nt(),await r3(l),a=Math.trunc(nt()-s),a>0&&(this.performance.segmentation=a),l.canvas&&(l.tensor.dispose(),l=vi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l||!l.tensor){fe("could not convert input to tensor"),r({error:"could not convert input to tensor"});return}s=nt(),this.config.skipFrame=await Dn(this,x0).call(this,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(nt()-s),this.analyze("Check Changed:");let u,c,d,h;this.config.async?(u=this.config.face.enabled?s3(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",s=nt(),u=this.config.face.enabled?await s3(this,l.tensor):[],a=Math.trunc(nt()-s),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?$b(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?qb(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",s=nt(),this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?await $b(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?await zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?await Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?await qb(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?Ob(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",s=nt(),d=this.config.hand.enabled?await Ob(l.tensor,this.config):[],a=Math.trunc(nt()-s),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?Yb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?t3(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",s=nt(),this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?await Yb(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?await t3(l.tensor,this.config):[]),a=Math.trunc(nt()-s),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,h]=await Promise.all([u,c,d,h]));let p=[];this.config.gesture.enabled&&(s=nt(),p=[...q$(u),...j$(c),...X$(d),...K$(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(nt()-s)),this.performance.total=Math.trunc(nt()-i),this.state="idle",this.result={face:u,body:c,hand:d,gesture:p,object:h,performance:this.performance,canvas:l.canvas,timestamp:Date.now(),get persons(){var f;return tR(u,c,d,p,(f=l==null?void 0:l.tensor)==null?void 0:f.shape)}},We(l.tensor),r(this.result)})}async warmup(t){let n=nt();if(t&&(this.config=Fn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let r;typeof createImageBitmap=="function"?r=await Dn(this,b0).call(this):typeof Image!="undefined"?r=await Dn(this,v0).call(this):r=await Dn(this,w0).call(this);let s=nt();return this.config.debug&&fe("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};_u=new WeakMap,Th=new WeakMap,Nh=new WeakMap,wi=new WeakMap,ki=new WeakMap,Du=new WeakMap,A0=new WeakMap,Ch=new WeakMap,x0=new WeakMap,b0=new WeakMap,v0=new WeakMap,w0=new WeakMap;return Dwe;})(); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/dist/human.node-gpu.js b/dist/human.node-gpu.js index 7b670ac2..8e0a9fd2 100644 --- a/dist/human.node-gpu.js +++ b/dist/human.node-gpu.js @@ -11325,7 +11325,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "2.0.3"; +var version = "2.1.1"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _lastInputSum, _lastCacheDiff, _sanity, _checkBackend, _skipFrame, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/dist/human.node-wasm.js b/dist/human.node-wasm.js index 9d7f580a..6c9c8470 100644 --- a/dist/human.node-wasm.js +++ b/dist/human.node-wasm.js @@ -11326,7 +11326,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "2.0.3"; +var version = "2.1.1"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _lastInputSum, _lastCacheDiff, _sanity, _checkBackend, _skipFrame, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/dist/human.node.js b/dist/human.node.js index 2b47dc61..9360c225 100644 --- a/dist/human.node.js +++ b/dist/human.node.js @@ -11325,7 +11325,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "2.0.3"; +var version = "2.1.1"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _lastInputSum, _lastCacheDiff, _sanity, _checkBackend, _skipFrame, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/server/build.log b/server/build.log index 18184e33..b763a12a 100644 --- a/server/build.log +++ b/server/build.log @@ -1,22 +1,22 @@ -2021-07-29 10:49:34 INFO:  @vladmandic/human version 2.0.3 -2021-07-29 10:49:34 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0 -2021-07-29 10:49:34 INFO:  Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.16","typescript":"4.3.5","typedoc":"0.21.4","eslint":"7.31.0"} -2021-07-29 10:49:34 INFO:  Clean: ["dist/*","types/*","typedoc/*"] -2021-07-29 10:49:34 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} -2021-07-29 10:49:34 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"} -2021-07-29 10:49:34 STATE: target: node type: node: {"imports":42,"importBytes":433972,"outputBytes":377240,"outputFiles":"dist/human.node.js"} -2021-07-29 10:49:34 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"} -2021-07-29 10:49:34 STATE: target: nodeGPU type: node: {"imports":42,"importBytes":433980,"outputBytes":377244,"outputFiles":"dist/human.node-gpu.js"} -2021-07-29 10:49:34 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"} -2021-07-29 10:49:34 STATE: target: nodeWASM type: node: {"imports":42,"importBytes":434047,"outputBytes":377316,"outputFiles":"dist/human.node-wasm.js"} -2021-07-29 10:49:34 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2817,"outputBytes":1214,"outputFiles":"dist/tfjs.esm.js"} -2021-07-29 10:49:34 STATE: target: browserNoBundle type: esm: {"imports":42,"importBytes":433883,"outputBytes":247685,"outputFiles":"dist/human.esm-nobundle.js"} -2021-07-29 10:49:35 STATE: target: browserBundle type: tfjs: {"modules":1552,"moduleBytes":5630928,"imports":7,"importBytes":2817,"outputBytes":2817976,"outputFiles":"dist/tfjs.esm.js"} -2021-07-29 10:49:35 STATE: target: browserBundle type: iife: {"imports":42,"importBytes":3250645,"outputBytes":1599157,"outputFiles":"dist/human.js"} -2021-07-29 10:49:36 STATE: target: browserBundle type: esm: {"imports":42,"importBytes":3250645,"outputBytes":1599149,"outputFiles":"dist/human.esm.js"} -2021-07-29 10:49:36 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"] -2021-07-29 10:50:01 INFO:  Linter complete: files: 74 errors: 0 warnings: 0 -2021-07-29 10:50:01 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"] -2021-07-29 10:50:01 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"] -2021-07-29 10:50:17 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"] -2021-07-29 10:50:31 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1 +2021-07-29 11:02:04 INFO:  @vladmandic/human version 2.1.1 +2021-07-29 11:02:04 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0 +2021-07-29 11:02:04 INFO:  Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.16","typescript":"4.3.5","typedoc":"0.21.4","eslint":"7.31.0"} +2021-07-29 11:02:04 INFO:  Clean: ["dist/*","types/*","typedoc/*"] +2021-07-29 11:02:04 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} +2021-07-29 11:02:04 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"} +2021-07-29 11:02:04 STATE: target: node type: node: {"imports":42,"importBytes":433972,"outputBytes":377240,"outputFiles":"dist/human.node.js"} +2021-07-29 11:02:04 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"} +2021-07-29 11:02:05 STATE: target: nodeGPU type: node: {"imports":42,"importBytes":433980,"outputBytes":377244,"outputFiles":"dist/human.node-gpu.js"} +2021-07-29 11:02:05 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"} +2021-07-29 11:02:05 STATE: target: nodeWASM type: node: {"imports":42,"importBytes":434047,"outputBytes":377316,"outputFiles":"dist/human.node-wasm.js"} +2021-07-29 11:02:05 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2817,"outputBytes":1214,"outputFiles":"dist/tfjs.esm.js"} +2021-07-29 11:02:05 STATE: target: browserNoBundle type: esm: {"imports":42,"importBytes":433883,"outputBytes":247685,"outputFiles":"dist/human.esm-nobundle.js"} +2021-07-29 11:02:05 STATE: target: browserBundle type: tfjs: {"modules":1552,"moduleBytes":5630928,"imports":7,"importBytes":2817,"outputBytes":2817976,"outputFiles":"dist/tfjs.esm.js"} +2021-07-29 11:02:06 STATE: target: browserBundle type: iife: {"imports":42,"importBytes":3250645,"outputBytes":1599157,"outputFiles":"dist/human.js"} +2021-07-29 11:02:06 STATE: target: browserBundle type: esm: {"imports":42,"importBytes":3250645,"outputBytes":1599149,"outputFiles":"dist/human.esm.js"} +2021-07-29 11:02:06 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"] +2021-07-29 11:02:31 INFO:  Linter complete: files: 74 errors: 0 warnings: 0 +2021-07-29 11:02:31 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"] +2021-07-29 11:02:31 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"] +2021-07-29 11:02:46 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"] +2021-07-29 11:03:02 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1