face-api/dist/face-api.esm-nobundle.js

8 lines
81 KiB
JavaScript
Raw Normal View History

2021-09-08 19:51:28 +02:00
/*
Face-API
homepage: <https://github.com/vladmandic/face-api>
author: <https://github.com/vladmandic>'
2021-09-08 19:51:28 +02:00
*/
var ur=Object.defineProperty;var ho=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var go=Object.prototype.hasOwnProperty;var xo=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(t,e)=>(typeof require!="undefined"?require:t)[e]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Ye=(o,t)=>{for(var e in t)ur(o,e,{get:t[e],enumerable:!0})},pr=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of bo(t))!go.call(o,a)&&a!==e&&ur(o,a,{get:()=>t[a],enumerable:!(r=ho(t,a))||r.enumerable});return o},w=(o,t,e)=>(pr(o,t,"default"),e&&pr(e,t,"default"));var n={};Ye(n,{version:()=>Po});w(n,mn);w(n,pn);w(n,un);import*as mn from"@tensorflow/tfjs/dist/index.js";import*as pn from"@tensorflow/tfjs-backend-webgl/dist/index.js";import*as un from"@tensorflow/tfjs-backend-wasm/dist/index.js";var fr="4.22.0",vo="4.22.0",yo="4.22.0",To="4.22.0",_o="4.22.0",Po={tfjs:fr,"tfjs-core":fr,"tfjs-converter":vo,"tfjs-backend-cpu":yo,"tfjs-backend-webgl":To,"tfjs-backend-wasm":_o};var Sr={};Ye(Sr,{AnchorPosition:()=>Ke,DrawBox:()=>ee,DrawBoxOptions:()=>de,DrawFaceLandmarks:()=>De,DrawFaceLandmarksOptions:()=>Fe,DrawTextField:()=>xt,DrawTextFieldOptions:()=>Wt,drawContour:()=>Z,drawDetections:()=>Io,drawFaceExpressions:()=>No,drawFaceLandmarks:()=>So});function Z(o,t,e=!1){if(o.beginPath(),t.slice(1).forEach(({x:r,y:a},i)=>{let s=t[i];o.moveTo(s.x,s.y),o.lineTo(r,a)}),e){let r=t[t.length-1],a=t[0];if(!r||!a)return;o.moveTo(r.x,r.y),o.lineTo(a.x,a.y)}o.stroke()}var lr={};Ye(lr,{computeReshapedDimensions:()=>je,getCenterPoint:()=>bt,isDimensions:()=>ue,isEven:()=>pe,isFloat:()=>Ge,isTensor:()=>dt,isTensor1D:()=>wo,isTensor2D:()=>Ve,isTensor3D:()=>K,isTensor4D:()=>R,isValidNumber:()=>G,isValidProbablitiy:()=>Mt,range:()=>X,round:()=>ht});var A=class o{constructor(t,e){if(!G(t)||!G(e))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:t,height:e})}`);this._width=t,this._height=e}get width(){return this._width}get height(){return this._height}reverse(){return new o(1/this.width,1/this.height)}};function dt(o,t){return o instanceof n.Tensor&&o.shape.length===t}function wo(o){return dt(o,1)}function Ve(o){return dt(o,2)}function K(o){return dt(o,3)}function R(o){return dt(o,4)}function Ge(o){return o%1!==0}function pe(o){return o%2===0}function ht(o,t=2){let e=10**t;return Math.floor(o*e)/e}function ue(o){return o&&o.width&&o.height}function je({width:o,height:t},e){let r=e/Math.max(t,o);return new A(Math.round(o*r),Math.round(t*r))}function bt(o){return o.reduce((t,e)=>t.add(e),new v(0,0)).div(new v(o.length,o.length))}function X(o,t,e){return Array(o).fill(0).map((r,a)=>t+a*e)}function G(o){return!!o&&o!==1/0&&o!==-1/0&&!Number.isNaN(o)||o===0}function Mt(o){return G(o)&&o>=0&&o<=1}var v=class o{constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}add(t){return new o(this.x+t.x,this.y+t.y)}sub(t){return new o(this.x-t.x,this.y-t.y)}mul(t){return new o(this.x*t.x,this.y*t.y)}div(t){return new o(this.x/t.x,this.y/t.y)}abs(){return new o(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new o(Math.floor(this.x),Math.floor(this.y))}};var C=class o{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(G)}static assertIsValidBox(t,e,r=!1){if(!o.isRect(t))throw new Error(`${e} - invalid box: ${JSON.stringify(t)}, expected object with properties x, y, width, height`);if(!r&&(t.width<0||t.height<0))throw new Error(`${e} - width (${t.width}) and height (${t.height}) must be positive numbers`)}constructor(t,e=!0){let r=t||{},a=[r.left,r.top,r.right,r.bottom].every(G),i=[r.x,r.y,r.width,r.height].every(G);if(!i&&!a)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[s,c,m,p]=i?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];o.assertIsValidBox({x:s,y:c,width:m,