javascript - tfjs mode.predict 返回相同的结果
问题描述
我有一个在浏览器上运行的网络模型。确实面部检测的问题是随机预测开始每次都返回所有乱码结果或相同的结果。
我有时观察到它tf.browser.fromPixels
似乎返回一个全零张量。我已经检查过了frame
,它似乎是有效的。
关于可能发生的事情的任何想法。
const pixels = tf.browser.fromPixels(frame).toFloat();
const shape = pixels.reshape([-1, 104, 104, 3]);
const tfResponse: any = this.model.predict(shape);
tfResponse.data().then((r) => {
try {
if ( this.lastResponse ) {
if ( UtilService.arraysEqual(r, this.lastResponse )) {
throw new Error('Prediction failure start');
}
}
this.lastResponse = r;
shape.dispose();
const detections: Array<Box> = this.parseDetectionResult(r);
if (detections.length > 0) {
resolve({resized: frame, face: detections});
} else {
reject('No face found.');
}
} catch (e) {
console.log(e);
}
})
HTML
<app-camera-overlay _ngcontent-c8="" style="position: absolute; width: 100%; height: 100%" _nghost-c11="">
<canvas _ngcontent-c11="" class="abs-center" id="mask-overlay" style="width: 640px; height: 360px;" width="640" height="360"></canvas>
</app-camera-overlay>
通常它的pixels
似乎充满了零。
任何帮助将不胜感激,谢谢。
解决方案
推荐阅读
- javascript - How to use Promise with generator?
- mysql - Mysql 为什么当我使用 group by Id 时 sum 函数不计算列的总和
- php - 表单提交按回车(在一个站点中,在另一个站点中不)
- multithreading - 在其他线程中生成线程时借用问题
- python - 如何绘制条形图,显示由数据框列组成的各种桶的频率计数?
- php - laravel elasticsearch搜索和分页结果
- php - 在 Dockerfile 中“php artisan storage:link”返回一个非零代码
- c++ - 如果未在 .txt 文件中声明,则使用 ifstream 分配默认值
- angular - 如何使用@Inject 并获取不在构造函数中的服务实例?
- php - 仅显示 MySQL 列值计数