react-native-fast-tflite icon indicating copy to clipboard operation
react-native-fast-tflite copied to clipboard

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

Open Pingou opened this issue 1 year ago • 9 comments

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> ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Pingou avatar Sep 24 '24 13:09 Pingou

I'm having the same issue.

asadwan avatar Sep 30 '24 13:09 asadwan

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

Clcada3301 avatar Oct 01 '24 10:10 Clcada3301

Same issue here. Any one have solution?

CannoChen avatar Oct 01 '24 13:10 CannoChen

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.

wojciech-kubiak avatar Oct 01 '24 13:10 wojciech-kubiak

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?

CannoChen avatar Oct 01 '24 13:10 CannoChen

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

Exactly the one i linked.

wojciech-kubiak avatar Oct 01 '24 13:10 wojciech-kubiak

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?

Miraii133 avatar Oct 01 '24 14:10 Miraii133

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.

wojciech-kubiak avatar Oct 01 '24 14:10 wojciech-kubiak

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!

CannoChen avatar Oct 01 '24 14:10 CannoChen

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

manu13008 avatar Oct 04 '24 16:10 manu13008

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",

Pingou avatar Oct 04 '24 16:10 Pingou

Are you seeing this on Android & iOS?

I am seeing only in Android

lucksp avatar Oct 06 '24 05:10 lucksp

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

diegomeire avatar Oct 06 '24 10:10 diegomeire

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

JamTheDev avatar Oct 08 '24 12:10 JamTheDev

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.

manu13008 avatar Oct 08 '24 12:10 manu13008

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 avatar Oct 08 '24 12:10 CannoChen

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

CannoChen avatar Oct 09 '24 05:10 CannoChen

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

lucksp avatar Oct 09 '24 12:10 lucksp

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

CannoChen avatar Oct 09 '24 13:10 CannoChen

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

RayanMoarkech avatar Oct 28 '24 23:10 RayanMoarkech

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 avatar Nov 21 '24 22:11 lucksp

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

lucksp avatar Nov 24 '24 15:11 lucksp