Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教关于如何调用静态文件以及LeapMotion插件的一点问题 #9

Open
YIN-jw opened this issue Apr 3, 2020 · 5 comments

Comments

@YIN-jw
Copy link

YIN-jw commented Apr 3, 2020

您好,抱歉再次打扰,关于静态文件想再请教您几个问题。
我在之后按照knn的安装步骤安装好了posenet插件,若有需要详细步骤在:https://github.com/YIN-jw/scratch3.0_posenet_install。其中在安装依赖时是直接yarn add @tensorflow/tfjs-core,yarn add @tensorflow-models/posenet(没有考虑tfjs库的版本号)。 之后能够在网页版中正常运行,但是knn插件又不能正常使用了。再重新yarn add @tensorflow/tfjs@0.10.0又能使用了,但是posenet不能使用。我猜想是因为knn插件使用的是tfjs@0.10.0(yarn add @tensorflow/tfjs@0.10.0),posenet需要的版本比knn要高,所以造成了knn不能再使用。
目前对于这个问题没有想到解决办法,请问您可以给我一些建议吗?
另外,在使用LeapMotion这个插件时,出现的结果都是‘0’,想请问一下这个插件的用法是什么?

@summerscar
Copy link
Member

你查一下yarn.lock knn tfjs的引用关系
在package.json 增加
"resolutions": {
"knn/{package}/{package}/ @tensorflow/tfjs": "0.1.0"
}
指定一下版本
参考 https://classic.yarnpkg.com/zh-Hans/docs/selective-version-resolutions/

leapmotion 需要一个硬件设备
https://www.ultraleap.com/product/leap-motion-controller/

@YIN-jw
Copy link
Author

YIN-jw commented Apr 5, 2020

抱歉我回复的晚了,感谢您的回复,我还是不太清楚具体该怎么修改。查看了位于../scratch-vm下的yarn.lock文件,目前依赖是这样的:
"@tensorflow-models/knn-classifier@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@tensorflow-models/knn-classifier/-/knn-classifier-1.2.2.tgz#a5a9045b3d225a06e60f2b1cc2de56bdac6748e8"
integrity sha512-QRnkCf7ErOxSRtvJ6yCwhlLREPcBJGaXRanF46f0iY6ii3Sybjb6Ux0qnNPTrHZChD0izPa3Z4GQEgSAykiHkQ==

"@tensorflow-models/mobilenet@^2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@tensorflow-models/mobilenet/-/mobilenet-2.0.4.tgz#7f40771fcc650f50febd49be72372d39c15f6f95"
integrity sha512-fkcxDBldlYitDCV88xETwAQoBIC8xYKdDu80uBDuBZBfNC4k/jeVbZHM28WjvTDsJN7d7dYO4NbIkRAH0XHKSQ==

"@tensorflow-models/posenet@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@tensorflow-models/posenet/-/posenet-2.2.1.tgz#2f0a68d909842f59eec195f23c6f3d4cebc53fa8"
integrity sha512-n9/g6DfjAyrBTf/zt1haRCyWsgALxUCzg9/Ks3Y2mbYavRZVSCSTRPy/qlE5Hr4tLfyckGfDN14zmGTthNcg/g==

"@tensorflow/tfjs-converter@^1.7.1":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.7.1.tgz#b96abbb1b38e96088709386cc21f4902809cabbf"
integrity sha512-CTQmTWAM+VqjxX1Qw9RhVrl32e1ITH2oVuWs/KgxXyyGNE9BLFQxFJhxQz/BPbxHFoIqZUK8RZiFrQudabx/lw==

"@tensorflow/tfjs-core@0.8.1":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-0.8.1.tgz#d93e87302e29620906003b697d2d8596410ad712"
integrity sha512-3XeO7gAxeeIlTUItxiZXazuhM3QMUrIPMq8wPm8IPFU+ucUy7zAAmD1elQ9pDeXYvWtb+lMK5mNiU5CBXs3ACQ==
dependencies:
seedrandom "~2.4.3"

"@tensorflow/tfjs-core@1.7.0":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.7.0.tgz#9207c8f2481c52a6a40135a6aaf21a9bb0339bdf"
integrity sha512-uwQdiklNjqBnHPeseOdG0sGxrI3+d6lybaKu2+ou3ajVeKdPEwpWbgqA6iHjq1iylnOGkgkbbnQ6r2lwkiIIHw==
dependencies:
"@types/offscreencanvas" "~2019.3.0"
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
"@types/webgl2" "0.0.4"
node-fetch "~2.1.2"
seedrandom "2.4.3"

"@tensorflow/tfjs-core@^1.7.1":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.7.1.tgz#145c3c70de0e0aef11ff7e9cadf7b3fa81ce13e2"
integrity sha512-aMbvvhgBFLGsV1uBFPlPvuv6OAjA8BzjyLDWHoss5Tgaj6S6PPt8xE5ea8+cUKqz5qNVGYmj03qR5S7SmJ3qnw==
dependencies:
"@types/offscreencanvas" "~2019.3.0"
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
"@types/webgl2" "0.0.4"
node-fetch "~2.1.2"
seedrandom "2.4.3"

