tfjs
tfjs copied to clipboard
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}
/>
doesn't work with "jsEngine": "hermes", works with "jsEngine": "jsc"
hermes
is not supported at this time , please refer to the issue . Thank you!
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 and tfjs-react-native
currently aren't compatible.
Hi, @zbagdzevicius
Apologize for the delayed response and please refer this comment, It seems like there is package dependancies compatibility issue so could you please try with package dependancies which are mentioned in this official documentation and let us know whether is it working as expected or not ?
If issue still persists please let us know ? Thank you!
"expo": "~44.0.2",
"expo-camera": "^12.1.0",
"expo-file-system": "^13.2.0",
"expo-gl": "^11.1.1",
"expo-gl-cpp": "^11.1.0",
"react": "17.0.1",
"react-native": "~0.64.3",
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
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 49
doesn't work with "jsEngine": "hermes", works with "jsEngine": "jsc"
This and I had to update all dependencies to the latest versions using yarn upgrade --latest
to resolve this issue. So far seems to work with Expo SDK 49. Here is the working repo.
Hi, @zbagdzevicius
Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.
The TFJs team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TFJs version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.
Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow.js space.
Thank you for your support and cooperation.
@SadmanYasar Did you made pose detection work with last expo SDK 49 please help
@RachidZianne I tried with pose detection model and have it running on Expo SDK 49. Source. However, it is not working as expected. FPS is very low, around 3-4 FPS on my phone. I think there isn't much support for this SDK version.
@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...
Any one got this error when building on android? Could not set unknown property 'classifier' for task ':expo-gl-cpp:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.
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 49
Hey @ovidb were you able to fix this?
What is the procedure to change the "jsEngine" to "jsc"? When I add this in my app.json, my app is crashing. Do I missing any installation or updating?