Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel 'Slice' or 'Multiply' "not registered" for any backend, tried multiple models. #881

Open
gboere opened this issue Aug 14, 2024 · 0 comments

Comments

@gboere
Copy link
Contributor

gboere commented Aug 14, 2024

I'm trying to write a Chrome extension using the latest NSFW.js and TF.js. All models I try to use, though, return an error along the lines of "Kernel 'Slice'" or "Kernel 'Multiply' isn't registered for backend 'cpu' (or 'webgl', or whatever).

I've tried the models included in the repo, and also the models in GantMan/nsfw_model and TeSheng93/tfjs-mobilenetv3. I'm sure I'm doing something wrong, but I'm lost.

// content.js:
import * as tf from "@tensorflow/tfjs";
import * as nsfwjs from "nsfwjs";

(async() => {
    await tf.setBackend('cpu');
    await tf.ready();
    tf.enableDebugMode();

    const model_path = chrome.runtime.getURL("/models/");
    const model = await nsfwjs.load(model_path, { size: 299 });

    const images = element.getElementsByTagName('img');
    let results = new Array(images.length);
    for(let i = 0; i < images.length; i++) {
        images[i].style.visibility = 'hidden';
        results[i] = await model.classify(images[i]);
    }
})();
// package.json
{
  "scripts": {
    "build": "bun bundler.ts",
  },
  "name": "unsfw",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "@types/bun": "latest",
    "@types/chrome": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@tensorflow/tfjs": "^4.20.0",
    "nsfwjs": "^4.1.0"
  },
}

Error:

Uncaught (in promise) Error: Kernel 'Slice' not registered for backend 'cpu'
    at Engine.runKernel (content.js:24596:13)
    at slice_ (content.js:27129:17)
    at slice__op (content.js:25190:22)
    at slice4d_ (content.js:29498:10)
    at slice4d__op (content.js:25190:22)
    at content.js:37521:16
    at content.js:24551:16
    at Engine.scopedRun (content.js:24561:19)
    at Engine.tidy (content.js:24550:17)
    at tidy (content.js:25417:17)
@gboere gboere changed the title Kernel 'Slice' ou 'Multiply' "not registered" for any backend, tried multiple models. Kernel 'Slice' or 'Multiply' "not registered" for any backend, tried multiple models. Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant