react-native - 无法在本机反应中解析我的 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 文件。但它仍然给出相同的错误。这就是为什么我想也使用上一个问题的答案再次问这个问题。
解决方案
推荐阅读
- wordpress - 使用 add_entry() 以编程方式创建 Gravity Forms 条目,但仍调用通常的钩子
- javascript - 如何使用多个条件指定 JSDOM fromFile
- android - OKHTTP3 抛出 ConnectionShutdownException
- r - 从字符串集中提取第一个字符
- javascript - 在 React Native 中将数据共享到社交媒体
- azure - 无法使用 SPFX Webpart 从 MS Graph 检索邮件:ResourceNotFound - 无法发现资源
- java - 如何从 jdbc-inbound-channel-adapter 捕获异常?
- python - 使用数组变量 Python 的名称保存文件
- mysql - SQL 多重计数与 3 个表
- android - 从 SharedPreferences 设置 arraylist 后,RecyclerView 图像不可见