question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tf.loadModel not working in react native

See original GitHub issue

TensorFlow.js version

0.10.3

Browser version

react-native 0.55.3

Problem:

tf.loadModel not working for local folder and remo url in react native, load local model not working for React

Feature request:

tf.loadModel react-native support

Code to reproduce the bug / link to feature request

const path = 'https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json';
const localPath = './tfjsmodel/model.json';

  async loadmodel(p) {
    const model = await this.loadHostedPretrainedModel(p);
    console.log(model);
  }

  async loadHostedPretrainedModel(p) {
    try {
      const model = await tf.loadModel(p);
      return model;
    } catch (err) {
      console.error(err);
    }
  }

this is the demo app i created for running tfjs in react-native, it can train and predict model locally, if you are interested this is the repo: https://github.com/tangtai/tfjsdemo

error i get when try to load model from url, i tried the code on react as well it returns the model successfully:

error i get when try to load model from local folder, for React it returns pending Promise :

the model i got from tensorflowjs file convertor: screen shot 2018-05-04 at 4 59 55 pm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
tafsiricommented, Sep 4, 2019

We just released a package for this! https://www.npmjs.com/package/@tensorflow/tfjs-react-native try it out and feel free to re-open this issues if you have trouble with it.

2reactions
Ivikassinghcommented, Mar 16, 2019

you can try webpack to import the cdn of tensorflowjs in Reactnative

Read more comments on GitHub >

github_iconTop Results From Across the Web

load model.json for tensorflowjs in reactjs not working
I'm trying to load a model.json file with it's weights.bin from the root directory in my react app. When I call an example...
Read more >
Loading models into tensorflow.js via react.js | by Manfye Goh
If you get the console log of “Load model success” means your model is successfully loaded into TF.js. BONUS: What if you just...
Read more >
Save and load models | TensorFlow.js
This tutorial will focus on saving and loading TensorFlow.js models ... tf.Model and tf.Sequential both provide a function model.save that ...
Read more >
Bug help! With tfjs : r/reactnative - Reddit
Hi, I'm new to React Native and trying to load a model using @tensorflow/tfjs-react-native and I've narrowed down the problem to the ...
Read more >
Tf.Loadmodel Is Not A Function - ADocLib
I overlooked the fact that you are not in Node.js but in ionic. tf.loadModel ... loadModel not working it fails to load model...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found