AI and ML for kids - part 1 | Create and code a face filter like on TikTok with Scratch

Micke Kring Micke Kring · · 2 min read
Läs på svenska
AI and ML for kids - part 1 | Create and code a face filter like on TikTok with Scratch

In this short series I thought I’d give you, as a primary school teacher, some lesson ideas for practical teaching in AI — and in this case the subfield ML, Machine Learning or maskininlärning in Swedish. Most children and adults already use services built on ML today, such as Siri, Alexa, or Google Assistant. Or, as in this case, various filters on social media. We do this within the framework of the subjects technology and mathematics.

I kommentarmaterialet för ämnet teknik i grundskolan kan vi läsa att

“An overarching purpose of teaching in the subject is that pupils shall develop interest in and knowledge about the technology that surrounds us.”* and that *“The subject of Technology in primary school aims to make the technology that surrounds us visible and comprehensible.”.

Programmering ingår i bägge ämnenas centrala innehåll och här kan vi introducera och experimentera lite med ML genom något som är elevnära.

Video

Scratch

In this example I’m using a version of Scratch from Machine Learning for Kids that you can find at scratch.machinelearningforkids.co.uk. It’s the same version as the link above, but this contains some extra extensions specifically for machine learning, like “Face detection”. If you haven’t worked with Scratch before, I recommend you learn it now. It’s free and open source from MIT. You can find it at scratch.mit.edu

Download my example

If you want something to start from, you can download my example from the video and play with it. Download the scratch file ML_Ansiktsfilter.sb3

Code summary

We run loops where we let the pre-trained model in Face detection continuously find the x and y coordinates of our left and right eyes. Then we create two sprites and draw eyes, and connect the coordinates from Face detection to movement of our eye sprites.

Questions?

If you have any questions, as usual just ask :)