import * as faceapi from "@vladmandic/face-api"; import * as path from "path"; import fs from "fs"; // SsdMobilenetv1Options export const minConfidence = 0.5; // TinyFaceDetectorOptions export const inputSize = 408; export const scoreThreshold = 0.5; export const getFaceDetectorOptions = (net: faceapi.NeuralNetwork) => { return net === faceapi.nets.ssdMobilenetv1 ? new faceapi.SsdMobilenetv1Options({ minConfidence }) : new faceapi.TinyFaceDetectorOptions({ inputSize, scoreThreshold }); }; export function saveFile(fileName: string, buf: Buffer) { const baseDir = process.env.OUT_DIR as string; if (!fs.existsSync(baseDir)) { fs.mkdirSync(baseDir); } fs.writeFileSync(path.resolve(baseDir, fileName), buf); }