diff --git a/CHANGELOG.md b/CHANGELOG.md index 99211584..d65c100a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # @vladmandic/human -Version: **1.8.1** +Version: **1.8.2** 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,14 @@ Repository: **** ## Changelog +### **1.8.2** 2021/05/04 mandic00@live.com + + +### **release 1.8 with major changes and tfjs 3.6.0** 2021/04/30 mandic00@live.com + + ### **1.8.1** 2021/04/30 mandic00@live.com - -### **origin/main** 2021/04/28 mandic00@live.com - - blazeface optimizations - add hand labels in draw - cleanup demo workflow diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index a0212109..08a6b040 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -731,5 +731,5 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var qA="1.8.1";var y0,u0,p0,s0,B0,b0,C0,U0,Y0,E2=class{constructor(e={}){y0.set(this,void 0);u0.set(this,void 0);p0.set(this,void 0);s0.set(this,void 0);this.analyze=(...e)=>{if(!B(this,u0))return;let n=this.tf.engine().state.numTensors,s=B(this,y0);e0(this,y0,n);let o=n-s;o!==0&&b(...e,o)};B0.set(this,e=>{if(!B(this,p0))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(n){return"backend not loaded"}return null});b0.set(this,async(e=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&e||this.tf.getBackend()!==this.config.backend){let s=S();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&b("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&&b("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&b("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 o=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),i=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&b(`wasm execution: ${o?"SIMD":"no SIMD"} ${i?"multithreaded":"singlethreaded"}`),this.config.debug&&!o&&b("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&D5();try{await this.tf.setBackend(this.config.backend)}catch(o){b("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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(b("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&&b(`gl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(S()-s)}});C0.set(this,async()=>{let e=(o,i="application/octet-stream")=>fetch(`data:${i};base64,${o}`).then(t=>t.blob()),n,s;switch(this.config.warmup){case"face":n=await e(F0);break;case"full":n=await e(q0);break;default:n=null}if(n){let o=await createImageBitmap(n);s=await this.detect(o,this.config),o.close()}return s});U0.set(this,async()=>new Promise(e=>{let n,s=0;switch(this.config.warmup){case"face":s=256,n="data:image/jpeg;base64,"+F0;break;case"full":case"body":s=1200,n="data:image/jpeg;base64,"+q0;break;default:n=null}let o=new Image;o.onload=async()=>{let i=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(s,s):document.createElement("canvas");i.width=o.naturalWidth,i.height=o.naturalHeight;let t=i.getContext("2d");t==null||t.drawImage(o,0,0);let a=await this.detect(i,this.config);e(a)},n?o.src=n:e(null)}));Y0.set(this,async()=>{let e=o=>Buffer.from(o,"base64"),n;if(this.config.warmup==="face"&&(n=e(F0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=e(q0)),!n)return null;let s;if(typeof r.node!="undefined"){let o=r.node.decodeJpeg(n),i=o.expandDims(0);this.tf.dispose(o),s=await this.detect(i,this.config),this.tf.dispose(i)}else this.config.debug&&b("Warmup tfjs-node not loaded");return s});this.tf=r,this.draw=Z5,this.version=qA,this.config=F(w,e),this.state="idle",e0(this,y0,0),e0(this,u0,!1),e0(this,p0,!1),e0(this,s0,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>L5(n,this.config),this.classes={facemesh:A5,emotion:o5,faceres:a5,body:this.config.body.modelPath.includes("posenet")?p5:j5,hand:v5,nanodet:W5},this.faceTriangulation=rA,this.faceUVMap=aA,this.sysinfo=B5()}similarity(e,n){return y5(e,n)}enhance(e){return l5(e)}match(e,n,s=0){return xA(e,n,s)}async load(e={}){this.state="load";let n=S();e&&(this.config=F(this.config,e)),B(this,s0)&&(this.config.debug&&b(`version: ${this.version}`),this.config.debug&&b(`tfjs version: ${this.tf.version_core}`),this.config.debug&&b("platform:",this.sysinfo.platform),this.config.debug&&b("agent:",this.sysinfo.agent),await B(this,b0).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&b("configuration:",this.config),this.config.debug&&b("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?n5(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?r5(this.config):null),this.models.handpose||(this.config.hand.enabled?R5(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?g5(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?S5(this.config):null),this.models.nanodet||(this.config.object.enabled?I5(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?x5(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await n5(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await r5(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await R5(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await g5(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await S5(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await I5(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await x5(this.config))),B(this,s0)&&(this.config.debug&&b("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),e0(this,s0,!1));let s=Math.trunc(S()-n);s>(this.perf.load||0)&&(this.perf.load=s)}async detect(e,n={}){return new Promise(async s=>{this.state="config";let o;this.config=F(this.config,n),this.state="check";let i=B(this,B0).call(this,e);i&&(b(i,e),s({error:i}));let t=S();await B(this,b0).call(this),await this.load();let a;e&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof Image!="undefined"&&e instanceof Image||typeof ImageData!="undefined"&&e instanceof ImageData||typeof ImageBitmap!="undefined"&&O5 instanceof ImageBitmap)&&(b("disabling video optimization"),a=this.config.videoOptimized,this.config.videoOptimized=!1),o=S();let x=L5(e,this.config);if(!x||!x.tensor){b("could not convert input to tensor"),s({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(S()-o),this.analyze("Get Image:");let l,d,y,u,p;this.config.async?(y=this.config.face.enabled?c5(this,x.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",o=S(),y=this.config.face.enabled?await c5(this,x.tensor):[],p=Math.trunc(S()-o),p>0&&(this.perf.face=p)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?l=this.config.body.enabled?b5(x.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(l=this.config.body.enabled?w5(x.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",o=S(),this.config.body.modelPath.includes("posenet")?l=this.config.body.enabled?await b5(x.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(l=this.config.body.enabled?await w5(x.tensor,this.config):[]),p=Math.trunc(S()-o),p>0&&(this.perf.body=p)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?E5(x.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",o=S(),d=this.config.hand.enabled?await E5(x.tensor,this.config):[],p=Math.trunc(S()-o),p>0&&(this.perf.hand=p)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(u=this.config.object.enabled?k5(x.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",o=S(),u=this.config.object.enabled?await k5(x.tensor,this.config):[],p=Math.trunc(S()-o),p>0&&(this.perf.object=p)),this.analyze("End Object:"),this.config.async&&([y,l,d,u]=await Promise.all([y,l,d,u])),r.dispose(x.tensor);let E=[];this.config.gesture.enabled&&(o=S(),E=[...IA(y),...NA(l),...OA(d),...kA(y)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(S()-o)),a&&(this.config.videoOptimized=a),this.perf.total=Math.trunc(S()-t),this.state="idle";let c={face:y,body:l,hand:d,gesture:E,object:u,performance:this.perf,canvas:x.canvas};s(c)})}async warmup(e={}){let n=S();if(e&&(this.config=F(this.config,e)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let s=this.config.videoOptimized;this.config.videoOptimized=!1;let o;typeof createImageBitmap=="function"?o=await B(this,C0).call(this):typeof Image!="undefined"?o=await B(this,U0).call(this):o=await B(this,Y0).call(this),this.config.videoOptimized=s;let i=S();return this.config.debug&&b("Warmup",this.config.warmup,Math.round(i-n),"ms",o),o}};y0=new WeakMap,u0=new WeakMap,p0=new WeakMap,s0=new WeakMap,B0=new WeakMap,b0=new WeakMap,C0=new WeakMap,U0=new WeakMap,Y0=new WeakMap;export{E2 as Human,E2 as default}; +2Q==`;var qA="1.8.2";var y0,u0,p0,s0,B0,b0,C0,U0,Y0,E2=class{constructor(e={}){y0.set(this,void 0);u0.set(this,void 0);p0.set(this,void 0);s0.set(this,void 0);this.analyze=(...e)=>{if(!B(this,u0))return;let n=this.tf.engine().state.numTensors,s=B(this,y0);e0(this,y0,n);let o=n-s;o!==0&&b(...e,o)};B0.set(this,e=>{if(!B(this,p0))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(n){return"backend not loaded"}return null});b0.set(this,async(e=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&e||this.tf.getBackend()!==this.config.backend){let s=S();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&b("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&&b("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&b("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 o=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),i=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&b(`wasm execution: ${o?"SIMD":"no SIMD"} ${i?"multithreaded":"singlethreaded"}`),this.config.debug&&!o&&b("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&D5();try{await this.tf.setBackend(this.config.backend)}catch(o){b("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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(b("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&&b(`gl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(S()-s)}});C0.set(this,async()=>{let e=(o,i="application/octet-stream")=>fetch(`data:${i};base64,${o}`).then(t=>t.blob()),n,s;switch(this.config.warmup){case"face":n=await e(F0);break;case"full":n=await e(q0);break;default:n=null}if(n){let o=await createImageBitmap(n);s=await this.detect(o,this.config),o.close()}return s});U0.set(this,async()=>new Promise(e=>{let n,s=0;switch(this.config.warmup){case"face":s=256,n="data:image/jpeg;base64,"+F0;break;case"full":case"body":s=1200,n="data:image/jpeg;base64,"+q0;break;default:n=null}let o=new Image;o.onload=async()=>{let i=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(s,s):document.createElement("canvas");i.width=o.naturalWidth,i.height=o.naturalHeight;let t=i.getContext("2d");t==null||t.drawImage(o,0,0);let a=await this.detect(i,this.config);e(a)},n?o.src=n:e(null)}));Y0.set(this,async()=>{let e=o=>Buffer.from(o,"base64"),n;if(this.config.warmup==="face"&&(n=e(F0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=e(q0)),!n)return null;let s;if(typeof r.node!="undefined"){let o=r.node.decodeJpeg(n),i=o.expandDims(0);this.tf.dispose(o),s=await this.detect(i,this.config),this.tf.dispose(i)}else this.config.debug&&b("Warmup tfjs-node not loaded");return s});this.tf=r,this.draw=Z5,this.version=qA,this.config=F(w,e),this.state="idle",e0(this,y0,0),e0(this,u0,!1),e0(this,p0,!1),e0(this,s0,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>L5(n,this.config),this.classes={facemesh:A5,emotion:o5,faceres:a5,body:this.config.body.modelPath.includes("posenet")?p5:j5,hand:v5,nanodet:W5},this.faceTriangulation=rA,this.faceUVMap=aA,this.sysinfo=B5()}similarity(e,n){return y5(e,n)}enhance(e){return l5(e)}match(e,n,s=0){return xA(e,n,s)}async load(e={}){this.state="load";let n=S();e&&(this.config=F(this.config,e)),B(this,s0)&&(this.config.debug&&b(`version: ${this.version}`),this.config.debug&&b(`tfjs version: ${this.tf.version_core}`),this.config.debug&&b("platform:",this.sysinfo.platform),this.config.debug&&b("agent:",this.sysinfo.agent),await B(this,b0).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&b("configuration:",this.config),this.config.debug&&b("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?n5(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?r5(this.config):null),this.models.handpose||(this.config.hand.enabled?R5(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?g5(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?S5(this.config):null),this.models.nanodet||(this.config.object.enabled?I5(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?x5(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await n5(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await r5(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await R5(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await g5(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await S5(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await I5(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await x5(this.config))),B(this,s0)&&(this.config.debug&&b("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),e0(this,s0,!1));let s=Math.trunc(S()-n);s>(this.perf.load||0)&&(this.perf.load=s)}async detect(e,n={}){return new Promise(async s=>{this.state="config";let o;this.config=F(this.config,n),this.state="check";let i=B(this,B0).call(this,e);i&&(b(i,e),s({error:i}));let t=S();await B(this,b0).call(this),await this.load();let a;e&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof Image!="undefined"&&e instanceof Image||typeof ImageData!="undefined"&&e instanceof ImageData||typeof ImageBitmap!="undefined"&&O5 instanceof ImageBitmap)&&(b("disabling video optimization"),a=this.config.videoOptimized,this.config.videoOptimized=!1),o=S();let x=L5(e,this.config);if(!x||!x.tensor){b("could not convert input to tensor"),s({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(S()-o),this.analyze("Get Image:");let l,d,y,u,p;this.config.async?(y=this.config.face.enabled?c5(this,x.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",o=S(),y=this.config.face.enabled?await c5(this,x.tensor):[],p=Math.trunc(S()-o),p>0&&(this.perf.face=p)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?l=this.config.body.enabled?b5(x.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(l=this.config.body.enabled?w5(x.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",o=S(),this.config.body.modelPath.includes("posenet")?l=this.config.body.enabled?await b5(x.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(l=this.config.body.enabled?await w5(x.tensor,this.config):[]),p=Math.trunc(S()-o),p>0&&(this.perf.body=p)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?E5(x.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",o=S(),d=this.config.hand.enabled?await E5(x.tensor,this.config):[],p=Math.trunc(S()-o),p>0&&(this.perf.hand=p)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(u=this.config.object.enabled?k5(x.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",o=S(),u=this.config.object.enabled?await k5(x.tensor,this.config):[],p=Math.trunc(S()-o),p>0&&(this.perf.object=p)),this.analyze("End Object:"),this.config.async&&([y,l,d,u]=await Promise.all([y,l,d,u])),r.dispose(x.tensor);let E=[];this.config.gesture.enabled&&(o=S(),E=[...IA(y),...NA(l),...OA(d),...kA(y)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(S()-o)),a&&(this.config.videoOptimized=a),this.perf.total=Math.trunc(S()-t),this.state="idle";let c={face:y,body:l,hand:d,gesture:E,object:u,performance:this.perf,canvas:x.canvas};s(c)})}async warmup(e={}){let n=S();if(e&&(this.config=F(this.config,e)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let s=this.config.videoOptimized;this.config.videoOptimized=!1;let o;typeof createImageBitmap=="function"?o=await B(this,C0).call(this):typeof Image!="undefined"?o=await B(this,U0).call(this):o=await B(this,Y0).call(this),this.config.videoOptimized=s;let i=S();return this.config.debug&&b("Warmup",this.config.warmup,Math.round(i-n),"ms",o),o}};y0=new WeakMap,u0=new WeakMap,p0=new WeakMap,s0=new WeakMap,B0=new WeakMap,b0=new WeakMap,C0=new WeakMap,U0=new WeakMap,Y0=new WeakMap;export{E2 as Human,E2 as default}; //# sourceMappingURL=human.esm-nobundle.js.map diff --git a/dist/human.esm.js b/dist/human.esm.js index 1861d85c..65c16b0e 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -4974,7 +4974,7 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var Kk="1.8.1";var Ql,Jd,Qd,Li,O0,ep,z0,_0,P0,Zie=class{constructor(t={}){Ql.set(this,void 0);Jd.set(this,void 0);Qd.set(this,void 0);Li.set(this,void 0);this.analyze=(...t)=>{if(!aa(this,Jd))return;let n=this.tf.engine().state.numTensors,a=aa(this,Ql);rs(this,Ql,n);let r=n-a;r!==0&&he(...t,r)};O0.set(this,t=>{if(!aa(this,Qd))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof Le))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ep.set(this,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let a=it();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&he("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&&he("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&he("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 r=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&he(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),this.config.debug&&!r&&he("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&nk();try{await this.tf.setBackend(this.config.backend)}catch(r){he("error: cannot set backend:",this.config.backend,r)}}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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(he("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let r=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&he(`gl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(it()-a)}});z0.set(this,async()=>{let t=(r,s="application/octet-stream")=>fetch(`data:${s};base64,${r}`).then(i=>i.blob()),n,a;switch(this.config.warmup){case"face":n=await t($0);break;case"full":n=await t(D0);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await this.detect(r,this.config),r.close()}return a});_0.set(this,async()=>new Promise(t=>{let n,a=0;switch(this.config.warmup){case"face":a=256,n="data:image/jpeg;base64,"+$0;break;case"full":case"body":a=1200,n="data:image/jpeg;base64,"+D0;break;default:n=null}let r=new Image;r.onload=async()=>{let s=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,a):document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight;let i=s.getContext("2d");i==null||i.drawImage(r,0,0);let o=await this.detect(s,this.config);t(o)},n?r.src=n:t(null)}));P0.set(this,async()=>{let t=r=>Buffer.from(r,"base64"),n;if(this.config.warmup==="face"&&(n=t($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(D0)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);this.tf.dispose(r),a=await this.detect(s,this.config),this.tf.dispose(s)}else this.config.debug&&he("Warmup tfjs-node not loaded");return a});this.tf=pu,this.draw=kg,this.version=Kk,this.config=Gn(dt,t),this.state="idle",rs(this,Ql,0),rs(this,Jd,!1),rs(this,Qd,!1),rs(this,Li,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>wg(n,this.config),this.classes={facemesh:W2,emotion:U2,faceres:X2,body:this.config.body.modelPath.includes("posenet")?rg:fg,hand:pg,nanodet:yg},this.faceTriangulation=fk,this.faceUVMap=mk,this.sysinfo=Pg()}similarity(t,n){return Z2(t,n)}enhance(t){return Y2(t)}match(t,n,a=0){return Ak(t,n,a)}async load(t={}){this.state="load";let n=it();t&&(this.config=Gn(this.config,t)),aa(this,Li)&&(this.config.debug&&he(`version: ${this.version}`),this.config.debug&&he(`tfjs version: ${this.tf.version_core}`),this.config.debug&&he("platform:",this.sysinfo.platform),this.config.debug&&he("agent:",this.sysinfo.agent),await aa(this,ep).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&he("configuration:",this.config),this.config.debug&&he("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?j2(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?q2(this.config):null),this.models.handpose||(this.config.hand.enabled?hg(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?ig(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?mg(this.config):null),this.models.nanodet||(this.config.object.enabled?xg(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?K2(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await j2(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await q2(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await hg(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await ig(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await mg(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await xg(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await K2(this.config))),aa(this,Li)&&(this.config.debug&&he("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),rs(this,Li,!1));let a=Math.trunc(it()-n);a>(this.perf.load||0)&&(this.perf.load=a)}async detect(t,n={}){return new Promise(async a=>{this.state="config";let r;this.config=Gn(this.config,n),this.state="check";let s=aa(this,O0).call(this,t);s&&(he(s,t),a({error:s}));let i=it();await aa(this,ep).call(this),await this.load();let o;t&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof Image!="undefined"&&t instanceof Image||typeof ImageData!="undefined"&&t instanceof ImageData||typeof ImageBitmap!="undefined"&&vg instanceof ImageBitmap)&&(he("disabling video optimization"),o=this.config.videoOptimized,this.config.videoOptimized=!1),r=it();let l=wg(t,this.config);if(!l||!l.tensor){he("could not convert input to tensor"),a({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(it()-r),this.analyze("Get Image:");let d,u,p,c,h;this.config.async?(p=this.config.face.enabled?J2(this,l.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",r=it(),p=this.config.face.enabled?await J2(this,l.tensor):[],h=Math.trunc(it()-r),h>0&&(this.perf.face=h)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?Ag(l.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",r=it(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?await Ag(l.tensor,this.config):[]),h=Math.trunc(it()-r),h>0&&(this.perf.body=h)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(u=this.config.hand.enabled?cg(l.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",r=it(),u=this.config.hand.enabled?await cg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.hand=h)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(c=this.config.object.enabled?bg(l.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",r=it(),c=this.config.object.enabled?await bg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.object=h)),this.analyze("End Object:"),this.config.async&&([p,d,u,c]=await Promise.all([p,d,u,c])),Ee(l.tensor);let m=[];this.config.gesture.enabled&&(r=it(),m=[...Wk(p),...Lk(d),...Vk(u),...Bk(p)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(it()-r)),o&&(this.config.videoOptimized=o),this.perf.total=Math.trunc(it()-i),this.state="idle";let f={face:p,body:d,hand:u,gesture:m,object:c,performance:this.perf,canvas:l.canvas};a(f)})}async warmup(t={}){let n=it();if(t&&(this.config=Gn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let a=this.config.videoOptimized;this.config.videoOptimized=!1;let r;typeof createImageBitmap=="function"?r=await aa(this,z0).call(this):typeof Image!="undefined"?r=await aa(this,_0).call(this):r=await aa(this,P0).call(this),this.config.videoOptimized=a;let s=it();return this.config.debug&&he("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};Ql=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,Li=new WeakMap,O0=new WeakMap,ep=new WeakMap,z0=new WeakMap,_0=new WeakMap,P0=new WeakMap;export{Zie as Human,Zie as default}; +2Q==`;var Kk="1.8.2";var Ql,Jd,Qd,Li,O0,ep,z0,_0,P0,Zie=class{constructor(t={}){Ql.set(this,void 0);Jd.set(this,void 0);Qd.set(this,void 0);Li.set(this,void 0);this.analyze=(...t)=>{if(!aa(this,Jd))return;let n=this.tf.engine().state.numTensors,a=aa(this,Ql);rs(this,Ql,n);let r=n-a;r!==0&&he(...t,r)};O0.set(this,t=>{if(!aa(this,Qd))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof Le))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ep.set(this,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let a=it();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&he("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&&he("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&he("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 r=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&he(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),this.config.debug&&!r&&he("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&nk();try{await this.tf.setBackend(this.config.backend)}catch(r){he("error: cannot set backend:",this.config.backend,r)}}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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(he("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let r=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&he(`gl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(it()-a)}});z0.set(this,async()=>{let t=(r,s="application/octet-stream")=>fetch(`data:${s};base64,${r}`).then(i=>i.blob()),n,a;switch(this.config.warmup){case"face":n=await t($0);break;case"full":n=await t(D0);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await this.detect(r,this.config),r.close()}return a});_0.set(this,async()=>new Promise(t=>{let n,a=0;switch(this.config.warmup){case"face":a=256,n="data:image/jpeg;base64,"+$0;break;case"full":case"body":a=1200,n="data:image/jpeg;base64,"+D0;break;default:n=null}let r=new Image;r.onload=async()=>{let s=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,a):document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight;let i=s.getContext("2d");i==null||i.drawImage(r,0,0);let o=await this.detect(s,this.config);t(o)},n?r.src=n:t(null)}));P0.set(this,async()=>{let t=r=>Buffer.from(r,"base64"),n;if(this.config.warmup==="face"&&(n=t($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(D0)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);this.tf.dispose(r),a=await this.detect(s,this.config),this.tf.dispose(s)}else this.config.debug&&he("Warmup tfjs-node not loaded");return a});this.tf=pu,this.draw=kg,this.version=Kk,this.config=Gn(dt,t),this.state="idle",rs(this,Ql,0),rs(this,Jd,!1),rs(this,Qd,!1),rs(this,Li,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>wg(n,this.config),this.classes={facemesh:W2,emotion:U2,faceres:X2,body:this.config.body.modelPath.includes("posenet")?rg:fg,hand:pg,nanodet:yg},this.faceTriangulation=fk,this.faceUVMap=mk,this.sysinfo=Pg()}similarity(t,n){return Z2(t,n)}enhance(t){return Y2(t)}match(t,n,a=0){return Ak(t,n,a)}async load(t={}){this.state="load";let n=it();t&&(this.config=Gn(this.config,t)),aa(this,Li)&&(this.config.debug&&he(`version: ${this.version}`),this.config.debug&&he(`tfjs version: ${this.tf.version_core}`),this.config.debug&&he("platform:",this.sysinfo.platform),this.config.debug&&he("agent:",this.sysinfo.agent),await aa(this,ep).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&he("configuration:",this.config),this.config.debug&&he("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?j2(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?q2(this.config):null),this.models.handpose||(this.config.hand.enabled?hg(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?ig(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?mg(this.config):null),this.models.nanodet||(this.config.object.enabled?xg(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?K2(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await j2(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await q2(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await hg(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await ig(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await mg(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await xg(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await K2(this.config))),aa(this,Li)&&(this.config.debug&&he("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),rs(this,Li,!1));let a=Math.trunc(it()-n);a>(this.perf.load||0)&&(this.perf.load=a)}async detect(t,n={}){return new Promise(async a=>{this.state="config";let r;this.config=Gn(this.config,n),this.state="check";let s=aa(this,O0).call(this,t);s&&(he(s,t),a({error:s}));let i=it();await aa(this,ep).call(this),await this.load();let o;t&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof Image!="undefined"&&t instanceof Image||typeof ImageData!="undefined"&&t instanceof ImageData||typeof ImageBitmap!="undefined"&&vg instanceof ImageBitmap)&&(he("disabling video optimization"),o=this.config.videoOptimized,this.config.videoOptimized=!1),r=it();let l=wg(t,this.config);if(!l||!l.tensor){he("could not convert input to tensor"),a({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(it()-r),this.analyze("Get Image:");let d,u,p,c,h;this.config.async?(p=this.config.face.enabled?J2(this,l.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",r=it(),p=this.config.face.enabled?await J2(this,l.tensor):[],h=Math.trunc(it()-r),h>0&&(this.perf.face=h)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?Ag(l.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",r=it(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?await Ag(l.tensor,this.config):[]),h=Math.trunc(it()-r),h>0&&(this.perf.body=h)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(u=this.config.hand.enabled?cg(l.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",r=it(),u=this.config.hand.enabled?await cg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.hand=h)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(c=this.config.object.enabled?bg(l.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",r=it(),c=this.config.object.enabled?await bg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.object=h)),this.analyze("End Object:"),this.config.async&&([p,d,u,c]=await Promise.all([p,d,u,c])),Ee(l.tensor);let m=[];this.config.gesture.enabled&&(r=it(),m=[...Wk(p),...Lk(d),...Vk(u),...Bk(p)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(it()-r)),o&&(this.config.videoOptimized=o),this.perf.total=Math.trunc(it()-i),this.state="idle";let f={face:p,body:d,hand:u,gesture:m,object:c,performance:this.perf,canvas:l.canvas};a(f)})}async warmup(t={}){let n=it();if(t&&(this.config=Gn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let a=this.config.videoOptimized;this.config.videoOptimized=!1;let r;typeof createImageBitmap=="function"?r=await aa(this,z0).call(this):typeof Image!="undefined"?r=await aa(this,_0).call(this):r=await aa(this,P0).call(this),this.config.videoOptimized=a;let s=it();return this.config.debug&&he("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};Ql=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,Li=new WeakMap,O0=new WeakMap,ep=new WeakMap,z0=new WeakMap,_0=new WeakMap,P0=new WeakMap;export{Zie as Human,Zie as default}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/dist/human.js b/dist/human.js index 87199b2f..6d689527 100644 --- a/dist/human.js +++ b/dist/human.js @@ -4974,7 +4974,7 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;var Kk="1.8.1";var Ql,Jd,Qd,Li,O0,ep,z0,_0,P0,Zk=class{constructor(t={}){Ql.set(this,void 0);Jd.set(this,void 0);Qd.set(this,void 0);Li.set(this,void 0);this.analyze=(...t)=>{if(!aa(this,Jd))return;let n=this.tf.engine().state.numTensors,a=aa(this,Ql);rs(this,Ql,n);let r=n-a;r!==0&&he(...t,r)};O0.set(this,t=>{if(!aa(this,Qd))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof Le))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ep.set(this,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let a=it();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&he("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&&he("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&he("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 r=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&he(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),this.config.debug&&!r&&he("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&nk();try{await this.tf.setBackend(this.config.backend)}catch(r){he("error: cannot set backend:",this.config.backend,r)}}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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(he("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let r=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&he(`gl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(it()-a)}});z0.set(this,async()=>{let t=(r,s="application/octet-stream")=>fetch(`data:${s};base64,${r}`).then(i=>i.blob()),n,a;switch(this.config.warmup){case"face":n=await t($0);break;case"full":n=await t(D0);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await this.detect(r,this.config),r.close()}return a});_0.set(this,async()=>new Promise(t=>{let n,a=0;switch(this.config.warmup){case"face":a=256,n="data:image/jpeg;base64,"+$0;break;case"full":case"body":a=1200,n="data:image/jpeg;base64,"+D0;break;default:n=null}let r=new Image;r.onload=async()=>{let s=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,a):document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight;let i=s.getContext("2d");i==null||i.drawImage(r,0,0);let o=await this.detect(s,this.config);t(o)},n?r.src=n:t(null)}));P0.set(this,async()=>{let t=r=>Buffer.from(r,"base64"),n;if(this.config.warmup==="face"&&(n=t($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(D0)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);this.tf.dispose(r),a=await this.detect(s,this.config),this.tf.dispose(s)}else this.config.debug&&he("Warmup tfjs-node not loaded");return a});this.tf=pu,this.draw=kg,this.version=Kk,this.config=Gn(dt,t),this.state="idle",rs(this,Ql,0),rs(this,Jd,!1),rs(this,Qd,!1),rs(this,Li,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>wg(n,this.config),this.classes={facemesh:W2,emotion:U2,faceres:X2,body:this.config.body.modelPath.includes("posenet")?rg:fg,hand:pg,nanodet:yg},this.faceTriangulation=fk,this.faceUVMap=mk,this.sysinfo=Pg()}similarity(t,n){return Z2(t,n)}enhance(t){return Y2(t)}match(t,n,a=0){return Ak(t,n,a)}async load(t={}){this.state="load";let n=it();t&&(this.config=Gn(this.config,t)),aa(this,Li)&&(this.config.debug&&he(`version: ${this.version}`),this.config.debug&&he(`tfjs version: ${this.tf.version_core}`),this.config.debug&&he("platform:",this.sysinfo.platform),this.config.debug&&he("agent:",this.sysinfo.agent),await aa(this,ep).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&he("configuration:",this.config),this.config.debug&&he("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?j2(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?q2(this.config):null),this.models.handpose||(this.config.hand.enabled?hg(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?ig(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?mg(this.config):null),this.models.nanodet||(this.config.object.enabled?xg(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?K2(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await j2(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await q2(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await hg(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await ig(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await mg(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await xg(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await K2(this.config))),aa(this,Li)&&(this.config.debug&&he("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),rs(this,Li,!1));let a=Math.trunc(it()-n);a>(this.perf.load||0)&&(this.perf.load=a)}async detect(t,n={}){return new Promise(async a=>{this.state="config";let r;this.config=Gn(this.config,n),this.state="check";let s=aa(this,O0).call(this,t);s&&(he(s,t),a({error:s}));let i=it();await aa(this,ep).call(this),await this.load();let o;t&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof Image!="undefined"&&t instanceof Image||typeof ImageData!="undefined"&&t instanceof ImageData||typeof ImageBitmap!="undefined"&&vg instanceof ImageBitmap)&&(he("disabling video optimization"),o=this.config.videoOptimized,this.config.videoOptimized=!1),r=it();let l=wg(t,this.config);if(!l||!l.tensor){he("could not convert input to tensor"),a({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(it()-r),this.analyze("Get Image:");let d,u,p,c,h;this.config.async?(p=this.config.face.enabled?J2(this,l.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",r=it(),p=this.config.face.enabled?await J2(this,l.tensor):[],h=Math.trunc(it()-r),h>0&&(this.perf.face=h)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?Ag(l.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",r=it(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?await Ag(l.tensor,this.config):[]),h=Math.trunc(it()-r),h>0&&(this.perf.body=h)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(u=this.config.hand.enabled?cg(l.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",r=it(),u=this.config.hand.enabled?await cg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.hand=h)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(c=this.config.object.enabled?bg(l.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",r=it(),c=this.config.object.enabled?await bg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.object=h)),this.analyze("End Object:"),this.config.async&&([p,d,u,c]=await Promise.all([p,d,u,c])),Ee(l.tensor);let m=[];this.config.gesture.enabled&&(r=it(),m=[...Wk(p),...Lk(d),...Vk(u),...Bk(p)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(it()-r)),o&&(this.config.videoOptimized=o),this.perf.total=Math.trunc(it()-i),this.state="idle";let f={face:p,body:d,hand:u,gesture:m,object:c,performance:this.perf,canvas:l.canvas};a(f)})}async warmup(t={}){let n=it();if(t&&(this.config=Gn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let a=this.config.videoOptimized;this.config.videoOptimized=!1;let r;typeof createImageBitmap=="function"?r=await aa(this,z0).call(this):typeof Image!="undefined"?r=await aa(this,_0).call(this):r=await aa(this,P0).call(this),this.config.videoOptimized=a;let s=it();return this.config.debug&&he("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};Ql=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,Li=new WeakMap,O0=new WeakMap,ep=new WeakMap,z0=new WeakMap,_0=new WeakMap,P0=new WeakMap;return Yie;})(); +2Q==`;var Kk="1.8.2";var Ql,Jd,Qd,Li,O0,ep,z0,_0,P0,Zk=class{constructor(t={}){Ql.set(this,void 0);Jd.set(this,void 0);Qd.set(this,void 0);Li.set(this,void 0);this.analyze=(...t)=>{if(!aa(this,Jd))return;let n=this.tf.engine().state.numTensors,a=aa(this,Ql);rs(this,Ql,n);let r=n-a;r!==0&&he(...t,r)};O0.set(this,t=>{if(!aa(this,Qd))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof Le))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ep.set(this,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let a=it();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&he("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&&he("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&he("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 r=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&he(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),this.config.debug&&!r&&he("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&nk();try{await this.tf.setBackend(this.config.backend)}catch(r){he("error: cannot set backend:",this.config.backend,r)}}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_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&(he("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let r=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&he(`gl version:${r.getParameter(r.VERSION)} renderer:${r.getParameter(r.RENDERER)}`)}await this.tf.ready(),this.perf.backend=Math.trunc(it()-a)}});z0.set(this,async()=>{let t=(r,s="application/octet-stream")=>fetch(`data:${s};base64,${r}`).then(i=>i.blob()),n,a;switch(this.config.warmup){case"face":n=await t($0);break;case"full":n=await t(D0);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await this.detect(r,this.config),r.close()}return a});_0.set(this,async()=>new Promise(t=>{let n,a=0;switch(this.config.warmup){case"face":a=256,n="data:image/jpeg;base64,"+$0;break;case"full":case"body":a=1200,n="data:image/jpeg;base64,"+D0;break;default:n=null}let r=new Image;r.onload=async()=>{let s=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(a,a):document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight;let i=s.getContext("2d");i==null||i.drawImage(r,0,0);let o=await this.detect(s,this.config);t(o)},n?r.src=n:t(null)}));P0.set(this,async()=>{let t=r=>Buffer.from(r,"base64"),n;if(this.config.warmup==="face"&&(n=t($0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(D0)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);this.tf.dispose(r),a=await this.detect(s,this.config),this.tf.dispose(s)}else this.config.debug&&he("Warmup tfjs-node not loaded");return a});this.tf=pu,this.draw=kg,this.version=Kk,this.config=Gn(dt,t),this.state="idle",rs(this,Ql,0),rs(this,Jd,!1),rs(this,Qd,!1),rs(this,Li,!0),this.perf={},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,handpose:null,iris:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,faceres:null},this.image=n=>wg(n,this.config),this.classes={facemesh:W2,emotion:U2,faceres:X2,body:this.config.body.modelPath.includes("posenet")?rg:fg,hand:pg,nanodet:yg},this.faceTriangulation=fk,this.faceUVMap=mk,this.sysinfo=Pg()}similarity(t,n){return Z2(t,n)}enhance(t){return Y2(t)}match(t,n,a=0){return Ak(t,n,a)}async load(t={}){this.state="load";let n=it();t&&(this.config=Gn(this.config,t)),aa(this,Li)&&(this.config.debug&&he(`version: ${this.version}`),this.config.debug&&he(`tfjs version: ${this.tf.version_core}`),this.config.debug&&he("platform:",this.sysinfo.platform),this.config.debug&&he("agent:",this.sysinfo.agent),await aa(this,ep).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&he("configuration:",this.config),this.config.debug&&he("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.nanodet,this.models.faceres]=await Promise.all([this.models.face||(this.config.face.enabled?j2(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?q2(this.config):null),this.models.handpose||(this.config.hand.enabled?hg(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?ig(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?mg(this.config):null),this.models.nanodet||(this.config.object.enabled?xg(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?K2(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await j2(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await q2(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await hg(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await ig(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await mg(this.config)),this.config.object.enabled&&!this.models.nanodet&&(this.models.nanodet=await xg(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await K2(this.config))),aa(this,Li)&&(this.config.debug&&he("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),rs(this,Li,!1));let a=Math.trunc(it()-n);a>(this.perf.load||0)&&(this.perf.load=a)}async detect(t,n={}){return new Promise(async a=>{this.state="config";let r;this.config=Gn(this.config,n),this.state="check";let s=aa(this,O0).call(this,t);s&&(he(s,t),a({error:s}));let i=it();await aa(this,ep).call(this),await this.load();let o;t&&this.config.videoOptimized&&typeof window!="undefined"&&typeof WorkerGlobalScope!="undefined"&&(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof Image!="undefined"&&t instanceof Image||typeof ImageData!="undefined"&&t instanceof ImageData||typeof ImageBitmap!="undefined"&&vg instanceof ImageBitmap)&&(he("disabling video optimization"),o=this.config.videoOptimized,this.config.videoOptimized=!1),r=it();let l=wg(t,this.config);if(!l||!l.tensor){he("could not convert input to tensor"),a({error:"could not convert input to tensor"});return}this.perf.image=Math.trunc(it()-r),this.analyze("Get Image:");let d,u,p,c,h;this.config.async?(p=this.config.face.enabled?J2(this,l.tensor):[],this.perf.face&&delete this.perf.face):(this.state="run:face",r=it(),p=this.config.face.enabled?await J2(this,l.tensor):[],h=Math.trunc(it()-r),h>0&&(this.perf.face=h)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?Ag(l.tensor,this.config):[]),this.perf.body&&delete this.perf.body):(this.state="run:body",r=it(),this.config.body.modelPath.includes("posenet")?d=this.config.body.enabled?await sg(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")&&(d=this.config.body.enabled?await Ag(l.tensor,this.config):[]),h=Math.trunc(it()-r),h>0&&(this.perf.body=h)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(u=this.config.hand.enabled?cg(l.tensor,this.config):[],this.perf.hand&&delete this.perf.hand):(this.state="run:hand",r=it(),u=this.config.hand.enabled?await cg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.hand=h)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(c=this.config.object.enabled?bg(l.tensor,this.config):[],this.perf.object&&delete this.perf.object):(this.state="run:object",r=it(),c=this.config.object.enabled?await bg(l.tensor,this.config):[],h=Math.trunc(it()-r),h>0&&(this.perf.object=h)),this.analyze("End Object:"),this.config.async&&([p,d,u,c]=await Promise.all([p,d,u,c])),Ee(l.tensor);let m=[];this.config.gesture.enabled&&(r=it(),m=[...Wk(p),...Lk(d),...Vk(u),...Bk(p)],this.config.async?this.perf.gesture&&delete this.perf.gesture:this.perf.gesture=Math.trunc(it()-r)),o&&(this.config.videoOptimized=o),this.perf.total=Math.trunc(it()-i),this.state="idle";let f={face:p,body:d,hand:u,gesture:m,object:c,performance:this.perf,canvas:l.canvas};a(f)})}async warmup(t={}){let n=it();if(t&&(this.config=Gn(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let a=this.config.videoOptimized;this.config.videoOptimized=!1;let r;typeof createImageBitmap=="function"?r=await aa(this,z0).call(this):typeof Image!="undefined"?r=await aa(this,_0).call(this):r=await aa(this,P0).call(this),this.config.videoOptimized=a;let s=it();return this.config.debug&&he("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};Ql=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,Li=new WeakMap,O0=new WeakMap,ep=new WeakMap,z0=new WeakMap,_0=new WeakMap,P0=new WeakMap;return Yie;})(); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/dist/human.node-gpu.js b/dist/human.node-gpu.js index 05d3d756..f3ac75d2 100644 --- a/dist/human.node-gpu.js +++ b/dist/human.node-gpu.js @@ -19515,7 +19515,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "1.8.1"; +var version = "1.8.2"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _sanity, _checkBackend, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/dist/human.node-wasm.js b/dist/human.node-wasm.js index 30816800..70a0cfa7 100644 --- a/dist/human.node-wasm.js +++ b/dist/human.node-wasm.js @@ -19516,7 +19516,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "1.8.1"; +var version = "1.8.2"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _sanity, _checkBackend, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/dist/human.node.js b/dist/human.node.js index 852b2883..1bfc6304 100644 --- a/dist/human.node.js +++ b/dist/human.node.js @@ -19515,7 +19515,7 @@ lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ 2Q==`; // package.json -var version = "1.8.1"; +var version = "1.8.2"; // src/human.ts var _numTensors, _analyzeMemoryLeaks, _checkSanity, _firstRun, _sanity, _checkBackend, _warmupBitmap, _warmupCanvas, _warmupNode; diff --git a/server/build.log b/server/build.log index 58bb6175..469cdae3 100644 --- a/server/build.log +++ b/server/build.log @@ -440,3 +440,37 @@ 2021-04-30 11:54:13 INFO:  Generate types: ["src/human.ts"] 2021-04-30 11:54:17 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"] 2021-04-30 11:54:17 INFO:  Generate TypeDocs: ["src/human.ts"] +2021-05-04 11:17:13 INFO:  @vladmandic/human version 1.8.1 +2021-05-04 11:17:13 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.0.0 +2021-05-04 11:17:13 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} +2021-05-04 11:17:13 STATE: Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":696,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:14 STATE: Build for: node type: node: {"imports":35,"importBytes":414920,"outputBytes":373580,"outputFiles":"dist/human.node.js"} +2021-05-04 11:17:14 STATE: Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":700,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:14 STATE: Build for: nodeGPU type: node: {"imports":35,"importBytes":414924,"outputBytes":373584,"outputFiles":"dist/human.node-gpu.js"} +2021-05-04 11:17:14 STATE: Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":746,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:14 STATE: Build for: nodeWASM type: node: {"imports":35,"importBytes":414970,"outputBytes":373634,"outputFiles":"dist/human.node-wasm.js"} +2021-05-04 11:17:14 STATE: Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:14 STATE: Build for: browserNoBundle type: esm: {"imports":35,"importBytes":415618,"outputBytes":230233,"outputFiles":"dist/human.esm-nobundle.js"} +2021-05-04 11:17:15 STATE: Build for: browserBundle type: tfjs: {"modules":1274,"moduleBytes":4114813,"imports":7,"importBytes":2488,"outputBytes":1111306,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:16 STATE: Build for: browserBundle type: iife: {"imports":35,"importBytes":1525530,"outputBytes":1337943,"outputFiles":"dist/human.js"} +2021-05-04 11:17:16 STATE: Build for: browserBundle type: esm: {"imports":35,"importBytes":1525530,"outputBytes":1337901,"outputFiles":"dist/human.esm.js"} +2021-05-04 11:17:16 INFO:  Generate types: ["src/human.ts"] +2021-05-04 11:17:23 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"] +2021-05-04 11:17:23 INFO:  Generate TypeDocs: ["src/human.ts"] +2021-05-04 11:17:53 INFO:  @vladmandic/human version 1.8.2 +2021-05-04 11:17:53 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.0.0 +2021-05-04 11:17:53 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true} +2021-05-04 11:17:53 STATE: Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":696,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:53 STATE: Build for: node type: node: {"imports":35,"importBytes":414920,"outputBytes":373580,"outputFiles":"dist/human.node.js"} +2021-05-04 11:17:53 STATE: Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":700,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:53 STATE: Build for: nodeGPU type: node: {"imports":35,"importBytes":414924,"outputBytes":373584,"outputFiles":"dist/human.node-gpu.js"} +2021-05-04 11:17:53 STATE: Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":746,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:53 STATE: Build for: nodeWASM type: node: {"imports":35,"importBytes":414970,"outputBytes":373634,"outputFiles":"dist/human.node-wasm.js"} +2021-05-04 11:17:53 STATE: Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:53 STATE: Build for: browserNoBundle type: esm: {"imports":35,"importBytes":415618,"outputBytes":230233,"outputFiles":"dist/human.esm-nobundle.js"} +2021-05-04 11:17:54 STATE: Build for: browserBundle type: tfjs: {"modules":1274,"moduleBytes":4114813,"imports":7,"importBytes":2488,"outputBytes":1111306,"outputFiles":"dist/tfjs.esm.js"} +2021-05-04 11:17:55 STATE: Build for: browserBundle type: iife: {"imports":35,"importBytes":1525530,"outputBytes":1337943,"outputFiles":"dist/human.js"} +2021-05-04 11:17:56 STATE: Build for: browserBundle type: esm: {"imports":35,"importBytes":1525530,"outputBytes":1337901,"outputFiles":"dist/human.esm.js"} +2021-05-04 11:17:56 INFO:  Generate types: ["src/human.ts"] +2021-05-04 11:18:01 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"] +2021-05-04 11:18:01 INFO:  Generate TypeDocs: ["src/human.ts"] diff --git a/wiki b/wiki index cdba1bc0..f9fc8596 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit cdba1bc0eeb88d37918a63e2023c1f704a1f4600 +Subproject commit f9fc859622290183712e7f984db59e3c8494afe9