Is there a way I can use TFLite models in Tensorflow JS? Specifically, I am using expo react native. This is the model I am trying to use in tensorflow js: TensorFlow Hub
Hi @ken_huang, You can load the tflite model if tensorflowjs using tflite.loadTFLiteModel and can make predictions using the .predict method. For more details please refer to this document Thank You.
1 Like
Yes, you can use our TFLite API to load a TFLite modal in JavaScript via TensorFlow.js:
You can then use:
tflite.loadTFliteModel(modelURL);
1 Like
Hey @Jason and @Kiran_Sai_Ramineni thank you so much! I am testing this right now, but I am coming across an error that states:
“”"
ERROR ReferenceError: Property ‘document’ doesn’t exist, js engine: hermes
ERROR Invariant Violation: “main” has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponent
wasn’t called., js engine: hermes
“”"
I searched for this error and apparently, it only happens if I have a library that depends on thedocument
object in web development. I am currently using expo react native and I have no idea how to resolve this error. I think it may be caused by “tensorflow/tfjs-tflite”: “^0.0.1-alpha.10”. Here is my installed packages list:
“”"
“react-native-async-storage/async-storage”: “^1.19.3”,
“tensorflow/tfjs”: “^4.11.0”,
“tensorflow/tfjs-react-native”: “^0.8.0”,
“tensorflow/tfjs-tflite”: “^0.0.1-alpha.10”,
“axios”: “^1.5.0”,
“babel-plugin-transform-inline-environment-variables”: “^0.4.4”,
“buffer”: “^6.0.3”,
“dotenv”: “^16.3.1”,
“expo”: “~49.0.7”,
“expo-asset”: “~8.10.1”,
“expo-av”: “~13.4.1”,
“expo-camera”: “~13.4.4”,
“expo-file-system”: “~15.4.4”,
“expo-gl”: “~13.0.1”,
“expo-image-manipulator”: “~11.3.0”,
“expo-media-library”: “~15.4.1”,
“expo-speech”: “~11.3.0”,
“expo-status-bar”: “~1.6.0”,
“openai”: “^4.3.1”,
“react”: “18.2.0”,
“react-native”: “0.72.4”,
“react-native-dotenv”: “^3.4.9”,
“react-native-fast-tflite”: “^0.3.1”,
“react-native-fs”: “^2.20.0”,
“react-native-image-resizer”: “^1.4.5”,
“react-native-safe-area-context”: “4.6.3”,
“react-native-safe-area-view”: “^1.1.1”,
“replicate”: “^0.16.1”,
“rn-fetch-blob”: “^0.12.0”
“”"
Also I removed the “@” symbol from some of these dependencies in this post because a new user can only “@” two people.