My first taught machine(s)

What the heck?

Yup, here I'll try and upload my first example of taught machine using ml5JS and with the help of Daniel Shiffman and Dídac Jaquet's website.

Objetive?

To upload here a basic teachable machine able to recognize herbal drugs as a starting point for my research task.

V1: MobileNet image classifier using ml5

The MobileNet model labeled this as ... with a confidence of ...



First things first, I've gone for a basic first step: trying to copy and understand Didac's example, which is a remake of the example found here but with a small variation: his version allows the user to upload a picture to be classified by the ANN. The code looks as follows:

 
      executaClasificador(); //This line executes the "executaClasificador" function 
      
      //This function classify the images
      function executaClasificador(){ 
      //Now we declare all the variables that we will use
        var image = document.getElementById('image');   // The image we want to classify
        var result = document.getElementById('result'); // The result tag in the HTML 
        var probability = document.getElementById('probability');   // The probability tag in the HTML
        
        const classifier = ml5.imageClassifier('MobileNet');    // Initialize the Image Classifier method with MobileNet

        var fileUploader = document.getElementById('fileUploader');//The element to upload images

        // Make a prediction with the selected image
        // This will return an array with a default of 10 options with their probabilities
        classifier.predict(image, function(results) {
          result.innerText = results[0].className;
          probability.innerText = results[0].probability.toFixed(4);
        });
      }
      
      //This function changes the image after selecting it
      fileUploader.onchange = function (event) {
        input = event.target;
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                image.src = e.target.result;
                executaClasificador();
            }

            reader.readAsDataURL(input.files[0]);
        }
      }
      

This first machine is valid for tinkering around and seeing what image classifiers are made of, classifying nearly any image you want fairly correctly, even though it's not perfect and it lacks some precision and accuracy. But the main weak point (as far as my requests are concerned) is that it is only prepared to use the MobileNet dataset from the cloud, which is enough for demonstration purposes and a very broad (and inespecific) range of pictures- which is absolutely not what I am looking for. So for my next example, I'll be looking for a more precise, accurate and specific image classifier, for which I'll try and learn how to use TensorFlow.

What is TensorFlow?

TensorFlow is a javaScript library designed to make ANNs easier to develop.