Applied AI & AI in business /

Build your own (insert your own topic of interest, here) classifier

April 16/5 min read
  • Jonatan Jönsson
    Jonatan JönssonSoftware Developer

How you can go from an idea to a prototype very quickly, without much prior knowledge.

AI can often feel overwhelming, but it really doesn't have to be! In this post I'm going to show you how you can go from an idea to a prototype very quickly, without much prerequisite knowledge. This is for all of you who have heard about AI but who have had a hard time using it for anything. I hope it can help!

In this post, I'm going to tell you how I helped a new colleague build a model to recognize trees using deep learning and transfer learning in less than one hour. I'm going to start with a bit of background to explain my own interest in all of this, and why I'm so passionate about what we're trying to achieve at Peltarion.

An ode to automation

When I was 16 I was tasked with transferring data from an Excel sheet to an inventory system on the web, for a company I was interning for. I started to manually copy/pasting data between the two systems. After a couple of minutes I got bored out of my mind and wanted to automate the work. I had no experience with programming at this time. But I got an idea to record the mouse movements and clicks and then play it on repeat, I used MouseTamer. It worked wonders and I got done with the task in 1 hour that my leader thought would take me the whole week. One could say that it was not a very nice task to give to a student, but I’m very thankful for it! Because I gained a new perspective on how to solve problems. I truly understood the power of automation.

Fast-forward to some classes I took in web design and we used a tool called DreamWeaver. A tool I grew to despite but yet again, I got to understand and be productive with web design without knowing all of the underlying systems, css, html, javascript. All thanks to the wonderful people at Adobe. Today, you would probably use something like wix.com or squarespace.com. Why am I talking about web design tools here? Because what they did for programming and web design, Peltarion is trying to do for AI and deep learning. This post will describe how you hopefully can get my MouseTamer/DreamWeaver experience but within the AI field.

Let's get started

To make this as easy to follow as possible, I'm going for the step-by-step format so you can follow along as you're trying this yourself. Before digging in, however, it might be a good idea to set up an account at platform.peltarion.com so you can dive right in when we get to that part.

Step 1: Finding the dataset

Through a very sophisticated Google search containing the phrase “Bark dataset” we find what we need. The first hit works. Download this data to your computer so you have it ready to upload.

Step 2: Retrieving the dataset

Copy the url to the zip file containing the dataset.

Step 3: Import the dataset into the Peltarion platform

Extra points to all those who have already created your account! For everyone else, you can find the platform here to set up your account. You'll be able to train the model with the GPUs you have in the community version of the platform. Create a project and use “Import data from URL…”, Paste the url from step 2. Click the arrow to start importing the dataset. Click done when it’s imported.

Step 4: Resize images

Modify the data category (the images), set width and height to 240. This will resize the images into something that is easier to build models for.

Step 5: Click 'Save version'

...And wait for it to finish.

Step 6: Start the experiment

Click 'Use in new experiment' (this button appears once the dataset has been saved). This is when the amazing experiment wizard appears! Click Next. Set target feature to category_1 (unfortunately anonymized). The recommended snippet is probably fine. Click Next.

Step 7: Using transfer learning

To use transfer learning, I followed how-to-use-pretrained-snippets (Step 7-10 is basically that guide condensed). Uncheck the Weights trainable checkbox. Click Next.

Step 8: Designing the network

Design the network so that it looks like in the picture below. Add a Dense block to the canvas by clicking in the block list to the right. Connect it to the yellow snippet block in the canvas (Click on the top red circle of the Dense block and drag to the yellow circle of the snippet block. Click on the line to the other dense block from the snippet block. Press the delete button (backspace on Mac). Connect the bottom red circle of the new Dense block to the top of the old Dense block. Click Settings, set Epochs to 1 instead of 10. Click 'Run'.

Super quick coffee break - it will take around 2 minutes for the experiment to finish.

Step 9: Run another experiment to compare

Click Duplicate, set Copy weights to epoch 1. Click Create

Step 10: Tweak the model

Tricky step ahead! Click the Expand all groups button to see the whole neural network. Shift+click and drag over all the elements. Check the Trainable checkbox in the settings pane to the right. Click on the Settings tab. Set Epochs to 50. Set learning rate to 0.00001. Click Run.

Step 11: Finish your coffee

Drink some more coffee (I guess tea is fine too) while you check the progress in the evaluation page, it appears after the first epoch has finished.

Step 12: Time to deploy

Click Deployment, and then New Deployment, choose your latest experiment. Click Create. Click Enable. Click Test Deployment. Upload an image of a tree by clicking on the image button. Click on the reload button to the right to get your prediction! It should have about a 50/50 chance of guessing the right tree. Maybe you can get it to be even better? Please tell me how!

(Sorry that it only shows a number, but that’s because the dataset was anonymized. I hope you get the point anyway. It would not be that hard to download the zip, unpack it, rename the folders into what the actual tree is (after you have the deployment, you can un-anonymize the dataset by googling the name of a tree, grab some images (use several to see what the most common prediction is), testing what the deployment gives you and renaming the most common prediction to that tree name, zip the renamed folders, upload as a zip and repeat the steps to get a deployment that gives you tree names instead of numbers)

AI for everybody

So having followed along for this post, I hope that you understand that AI doesn’t need to be inaccessible. You don’t need to have a math/machine learning/programming major to use AI, there are tools/guides that you can use! I created a tree identifier. What will you create? My hope is that you will now be able to surprise someone who asks you to do boring things by being a bit creative.

    • Jonatan Jönsson

      Jonatan Jönsson

      Software Developer

      Jonatan Jönsson is a software developer at Peltarion. He has 10 years of experience within the software industry, working with companies such as Ericsson, IGT and Fortnox. Jonatan is passionate about software development and artificial intelligence, especially how biological cells can be used to influence the design of artificial general intelligence. He has a bachelor's degree in International Software Engineering from the Blekinge Institute of Technology and studied artificial intelligence abroad at Georgia Institute of Technology.

    Data science topics

    02/ More on applied AI