Skip to content
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

@tensorflow/tfjs-react-native can't be installed successfully expo 51 #8292

Open
JRfan123 opened this issue Jun 2, 2024 · 18 comments
Open

Comments

@JRfan123
Copy link

JRfan123 commented Jun 2, 2024

Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): mac
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: not
  • TensorFlow.js installed from (npm or script link): npx expo install @tensorflow/tfjs-react-native
  • TensorFlow.js version:
  • CUDA/cuDNN version:

Describe the problem

image

The conflict between expo camera @ "^ 13.4.4" resulted in installation dependency failure, but after expo 50, a new version of the camera is installed by default, and the new camera is not compatible with the old camera

expo document : https://docs.expo.dev/versions/latest/sdk/camera/

by the way: I want to use the transpose api about the image to handle image


    const imageBuffer = await Image.resolveAssetSource(require("@/assets/images/dogs.jpg")).uri;
    const imageData = await fetch(imageBuffer);
    const imageBlob = await imageData.blob();
    const imageArrayBuffer = await imageBlob.arrayBuffer();
    const imageUint8Array = new Uint8Array(imageArrayBuffer);
    
    // 将图像转换为 TensorFlow.js 张量并进行预处理
    const imageTensor = decodeJpeg(imageUint8Array);
    const inputImage = tf.transpose(imageTensor, [2, 0, 1]).expandDims(0).div(tf.scalar(255));

Provide the exact sequence of commands / steps that you executed before running into the problem

Any other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

@Jersyfi
Copy link

Jersyfi commented Jun 2, 2024

@JRfan123 The imports in tfjs-react-native for expo camera are not up to date. With SDK the expo-camera import changed from 'expo-camera' to 'expo-camera/lagacy'. It would be better if the tfjs-react-native would be updated to newer expo versions but at the moment i'll get no progress on this. Maybe you have time to create a pull request for requesting the changes.

@JRfan123
Copy link
Author

JRfan123 commented Jun 3, 2024

ok , i will try it

@gaikwadrahul8
Copy link
Contributor

Hi, @JRfan123

I apologize for the delayed response and @Jersyfi thank you for your pointers and I see Expo changelog from official documentation You can find the old versions at expo-camera/legacy and expo-sqlite/legacy during SDK 51, and they will be removed in SDK 52. so following an initial assessment, it appears that updating @tensorflow/tfjs-react-native to support newer Expo versions might be required.

I will raise this issue for discussion in our upcoming internal meeting and provide a status update soon. We are also open to contributions on this matter. Feel free to submit a pull request for our team's review and we will take appropriate action to integrate your contribution if it aligns with our goals.

// Legacy APIs (SDK 50)
import { Camera } from 'expo-camera';

// Legacy APIs (SDK 51): if you import the legacy packages in your app, update
// the imports to the following:
import { Camera } from 'expo-camera/legacy';

Thank you for your cooperation and patience.

@Jersyfi
Copy link

Jersyfi commented Jun 9, 2024

@gaikwadrahul8 Thank you for seeing the need of updating. It would make sence to update to the newest expo-camera API and also to support the newest expo-gl version and drop the expo-gl-cpp. On Expo SDK 50 the @tensorflow/tfjs-react-native package was running with high performance issues for iOS and Android and not on all devices. I can provide the package.json with the running versions for SDK 50.

