Training an artificial intelligence model sounds like a really complicated thing, right? Make no mistake, as a general rule it is a complex activity that requires knowledge of programming, mathematics, statistics, etc. We will also need a good dataset with the necessary digital assets for both training and validation of the model. And, of course, we must also have an extensive set of tools and the necessary hardware to use them. That said, unless you are a professional in the sector, everything sounds too complicated for ordinary mortals.
Cloud services help reduce this list of requirements or, rather, allow us to move part of them to the cloud (for a small price, of course). Amazon AWS, Microsoft Azure, and Google Cloud offer suites of tools and resources that make things a little easier. Nevertheless, what is still needed is a broad knowledge base, as well as the necessary budget to assume the costs of using said cloud services. We are not talking about a high bill if we limit ourselves to carrying out personal tests, but as a general rule it is not free.
There are, however, some services that allow us to take our first steps in this field, some of which are free, and there are also options zero-code, that is, we will not have to write a single line of code to use them. This, of course, will not provide us with in-depth learning about how a model works, but it will allow us a first contact that can be most rewarding. If you want to go through that first experience, then We tell you how to train your first artificial intelligence model, without having to use code and completely free of charge.
Train your first AI model with the Teachable Machine
As I said before, we are going to use a free service, from Google, with which we can train a model, using supervised learning (if you don’t know what this means, you can see it here). The Teachable Machine is a model designed to distinguish and classify images, sounds and body postures, and for training we can use datasets or our own webcam.
In this example we are going to carry out a very common exercise, a classifier of cats and dogs. Therefore, we need a good dataset with images of both types of pets. But don’t worry, you won’t have to spend hours looking for the necessary images, since we can find many datasets already prepared and ready to download on the Internet. For this example we are going to use the Cat & Dogs dataset by Arsh Anwar, which you can download for free from Kaggle. Once the file is downloaded, unzip it and you will see that it consists of several folders with many images of cats and dogs:
Now go to the Teachable Machine, through this link and, on the page that will open, click on the “First steps” button. This will take you to a page where you will have to choose the type of content you want the model to know how to classify. In this case you will have to choose “Image project” and then select “Standard image model”. This will take you to the model settings:
The classes (Class) are, as you can deduce, the different options for classification, in this case “cat” and “dog”. Although this won’t affect how the model works, you can rename them to better identify them and make the output of the AI more clear once it’s up and running. To do this, click on the pencil-shaped icon that appears to the right of each name and put Cats in one and Dogs in another.
The next thing is, you can imagine, start uploading the images for training. Now, at this point you must take into account that the Teachable Machine will use the resources of your PC to process the training. What does this mean? Well, if you upload thousands of images, the process can take forever. For a first test, you can start by using a hundred or two hundred images from each category. If you verify that your system processes them in a reasonable time, you can carry out the process again with more images of each type. Obviously, the more images you use in training, the higher success rate the model will have.
Clarified this point, let’s go with the images. Click on the “Upload” button of the first of the two classes and drag the images you want from the dataset/training_set/cats folder (if you put the kittens first, obviously otherwise you will have to go to the subfolder dogs). Then repeat this process with the second class and the images that correspond to it. The result should be something like this:
In this example we are using only two classes to keep it simple, but as you can see you can add more if you want so that the AI model is able to distinguish between more types of elements. So, with everything set up, it’s time to make the model learn from the labeled data in the dataset. To do this, click on the “Prepare model” button, leave that tab open and do not use the computer for any other purpose during the process.
During the process, it is more than likely that this browser message will be displayed:
If you hit wait, it will show up again soon after, so the best thing to do is leave it there, as it will disappear when the preparation phase is over. Of course, do not change the browser tab or window in the operating system, and under no circumstances click on “Exit the page”. In a few minutes (the time will depend on the number of images you have selected and the technical specifications of your PC), the training will start, and you will be able to see its progress along with the time spent so far. When the process is finished, the page will look like this:
So now comes the moment that you were surely waiting for, let’s test your model! In the section on the right, make sure that the input selector is activated, click on the arrow that appears to the right of Webcam and choose “File”. Then the box with the webcam image will change to show a file upload section, which you can use in the same way as the image upload sections for the different classes. For this test, it uses the cats and dogs subfolders of the “Test_sets” directory. We use different folders to avoid using the same images in the training process and in the validation.
When you upload an image, it will be displayed in that section and, under it, you will be able to see the percentage value of the image for each of the defined classes, for example
Repeat this process as many times as you like to verify that the model is working correctly, or if you find faults, you can retrain it with a larger set of images.
!! Congratulations!! You have now trained your first artificial intelligence model. As you can see at the top, you can export the model you just created. And what can you do with it? We will tell you that soon, in a future article.