When trying to integrate a pretrained tensorflow model with expo (react-native), the following error occurs within these lines:
_graph = async () => {
try {
const tfImageRecognition = new TfImageRecognition({
model: require('./assets/tensorflow_inception_graph.pb'),
labels: require('./assets/tensorflow_labels.txt')
});
const results = await tfImageRecognition.recognize({
image: this.state.image
});
results.forEach(
result => ((preder2 = result.confidence), (items = result.name))
);
await tfImageRecognition.close();
this.setState({
result: items,
value: preder2 * 100 + "%"
});
console.log(this.state.result);
} catch (err) {
this.setState({
result: "No Internet",
value: "Please connect to the internet"
});
console.log(err);
}
}
I have been trying to find the reason why this is not working but I cannot find a definite solution. The relative paths linking to the assets are correct and the extensions are present in the app.json. Furthermore the model is trained using the tensorflow api which should make it compatible with the react-native implementation.
const tfImageRecognition = new TfImageRecognition({
model: require('./assets/tensorflow_inception_graph.pb'),
labels: require('./assets/tensorflow_labels.txt')
});
The code changed immediately to "catch(err)" branch, which means it could not load the model and labels?
I am using expo SDK version 28.0.0, Expo XDE and react-native-tensorflow version ^0.1.8
PLz help me.