【问题标题】:how to use teachable machine model in react native expo如何在反应原生博览会中使用可教机器模型
【发布时间】:2021-07-30 14:52:38
【问题描述】:

我正在使用可教机器导出模型。

const modelJson = require("./assets/models/model.json");
const modelWeights = require("./assets/models/weights.bin");


useEffect(() => {
    let checkTf = async () => {
      await tf.ready();
      const model = await tf.loadLayersModel(bundleResourceIO(modelJson, modelWeights));
      setModel(model);
      setDisplayText("loaded Models");
      setTfReady(true);
    };
    checkTf();
  }, []);

在预测图像异步函数中加载的模型:

const imageTensor = images.next().value;
const prediction = (await model.predict())[0]; //ERROR
const highestPropPred = prediction[0];

无法加载预测此错误:

[Unhandled promise rejection: Error: Error when checking : expected input_1 to have 4 dimension(s), but got array with shape [200,152,3]]

【问题讨论】:

    标签: react-native machine-learning deep-learning


    【解决方案1】:

    我建议您尝试使用 reshape 函数将图像重塑为 [1 ,200 , 150, 3]。

    【讨论】:

      【解决方案2】:

      我不确定,但据我所知,您应该退出您的 expo 应用程序,以便可以将 tf 用于 RN 或使用裸 RN 项目。

      【讨论】:

      • expo应用使用mobilenet库正常运行。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多