tfjs: Error: Argument "x" passed to 'conv2d' must be a Tensor or TensorLike, but got 'tensor'
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): no
- OS Platform for development: Windows 10, RN expo SDK
- Mobile device: Android 10, Huawei P30 pro
- TensorFlow.js installed from: npm
- TensorFlow.js version: ^4.0.0
- Tensorflow.js react-native version: ^0.8.0
Describe the current behavior on android, type of images.next().value is ‘Tensor’, not Tensor or TensorLike. It results in error " Error: Argument “x” passed to ‘conv2d’ must be a Tensor or TensorLike, but got ‘tensor’ "
Describe the expected behavior should work the same as on iOS
Problem happens only with Hermes JS engine
Standalone code to reproduce the issue
import { dispose, Tensor3D } from "@tensorflow/tfjs";
import { cameraWithTensors } from "@tensorflow/tfjs-react-native";
export const ExampleComponent = () => {
const handleCameraStream = useCallback(
(images: IterableIterator<Tensor3D>) => {
const loop = async () => {
const tensor = images.next().value;
detectGesture(tensor); // error happens here, model predict is called inside and specified error occurs
},
[isGestureDetectionReady]
);
return
<TensorCamera
type={CameraType.front}
cameraTextureHeight={640}
cameraTextureWidth={640}
resizeHeight={640}
resizeWidth={640}
onReady={handleCameraStream}
autorender={true}
/>
}
<TensorCamera
type={CameraType.front}
autoFocus={false}
pictureSize={pictureSize}
style={{
position: "absolute",
left: 50,
top: 100,
width: 120,
height: 120,
zIndex: 1,
borderWidth: 1,
borderColor: "black",
borderRadius: 0,
}}
cameraTextureHeight={640}
cameraTextureWidth={640}
resizeHeight={640}
resizeWidth={640}
zoom={0}
onReady={handleCameraStream}
autorender={true}
/>
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (4 by maintainers)
I tried with the recommended dependencies an it works.
The issue with the suggested version is that support for 44 has been dropped by expo quite a bit of time ago.
The latest currently supported version of expo is 47.
I tried running with specifying
"jsEngine": "jsc"in the app.json but that also doesn’t work witht the latest expo 49doesn’t work with “jsEngine”: “hermes”, works with “jsEngine”: “jsc”
@SadmanYasar Thanks: as u mentioned it’s working as expected but so far I got it working adding on app.json. “jsEngine”: “jsc”, “assetBundlePatterns”: [ “**/*” ], “plugins”: [ [ “expo-camera”, { “cameraPermission”: “Allow $(PRODUCT_NAME) to access your camera.” } ] ] then I got some poses displaying on the camera 😃 Hope for next release…
I was experiencing this on the latest version of tfjs regardless of whether hermes was enabled or not. Downgrading to an older version of tfjs (
3.7.0) fixed this for me. Seems like v4 of tfjs andtfjs-react-nativecurrently aren’t compatible.