Artificial Intelligence 5: Software Options for your AI Model

Software Options for your AI Model

Artificial Intelligence 5

This lesson will help you earn points in explaining your AI project in the Demo video part of the rubric

In this lesson, you will…

  • Learn how to integrate your AI model into a project
  • Start to code your AI project

Key Terms and Concepts

  • Software - term for programs or applications that run on a computer or device

Integrating your Platform

By now, your team should have trained its AI model using a healthy dataset. You’ve tested the model with new and diverse data to make sure it performs fairly and accurately. But you can’t just leave it there! You want your model to take action based on the prediction it makes. 

You will need to implement your model into some platform or software system to make it useful and meaningful, and to be able to solve your chosen problem.

Most of the platforms discussed in Artificial Intelligence 4 will allow you to use your model directly within the platform to create an app or program that can help to achieve your goals. The one platform that just allows you to create the model is Teachable Machine. You will need to use an alternate platform, like Scratch versions from the MIT Media Lab or Stretch3, to use the model to perform some action. 

Check out your chosen platform below to learn how to integrate your trained model.

Stretch 3 (integrated with Teachable Machine)

stretch3.github.io

Stretch3 is a version of Scratch that easily incorporates machine learning models created with Teachable Machine. After you train your model in Teachable Machine, click the Export Model button.

This uploads your model to the Teachable Machine server and gives you a URL you can use in Stretch3. Copy the URL.

Open a new project in Stretch3: https://stretch3.github.io.

Click on the button to add an extension.

Add the TM2Scratch extension by clicking on it.

You will now have access to the TM2 blocks. Drag out the classification model URL block. In this example, we used a sound model, but you could also have an image or pose classification model.

Paste the copied URL from your Teachable Machine model into the blank field for URL.

To activate your model, click on the green classification model URL block to run it. It will be highlighted in yellow. When the highlight disappears, your model has been loaded, and your different classes will be accessible. 

For example, you can use a when received sound label block. This event handler will be triggered when the program detects, in this case, one of the sounds the model was trained to detect. The dropdown for label should have all the different classes you trained. In this example, it will detect snaps, claps, whistles, and background noise.

You can then code your project to take action when a label is classified. You could have a sprite do different actions depending on which sound it hears. Tailor your code to whatever your particular solution is!

Here is a video showing how to incorporate the Snap, Clap, Whistle model into Stretch3.

Machine Learning for Kids
MIT App Inventor
mblock

Activity: Coding your AI Model

What you will do:

1. Review what is needed for your particular platform to add your trained AI model to a project.

2. Create a new project in your selected platform and add your model. How you do it will depend on the process for your particular platform.

3. Take action! Add components and code to the platform so your project takes an action based on the prediction from your model.

Reflection

You’ve started to code the guts of the action part of your AI project! Here is where you can see the results of your model and what it can really do!

Now is a good time to check in with your Project Plan/Canvas to see how your project is progressing. You might want to adjust timelines and tasks based on the platform you are using and the steps you will need to achieve the goals for your project.

Once you get your code working, it’s also time to check back in with your users. Find some people to test out your project and provide feedback.

Additional Resources: Advanced Integrations

More tutorials for coding with platforms that can use an AI model can be found below.

 

MIT Media Lab Scratch version that can use a Teachable Machine model

 

Want to use some hardware like micro:bit?