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
*/
2023-01-29 16:08:46 +01:00
var lr=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var go=Object.getOwnPropertyNames;var xo=Object.prototype.hasOwnProperty;var vo=(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 Ve=(o,t)=>{for(var e in t)lr(o,e,{get:t[e],enumerable:!0})},fr=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of go(t))!xo.call(o,a)&&a!==e&&lr(o,a,{get:()=>t[a],enumerable:!(r=bo(t,a))||r.enumerable});return o},P=(o,t,e)=>(fr(o,t,"default"),e&&fr(e,t,"default"));var n={};Ve(n,{version:()=>Po});P(n,mn);P(n,pn);P(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 dr="4.2.0",yo="4.2.0",_o="4.2.0",To="4.2.0",wo="4.2.0",Po={tfjs:dr,"tfjs-core":dr,"tfjs-converter":yo,"tfjs-backend-cpu":_o,"tfjs-backend-webgl":To,"tfjs-backend-wasm":wo};var Wr={};Ve(Wr,{AnchorPosition:()=>Ke,DrawBox:()=>ee,DrawBoxOptions:()=>de,DrawFaceLandmarks:()=>De,DrawFaceLandmarksOptions:()=>Fe,DrawTextField:()=>et,DrawTextFieldOptions:()=>kt,drawContour:()=>Z,drawDetections:()=>No,drawFaceExpressions:()=>So,drawFaceLandmarks:()=>Ao});function Z(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 hr={};Ve(hr,{computeReshapedDimensions:()=>je,getCenterPoint:()=>yt,isDimensions:()=>ue,isEven:()=>pe,isFloat:()=>Ge,isTensor:()=>xt,isTensor1D:()=>Fo,isTensor2D:()=>Ye,isTensor3D:()=>K,isTensor4D:()=>R,isValidNumber:()=>G,isValidProbablitiy:()=>It,range:()=>U,round:()=>vt});var S=class{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 S(1/this.width,1/this.height)}};function xt(o,t){return o instanceof n.Tensor&&o.shape.length===t}function Fo(o){return xt(o,1)}function Ye(o){return xt(o,2)}function K(o){return xt(o,3)}function R(o){return xt(o,4)}function Ge(o){return o%1!==0}function pe(o){return o%2===0}function vt(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 S(Math.round(o*r),Math.round(t*r))}function yt(o){return o.reduce((t,e)=>t.add(e),new g(0,0)).div(new g(o.length,o.length))}function U(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 It(o){return G(o)&&o>=0&&o<=1}var g=class{constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}add(t){return new g(this.x+t.x,this.y+t.y)}sub(t){return new g(this.x-t.x,this.y-t.y)}mul(t){return new g(this.x*t.x,this.y*t.y)}div(t){return new g(this.x/t.x,this.y/t.y)}abs(){return new g(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new g(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(G)}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(G),s=[r.x,r.y,r.width,r.height].every(G);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.assertIsValidBox({x:i,y:c,width:m,height: