我正在嘗試從我的react應(yīng)用程序中的根目錄中加載一個(gè)帶有權(quán)重.bin的model.json文件。當(dāng)我調(diào)用我從 storage.googleapis.com 在線找到的示例時(shí),它有效,但從我的根加載不起作用。App.js的內(nèi)容在我的反應(yīng)應(yīng)用程序中...import React from "react";import "./styles.css";const tf = require("@tensorflow/tfjs");// example model - workingasync function predict() { const model = await tf.loadGraphModel( "https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json" ); console.log(typeof model);}// my model - not workingasync function predictAlt() { const myModel = await tf.loadLayersModel("file://my-model.json"); console.log(typeof model);}export default function App() { return ( <div className="App"> <button onClick={predict} style={{ fontSize: "20px" }}> example model </button> <br /> <br /> <button onClick={predictAlt} style={{ fontSize: "20px" }}> my model </button> </div> );}
load model.json for tensorflowjs in reactjs
躍然一笑
2022-08-18 15:42:01