react-native-fast-tflite
react-native-fast-tflite copied to clipboard
Unable to load model from local directory
// Asset from React Native Bundle loadTensorflowModel(require('assets/my-model.tflite'))
When loading from project assets it was working total accurate. But i tried loading from my device local directory like:
// File on the local filesystem loadTensorflowModel('file:///var/mobile/.../my-model.tflite')
it says [Error: TFLite: Invalid source passed! Source should be either a React Native require(..) or a { url: string }object!]
I tried using with loadTensorflowModel('https://tfhub.dev/google/lite-model/object_detection_v1.tflite')
but it says JNI error exception, expect http or https but recieve "file://"
I am using "react-native-fast-tflite": "^1.2.0"
Any solution how can i load my model from my device local directory?
[Error: TFLite: Invalid source passed! Source should be either a React Native require(..) or a { url: string }object!]
Did you try to pass { url: 'https://...' }
as the error suggests? An object with the url
key?
if I use { url: 'https://'+file_path }
error: JNI GetObjectRefType called with pending exception java.net.UnknownHostException: Unable to resolve host "file": No address associated with hostname
and if i use { url: file_path }:
Error: JNI DETECTED ERROR IN APPLICATION: JNI GetObjectRefType called with pending exception java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but was 'file'
Gotcha, yea well this should work and shouldn't be easy to fix. If you fix this, please send a PR. Otherwise I don't have time to fix this now because of other libraries.
can anyone test this open PR to fix? https://github.com/mrousavy/react-native-fast-tflite/pull/82