【发布时间】:2019-06-16 12:00:45
【问题描述】:
我正在开发一个 chrome 扩展,我在其中使用我训练有素的 keras 模型。为此,我需要导入一个库tensorflow.js。我该怎么做?
我尝试通过两种方式在我的项目中导入tensorflow.js:
1) 在background.js import * as tf from '@tensorflow/tfjs'; 中
2) 我下载了tf.min.js 并尝试将其添加到我的manifest.json中
manifest.json
{
"manifest_version": 2,
"name": "my_project",
"version": "0.1",
"background": {
"scripts": ["background.js", "tf.min.js"]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["jquery-3.1.1.min.js","content.js"]
}
]
}
在第一种情况下,错误是“意外的令牌 *”;
在第二种情况下,错误是“Uncaught (in promise) ReferenceError: tf is not defined”。
我做错了什么?
【问题讨论】:
标签: javascript tensorflow google-chrome-extension tensorflow.js