title: TensorflowJS: Failed to parse model.json
body: <p>I have retrained and converted a Mobilenet model into a model.json-file. This file is loaded into my image classification platform (got a 200 OK status code), but is not recognized as proper json. </p>
  
  <p>I have used these sites to validate my json file</p>
  
  <p><a href="https://jsonlint.com/" rel="noreferrer">https://jsonlint.com/</a></p>
  
  <p><a href="https://jsonformatter.curiousconcept.com/" rel="noreferrer">https://jsonformatter.curiousconcept.com/</a></p>
  
  <p>And both return my file as being validated json. </p>
  
  <p>Two other JSON-files are loaded into the page in the same way, and they return no errors</p>
  
  <p>Yet I still keep getting this error:</p>
  
  <p><code>Uncaught (in promise) Error: Failed to parse model JSON of response from https://localhost/pathto/model.json. Please make sure the server is serving valid JSON for this request.</code></p>
  
  <p>Does anyone know what might be wrong with the file?</p>
  
  <p>EDIT:
  I haven't touched the model.json in any way, I simply loaded it into my index.js file and got the error. </p>
  
  <p>Also this my index.js (the full version):</p>
  
  <pre><code>  const MODEL_URL =
        "https://localhost/tfjs_models/model.json";
      const WEIGHTS_URL =
        "https://localhost/tfjs_models/weights_manifest.json";
      let model;
      let IMAGENET_CLASSES = [];
      let offset = tf.scalar(128);
      async function loadModelAndClasses() {
    $.getJSON(
      "https://localhost/tfjs_models/labels.json",
      function(data) {
        $.each(data, function(key, val) {
          IMAGENET_CLASSES.push(val);
        });
      }
    );
    model = await tf.loadGraphModel(MODEL_URL, WEIGHTS_URL);
    //console.log("After model is loaded: " + tf.memory().numTensors);
    $(".loadingDiv").hide();
    $("#inputImage").attr("disabled", false);
  }
  loadModelAndClasses();
  function readURL(input) {
    if (input.files &amp;&amp; input.files[0]) {
      var reader = new FileReader();
  
      reader.onload = function(e) {
        $("#imageSrc")
          .attr("src", e.target.result)
          .width(224)
          .height(224);
      };
  
      reader.readAsDataURL(input.files[0]);
      //console.log("After image is loaded: " + tf.memory().numTensors);
  
      reader.onloadend = async function() {
        console.log("Before predictions: " + tf.memory().numTensors);
  
        let imageData = document.getElementById("imageSrc");
  
        //console.log("After offset: " + tf.memory().numTensors);
        let pixels1 = tf.fromPixels(imageData);
        let pixel2 = pixels1.resizeNearestNeighbor([224, 224]);
        let pixel3 = pixel2.toFloat();
        console.log("After pixels are formed: " + tf.memory().numTensors);
  
        let pixels = pixel3.sub(offset);
        let pixels4 = pixels.div(offset);
        let pixels5 = pixels4.expandDims();
        console.log("After pre-processing: " + tf.memory().numTensors);
  
        const output = await model.predict(pixels5);
        console.log("After output: " + tf.memory().numTensors);
        const predictions = Array.from(output.dataSync())
          .map(function(p, i) {
            return {
              probabilty: p,
              classname: IMAGENET_CLASSES[i]
            };
          })
          .sort((a, b) =&gt; b.probabilty - a.probabilty)
          .slice(0, 10);
  
        //console.log(predictions);
        var html = "";
        for (let i = 0; i &lt; 10; i++) {
          html += "&lt;li&gt;" + predictions[i].classname + "&lt;/li&gt;";
        }
        $(".predictionList").html(html);
        console.log("After predictions: " + tf.memory().numTensors);
  
        pixels.dispose();
        pixels1.dispose();
        pixel2.dispose();
        pixel3.dispose();
        pixels4.dispose();
        pixels5.dispose();
        output.dispose();
        console.log("After dispose: " + tf.memory().numTensors);
      };
    }
  }
  </code></pre>
  
  <p>This is the link to the model as it was generated by TensorflowJS Converter. </p>
  
  <p><a href="https://github.com/dvbeelen/tfjs_model" rel="noreferrer">https://github.com/dvbeelen/tfjs_model</a></p>