1 00:00:00,160 --> 00:00:05,200 Welcome everybody to the tutorial Text Recognition with LearningML and Scratch. 2 00:00:05,200 --> 00:00:11,199 We start by navigating to the LearningML platform. So last time, I saved the project to my account. 3 00:00:11,199 --> 00:00:16,800 So I can now easily retrieve it by going to My Things and loading the projects. 4 00:00:18,160 --> 00:00:23,679 So this way, I don't need to create the classes again and add all the training examples. They're 5 00:00:23,679 --> 00:00:28,800 already there. You can also upload projects that are saved on your computer. So let's train the 6 00:00:28,800 --> 00:00:35,119 model and once it has trained let's go to the programming platform by clicking on the scratch 7 00:00:35,119 --> 00:00:44,289 icon okay so we're now in the scratch programming platform to which we have added our own blocks so 8 00:00:44,289 --> 00:00:51,409 today we will work with the learning ml text blocks so let's let's try it so what did we 9 00:00:51,409 --> 00:00:55,969 want to do well we want to have a virtual assistant um let's add a costume for our 10 00:00:55,969 --> 00:01:07,400 virtual assistant. So let's search for robot. Let's pick the retro one. Has it 11 00:01:07,400 --> 00:01:13,879 been added? Yes. And let's remove the two others. Let's add some code for our robot. 12 00:01:13,879 --> 00:01:24,319 So we want to have a nice robot, so it should talk to us. Hi there, I am your 13 00:01:24,319 --> 00:01:33,859 assistant and then it should ask us what we want him to do and we can find this 14 00:01:33,859 --> 00:01:43,700 in the light blue colored blocks so he asks us a question how can I help you 15 00:01:43,700 --> 00:01:51,700 and let's also add an event to start this sequence of blocks okay so let's 16 00:01:51,700 --> 00:01:59,620 click on the flag and our robot says how asks how can I help you and a prompt 17 00:01:59,620 --> 00:02:08,199 appears so let me write there lights off and nothing happens that is because 18 00:02:08,199 --> 00:02:16,060 we're not telling the robot to do something with that answer so let's 19 00:02:16,060 --> 00:02:23,199 let's add that so we have here the block answer so that is what we just that is 20 00:02:23,199 --> 00:02:29,400 our input. So, for now, let's start with something easy. Let him just repeat the answer. 21 00:02:30,780 --> 00:02:41,020 This. And let's try again. So, the prompt appears. Lights off. And he just repeats our answer. 22 00:02:44,389 --> 00:02:50,430 Okay. But we don't want him just to repeat the answer. We want him to understand what we want. 23 00:02:50,430 --> 00:02:53,289 So let's use our AI model. 24 00:02:54,129 --> 00:02:57,349 And we have a block that says classify text. 25 00:02:57,550 --> 00:02:59,069 So it takes a parameter text. 26 00:02:59,229 --> 00:03:01,110 So that is our input, our answer. 27 00:03:01,330 --> 00:03:04,830 So let's move answer there. 28 00:03:06,409 --> 00:03:08,030 And let him repeat this. 29 00:03:13,360 --> 00:03:15,460 Lights off. 30 00:03:15,879 --> 00:03:18,120 And now he repeats switch off. 31 00:03:19,120 --> 00:03:24,379 So the label, the predicted label for our input is switched off. 32 00:03:24,379 --> 00:03:34,090 and our robot has repeated that prediction that label okay so but that's not everything 33 00:03:34,090 --> 00:03:40,990 we also want him to do something so let's add a backdrop so we can actually switch a light off 34 00:03:40,990 --> 00:03:51,590 and on so let's find one um let's take a bedroom this one let's move our robot a bit here okay 35 00:03:51,590 --> 00:03:58,750 let's go back to the backdrop let's give it a name so this is the one where we have the lights 36 00:03:58,750 --> 00:04:08,849 on and then we have another one um let's rename this as lights off and let's hack it a bit 37 00:04:08,849 --> 00:04:22,779 um so let's add a rectangle here a bit clumsy like this and let's make it dark 38 00:04:22,779 --> 00:04:31,259 and let's call this lights off. So, let's add some code for our backdrops. 39 00:04:33,180 --> 00:04:38,439 So, let's think of it first. So, what needs to happen is the following. So, when the robot 40 00:04:38,439 --> 00:04:45,160 receives an order, it should send a message to the current backdrop to change. If the message 41 00:04:45,160 --> 00:04:51,660 is switch on, the current backdrop should change to the lights on backdrop and otherwise, when it 42 00:04:51,660 --> 00:04:57,339 receives switch off the current backdrop should change to the lights off backdrop so how are we 43 00:04:57,339 --> 00:05:04,620 going to do that well we have other blocks for that so we have event blocks when i receive 44 00:05:05,420 --> 00:05:08,779 a message so we're now adding code to the backdrop 45 00:05:10,540 --> 00:05:19,389 so let's add a new type of message the first one switch on and we have a second message 46 00:05:19,389 --> 00:05:22,509 We have two types of message. 47 00:05:22,509 --> 00:05:27,250 One is switch on, the other one is switch off. 48 00:05:27,250 --> 00:05:28,550 So we have two messages. 49 00:05:28,550 --> 00:05:31,069 What do we need to do? 50 00:05:31,069 --> 00:05:33,370 We need to change the backdrop. 51 00:05:33,370 --> 00:05:35,290 So we need to change the looks. 52 00:05:35,290 --> 00:05:37,509 So that's in the purple blocks. 53 00:05:37,509 --> 00:05:38,949 So what needs to happen here? 54 00:05:38,949 --> 00:05:46,529 Well, when the message is switch on, the backdrop should change to the lights on backdrop. 55 00:05:46,529 --> 00:05:52,490 When the message is switched off, the backdrop should change to the lights off backdrop. 56 00:05:52,490 --> 00:05:56,649 Okay, so that's the code for our backdrop. 57 00:05:56,649 --> 00:06:01,439 Let's now go back to our robot. 58 00:06:01,439 --> 00:06:07,360 So let's run the program just once more, see what happens. 59 00:06:07,360 --> 00:06:11,240 So off, let's be really short now, switch off. 60 00:06:11,240 --> 00:06:16,939 So nothing has changed because the backdrops, they haven't received any message. 61 00:06:16,939 --> 00:06:26,300 So the robot needs to broadcast the message and for this we have other event blocks. 62 00:06:26,300 --> 00:06:33,519 So the robot needs to broadcast the message it has just received. 63 00:06:33,519 --> 00:06:44,180 So let's add another classified text together with the answer. 64 00:06:44,180 --> 00:06:49,579 So now it will just repeat, it will say what it will do and then it will broadcast that 65 00:06:49,579 --> 00:06:56,540 message, such that the backdrops, the current backdrop will change. So, hi there, I'm your 66 00:06:56,540 --> 00:07:06,420 assistant. So, lights off, switch off, and the backdrop has changed, and the lights are off. 67 00:07:06,899 --> 00:07:20,160 So, let's switch them back on. So, switch on, and the light is back. So, this is just a very simple 68 00:07:20,160 --> 00:07:26,319 illustration of how you can use the AI models within Scratch. Other examples can be found 69 00:07:26,319 --> 00:07:34,720 on the LearningML webpage and our FIAS project page. See you in a next tutorial!