私は事前に訓練された開始モデルを提供しており、これまで公式のチュートリアルに従ってきました。それはTensorflowのサービングAPIからであるように私はprediction_service.protoを使用していNodejs Tensorflow Serving Client Error 3
{ Error: contents must be scalar, got shape [305]
[[Node: map/while/DecodeJpeg = DecodeJpeg[_output_shapes=[[?,?,3]], acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](map/while/TensorArrayReadV3)]]
at /server/node_modules/grpc/src/client.js:554:15 code: 3, metadata: Metadata { _internal_repr: {} } }
次のように私は現在、エラーコード3を取得しています。ここで私は関数を定義し、私のNodejsファイルです:
const PROTO_PATH = "./pb/prediction_service.proto";
const TensorflowServing = grpc.load(PROTO_PATH).tensorflow.serving;
const testClient = new TensorflowServing.PredictionService(
TF_TEST, grpc.credentials.createInsecure()
);
function getTestModelMsg(val){
return {
model_spec: { name: "inception", signature_name: "predict_images", version: 1},
inputs: {
images: {
dtype: "DT_STRING",
tensor_shape: {
dim: [{size: 220}, {size: 305}],
unknown_rank: false
},
string_val: val
}
}
}
}
function predictTest(array, callback) {
testClient.predict(getTestModelMsg(array), (error, response) => {
if(error)
return callback(error);
callback(null, response.outputs)
})}
は、次のように私は、二値画像として画像に渡している:
fs.readFile('./test/Xiang_Xiang_panda.jpg', (err, data) => {
if(err) {
return res.json({message: "Not found"});
}
predictTest(data.toString('binary') , (error, outputs) => {
if (error) {
console.error(error);
return res.status(500).json({ error });
}
res.status(200).json({ outputs });
})
})
私はしばらくの間、この時に立ち往生してきましたもし誰かがここで私を助けることができたら本当に感謝します!どんな助けも素晴らしいだろう! ありがとうございます! :)