问题描述
我正在尝试创建一个简单的应用程序来检测和标记它。但是我遇到了这个错误。
我正在使用节点v12.18.2和tfjs v2.3.0
const fs = require('fs');
const tfnode = require('@tensorflow/tfjs-node');
require('@tensorflow/tfjs-backend-cpu');
const mobilenet = require('@tensorflow-models/mobilenet');
const knnClassifier = require('@tensorflow-models/knn-classifier');
const { config } = require('dotenv');
config({
path: __dirname + '/.env'
})
async function main(){
const model = await mobilenet.load();
const classifier = await knnClassifier.create();
const buf = fs.readFileSync('./41.jpg');
const decode = tfnode.node.decodeImage(buf);
training(model,classifier,decode,'zubat');
const buf2 = fs.readFileSync('./744.jpg');
const decode2 = tfnode.node.decodeImage(buf2);
training(model,decode2,'Rockruff');
const predict = fs.readFileSync('./pokemon.jpg');
let predict2 = tfnode.node.decodeImage(predict);
let data = await classifier.predictClass(predict2,3);
console.log(data);
}
main();
async function training(model,data,label){
return new Promise(async resolve => {
const embedding = model.infer(
data,false
);
classifier.addExample(
embedding,label
)
})
}
错误:
2020-08-16 17:48:30.338749: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-08-16 17:48:30.365755: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x10851dbe0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-16 17:48:30.365788: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host,Default Version
(node:11983) UnhandledPromiseRejectionWarning: Error: Invalid TF_Status: 5
Message: Could not find valid device for node.
Node:{{node Sqrt}}
All kernels registered for op Sqrt :
device='XLA_CPU'; T in [DT_FLOAT,DT_DOUBLE,DT_COMPLEX64,DT_BFLOAT16,DT_COMPLEX128,DT_HALF]
device='XLA_CPU_JIT'; T in [DT_FLOAT,DT_HALF]
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_DOUBLE]
device='CPU'; T in [DT_BFLOAT16]
device='CPU'; T in [DT_COMPLEX64]
device
41.jpg,744.jpg和pokemon.jpg在这里。
我的计算机规格是MBP 2020基本型号和PC with dxdiag log
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)