Use AI to distinguish edible mushrooms form toxic mushrooms !

Have you ever hiked or went for a walk and found mushrooms ? We all know that some of them are deadly , but very few of us know which ones are toxic and which ones are not. For a mushroom lover like me, this situation can be very frustrating. To enjoy mushrooms harvest peacfully AI can helps us.


What is Machine Learning ?

Machin learning is all about teaching a computer to perform a task. What if this task was to recognize different sepcies of mushrooms ? The main purpose of our program will be to recognize different types of mushrooms and then allow people to pick the good ones.
This AI will be based on image recognition. Image recognition refers to technologies that identify places, logos, people, objects, buildings, and several other variables in images. Additionally, mobile phones equipped with cameras are leading to the creation of limitless digital images and videos. Thus, our technology works by comparing selected images from given images within a database. In fact, to allow people to identify deadly mushrooms from edible mushrooms, the machine has to learn all about mushrooms types or at least as much as possible to be as more precise as it can.

  • Curious about image recognition? Take a quick look at these videos !


  • First thing first:
  • Teach the machine all about mushrooms
  • There are several types of mushrooms in the nature. To be able to recognize them, the AI must "learn" evrything about them. So your first step will be to teach the machin all about mushrooms.

  • Edible mushrooms
  • Toxic mushrooms
  • Image classiffication

    To do so, we need to build a data set in order to train our machine. We are going to use several tools.
    First, a pretrained image classification model called MobileNet, that has been trained to recognize the content of certain images. We uses ml5.js a library built on top of TensorFlow.js to load the MobileNet model into our browser and To learn more about these tools and how they work clic here !

    Set up a project directory

  • Mushrooms-ml5 : the project folder
  • Images : Folder that contains your images.Here obviously images of several types of mushrooms
  • Index.html : an .html file that contains your code and libraries
  • Sketch.js : a file that contains your JavaScript code
  • In .html refer to you .ml5 library like bellow :

    In you java script refer to the .ml5 library :


    To drop by yourself any photo you want use the "dropzone" varibale in you JavaScript code :

    First results :

    You can see that results are not so accurate. In fact to be precise the machine must be trained by the presentation of many videos so it can distinguish with accurracy the different components of mushrooms (cap,annulus,stem,)

    Make AI Useful,turn these functions into an app : Mushrooms Lovers.

    Imagine you are in the countryside ready for a forest walk. You decide to harvest mushrooms for the dinner but are concerned about you abilitis to recognize edible mushrooms. Well,thanks to your phone camera and AI you can stop worrying To be more useful the functions we used here coulf be used to build an application which purpose would be to recognize mushrooms and distinguish lethal mushrooms from edible mushrooms. Just like in plant recogniton applications ("Iplant") you can use the camera to take in picture the mushrooms you find. After tje call made by the mahchine to its data set and thanks to AI, the application will be able to give you details about your findings !

    BON APPETIT !