1 00:00:00,390 --> 00:00:06,030 Hi and welcome to 12. tree where we start building our fruit classifier and we start using some of these 2 00:00:06,030 --> 00:00:08,290 callbacks we learnt in the previous section. 3 00:00:08,670 --> 00:00:13,110 So let's talk a bit about fruit datasets called fruit 360. 4 00:00:13,110 --> 00:00:16,440 Basically it was it was part of a Kaggle competition. 5 00:00:16,530 --> 00:00:18,530 This is a link to the actual dataset here. 6 00:00:18,780 --> 00:00:21,460 It consists of 81 types of fruits. 7 00:00:21,840 --> 00:00:28,770 That's 81 classes and approximately 45 images per class and all images are rendered by 100 pixels and 8 00:00:28,770 --> 00:00:30,000 in color. 9 00:00:30,660 --> 00:00:33,040 So these are some examples of fruits here. 10 00:00:34,030 --> 00:00:36,780 Honestly I can't identify some of these myself. 11 00:00:37,420 --> 00:00:40,950 But you we're going to try and justify it to do just that. 12 00:00:40,970 --> 00:00:43,480 So let's go to I put it in the book. 13 00:00:43,810 --> 00:00:44,080 OK. 14 00:00:44,080 --> 00:00:47,860 So here we are at Chapter 12 the building of a fruit classifier. 15 00:00:47,890 --> 00:00:49,040 Let's bring up this file. 16 00:00:50,100 --> 00:00:54,400 But before we begin I hope you downloaded your fruit trees 60 datasets. 17 00:00:54,760 --> 00:00:58,290 And I wanted you to put that at File. 18 00:00:58,290 --> 00:00:59,630 Let's go to it here. 19 00:01:00,090 --> 00:01:03,450 Into this folder that it should have extracted into this for the here. 20 00:01:03,930 --> 00:01:08,850 And basically I want you to make sure that it's named train and validation. 21 00:01:08,850 --> 00:01:14,480 It should be as I've zipped it or compressed it correctly and you can take a look at the fruits here. 22 00:01:14,520 --> 00:01:20,540 So you can take a look at some mangoes of mangos all look quite similar to each other. 23 00:01:20,940 --> 00:01:21,210 OK. 24 00:01:21,220 --> 00:01:22,450 So let's go back to this here. 25 00:01:22,500 --> 00:01:33,610 So let's go back to the book and Firstly like we have done in our dogs with cats CNN we declare our 26 00:01:33,630 --> 00:01:39,380 doctors here and we just create some image data generators for training and validation and are trained 27 00:01:39,380 --> 00:01:44,400 and ready to and validation generates a notice with no categorical and binary. 28 00:01:44,730 --> 00:01:48,780 And also notice we have to declare a number of classes here as well. 29 00:01:48,860 --> 00:01:54,830 This dataset even though the data set is encoded into 100 by 100 pixels I'm going to use a resize as 30 00:01:54,840 --> 00:01:58,890 to the two Bertelli to basically make our training faster. 31 00:01:59,010 --> 00:02:02,090 We use a similar scene and never used for Safar here as well. 32 00:02:04,470 --> 00:02:10,680 And then we declare this is important but that's creates all callbacks So as you can see in the presentation 33 00:02:11,160 --> 00:02:17,430 this one is a checkpoint Colback and checkpointing basically ensures I received a best model after every 34 00:02:17,430 --> 00:02:17,810 box. 35 00:02:17,820 --> 00:02:23,550 If you train for 20 bucks and the best model is an e-book 16 it'll be that will be the one we save here. 36 00:02:24,060 --> 00:02:24,840 We need to specify. 37 00:02:24,840 --> 00:02:28,910 Finally I'm actually didn't mention that in our slides but it's much just the directory it's actually 38 00:02:28,910 --> 00:02:32,590 a file and we want to see it as otherwise it will not work. 39 00:02:32,630 --> 00:02:38,760 Ill be stopping here really stopping the problems as we have said here and it is something basically 40 00:02:38,760 --> 00:02:45,540 tells us when if this thing has stopped improving it'll stop letting the plateau which wasn't actually 41 00:02:45,540 --> 00:02:47,340 used in this example here. 42 00:02:47,430 --> 00:02:50,640 However we could have used it in another example it really happens. 43 00:02:50,640 --> 00:02:55,820 Unless you have training for exhaustive number of ebox but it's always good to have it just in case. 44 00:02:55,920 --> 00:02:59,880 So we create our callbacks here and actually did not add it in here. 45 00:03:00,150 --> 00:03:01,440 Quickly put it in. 46 00:03:01,730 --> 00:03:07,620 And basically what we do when we compile sorry not comparable with that model is that we point our callbacks 47 00:03:07,620 --> 00:03:10,180 to a callback array here. 48 00:03:10,410 --> 00:03:18,870 So as you can see you know we've trained for five hypoxia and basically you can see this up with this. 49 00:03:19,290 --> 00:03:23,740 Basically this tells us that a model was saved to hear after every epoch. 50 00:03:24,090 --> 00:03:29,460 And basically what happened is that after here it noted that valediction loss didn't improve didn't 51 00:03:29,460 --> 00:03:30,150 improve. 52 00:03:30,330 --> 00:03:33,680 If we are trained for more ebox which I probably should have left it for this example. 53 00:03:33,690 --> 00:03:39,330 But if we are trained for more POCs we would've initiated the stopping metric and this would have stopped 54 00:03:39,330 --> 00:03:40,260 training. 55 00:03:40,260 --> 00:03:47,760 So basically I could have said it to train at 10 epochs which I probably should have done away with 56 00:03:47,760 --> 00:03:47,850 it. 57 00:03:47,850 --> 00:03:49,020 I did find a box here. 58 00:03:49,020 --> 00:03:49,620 Sorry. 59 00:03:49,980 --> 00:03:51,410 And you can do it on your own. 60 00:03:51,450 --> 00:03:58,140 Set it to return the box and train it and you'll see it's going to stop after maybe six ebox. 61 00:03:58,230 --> 00:04:00,640 So let's take a look at the confusion metrics here. 62 00:04:00,900 --> 00:04:04,250 It's not printed correctly and I'll show you how we solve this too. 63 00:04:04,470 --> 00:04:08,120 And that's because we have 81 classes in this year. 64 00:04:08,260 --> 00:04:12,560 Our pacification report is well laid out. 65 00:04:12,570 --> 00:04:17,570 But it's a bit tedious to read don't get a ton of information unless you actually drill down and see 66 00:04:17,570 --> 00:04:20,510 something like oh pomegranates are basically bad. 67 00:04:20,890 --> 00:04:29,150 OK so here's another way to visualize the confusion matrix which was probably not best visualize at 68 00:04:29,150 --> 00:04:30,330 all like that. 69 00:04:31,610 --> 00:04:32,270 So here we go. 70 00:04:32,300 --> 00:04:36,720 Now there's a problem here with this we can actually increase the plot size here. 71 00:04:36,710 --> 00:04:40,570 Let's try 20 by 20. 72 00:04:40,700 --> 00:04:43,280 I'll probably take about maybe 10 seconds to run. 73 00:04:44,400 --> 00:04:47,200 Of Allision that did degenerate that isn't run. 74 00:04:47,200 --> 00:04:51,280 So let's quickly go back here and run this in the beginning. 75 00:04:51,430 --> 00:04:54,980 It's good that actually you actually see these areas and see how I solve it. 76 00:04:55,510 --> 00:04:55,960 OK. 77 00:04:56,290 --> 00:04:59,790 That's because when the book was saved would actually run. 78 00:05:00,040 --> 00:05:02,200 And let's run this this should work now. 79 00:05:04,170 --> 00:05:06,500 It's loading on model that's a model I see. 80 00:05:06,520 --> 00:05:12,120 Prior to training that one I think it was a fairly good model if I'm not mistaken. 81 00:05:23,260 --> 00:05:23,710 There we go. 82 00:05:23,740 --> 00:05:27,320 So this 20 20 did make a nice difference. 83 00:05:27,380 --> 00:05:29,360 We have a nice legend here as well. 84 00:05:29,530 --> 00:05:33,690 So you can see there's a nice diagonal in the middle here. 85 00:05:33,940 --> 00:05:35,570 So that is good. 86 00:05:35,590 --> 00:05:38,110 Now we can see little spots here and there. 87 00:05:38,170 --> 00:05:39,490 This one is here. 88 00:05:39,500 --> 00:05:41,600 I'm not sure what it is corresponds to. 89 00:05:41,920 --> 00:05:42,700 Let's see. 90 00:05:42,700 --> 00:05:44,280 Looks like kumquats. 91 00:05:44,320 --> 00:05:50,300 And it's been mixed up with and I think this is mandarin's entirely sure. 92 00:05:50,330 --> 00:05:55,720 But you can analyze this on your own and take a look and see what's being confused as what. 93 00:05:55,720 --> 00:05:59,960 So this is a nice visual representation of all confusion matrix here. 94 00:06:00,690 --> 00:06:01,610 OK. 95 00:06:01,990 --> 00:06:04,550 So let's test this here. 96 00:06:04,570 --> 00:06:09,270 Now I've created this open see the thing that actually brings up our fruits and tells us to predict 97 00:06:09,280 --> 00:06:11,250 value and what it actually was. 98 00:06:11,470 --> 00:06:12,580 So let's run this. 99 00:06:12,590 --> 00:06:13,200 Here we are. 100 00:06:13,450 --> 00:06:16,890 So predicted a passion for it actually was a passion for it. 101 00:06:16,930 --> 00:06:19,090 And that is not whole depression. 102 00:06:19,120 --> 00:06:22,220 I've seen look but fair enough. 103 00:06:22,220 --> 00:06:26,760 Brandied is a red banana and it got it correctly as a red banana tomato tree. 104 00:06:26,760 --> 00:06:29,860 I think that's type tree good here. 105 00:06:30,830 --> 00:06:31,470 Group. 106 00:06:31,530 --> 00:06:32,640 White or green. 107 00:06:32,640 --> 00:06:34,390 Looks like a light green to me. 108 00:06:34,440 --> 00:06:35,520 Avocado ripe. 109 00:06:35,520 --> 00:06:35,910 Good to know. 110 00:06:35,920 --> 00:06:37,410 That's right. 111 00:06:37,950 --> 00:06:40,910 Goldberry said actually getting everything right. 112 00:06:40,980 --> 00:06:43,460 This is quite quite good classify. 113 00:06:44,190 --> 00:06:48,330 And basically we can take a look at old classified results which probably should have mentioned before 114 00:06:48,750 --> 00:06:50,530 it is 3 percent. 115 00:06:50,730 --> 00:06:52,410 But is that the one we actually use. 116 00:06:52,410 --> 00:06:53,190 No. 117 00:06:53,190 --> 00:06:57,600 The one we actually would be with checkpointing which is very useful. 118 00:06:57,610 --> 00:07:03,060 The one we actually use probably was one of about 92 points of nine percent almost 90 percent after 119 00:07:03,070 --> 00:07:04,050 destry pox. 120 00:07:04,140 --> 00:07:08,280 In each Epopt of what just over five under five minutes to run. 121 00:07:08,280 --> 00:07:12,250 So this is quite good for treating such a complicated dataset using OCP. 122 00:07:12,750 --> 00:07:14,950 So let's just run it want one more time. 123 00:07:14,970 --> 00:07:17,780 Let's see if we get Shirleys get 1 in 10 wrong. 124 00:07:17,850 --> 00:07:19,080 It's a good one. 125 00:07:19,080 --> 00:07:20,460 We're all very good. 126 00:07:20,520 --> 00:07:23,220 So yes pomegranates are a problem. 127 00:07:23,220 --> 00:07:25,790 I'll be fair to be fair to stars that I can apply to me. 128 00:07:25,830 --> 00:07:29,060 However this part of it is something like an apple good. 129 00:07:29,220 --> 00:07:32,610 So everything else is correct. 130 00:07:32,670 --> 00:07:36,630 So that's it for basically using carrots is called Back future. 131 00:07:36,860 --> 00:07:40,970 We've seen checkpoints stopping and leaning read adjustments on too. 132 00:07:41,340 --> 00:07:42,340 That's it for the Shapter.