Open marikani opened 5 years ago
Hi guy. i already sovle this problem( see https://github.com/reneweb/react-native-tensorflow/issues/34).
really? TFLite ending is .tflite
not .pb
so how could this one help?
I have also the same issue:
Could not invoke TfliteREactNative.loadModels
null
/path/to/my/model.tflite
This is how I initialize the model:
async init() {
try {
console.log( "started initialization of TENSOR FLOW LITE" );
let tfLite = new Tflite();
await tfLite.loadModel( {
model: this.props.protobuf, // required
labels: this.props.labels, // required
numThreads: 1, // defaults to 1
} );
this.setState( {tfLite: tfLite} );
} catch ( err ) {
if ( err.description === "cancelled" ) {
console.log( "cancelled by user" );
}
console.error( "Got error on init(): ", err );
}
}
I'm passing the path to model file and labels as props. This approach is working exactly the same way for react-native-tensorflow but with a .pb file of caurse instead of an .tflite file as in this case.
I tried with putting file://
before the actual file, but didn't help.
By the way: First I had this one:
[15:20:16] E | ReactNativeJS ▶︎ 'Got error on init(): ', { [TypeError: null is not an object (evaluating 'TfliteReactNative.loadModel')]
│ line: 115254,
│ column: 26,
└ sourceURL: 'http://localhost:8081/index.bundle?platform=android&dev=true&minify=false' }
but it was due of missing steps from Android part, so I'm adding it here, just in case someone else ends up in the same situation and needs quick help.
Any updates on how to fix this? I am also getting this same error. I used the example code provided in the repo and have placed the models and labels in the android/app/src/main/assets directory as well, and in a models directory in my react-native code src.
nope and the project seams not to be updated as frequently as it should to become reliable. I suggest you check out the real deal: https://github.com/tensorflow/tfjs/tree/master/tfjs-react-native just compare the stars
Hey @Macilias, thanks for the suggestion will look into it as well! I finally got it to work by the following steps:
@marikani @ShaharyarMaroof I couldn't solve it by following what you did. Help me =/
Hey @robsonpsdesv I was able to get the model up by following these steps which are similar to the ones @ShaharyarMaroof did
assets
in app/src/main/
android/app/build.gradle
the lines from the README (I normally put it towards the end of the file)
aaptOptions {
noCompress 'tflite'
}
Do let us know what your error might have been
Yes @ShaharyarMaroof succecfuly, tks;)
I have also the same issue:
Could not invoke TfliteREactNative.loadModels null /path/to/my/model.tflite
This is how I initialize the model:
async init() { try { console.log( "started initialization of TENSOR FLOW LITE" ); let tfLite = new Tflite(); await tfLite.loadModel( { model: this.props.protobuf, // required labels: this.props.labels, // required numThreads: 1, // defaults to 1 } ); this.setState( {tfLite: tfLite} ); } catch ( err ) { if ( err.description === "cancelled" ) { console.log( "cancelled by user" ); } console.error( "Got error on init(): ", err ); } }
I'm passing the path to model file and labels as props. This approach is working exactly the same way for react-native-tensorflow but with a .pb file of caurse instead of an .tflite file as in this case. I tried with putting
file://
before the actual file, but didn't help.By the way: First I had this one:
[15:20:16] E | ReactNativeJS ▶︎ 'Got error on init(): ', { [TypeError: null is not an object (evaluating 'TfliteReactNative.loadModel')] │ line: 115254, │ column: 26, └ sourceURL: 'http://localhost:8081/index.bundle?platform=android&dev=true&minify=false' }
but it was due of missing steps from Android part, so I'm adding it here, just in case someone else ends up in the same situation and needs quick help.
Hello, if possible, can you please share your working code? I'm getting same error and none of those methods are working.
My solution is related with emulator. If you are using real device it works.
Since the official docs do not tell us to create a 'models' directory inside the 'assets' directory, removing 'models' from the path should work.
tflite.loadModel({
model: 'mobilenet_v1_1.0_224.tflite',// required
labels: 'mobilenet_v1_1.0_224.txt', // required
numThreads: 1, // defaults to 1
},
I am facing this problem.