aby*_*are 5 python react-native tensorflow tensor tensorflow2.0
我正在使用 React Native 跟踪cameraWithTensors 示例代码,但收到一个奇怪的错误,即相机张量是“Tensor”而不是 Tensor 或 TensoreLike
handleCameraStream(images, updatePreview, gl) {
const loop = async () => {
const nextImageTensor = images.next().value;
nextImageTensor.toFloat();
// throws [Error: Argument 'x' passed to 'cast' must be a Tensor or TensorLike, but got 'Tensor']
nextImageTensor.expandDims(0);
// throws [Error: Argument 'x' passed to 'expandDims' must be a Tensor or TensorLike, but got 'Tensor']
// Solved both of it using tf.func but my model is giving a similar error now
model.predict( tf.expandDims( tf.cast(nextImageTensor, 'float32'), 0) );
// throws [Error: Argument 'x' passed to 'stridedSlice' must be a Tensor or TensorLike, but got 'Tensor']
//requestAnimation(loop);
}
loop();
}
return <View>
<TensorCamera
// Standard Camera props
style={styles.camera}
type={Camera.Constants.Type.back}
// Tensor related props
cameraTextureHeight={textureDims.height}
cameraTextureWidth={textureDims.width}
resizeHeight={640}
resizeWidth={640}
resizeDepth={3}
onReady={handleCameraStream}
autorender={true}
/>
</View>
Run Code Online (Sandbox Code Playgroud)
不确定这个错误意味着什么。我尝试打印出基本张量和相机张量,它们看起来都很相似
console.log(tf.tensor4d([[
[[1, 3], [2, 8]],
[[3, 9], [4, 2]]
]]))
// {"dataId": {"id": 247}, "dtype": "float32", "id": 253, "isDisposedInternal": false, "kept": false, "rankType": "4", "shape": [1, 2, 2, 2], "size": 8, "strides": [8, 4, 2]}
console.log( tf.expandDims( tf.cast(nextImageTensor, 'float32'), 0))
// {"dataId": {"id": 246}, "dtype": "float32", "id": 255, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 14, "shape": [1, 640, 640, 3], "size": 1228800, "strides": [1228800, 1920, 3]}
Run Code Online (Sandbox Code Playgroud)
有谁知道这是怎么回事?
| 归档时间: |
|
| 查看次数: |
384 次 |
| 最近记录: |