BodyPix - 错误:在注册表中找不到后端 [英] BodyPix - Error: No backend found in registry
问题描述
我正在尝试通过 TensorFlow 网站上的教程设置 BodyPix,但出现以下错误
I'm trying to setup BodyPix via the tutorial on the TensorFlow website, and I'm getting the following error
Uncaught (in promise) Error: No backend found in registry.
at Engine.getSortedBackends (engine.js:248)
at Engine.initializeBackendsAndReturnBest (engine.js:257)
at Engine.get backend [as backend] (engine.js:94)
at Engine.makeTensor (engine.js:556)
at makeTensor (tensor_ops_util.js:57)
at tensor (tensor.js:48)
at Module.decodeWeights (io_utils.js:212)
at GraphModel.loadSync (graph_model.js:118)
at GraphModel.load (graph_model.js:102)
at async loadGraphModel (graph_model.js:348)
我尝试安装几个我认为可能有帮助的软件包,但我真的不知道现在该怎么做..感谢我能得到的任何输入.
I tried installing several packages that I thought might help, but I'm really not sure what to do now.. appreciate any input I could get.
package.json
"dependencies": {
"@babel/core": "^7.11.1",
"@babel/preset-env": "^7.11.0",
"@tensorflow-models/body-pix": "^2.0.5",
"@tensorflow/tfjs": "^2.3.0",
"@tensorflow/tfjs-converter": "^2.3.0",
"@tensorflow/tfjs-core": "^2.3.0",
"@tensorflow/tfjs-node-gpu": "^2.3.0"
},
"devDependencies": {
"babel-loader": "^8.1.0",
"webpack-dev-server": "^3.11.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
}
index.js
import * as bodyPix from '@tensorflow-models/body-pix';
const img = document.getElementById('image');
async function loadAndPredict() {
const net = await bodyPix.load(/** optional arguments, see below **/);
/**
* One of (see documentation below):
* - net.segmentPerson
* - net.segmentPersonParts
* - net.segmentMultiPerson
* - net.segmentMultiPersonParts
* See documentation below for details on each method.
*/
const segmentation = await net.segmentPerson(img);
console.log(segmentation);
}
loadAndPredict();
推荐答案
我在使用相同版本的 body-pix
并遇到了完全相同的问题.我通过从 @tensorflow/tfjs
包中导入模块解决了这个问题.似乎需要导入这些模块来注册后端.您可能需要执行以下操作才能解决此问题:
I was using the same version of body-pix
and ran into the exact same issue. I resolved the problem by importing modules from @tensorflow/tfjs
package. It seems importing these modules is necessary to register the backends. You may have to do the following to fix this issue:
import * as tf from '@tensorflow/tfjs';
...
console.log('Using TensorFlow backend: ', tf.getBackend());
loadAndPredict();
这篇关于BodyPix - 错误:在注册表中找不到后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!