Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load model from local directory #63

Open
mashad6 opened this issue May 8, 2024 · 3 comments
Open

Unable to load model from local directory #63

mashad6 opened this issue May 8, 2024 · 3 comments

Comments

@mashad6
Copy link

mashad6 commented May 8, 2024

Screenshot 2024-05-08 at 3 30 25 PM

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

@mrousavy
Copy link
Owner

mrousavy commented May 8, 2024

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

@mashad6
Copy link
Author

mashad6 commented May 8, 2024

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'

@mrousavy
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants