title: tensorflow js RGB to Lab from input img
body: <p>I have been searching and debugging but I can not find anything that works for me. I'm doing a web application in which I try to go from black and white images to color and for that I have put an input in which I load the image and make the inference (currently with an image-to-image model).</p>
  
  <p>The fact is that I want to transform the image of rgb to lab as a preprocess before it enters the network because that is how I intend to train it. My code is as follows:</p>
  
  <pre><code>var myInput = document.getElementById('myFileInput');
  
  function processPic() {
      if (myInput.files &amp;&amp; myInput.files[0]) {
          var reader = new FileReader();
  
          reader.onload = function (e) {
              $('#prev_img_id').attr('src', e.target.result);
              //Initiate the JavaScript Image object.
              var image = new Image();
             //Set the Base64 string return from FileReader as source.
             image.src = e.target.result;
             image.onload = function () {
                 //alert(this.height)
                 const webcamImage = tf.fromPixels(this);
                 const batchedImage = webcamImage.expandDims(0);
                 predict(batchedImage.toFloat().div(tf.scalar(127)).sub(tf.scalar(1)))
              }
          }
  
          reader.readAsDataURL(myInput.files[0]);
      }
  }
  
  myInput.addEventListener('change', processPic, false);
  
  
  function predict(the_img) {
      //get predictions 
      let pred = mobilenet.predict(the_img);
      //retreive the highest probability class label 
      let cls = pred.argMax().buffer().values[0];
  
      alert(IMAGENET_CLASSES[cls]);
  }
  </code></pre>