首页 > 解决方案 > 无法在本机反应中解析我的 tensoflow 模块

问题描述

下面给出我的方法。

async recognizeImage() {

        try {
            const tfImageRecognition =  new TfImageRecognition({
                model: require('../data/graph.pb'),
                labels: require('../data/labels.txt')
            })



            const results = await tfImageRecognition.recognize({
                image: this.image
            })

            const resultText = `Name: ${results[0].name} - Confidence: ${results[0].confidence}`
            this.setState({result: resultText})

            await tfImageRecognition.close()
        } catch(err) {
            console.log(err);
        }
    }  

它给了我一个错误,就像Unable to resolve "./graph.pb" from "app\screens\foodfind.js"我展示了一个类似的问题之王并找到了两个答案,例如创建一个文件rn-cli.config.js,我做到了,我还添加了

"packagerOpts": {
      "assetExts": ["pb", "txt"]
    },

到 app.json 文件。但它仍然给出相同的错误。这就是为什么我想也使用上一个问题的答案再次问这个问题。

这是我的文件架构

标签: react-nativetensorflow

解决方案


推荐阅读