【发布时间】:2020-11-19 03:05:48
【问题描述】:
我已经在Teachable Machine 上训练了我自己的模型,我下载了它然后我对其进行了测试,它使用纯 javascript 代码运行良好,但是当我尝试使用 ml5 包在我的 angular 项目中实现它时,我有一些当我试图将我拥有的训练有素的模型传递给他时出现问题,它总是告诉我我的模型无效,即使我遵循了ML5 documentation 上的整个文档,他们说我可以将一个 URL 传递给我训练有素的模型作为参数但仍然是相同的问题,我不知道问题出在哪里。
我的加载模型的组件函数:
async loadModel() {
this.model = await ml5.imageClassifier('https://teachablemachine.withgoogle.com/models/6QKQUqglC/model.json', this.modelLoadedf);
console.log(this.model);
this.modelLoaded = true;
await this.loadTrainableModel();
}
async loadTrainableModel() {
// Initialize the Image Classifier method with MobileNet
this.customModel.modelLoaded = false;
const features = await ml5.featureExtractor('https://teachablemachine.withgoogle.com/models/6QKQUqglC/model.json');
console.log('feature extractor loaded ....');
this.customModel.model = await features.classification();
console.log('custom classifier loaded....');
this.customModel.modelLoaded = true;
}
两个“imageClassifier”和“featureExtractor”总是因为我传递给他们的模型而返回错误。
我的问题有什么解决办法吗?
【问题讨论】: