【问题标题】:model not valid when loading custom trained model to ml5 imageClassifier将自定义训练模型加载到 ml5 imageClassifier 时模型无效
【发布时间】: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”总是因为我传递给他们的模型而返回错误。

我的问题有什么解决办法吗?

【问题讨论】:

    标签: angular ml5


    【解决方案1】:

    您提到的相同逻辑在 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
            );
          };
    

    【讨论】:

      猜你喜欢
      • 2021-01-12
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      • 2023-01-13
      • 2019-12-11
      • 2019-06-03
      • 1970-01-01
      相关资源
      最近更新 更多