I’ve built an app that uses the following code to load a trained Tensorflow model (simple classifier NN built in Python).
import * as tf from '@tensorflow/tfjs';
....
const model = await tf.loadLayersModel('./assets/models/model.json');
This works on the browser but not when testing on Android. The app is written in Vanilla JS.
In the Android Studio logcat I see the following error:
E Unable to open asset URL: http://localhost/assets/models/model.json
I also added these in the AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
So far I’ve looked into using the @capacitor/filesystem
package but I’m not sure how to replicate the model-loading behaviour of loadLayersModel
.
How can I replicate the working behaviour of the app running on the browser, in Android?
I’d eventually tackle IOS too but one thing at a time .
Thanks!