[英]Fail to load frozen model in Tensorflowjs
I try to load converted tensorflow model, but console shows the error as the following: 我尝试加载转换后的Tensorflow模型,但控制台显示以下错误:
Version: 版:
"dependencies": {
"@tensorflow-models/posenet": "0.1.2",
"@tensorflow/tfjs": "0.11.4",
"@tensorflow/tfjs-converter": "^0.6.1",
"asyncawait": "^1.0.7",
"stats.js": "^0.17.0"
}
Code: 码:
import * as tf from '@tensorflow/tfjs';
import {loadFrozenModel} from '@tensorflow/tfjs-converter';
const MODEL_URL = 'faster_rcnn/web_model/tensorflowjs_model.pb';
const WEIGHTS_URL = 'faster_rcnn/web_model/weights_manifest.json';
const model =(async () => {
await loadFrozenModel(MODEL_URL, WEIGHTS_URL)})();
I put the model in Google drive: 我将模型放在Google云端硬盘中:
https://drive.google.com/file/d/1yNIC9TD1MWzJyI3ewnJCmM1bmTAYC_1E/view?usp=sharing https://drive.google.com/file/d/1yNIC9TD1MWzJyI3ewnJCmM1bmTAYC_1E/view?usp=sharing
Please help. 请帮忙。
Thank you! 谢谢!
You have to pass the storage type to loadFrozenModel()
. 您必须将存储类型传递给
loadFrozenModel()
。 Which would be in your case: file:///
. 在您的情况下:
file:///
。
Another problem in you code is that the immediatly called async function doesn't return anything, so your model variable stays undefined. 代码中的另一个问题是,立即调用的异步函数不会返回任何内容,因此您的模型变量保持未定义状态。
To fix both: 要解决这两个问题:
(async () => {
const model = loadFrozenModel('file:///' + MODEL_URL, 'file:///' + WEIGHTS_URL);
//Now you can only use 'model' in here.
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.