我已经在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“的模型,它们总是返回错误。
我的问题有什么解决方案吗?
发布于 2021-08-07 16:30:49
这里在React中实现了您提到的相同逻辑。这可能会有帮助:https://dementorwriter.medium.com/picture-classification-with-react-ml5-c45672aeb961
const setup = (p5: p5Types, canvasParentRef: Element) => {
capture.current = p5.createCapture(p5.VIDEO).parent(canvasParentRef);
const featureExtractor = ml5.featureExtractor("MobileNet", {epochs: props.numberOfEpochs}, modelReady);
classifier.current = featureExtractor.classification(
capture.current,
videoReady
);
};https://stackoverflow.com/questions/64904809
复制相似问题