问题描述
我正在使用 tensorflow bodypix 模型创建一个身体分割应用程序.它在浏览器中运行良好.我正在使用 webpack 来使用它的模块(见下文)
它在 chrome 中运行良好,运行 npx webpack
后按预期输出.
但是,当简单地通过创建一个主电子文件来使用电子运行它时,它只会输出一个空白的白色屏幕,并在控制台中显示以下错误-
它指向的行来自一个看起来像这样的缩小代码-
我认为电子只是没有顶栏的铬,但这似乎是错误的.有人可以帮我吗我正在使用以下版本-
<块引用>nodejs v12.16.3"、electron11.1.1"、tfjs2.8.2"
查看chrome和electron的截图-
IN CHROME(点击放大)
...................................................
IN ELECTRON(点击放大)
解决方案
我以前有
在我的主代码中,我已将文件夹从 wasm(dist/) 复制到项目的文件夹中.
从我的项目文件夹中删除相同的内容并将代码更改为 -
我是怎么回到这里的?
首先感谢@edkeveked 的努力并指出我在 Electron App (Nodejs) 中加载 TensorflowJS 时出错p>
我通过创建一个 electron hello world 项目然后添加 tfjs 和 tfjs-backend-wasm 得到了解决方案.新项目工作正常,但是即使将 node_modules 从新项目移动到旧项目也不适用于旧项目.但是一旦我更改了 wasm 路径,它就可以正常工作.
更新:
现在我已经多次遇到这个问题,每次都是通过创建一个新文件夹来解决的,首先安装电子并先创建一个简单的电子应用程序,然后安装其他依赖项并将旧代码复制到新文件夹中.(警告:不要'不复制节点模块文件夹)
好像是tfjs或者electron的bug
I am creating a body segmentation app using tensorflow bodypix model. It works fine in the browser. I am using webpack to use its modules(see below)
It works exactly fine in chrome and giving output as expected after running npx webpack
.
However when irun it with electron simply by creating a main electron file it outputs nothing but a blank white screen with the following error in console-
the line where it is pointing is from a minified codew which looks like this-
i thought that electron is simply chrome without top bars, but this seems wrong. can someone help me here i am using following versions-
"nodejs v12.16.3", "electron11.1.1", "tfjs2.8.2"
see the screen shot of chrome and electron-
IN CHROME(click to enlarge)
................................................
IN ELECTRON(click to enlarge)
THE SOLUTION
i previously have
in my main code, and i have copied the folder from wasm(dist/) to project's folder.
Deleting the same from my project's folder and changing the code to -
How i recahed here?
at first thanks to @edkeveked for his effort and pointing me toError loading TensorflowJS in Electron App (Nodejs)
i got the solution by creating an electron hello world project and then adding tfjs, then tfjs-backend-wasm. the new project is working correctly but however even moving the node_modules from new project to older one is not working for the older. but as soon i changed the wasm path, it worked giving no error.
Update:
now I have encountered the problem several times and everytime it's solved by creating a new folder, first installing electron and creating a simple electron app first, and then installing other dependencies and copying old code in the new folder.(warning: don't copy the node modules folder)
It seems to be a bug in tfjs or electron
这篇关于this.util.TextEncoder 不是仅在电子应用程序中的构造函数(适用于 chrome)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!