tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

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

Open JRfan123 opened this issue 1 year ago • 25 comments

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.

JRfan123 avatar Jun 02 '24 10:06 JRfan123

@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.

Jersyfi avatar Jun 02 '24 14:06 Jersyfi

ok , i will try it

JRfan123 avatar Jun 03 '24 03:06 JRfan123

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.

gaikwadrahul8 avatar Jun 05 '24 20:06 gaikwadrahul8

@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.

Jersyfi avatar Jun 09 '24 12:06 Jersyfi

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

JRfan123 avatar Jun 11 '24 11:06 JRfan123

@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

Arijitofficial avatar Jun 18 '24 06:06 Arijitofficial

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

EmePin avatar Jun 18 '24 22:06 EmePin

Anyone solved this issue ?

gimhantharuke456 avatar Jun 22 '24 16:06 gimhantharuke456

At the moment i can't continue the update to SDK51 but @JRfan123 already made a PR https://github.com/tensorflow/tfjs/pull/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.

Jersyfi avatar Jun 25 '24 20:06 Jersyfi

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?

XAUdrizzy avatar Jul 08 '24 11:07 XAUdrizzy

Facing the same problem! :(

joaointech avatar Jul 25 '24 15:07 joaointech

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

gimhantharuke456 avatar Jul 28 '24 17:07 gimhantharuke456

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

chrisdev3001 avatar Aug 07 '24 01:08 chrisdev3001

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!

sepretf avatar Sep 18 '24 07:09 sepretf

Will this be supported or what?

Martinnord avatar Nov 11 '24 15:11 Martinnord

@gaikwadrahul8 Any update ?

johannbuscail avatar Nov 29 '24 09:11 johannbuscail

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

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

immanuel-rajadurai avatar Nov 29 '24 16:11 immanuel-rajadurai

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.

YangMun avatar Dec 02 '24 01:12 YangMun

Can we get an update on this, please? The package is pretty much unusable in its current state. Downgrading expo-camera to 13.4.4 leads to a bunch of other issues, so would be nice if this worked with more recent versions

ArtjomUEA avatar Jan 10 '25 02:01 ArtjomUEA

Agreed... I've spent about 12 hours now bumping dependency versions around, and still can't get the boilerplate example to run successfully. Pretty disappointed with the state of this package.

stevemer avatar Jan 10 '25 15:01 stevemer

is there's any update on this issue?

aaaroz avatar Jan 16 '25 03:01 aaaroz

is there's any update on this issue?

actually no mate, either u have to make an api or downgrade the expo version

gimhantharuke456 avatar Jan 16 '25 03:01 gimhantharuke456

is there's any update on this issue?

actually no mate, either u have to make an api or downgrade the expo version

all right, i decided to make an api instead

aaaroz avatar Jan 16 '25 03:01 aaaroz

Opened this PR https://github.com/tensorflow/tfjs/pull/8521 to resolve the issue with package updates and React Native architecture alignment.

sanjaiyan-dev avatar Feb 20 '25 14:02 sanjaiyan-dev

running expo 53. Any solution? I'm still having issues.

MrBCftw avatar May 17 '25 06:05 MrBCftw