0

Currently I am trying to load a json model that I've converted from tensorflow into my tensorflow function.

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js">
</script>
<script>
    //!pip install tensorflowjs;
    // * as tf from '@tensorlowjs/tfjs';
    async function tensorFlow(){
    const model = await tf.loadLayersModel('AI-Model/model.json');

}

tensorFlow()

</script>

Directory of my GitHub Repository

However, when I try to add the json file I get the error that loadLayersModel() expects a http request. Is there a way to load in my model from the repository? If not how do I go about this?

2 Answers2

0

Tensorflow.js can't access local files directly (unless you're doing it in Node.js). Take a look at some of these answers.

Looking at the Tensorflow.js API, your options appear to be either:

  1. Load the model from an HTTP server
  2. Load the model from user-selected files from HTML file input elements.
-1

Replace this line const model = await tf.loadLayersModel('AI-Model/model.json'); by const model = await tf.loadGraphModel('http:AI-Model/model.json');