首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将自定义训练模型加载到ml5 imageClassifier时模型无效

将自定义训练模型加载到ml5 imageClassifier时模型无效
EN

Stack Overflow用户
提问于 2020-11-19 11:05:49
回答 1查看 60关注 0票数 0

我已经在Teachable Machine上训练了我自己的模型,我下载了它,然后我测试了它,它使用纯javascript代码工作得很好,但是当我试图使用ml5包在我的angular项目上实现它时,我遇到了一些问题,当我试图将我训练过的模型传递给他时,它总是告诉我我的模型是无效的,尽管我遵循了ML5 documentation上的整个文档,他们说我可以将url作为参数传递到我训练过的模型,但仍然存在同样的问题,我不知道问题是从哪里产生的。

我的模型加载组件函数:

代码语言:javascript
复制
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“的模型,它们总是返回错误。

我的问题有什么解决方案吗?

EN

回答 1

Stack Overflow用户

发布于 2021-08-07 16:30:49

这里在React中实现了您提到的相同逻辑。这可能会有帮助:https://dementorwriter.medium.com/picture-classification-with-react-ml5-c45672aeb961

代码语言:javascript
复制
      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
        );
      };
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64904809

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档