加载model.json Tensorflow.js时出错,提供的IOHandler没有实现`load`方法

问题描述

当我尝试将训练好的模型加载到我的Web应用程序时,出现以下错误,从路径正确访问了json(我尝试使用console.log打印,并且可以),问题是tf.loadLayers尝试加载时...

Vue应用代码

  import * as tf from '@tensorflow/tfjs';

  export default {
    data(){
      return {
        modelJSON: require('../model/jsmodel/model.json'),}
    },mounted(){
    this.loadModel();
  },methods: {
      async loadModel(){
        this.model = await tf.loadLayersModel(this.modelJSON)
      },...

错误

models.js?411e:207 Uncaught (in promise) Error: Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.
    at loadLayersModelFromIOHandler (models.js?411e:207)
    at loadLayersModelInternal (models.js?411e:190)
    at Module.loadLayersModel (exports.js?79b0:220)
    at _callee$ (SingleTweet.vue?b47c:40)
    at tryCatch (runtime.js?96cf:63)
    at Generator.invoke [as _invoke] (runtime.js?96cf:293)
    at Generator.eval [as next] (runtime.js?96cf:118)
    at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
    at _next (asyncToGenerator.js?1da1:25)
    at eval (asyncToGenerator.js?1da1:32)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)