Kernel 'Slice' or 'Multiply' "not registered" for any backend, tried multiple models.
Opened this issue · 0 comments
gboere commented
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)