|
@@ -58,14 +58,15 @@ function tensorFlowWebPackStatus() {
|
|
|
|
|
|
// if (os.isWin10) alert("是win10");
|
|
|
|
|
|
-let __inputSize = 320;
|
|
|
+let __inputSize = 128;
|
|
|
|
|
|
async function detectTest() {
|
|
|
const inputSizeList = [128, 160, 224, 320, 416, 512, 608];
|
|
|
const succRate = [0, 0, 0, 0, 0, 0, 0];
|
|
|
+ const detectTimes = 6;
|
|
|
|
|
|
for (let idx = 0; idx < inputSizeList.length; idx++) {
|
|
|
- for (let n = 0; n < 10; n++) {
|
|
|
+ for (let n = 0; n < detectTimes; n++) {
|
|
|
await new Promise(resolve => setTimeout(resolve, 3 * 1000));
|
|
|
const inputSize = inputSizeList[idx];
|
|
|
const videoEl = document.getElementById("video");
|
|
@@ -74,7 +75,12 @@ async function detectTest() {
|
|
|
inputSize: inputSize,
|
|
|
scoreThreshold: 0.5,
|
|
|
});
|
|
|
- const result = await faceapi.detectAllFaces(videoEl, options);
|
|
|
+ // const result = await faceapi.detectAllFaces(videoEl, options);
|
|
|
+ // console.log(result);
|
|
|
+ const result = await Promise.race([
|
|
|
+ faceapi.detectAllFaces(videoEl, options),
|
|
|
+ new Promise(resolve => setTimeout(resolve, 10 * 1000)),
|
|
|
+ ]);
|
|
|
|
|
|
if (result && result.length >= 1) {
|
|
|
console.log(`inputSize: ${inputSize} ${result.length}`);
|
|
@@ -83,14 +89,15 @@ async function detectTest() {
|
|
|
console.log(`inputSize: ${inputSize} 检测失败`);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
+ console.log(error);
|
|
|
console.log(`inputSize: ${inputSize} 检测失败-异常`);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // if (succRate[idx] === 10) {
|
|
|
- // console.log(`inputSize: ${inputSizeList[idx]} 提前选中`);
|
|
|
- // break;
|
|
|
- // }
|
|
|
+ if (succRate[idx] === detectTimes) {
|
|
|
+ console.log(`inputSize: ${inputSizeList[idx]} 提前选中`);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
console.log({ succRate });
|
|
@@ -99,6 +106,7 @@ async function detectTest() {
|
|
|
const idx = succRate.indexOf(max);
|
|
|
|
|
|
__inputSize = inputSizeList[idx];
|
|
|
+ window.__inputSize = __inputSize;
|
|
|
console.log("最好的 inputSize 为: " + __inputSize);
|
|
|
window._hmt.push([
|
|
|
"_trackEvent",
|