-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cameraWithTensors Error: Argument 'x' passed to 'cast' must be a Tensor or TensorLike, but got 'Tensor' #5972
Comments
The link above refers to previous version(0.2) , can you try with latest version https://js.tensorflow.org/api_react_native/0.8.0/#cameraWithTensors and let us know. Thank you |
Hey @rthadur, thanks for replying back.
And the code for 0.8.0 looks the same, except 0.2 has these camera configs
I removed those, still no go |
I was reading through the documentation to make sure I hadn't missed anything and I saw it talks about npm run web and the example is a webcam one. I'm trying to run it on android and iOS. Does tfjs-react-native only run on react native web? |
I found this working example for mobile. I'll try to downgrade all the packages to what this example uses, maybe that will work 🤞 |
It's hard to find installtion documentation for older versions of expo and components. Lot of setup seems to have changed. I tried just downgrading @tensorflow/tfjs to "3.9.0" but still the same issue. Were you able to reproduce this issue? |
I tried creating a repo to reproduce the issue https://github.com/sarons/TensorCameraBug The problem seems to be pecular to repos that don't have expo. Projects created from expo and running on expo go seems to mask the issue. I only added expo sdk because tensorflowjs needs expo camera. |
Hi @sarons sorry for the delay.. Our team is fairly busy lately and haven't had a chance to look into this. I quickly tried the current pose detection demo with expo and it doesn't work anymore on my iPhone.. still trying to figure out why. Most likely related to expo-gl not compatible with the new iOS maybe? I will try take a closer look some time this week. Thanks for your patience. |
Thanks @jinjingforever. I'm trying this on an android device btw, same issue on it. |
Hi, I took a closer look today and here are what I found:
const {getDefaultConfig} = require('metro-config');
module.exports = (async () => {
const defaultConfig = await getDefaultConfig();
const {assetExts} = defaultConfig.resolver;
return {
resolver: {
// Add bin to assetExts
assetExts: [...assetExts, 'bin'],
},
};
})();
Give these a try and let me know how it goes. Thanks! |
Hey @jinjingforever, thanks for looking into it. My metro config is the same as yours. I just didn't have it in the repo branch. Doing tf.ready() as well, still no go with my current setup which is
I downgraded to your versions. Not sure how you got expo 44 working with expo-camera 11 on device. react-native-unimodules has been depreciated since expo 43 but the old camera version needs it. So when I try to compile android on device, I'm hit with
maybe unimodules and new expo are incompatible on android. Any chance you have an android device handy? I'm open to using old expo, if it only works there. Just don't have old expo documentation. The new one adds a bunch of stuff to podfile and gradle. |
Hi @sarons I created a PR that uses expo 44 with the latest expo-camera (12.1.0) without react-native-unimodules, and it seems to work on both my iPhone and Pixel 2. However it is an expo app:) Please give it a try and see if it works. Frankly I am not too familiar with what the differences are between an expo app and a react-native CLI app. Is there any way you could diff them? |
Thanks @jinjingforever I'll try it out the changes you made. Altough I had done an expo upgrade on your pose app a while back and it was working fine through the expo go fine. I have also never used expo, there maybe other differences too. Only dealing with it since tensorflow is locked in with expo-camera. Tried to do it the expo way, but registerRootComponent hardcodes app name it to'main' here and withExpoRoot isn't avaiable publicly. At this point, I'm even considering creating a new expo app and move all my existing code to it. Desperate times.. ¯_(ツ)_/¯ |
Hey @jinjingforever, I have got it working in the bug repo with the npm versions you used in your PR . Still getting the same error on my main repo with the same versions, but atleast I have a working reference now. Thanks |
Thanks for the update @sarons. Sorry for this tedious process.. Hope you find the root cause soon. |
I have the same problem trying to cast or use a tensor as well. const imageTensor = images.next().value as tf.Tensor3D
// tf.node.js: [Error: Argument 'x' passed to 'cast' must be a Tensor or TensorLike, but got 'Tensor']
imageTensor.cast('float32') However, I can do For some reason, getGlobalTensorClass().prototype.cast = function (dtype) {
this.throwIfDisposed();
console.log(this instanceof Tensor); // false
console.log(this instanceof getGlobalTensorClass()); // true
return cast(this, dtype);
}; I think this is a reason why it doesn't pass the On the other hand, I also get this error when using image tensor with a model. However, the error is thrown from |
Good news: I get it to work now! Since My solution is to replace all the |
Closing as stale. Please @mention us if this needs more attention. |
@rthadur @jinjingforever I think this issue still needs attention. The root cause is the fact that there are 2 definitions of |
Hello, I upgraded Expo and React-Native to 45, but 0.68.2 also has the same error. How should I deal with it? It works normally on 0.64 and EXPO 44, thank you |
I passed the video frame data into the face-landmarks- Detection detector. The detector execution returns the following error This content worked normally in the previous EXPO build. I wonder if there was an incompatibility between TFJS-React-Native and the new EXPO 45 SDK, EXPO-GL and Expo-GL-CPP, which led to an error. The following is the version of the core package I use now. There are no major problems such as flash back, but there are errors in the prediction process of the model network. Older versions of the environment can execute: New version environment execution error: Execute detector error section const faces = await faceDetector I don't know much about TFJS. Thank you for your help. Thank you |
I turned off Hermes to fix the above problem, and it is not clear if there was any deviation in compiling with Hermes :hermes_enabled => flags[:hermes_enabled], However, the following error occurs when running the own model on TFJS, which is similar to this topic return problem, and I will try to solve it: Error: Argument 'x' passed to 'cast' must be numeric tensor, but got string tensor |
This problem has been dealt with. The main reason is related to the data I sent in, which was modified during the update and forgot to restore. It has nothing to do with TFJS |
Closing as stale. Please @mention us if this needs more attention. |
I am having the exact same issue when calling |
i am also getting similar error from last 2 month Error: Argument 'x' passed to 'expandDims' must be a Tensor or TensorLike, but got 'Promise please help @Looooong @jinjingforever @mingmingshen @Google-ML-Butler |
Still the same issue: *Unhandled promise rejection: Error: Argument 'x' passed to 'conv2d' must be a Tensor or TensorLike, but got 'Tensor'] |
Still the same: Following are the versions of the important packages of my environment: "@tensorflow/tfjs": "^4.11.0",
"@tensorflow/tfjs-react-native": "^0.8.0",
"expo": "^49.0.0",
"expo-camera": "~13.4.4",
"expo-constants": "~14.4.2",
"expo-gl": "~13.0.1",
"expo-image-manipulator": "~11.3.0",
"react": "18.2.0",
"react-native": "0.72.4", |
Same issue here unfortunately
I am using an old version because the new versions fails to call tf.scalar(), but the error is exactly the same. I cannot test without hermes because I have react-native modules which needs hermes. |
I used to use Alternatively, Basically, the patchs replace all |
For me, I can confirm that using I think this should be addresses ASAP, at least update the documentation about it.
|
I'm trying to run TensorCamera with React Native. Follwing the example code
but I get an error that says the ImageTensors are 'Tensor' not Tensor or TensorLike
I'm tried front & back camera, same issue with both. Tried printing out the image tensor and it looks alright
Am I missing something? Seems like a simple usecase for cameraWithTensors. Please help
The text was updated successfully, but these errors were encountered: