{"action":"opened","issue":{"url":"https://api.github.com/repos/jazzystring1/react-native-tensorflow-lite/issues/1","repository_url":"https://api.github.com/repos/jazzystring1/react-native-tensorflow-lite","labels_url":"https://api.github.com/repos/jazzystring1/react-native-tensorflow-lite/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/jazzystring1/react-native-tensorflow-lite/issues/1/comments","events_url":"https://api.github.com/repos/jazzystring1/react-native-tensorflow-lite/issues/1/events","html_url":"https://github.com/jazzystring1/react-native-tensorflow-lite/issues/1","id":371551670,"node_id":"MDU6SXNzdWUzNzE1NTE2NzA=","number":1,"title":"Tensorflow Lite Image Recognizer","user":{"login":"user507","id":44266303,"node_id":"MDQ6VXNlcjQ0MjY2MzAz","avatar_url":"https://avatars0.githubusercontent.com/u/44266303?v=4","gravatar_id":"","url":"https://api.github.com/users/user507","html_url":"https://github.com/user507","followers_url":"https://api.github.com/users/user507/followers","following_url":"https://api.github.com/users/user507/following{/other_user}","gists_url":"https://api.github.com/users/user507/gists{/gist_id}","starred_url":"https://api.github.com/users/user507/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/user507/subscriptions","organizations_url":"https://api.github.com/users/user507/orgs","repos_url":"https://api.github.com/users/user507/repos","events_url":"https://api.github.com/users/user507/events{/privacy}","received_events_url":"https://api.github.com/users/user507/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-18T14:14:04Z","updated_at":"2018-10-18T14:14:04Z","closed_at":null,"author_association":"NONE","body":"@jazzystring1 , Hello. I have a problem, can you help me please?\r\n![image](https://user-images.githubusercontent.com/44266303/47159812-49b2a680-d2f7-11e8-8a1a-dbcef5ecfe1d.png)\r\n\r\n```\r\nimport React, {Component} from 'react';\r\nimport {StyleSheet, Text, View} from 'react-native';\r\nimport {TFLiteImageRecognition} from 'react-native-tensorflow-lite';\r\n\r\nexport default class App extends Component {\r\n  constructor() {\r\n    super();\r\n    this.state = {};\r\n\r\n    try {\r\n      // Initialize Tensorflow Lite Image Recognizer\r\n      this.classifier = new TFLiteImageRecognition({\r\n        model: \"./assets/mobilenet_quant_v1_224.tflite\",  // Your tflite model in assets folder.\r\n        labels: \"./assets/label.txt\" // Your label file\r\n      })\r\n\r\n    } catch(err) {\r\n      alert(err)\r\n    }\r\n  }\r\n\r\n  componentWillMount() {\r\n    this.classifyImage(\"./assets/apple.jpg\") // Your image path.\r\n  }\r\n\r\n  async classifyImage(imagePath) {\r\n    try {\r\n      const results = await this.classifier.recognize({\r\n        image: imagePath, // Your image path.\r\n        inputShape: 224, // the input shape of your model. If none given, it will be default to 224.\r\n      });\r\n\r\n      const resultObj = {\r\n        name: \"Name: \" + results[0].name,\r\n        confidence: \"Confidence: \" + results[0].confidence,\r\n        inference: \"Inference: \" + results[0].inference + \"ms\"\r\n      };\r\n      this.setState(resultObj)\r\n\r\n    } catch(err) {\r\n      console.error(err)\r\n    }\r\n  }\r\n\r\n  componentWillUnmount() {\r\n    this.classifier.close() // Must close the classifier when destroying or unmounting component to release object.\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <View style={styles.container}>\r\n        <View>\r\n          <Text style={styles.results}>\r\n            {this.state.name}\r\n          </Text>\r\n          <Text style={styles.results}>\r\n            {this.state.confidence}\r\n          </Text>\r\n          <Text style={styles.results}>\r\n            {this.state.inference}\r\n          </Text>\r\n        </View>\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n    justifyContent: 'center',\r\n    alignItems: 'center',\r\n    backgroundColor: '#F5FCFF',\r\n  }\r\n});\r\n```\r\nFile tree:\r\n```\r\n-android\r\n-assets\r\n    -apple.jpg\r\n    -labels.txt\r\n    -mobilenet_quant_v1_224.tflite\r\n...\r\n-App.js\r\n-package.json\r\n...\r\n```\r\n"}}
{"actor":{"display_login":"user507"}}