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
*/
2022-03-07 19:17:31 +01:00
var ur=Object.defineProperty;var co=Object.getOwnPropertyDescriptor;var mo=Object.getOwnPropertyNames;var po=Object.prototype.hasOwnProperty;var uo=(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 new Error('Dynamic require of "'+o+'" is not supported')});var Fe=(o,t)=>{for(var e in t)ur(o,e,{get:t[e],enumerable:!0})},y=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of mo(t))!po.call(o,a)&&(e||a!=="default")&&ur(o,a,{get:()=>t[a],enumerable:!(r=co(t,a))||r.enumerable});return o};var n={};Fe(n,{version:()=>To});y(n,un);y(n,fn);y(n,ln);import*as un from"@tensorflow/tfjs/dist/index.js";import*as fn from"@tensorflow/tfjs-backend-webgl/dist/index.js";import*as ln from"@tensorflow/tfjs-backend-wasm/dist/index.js";var fo="3.14.0",lo="3.14.0",ho="3.14.0",bo="3.14.0",go="3.14.0",xo="3.14.0",vo="3.14.0",yo="3.14.0",To={tfjs:fo,"tfjs-core":lo,"tfjs-data":ho,"tfjs-layers":bo,"tfjs-converter":go,"tfjs-backend-cpu":xo,"tfjs-backend-webgl":vo,"tfjs-backend-wasm":yo};var Ir={};Fe(Ir,{AnchorPosition:()=>Ae,DrawBox:()=>ue,DrawBoxOptions:()=>ke,DrawFaceLandmarks:()=>Oe,DrawFaceLandmarksOptions:()=>$e,DrawTextField:()=>st,DrawTextFieldOptions:()=>Vt,drawContour:()=>q,drawDetections:()=>Io,drawFaceExpressions:()=>No,drawFaceLandmarks:()=>So});function q(o,t,e=!1){if(o.beginPath(),t.slice(1).forEach(({x:r,y:a},s)=>{let i=t[s];o.moveTo(i.x,i.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 fr={};Fe(fr,{computeReshapedDimensions:()=>Me,getCenterPoint:()=>ut,isDimensions:()=>se,isEven:()=>ae,isFloat:()=>Ee,isTensor:()=>mt,isTensor1D:()=>_o,isTensor2D:()=>De,isTensor3D:()=>Z,isTensor4D:()=>R,isValidNumber:()=>Y,isValidProbablitiy:()=>wt,range:()=>X,round:()=>pt});var S=class{constructor(t,e){if(!Y(t)||!Y(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 S(1/this.width,1/this.height)}};function mt(o,t){return o instanceof n.Tensor&&o.shape.length===t}function _o(o){return mt(o,1)}function De(o){return mt(o,2)}function Z(o){return mt(o,3)}function R(o){return mt(o,4)}function Ee(o){return o%1!==0}function ae(o){return o%2===0}function pt(o,t=2){let e=10**t;return Math.floor(o*e)/e}function se(o){return o&&o.width&&o.height}function Me({width:o,height:t},e){let r=e/Math.max(t,o);return new S(Math.round(o*r),Math.round(t*r))}function ut(o){return o.reduce((t,e)=>t.add(e),new b(0,0)).div(new b(o.length,o.length))}function X(o,t,e){return Array(o).fill(0).map((r,a)=>t+a*e)}function Y(o){return!!o&&o!==1/0&&o!==-1/0&&!Number.isNaN(o)||o===0}function wt(o){return Y(o)&&o>=0&&o<=1}var b=class{constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}add(t){return new b(this.x+t.x,this.y+t.y)}sub(t){return new b(this.x-t.x,this.y-t.y)}mul(t){return new b(this.x*t.x,this.y*t.y)}div(t){return new b(this.x/t.x,this.y/t.y)}abs(){return new b(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new b(Math.floor(this.x),Math.floor(this.y))}};var F=class{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(Y)}static assertIsValidBox(t,e,r=!1){if(!F.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(Y),s=[r.x,r.y,r.width,r.height].every(Y);if(!s&&!a)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[i,c,m,p]=s?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];F.assertIs