user4609276
user4609276

Reputation:

BodyPix - Error: No backend found in registry

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();

Upvotes: 1

Views: 2912

Answers (2)

Ritik
Ritik

Reputation: 63

For me adding this script worked, try this

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>

Upvotes: 0

Prashant Sharma
Prashant Sharma

Reputation: 71

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();

Upvotes: 7

Related Questions