我尝试通过 TensorFlow 网站上的教程设置 BodyPix,但收到以下错误
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)
Run Code Online (Sandbox Code Playgroud)
我尝试安装几个我认为可能有帮助的软件包,但我真的不知道现在该怎么做......感谢我能得到的任何输入。
包.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"
}
Run Code Online (Sandbox Code Playgroud)
索引.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();
Run Code Online (Sandbox Code Playgroud)
小智 7
我使用的是相同版本body-pix并遇到了完全相同的问题。我通过从@tensorflow/tfjs包中导入模块解决了这个问题。似乎需要导入这些模块来注册后端。您可能需要执行以下操作才能解决此问题:
import * as tf from '@tensorflow/tfjs';
...
console.log('Using TensorFlow backend: ', tf.getBackend());
loadAndPredict();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2737 次 |
| 最近记录: |