安装TensorFlow后运行,出现以下错误提示,请问是哪里问题?
VM127:1 thirdScriptError
Cannot read property 'setWebGLContext' of undefined;at App lifeCycleMethod onLaunch function
TypeError: Cannot read property 'setWebGLContext' of undefined
at t (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1089:384)
at Object.exports.setupWechatPlatform (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1089:1537)
at Object.exports.configPlugin (http://127.0.0.1:56710/appservice/__onlineplugin__/wx6afed118d9e81df9/0.0.6/appservice.js:1074:148)
"plugins": { "tfjsPlugin": { "version": "0.0.6", "provider": "wx6afed118d9e81df9" } } 将上面的version改为0.1.0,就好了
应该是版本代代码不同的问题,修改一下版本
"@tensorflow-models/posenet": "^2.1.3", "@tensorflow/tfjs-converter": "^1.2.2", "@tensorflow/tfjs-core": "^1.2.2", "fetch-wechat": "^0.0.3", "regenerator-runtime": "^0.13.2"
删除node_modules 重新install 并且构建一下
都是按照腾讯课程的配置,检查过,没有问题。
TensorFlow的配置参数正确吗
TypeError: Cannot read property 'setWebGLContext' of undefined
这个消息。运行不下去。
教程没有过多的参数设定,基本就是如下几步:
添加TensorFlow.JS插件
https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx6afed118d9e81df9&token=1076294821&lang=zh_CN
安装Node.js
https://nodejs.org
npm安装第三方库
在项目目录下:
```
npm init
npm install @tensorflow/tfjs-core
npm install @tensorflow/tfjs-converter
npm install @tensorflow/tfjs-layers
npm install fetch-wechat
npm install regenerator-runtime
```
然后去微信小程序开发工具里面"构建npm"
第三方库的导入
```
var fetchWechat = require('fetch-wechat');
var tf = require('@tensorflow/tfjs-core');
var plugin = requirePlugin('tfjsPlugin');
```
app.json里面添加
"plugins": {
"tfjsPlugin": {
"version": "0.0.6",
"provider": "wx6afed118d9e81df9"
}
}
在app.js里配置插件
```
App({
onLaunch: function () {
plugin.configPlugin({
fetchFunc: fetchWechat.fetchFunc(),
tf, canvas: wx.createOffscreenCanvas()
})
}
})
```
帮忙看下有无问题,谢谢!