mrousavy / react-native-fast-tflite

🔥 High-performance TensorFlow Lite library for React Native with GPU acceleration
https://mrousavy.com
MIT License
732 stars 41 forks source link

fatal error: 'tensorflow/lite/c/c_api.h' file not found #91

Open Pingou opened 2 months ago

Pingou commented 2 months ago

on 1.4.0, I have the following error on mac m2 when compiling:

In file included from /Users/pingou/react/app/node_modules/react-native-fast-tflite/cpp/TensorHelpers.cpp:9: /Users/pingou/react/app/node_modules/react-native-fast-tflite/android/../cpp/TensorHelpers.h:15:10: fatal error: 'tensorflow/lite/c/c_api.h' file not found

include <tensorflow/lite/c/c_api.h>

     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
asadwan commented 1 month ago

I'm having the same issue.

Clcada3301 commented 1 month ago

I'm having the same issue. fatal error: 'tensorflow/lite/c/c_api.h' file not found

CannoChen commented 1 month ago

Same issue here. Any one have solution?

wojciech-kubiak commented 1 month ago

Same here. Temporary fix is to manually clone tensorflow repo into node_modules/react-native-fast-tflite/. This is removed every time you run yarn install, but you can build the app for now.

CannoChen commented 1 month ago

Same here. Temporary fix is to manually clone tensorflow repo into node_modules/react-native-fast-tflite/. This is removed every time you run yarn install, but you can build the app for now.

Can you elaborate on your solution? Exactly which module of tensorflow is copied in?

wojciech-kubiak commented 1 month ago

Can you elaborate on your solution? Exactly which module of tensorflow is copied in?

Exactly the one i linked.

Miraii133 commented 1 month ago

Can you elaborate on your solution? Exactly which module of tensorflow is copied in?

Exactly the one i linked.

By clone tensor flow repo, did you mean the entire repo of tensorflow?

wojciech-kubiak commented 1 month ago

By clone tensor flow repo, did you mean the entire repo of tensorflow?

yes, the entire repo.

EDIT: I cloned the entire repo but it's not necessary, see below.

CannoChen commented 1 month ago

Can you elaborate on your solution? Exactly which module of tensorflow is copied in?

Exactly the one i linked.

By clone tensor flow repo, did you mean the entire repo of tensorflow?

No, It is not neccessary! The only thing you must do is to copy tensorflow/lite dir to react-native-fast-tflite/cpp.

In my project, It work fine! But, I meet other issue again. It can't read my tflite model now!

manu13008 commented 1 month ago

@CannoChen was the next issue related also to this issue ? Thanks

Pingou commented 1 month ago

Same here. Temporary fix is to manually clone tensorflow repo into node_modules/react-native-fast-tflite/. This is removed every time you run yarn install, but you can build the app for now.

have you tried pointing to master instead of the npm version? Ex of package.json: "react-native-fast-tflite": "git://github.com/mrousavy/react-native-fast-tflite#master",

lucksp commented 1 month ago

Are you seeing this on Android & iOS?

I am seeing only in Android

diegomeire commented 1 month ago

This is what I did to solve it: 1- Added the package normally through yarn add react-native-fast-tflite 2- Kept a copy of tensorflow in the app folder 3- Added a post install script on package.json to copy the tensorflow folder to node_modules: "postinstall": "cp -r ./tensorflow ./node_modules/react-native-fast-tflite"

Now, every time I run yarn install or add another package, the tensorflow folder is re-copied. This worked for me. Hope it helps

JamTheDev commented 1 month ago

Same problem here. I hope a solution can be delivered this week . I need TFLite for my project. Thanks

manu13008 commented 1 month ago

Same problem here. I hope a solution can be delivered this week . I need TFLite for my project. Thanks

Just take the 1.3.0 version while waiting for the issue to be fixed.

CannoChen commented 1 month ago

Same problem here. I hope a solution can be delivered this week . I need TFLite for my project. Thanks

You can try using tensorflowjs directly. For me, I gave up using this repo. after I used tensorflowjs, my project worked correctly. You can find the code in my project: https://github.com/CannoChen/SmartBMS

CannoChen commented 1 month ago

@CannoChen was the next issue related also to this issue ? Thanks

No, it isn't. In my view, I dont suggest you to use this repo. I suggest that you should use tensorflowjs directly!!! It more simple, and more close to tensorflow_lite model.

lucksp commented 1 month ago

@CannoChen was the next issue related also to this issue ? Thanks

No, it isn't. In my view, I dont suggest you to use this repo. I suggest that you should use tensorflowjs directly!!! It more simple, and more close to tensorflow_lite model.

I’d like to try using TFJS directly. But are the docs from tensorflow correct to install in React native?

CannoChen commented 1 month ago

@CannoChen was the next issue related also to this issue ? Thanks

No, it isn't. In my view, I dont suggest you to use this repo. I suggest that you should use tensorflowjs directly!!! It more simple, and more close to tensorflow_lite model.

I’d like to try using TFJS directly. But are the docs from tensorflow correct to install in React native?

Of course, you can! But there are some tricks that you may focus:

RayanMoarkech commented 3 weeks ago

I think this issue is related to the file change to android/CMakeLists.txt https://github.com/mrousavy/react-native-fast-tflite/commit/35d7cbdcb25fee51584f0c5667c9764d4f2ffcfe

lucksp commented 2 days ago

any update on this? I need the fix in 1.5.0 to load file on android...but tensorflow/lite/c/c_api.h missing is still throwing an error.

lucksp commented 5 hours ago

For those interested, please test https://github.com/mrousavy/react-native-fast-tflite/pull/112 PR posted from @bang9