{
    // Excluded name, version, private, main & scripts
    },
    "dependencies": {
        "@hookform/resolvers": "^3.3.4",
        "@mediapipe/pose": "^0.5.1675469404", // required
        "@react-native-async-storage/async-storage": "1.21.0", // required
        "@react-native-community/datetimepicker": "7.7.0",
        "@react-native-firebase/app": "^20.0.0",
        "@react-native-firebase/auth": "^20.0.0",
        "@react-native-firebase/firestore": "^20.0.0",
        "@react-native-firebase/functions": "^20.0.0",
        "@react-native-firebase/storage": "^20.0.0",
        "@react-navigation/bottom-tabs": "^6.5.20",
        "@react-navigation/native": "^6.1.17",
        "@react-navigation/native-stack": "^6.9.26",
        "@tensorflow-models/pose-detection": "^2.1.3", // required
        "@tensorflow/tfjs": "^4.19.0", // required
        "@tensorflow/tfjs-backend-webgl": "^4.19.0", // required
        "@tensorflow/tfjs-backend-webgpu": "^4.19.0", // required
        "@tensorflow/tfjs-react-native": "^1.0.0", // required
        "expo": "50.0.19", // required and below SDK 51
        "expo-av": "~13.10.6",
        "expo-build-properties": "~0.11.1",
        "expo-camera": "~14.1.3", // required and below version 15
        "expo-dev-client": "~3.3.12",
        "expo-device": "~5.9.4",
        "expo-file-system": "~16.0.9",
        "expo-gl": "~13.6.0", // required
        "expo-image": "~1.10.6",
        "expo-image-manipulator": "~11.8.0",
        "expo-image-picker": "~14.7.1",
        "expo-keep-awake": "~12.8.2",
        "expo-linear-gradient": "~12.7.2",
        "expo-linking": "~6.2.2",
        "expo-screen-orientation": "~6.4.1",
        "expo-splash-screen": "~0.26.5",
        "expo-status-bar": "~1.11.1",
        "expo-system-ui": "~2.9.4",
        "expo-web-browser": "~12.8.2",
        "lucide-react-native": "^0.378.0",
        "react": "18.2.0",
        "react-hook-form": "^7.51.1",
        "react-native": "0.73.6",
        "react-native-fs": "^2.20.0", // required
        "react-native-gesture-handler": "~2.14.0",
        "react-native-reanimated": "~3.6.2",
        "react-native-safe-area-context": "4.8.2",
        "react-native-screens": "~3.29.0",
        "react-native-svg": "14.1.0",
        "react-native-ui-lib": "^7.22.0",
        "seedrandom": "^3.0.5"
    },
    "devDependencies": {
        "@babel/core": "^7.20.0",
        "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
        "@babel/plugin-proposal-optional-chaining": "^7.21.0",
        "@babel/plugin-transform-arrow-functions": "^7.24.1",
        "@babel/plugin-transform-optional-chaining": "^7.24.1",
        "@babel/plugin-transform-shorthand-properties": "^7.24.1",
        "@babel/plugin-transform-template-literals": "^7.24.1",
        "@babel/preset-env": "^7.24.3",
        "@react-native/babel-preset": "*",
        "@types/react": "~18.2.79",
        "@typescript-eslint/eslint-plugin": "^6.12.0",
        "@typescript-eslint/parser": "^6.12.0",
        "eslint": "^8.45.0",
        "eslint-config-prettier": "^9.0.0",
        "eslint-config-universe": "^12.0.0",
        "eslint-plugin-prettier": "^5.1.3",
        "eslint-plugin-react-native": "^4.1.0",
        "prettier": "3.0.0",
        "typescript": "~5.3.3"
    }
}

@JRfan123 did you get the SDK 51 running on your side? Maybe i can help out with spending some time.

@JRfan123
Copy link
Author

@Jersyfi I apologize for the delayed response, I had successfully in my side , and I will try to make a pull request this week

@Arijitofficial
Copy link

@Jersyfi I apologize for the delayed response, I had successfully in my side , and I will try to make a pull request this week

Is it merged yet? we are still facing the same issue

@EmePin
Copy link

EmePin commented Jun 18, 2024

@Jersyfi How did you make it work on SDK 51? and does the apk work for you with eas build -p android --profile preview?

@gimhantharuke456
Copy link

Anyone solved this issue ?

@Jersyfi
Copy link

Jersyfi commented Jun 25, 2024

At the moment i can't continue the update to SDK51 but @JRfan123 already made a PR #8306 that need attention. @gaikwadrahul8 can you please have a look at the changes? I overlooked it even if it is minimalistic but it makes sense with reading the changelog on expo-camera.

@XAUdrizzy
Copy link

At the moment i can't continue the update to SDK51 but @JRfan123 already made a PR #8306 that need attention. @gaikwadrahul8 can you please have a look at the changes? I overlooked it even if it is minimalistic but it makes sense with reading the changelog on expo-camera.

Any updates on this topic?

@joaops95
Copy link

Facing the same problem! :(

@gimhantharuke456
Copy link

I tried so many ways finally I decided to make an api and work with the model

@chrisdev3001
Copy link

In my case camera and model.predict working only on IOS (using expo go)
but with android is like that the model is predicting nothing using estimatePoses :(

any updates about this?

I've tried to use legacy camera and it is not working enought

@sepretf
Copy link

sepretf commented Sep 18, 2024

In my case camera and model.predict working only on IOS (using expo go) but with android is like that the model is predicting nothing using estimatePoses :(

any updates about this?

I've tried to use legacy camera and it is not working enought

Hey, I’ve been having issues with integrating TensorFlow's pose estimation models on iOS/Android for a couple of years too...
So, I shifted to a different approach a few months ago—using a Node.js API with tfjs that I call within an iframe to process the images. My API is PoseTracker.com (https://www.posetracker.com/), additionally, we've been developing pre-trained fitness exercises! A big advantage is that there's no need to install any SDK/libraries—just call the API. We are focus mainly on pose estimation, but I'm open to exploring other models as well, so feel free to reach out!

@Martinnord
Copy link

Will this be supported or what?

@johannbuscail
Copy link

@gaikwadrahul8 Any update ?

@immanuel-rajadurai
Copy link

I am facing the same issue #8292 as described by JRfan123.

I need to build an APK asap this weekend. Any quick fix?

@YangMun
Copy link

YangMun commented Dec 2, 2024

I have the same problem. I need to recognize hands for sign language learning.
Currently expo: 52 SDK, expo-camera: 16.0.7.
@tensorflow/tfjs-react-native version of the crash is happening and it doesn't even come up in the document, so I'd like to know how to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests