tensorflow.js的WebGL后端很晚才加载模型(blazeface)

时间:2020-10-22 16:03:19

标签: tensorflow webgl tensorflow.js

我正在尝试将blazeface模型添加到我的应用程序中。我刚刚发现,当我使用WebGL后端时,第一次调用estimateFaces()

<TBError>
   <tipoError>DATO</tipoError>
   <codigoError>87</codigoError>
   <mensajeError>El formulario multipart enviado es incorrecto. Verifique las especifiaciones para la aplicaci�n cliente.</mensajeError>
</TBError>

需要将近18秒。 WASM或CPU后端不是这种情况。您还可以在blazeface demo感受到不同。从右上方菜单将后端设置为WebGL,然后打开您的cam。人脸检测的第一个蒙版的加载方式比WASM或cpu后端的加载方式晚。你知道为什么会这样吗?

张量如下:

 console.log("estimate started") 
        const predictions = await model.estimateFaces(
          this.refVideo.current,
          returnTensors,
          flipHorizontal,
          annotateBoxes
        );
 console.log("estimate finished") // first time it is very slow with WebGL

1 个答案:

答案 0 :(得分:0)

我相信这个问题与Blazeface的权重载入GPU的时间有关。导入Facemesh时遇到了同样的问题。每当我使用wasm后端加载它,然后将后端更改为webgl时,它都会滞后约5秒钟,然后才能正常工作。对我有用的是在加载Facemesh模型之前将后端设置为webgl