"@tensorflow/tfjs-layers@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-0.5.0.tgz#0ec8d07b46863a162d3e0c60fae3d1087d8aa3ce"
integrity sha512-C7vNAaHoe0+Nk6A1wRZ9iKLjDhZqFMCXEPO9fVz4cRWl2sVa/foYOxR/gLn6OYFlTZADA5D7fRK24KqsmZ7/SA==

"@tensorflow/tfjs@0.10.0":
version "0.10.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-0.10.0.tgz#c64f8740b46c2ba734dc0564d37e6a2c33055511"
integrity sha512-8nTBG9APxafEMETega1vZ5V8IzSH6205yIcButLSS++OtuCLGwTsdCFuUMaf5+RnXdxhcJaGWawc+eT55Wk5vg==
dependencies:
"@tensorflow/tfjs-core" "0.8.1"
"@tensorflow/tfjs-layers" "0.5.0"

在package.json文件中是这样的:
"dependencies": {
"@tensorflow-models/knn-classifier": "^1.2.2",
"@tensorflow-models/mobilenet": "^2.0.4",
"@tensorflow-models/posenet": "^2.2.1",
"@tensorflow/tfjs": "0.10.0",
"@tensorflow/tfjs-converter": "^1.7.1",
"@tensorflow/tfjs-core": "^1.7.1",
"@vernier/godirect": "1.5.0",
"arraybuffer-loader": "^1.0.6",
"atob": "2.1.2",
"babel-polyfill": "^6.26.0",
"btoa": "1.2.1",
"canvas": "^2.6.1",
"canvas-toBlob": "1.0.0",
"decode-html": "2.0.0",
"diff-match-patch": "1.0.4",
"face-api.js": "^0.22.2",
"format-message": "6.2.1",
"htmlparser2": "3.10.0",
"immutable": "3.8.1",
"jszip": "^3.1.5",
"minilog": "3.1.0",
"nets": "3.2.0",
"scratch-parser": "5.0.0",
"scratch-sb1-converter": "0.2.7",
"scratch-translate-extension-languages": "0.0.20190416132834",
"socket.io-client": "2.0.4",
"text-encoding": "0.7.0",
"worker-loader": "^1.1.1"
},

我尝试在上一行的逗号之后添加:
"resolutions": {
"knn//@tensorflow/tfjs": "0.10.0"
}
"resolutions": {
"knn/{package}/{package}/@tensorflow/tfjs": "0.10.0"
}
"resolutions": {
"scratch3_knn/
/@tensorflow/tfjs": "0.10.0"
}
"resolutions": {
"@tensorflow/knn-classifier/@tensorflow/tfjs": "0.10.0"
}

之后webpack-dev-server --https报错Unexpected string in JSON at position2513。看了相关的资料也没弄懂原因,能麻烦再指点一下吗?

@YIN-jw
Copy link
Author

YIN-jw commented Apr 5, 2020

好像格式有点问题,修正:两个 ‘/’ 之间是用的 ‘*’ 号。

@summerscar
Copy link
Member

我用knn和faceapi存在依赖问题是这样解决的
"resolutions": {
"face-api.js/tfjs-image-recognition-base/@tensorflow/tfjs-core": "1.2.9"
}

我不确定是否和你是同一个问题

@YIN-jw
Copy link
Author

YIN-jw commented Apr 7, 2020

抱歉再请问一下,您在安装posenet插件时有遇到和knn插件版本不同,knn插件不能使用的情况吗?(我这边 knn和faceapi两个插件却可以同时使用)
刚开始安装knn插件用的是@tensorflow/tfjs@0.10.0(包括tfjs-core@0.8.1和tfjs-layers@0.5.0),之后安装posenet插件使用了@tensorflow/tfjs-core@1.7.2和@tensorflow/tfjs-converter@1.7.2,将之前的版本覆盖了。
我在package.json中添加
"resolutions": {
"@tensorflow/knn-classifier/@tensorflow/tfjs-core": "0.8.1"
}对版本进行限制,webpack-dev-server --https可以运行通过了,但是控制台显示:
1

Uncaught Error: 'realDivide' not yet implemented or not found in the registry. Did you forget to import the kernel?
at ha (tf-core.esm.js:17)
at o.t.realDivide (tf-core.esm.js:17)
at tf-core.esm.js:17
at tf-core.esm.js:17
at tf-core.esm.js:17
at t.scopedRun (tf-core.esm.js:17)
at t.tidy (tf-core.esm.js:17)
at f (tf-core.esm.js:17)
at tf-core.esm.js:17
at t.scopedRun (tf-core.esm.js:17)]

tf-core.esm.js:17 Uncaught TypeError: Cannot read property 'backend' of undefined
at t.moveData (tf-core.esm.js:17)
at t.get (tf-core.esm.js:17)
at tf-core.esm.js:17
at Array.map ()
at o.runWebGLProgram (tf-core.esm.js:17)
at tf-core.esm.js:17
at Object.kernelFunc (tf-core.esm.js:17)
at f (tf-core.esm.js:17)
at tf-core.esm.js:17
at t.scopedRun (tf-core.esm.js:17)

感觉可能是版本没有限制正确或者是其他原因,感觉离解决很近了,不知道是不是哪里还没有考虑详细。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants