-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
fix: read local files on Android for 'file:///...' #82
fix: read local files on Android for 'file:///...' #82
Conversation
Drafted because of an out of memory error I discovered with this approach. Will re-open if/when I discover a fix. |
How can you fix on Android? iOS working ok |
Hey @davidgaag, I tried your updated code, and surprisingly it worked, you can check some more reasonable cases if needed, thanks |
thanks for your PR! We'll test this internally |
Should the loading-models section of README be updated to show the difference between File & URL? I think the current URL scheme is documented incorrectly. The reason is, if you don't use
The example should be: // Asset from React Native Bundle
loadTensorflowModel(require('assets/my-model.tflite'))
// File on the local filesystem
loadTensorflowModel('file:///var/mobile/.../my-model.tflite')
// Remote URL
loadTensorflowModel({ url: 'https://tfhub.dev/google/lite-model/object_detection_v1.tflite' }) |
Hi @mrousavy , could you please let us know when this PR might be merged? |
@Ajith-JSN did you test this PR? Does it work for you? |
Yes, I have tested it, and it works fine |
thanks for your PR! :) |
Hi everyone, has this commit been included in the 1.4.0 release? |
Has this been tested on iOS also? I am seeing the same issue there when trying to load a
|
I have created a pull request at #102. Please try out if it fixed the issue. |
When loading the model with a
file:///
URI on Android, a network request was attempted, causing Android to throw the errorExpected URL scheme 'http' or 'https' but was 'file'
.This pull request adds a check for the URI scheme, and if it's
file
, the app will now load from the local file system.I also included a check for the .tflite extension when loading the file to ensure other files aren't read/misused.
Please note that I tried to run the Jest tests, but was stopped by an error in a react-native file/dependency. I tried to figure out how to exclude that file and run the tests anyways, but I had no luck.
(This is my first PR/open source contribution, so I hope I did this right 😅)
fixes #80 fixes #63