tf.loadModel not working in ionic
See original GitHub issueTensorFlow.js version
0.10.0
Browser version
cli packages: (C:\Users\Administrator\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5
Node : v8.9.1
npm : 5.6.0
OS : Windows 10
Describe the problem or feature request
tf.loadModel not working, it fails to load model from local folder ( ie. assets/model ) however, web version is working, when it runs on http://localhost:8100/ionic-lab
Code to reproduce the bug / link to feature request
import {Component} from '@angular/core';
import {IonicPage, AlertController} from 'ionic-angular';
import * as tf from "@tensorflow/tfjs";
@IonicPage()
@Component({
selector: 'page-tfpretrainedversion',
templateUrl: 'tfpretrainedversion.html',
})
export class TfpretrainedversionPage {
kerasTraindedModel: tf.Model;
KERAS_MODEL_JSON = 'assets/model/model.json';
constructor(private httpClient: HttpClient,
private alertCtrl: AlertController,
private loadingService: LoadingServiceProvider) {
this.loadPretrainedModel();
}
loadPretrainedModel() {
tf.loadModel(this.KERAS_MODEL_JSON)
.then((result) => {
this.kerasTraindedModel = result;
})
.catch((error)=>{
let prompt = this.alertCtrl.create({
title: 'Error',
subTitle: error,
buttons: ['OK']
});
prompt.present();
});
}
}
here is a error message
and here is a data structure
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (2 by maintainers)
Top Results From Across the Web
hybrid mobile app - Tensorflowjs in ionic - Stack Overflow
However, when i build the project for android tf.loadModel method not working, it fails to load model from local folder ( ie. assets/model...
Read more >Tf.Loadmodel Is Not A Function - ADocLib
Describe the problem or feature request. tf.loadModel not working it fails to load model from AlertController} from 'ionicangular'; import as tf from ...
Read more >@tensorflow/tfjs - npm
TensorFlow.js Data, a simple API to load and prepare data analogous to tf.data. TensorFlow.js Converter, tools to import a TensorFlow SavedModel ...
Read more >tf.keras.models.load_model | TensorFlow v2.11.0
LoadOptions object that specifies options for loading from SavedModel. Returns. A Keras model instance. If the original ...
Read more >[Resolved]-I need my Ionic app to get a specific xlsx file to run
But now I want to use real data I got, but get stuck on two major problems: first of all, the file that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
TensorflowJs loads the models via fetch(). fetch() does not support loading local-files. https://fetch.spec.whatwg.org/
To make this happen, I used this workaround in a Cordova-Projekt:
Import a polyfill (https://github.com/github/fetch) and replace the global-fetch.
Now, it’s possible to load local files (file:///) like:
Any follow up on this issue? @gabrielglbh Thanks!