tfjs: Error: The shape of dict[‘input_tensor’] provided in model.execute(dict) must be [1,-1,-1,3]
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information MacOS Big Sur Node v15.7.0 NPM 7.20.0
I’m running @tensorflow/tfjs-node v 3.7.0
I attempted to convert my saved model to friendly model json using tensorflowjs_converter
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--saved_model_tags=serve \
--signature_name=serving_default \
/saved_model \
/json-model
When run model.predict(), it’s throwing these errors
Error: The shape of dict['input_tensor'] provided in model.execute(dict) must be [1,-1,-1,3], but was [1,600,800,4]
at Object.assert (/object-detection/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:337:15)
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7478:28
at Array.forEach (<anonymous>)
at GraphExecutor.checkInputShapeAndType (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7470:29)
at GraphExecutor.<anonymous> (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7272:34)
at step (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:81:23)
at Object.next (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:62:53)
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:55:71
at new Promise (<anonymous>)
at __awaiter (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:51:12)
I have also tried model.executeAsync() instead of model.predict(), executeAsync() NOTE: When use with SavedModel(without the conversion) it works for both image types
for jpg image
Image: 1440000 bytes with shape: Tensor {
kept: false,
isDisposedInternal: false,
shape: [ 1, 600, 800, 3 ],
dtype: 'int32',
size: 1440000,
strides: [ 1440000, 2400, 3 ],
dataId: {},
id: 918,
rankType: '4',
scopeId: 2
}
Error: Invalid TF_Status: 3
Message: In[0] and In[1] has different ndims: [1,8,8,64,2] vs. [2,1]
for png image
Error: The shape of dict['input_tensor'] provided in model.execute(dict) must be [1,-1,-1,3], but was [1,600,800,4]
If I add ----control_flow_v2=True to do the conversion, it will fail to loadGraphModel.
I'm running @tensorflow/tfjs-node v 3.7.0 and I'm still getting this error "Cannot read property 'outputs' of undefined" when tried to load model json that was converted from saved model using tensorflowjs_converter.
When I changed to @tensorflow/tfjs-node@next, it would throw "Cannot read property 'children' of undefined"
model = await tf.loadGraphModel(modelPath);
2021-07-10 13:26:00.618147: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
TypeError: Cannot read property 'outputs' of undefined
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3851:31
at Array.forEach ()
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3848:29
at Array.forEach ()
at OperationMapper.mapFunction (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3846:18)
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3679:56
at Array.reduce ()
at OperationMapper.transformGraph (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3678:48)
at GraphModel.loadSync (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7763:68)
at GraphModel. (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7737:52)
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 22 (7 by maintainers)
Hi, @playground
Apologize for the delayed response and I tried to replicate the same issue from my end and it’s giving similar error message so we’ll have to dig more into this issue and will update you soon, thank you for noticing this issue I really appreciate your efforts and time. Thank you!
CC :@mattsoulanille
Here is error log output for your reference, I tried with
.predict()
,.execute()
and.executeAsync()
: