reneweb / react-native-tensorflow

A TensorFlow inference library for react native
Apache License 2.0
358 stars 59 forks source link

Model file not found on iOS device #12

Closed kentyunge closed 6 years ago

kentyunge commented 6 years ago

I'm unable to get the *.pb file working in release mode. Everything seems to work while running in debug mode on a simulator but when deploying in release mode to simulator or device I get the following error:

Error: Couldn't find 'file://var/.. ../assets/rounded_graph.pb' in bundle

I am using the example project from the repo with little changes outside of pointing to my model/label files and passing in appropriate params.

const ir = new TfImageRecognition({
  model:require('./assets/rounded_graph.pb'),
  labels: require('./assets/retrained_labels.txt'),
  imageMean: 128, // Optional, defaults to 117
  imageStd: 128 // Optional, defaults to 1
});

const results = await ir.recognize({
  image: _image,
  outputName: "final_result"
});

if (results) {
  this.setState({results: results, selectedImage: _image}); 
}

react-native: 0.52.1

phanoophong commented 6 years ago

add model and label to root project ( ios ) by Xcode. to use you can call file name only not require.

example

const ir = new TfImageRecognition({ model: 'rounded_graph.pb', labels: 'retrained_labels.txt' }

reneweb commented 6 years ago

I've just pushed a fix for this as described in the pr here: #13 - hopefully that should fix the issue