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

tflite object is empty after loading model #18

Open
nekapoor opened this issue Nov 27, 2019 · 2 comments
Open

tflite object is empty after loading model #18

nekapoor opened this issue Nov 27, 2019 · 2 comments

Comments

@nekapoor
Copy link

Hello!

I followed all the instructions to load a model and I don't get an error. Here is my code for loading a model:

    let tflite = new Tflite();
    tflite.loadModel({
      model: 'models/model.tflite',// required
      labels: 'models/labels.txt',  // required
      numThreads: 1,
      async: false                              // defaults to 1  
    },
    (err, res) => {
      if(err) {
        console.log(err);
      }
      else {
        console.log(res);
        console.log(tflite);
      }
    });

As you can see in the success else block, I console log the tflite object. But it's empty. I figured the loadmodel method would populate it with something?

But in the log, all I get is Tflite {}

Is this correct? Because I am unable to then make calls on image classification with this tflite object I have.

Thanks ahead of time

@shaqian
Copy link
Owner

shaqian commented Dec 19, 2019

Hi,

Have you had a try with the example app?
https://github.com/shaqian/tflite-react-native/blob/master/example

What if you move console.log(tflite); out of the callback function?

Thanks,
Qian

@QuevedoIB
Copy link

QuevedoIB commented Apr 20, 2020

I'm facing same issue:
let tflite = new Tflite();
Results in an empty object without loadModel method.

import { NativeModules, Image } from 'react-native';

const { TfliteReactNative } = NativeModules;

  loadModel(args, callback) {
    console.log(TfliteReactNative, "liter") //outputs undefined
    TfliteReactNative.loadModel(
      args['model'],
      args['labels'] || '',
      args['numThreads'] || 1,
      (error, response) => {
        callback && callback(error, response);
      });
  }

My error comes when trying to call loadModules from TfliteReactNative

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

3 participants