久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

this.util.TextEncoder 不是僅在電子應用程序中的構造

this.util.TextEncoder is not a constructor only in electron app (works in chrome)(this.util.TextEncoder 不是僅在電子應用程序中的構造函數(適用于 chrome))
本文介紹了this.util.TextEncoder 不是僅在電子應用程序中的構造函數(適用于 chrome)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 tensorflow bodypix 模型創建一個身體分割應用程序.它在瀏覽器中運行良好.我正在使用 webpack 來使用它的模塊(見下文)

import * as wasm from "@tensorflow/tfjs-backend-wasm";從@tensorflow/tfjs-core"導入 * as tf;從@tensorflow-models/body-pix"導入*作為bodyPix;wasm.setWasmPaths("./wasm/");tf.setBackend("wasm").then(() => {//一些簡單的香草js代碼});//更多的香草js代碼...

它在 chrome 中運行良好,運行 npx webpack 后按預期輸出.

但是,當簡單地通過創建一個主電子文件來使用電子運行它時,它只會輸出一個空白的白色屏幕,并在控制臺中顯示以下錯誤-

Uncaught TypeError: this.util.TextEncoder 不是構造函數在新的<匿名>(main.js:2)

它指向的行來自一個看起來像這樣的縮小代碼-

...SOME_CODE...&&Me().setPlatform("node",new class{構造函數(){this.util=n(758),this.textEncoder=new this.util.TextEncoder}...SOME_MORE_CODE...

我認為電子只是沒有頂欄的鉻,但這似乎是錯誤的.有人可以幫我嗎我正在使用以下版本-

<塊引用>

nodejs v12.16.3"、electron11.1.1"、tfjs2.8.2"

查看chrome和electron的截圖-

IN CHROME(點擊放大)

...................................................

IN ELECTRON(點擊放大)

解決方案

解決方案

我以前有

wasm.setWasmPaths("./wasm/");tf.setBackend("wasm").then(() => {//一些簡單的香草js代碼});

在我的主代碼中,我已將文件夾從 wasm(dist/) 復制到項目的文件夾中.

從我的項目文件夾中刪除相同的內容并將代碼更改為 -

wasm.setWasmPaths("../node_modules/@tensorflow/tfjs-backend-wasm/dist/");//或從 ./開始,如果您的主文件與 node_modules 位于同一文件夾中tf.setBackend("wasm").then(() => {//...});

我是怎么回到這里的?

首先感謝@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)

import * as wasm from "@tensorflow/tfjs-backend-wasm";
import * as tf from "@tensorflow/tfjs-core";
import * as bodyPix from "@tensorflow-models/body-pix";

wasm.setWasmPaths("./wasm/");
tf.setBackend("wasm").then(() => {
  //some simple vanilla js code
});
//some more vanilla js code...

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-

Uncaught TypeError: this.util.TextEncoder is not a constructor
    at new <anonymous> (main.js:2)

the line where it is pointing is from a minified codew which looks like this-

...SOME_CODE...&&Me().setPlatform("node",new class{
constructor(){this.util=n(758),this.textEncoder=new this.util.TextEncoder}...SOME_MORE_CODE...

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

wasm.setWasmPaths("./wasm/");
tf.setBackend("wasm").then(() => {
  //some simple vanilla js code
});

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 -

wasm.setWasmPaths("../node_modules/@tensorflow/tfjs-backend-wasm/dist/"); //or start from ./ if your main file is in same folder as node_modules
tf.setBackend("wasm").then(() => {
  //...
});

How i recahed here?

at first thanks to @edkeveked for his effort and pointing me to

Error 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)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 欧美黄色一级大片 | 亚洲精品免费在线 | 天天干天天操天天摸 | 欧美视频在线观看一区 | 国产精品久久久精品 | 国产有码视频 | 四虎av | 亚洲成人毛片 | 亚洲一区二区三区视频 | 中国极品少妇xxxx做受 | 亚洲综合伊人 | 天天摸天天操 | 久久久久久一区 | 日韩久久一区 | 午夜av网站 | 一区二区三区四区在线视频 | 91av在线免费观看 | 天天色天天干天天 | 国产香蕉视频 | 亚洲免费视频一区 | 天天噜 | 日本一级淫片色费放 | 日韩欧美亚洲 | 黑人精品一区二区 | 欧美精品亚洲精品 | 九九热在线精品视频 | 国产成人精品毛片 | 午夜精品视频在线 | 男女啪啪免费网站 | 欧美日日夜夜 | 欧美性猛交xxxx免费看久久久 | 九九热在线视频 | 欧美激情啪啪 | 日韩中文字幕在线观看 | 日韩一区二区av | 中文字幕在线免费看 | 久久久久免费 | 日韩成人中文字幕 | 欧美69视频 | 99久久婷婷国产综合精品草原 | 日韩美女一区二区三区 |