1 00:00:00,420 --> 00:00:09,390 In this video we are going to create our first CNN model for dog and cat boots like that we discussed 2 00:00:09,660 --> 00:00:13,140 in our last lecture. 3 00:00:13,240 --> 00:00:17,460 We have our data in the form of jpeg images. 4 00:00:17,710 --> 00:00:24,370 You can download this images from the links that we have provided in the resources section of this video 5 00:00:26,300 --> 00:00:29,540 once you download the zip file and extract it. 6 00:00:30,530 --> 00:00:41,150 You will get three folders this crane and validation each of this for years content do so for years. 7 00:00:41,280 --> 00:00:42,530 Cats and dogs. 8 00:00:44,010 --> 00:00:51,780 And in this folders you can find the images of cats and dogs that we are going to use for our model 9 00:00:54,080 --> 00:01:03,050 one thing you can straightaway notice is that the dimensions of this images are not standardized so 10 00:01:03,050 --> 00:01:06,240 you can see this is a portrait image. 11 00:01:06,850 --> 00:01:09,190 And this is a landscape image. 12 00:01:09,410 --> 00:01:13,700 So we have to resize our images as well. 13 00:01:13,720 --> 00:01:17,130 Now we have around 4000 different images. 14 00:01:17,380 --> 00:01:21,800 We will use 2000 images for training. 15 00:01:21,870 --> 00:01:30,020 We will be called a thousand images for our passing purpose and really take another posing images for 16 00:01:30,020 --> 00:01:31,350 our validation data site 17 00:01:34,560 --> 00:01:36,450 now before starting. 18 00:01:36,450 --> 00:01:44,670 We will save the location of this four years in three variables that are creating directory validation 19 00:01:44,670 --> 00:01:45,240 that victory. 20 00:01:45,360 --> 00:01:55,560 And as directory so just copy the address of this for years and save it. 21 00:01:55,710 --> 00:01:59,650 And this three different variables. 22 00:01:59,740 --> 00:02:06,740 Now if you are copying you will get backward slash instead of forward slices. 23 00:02:06,820 --> 00:02:12,540 So just remember to put art before pasting this folder addresses 24 00:02:15,350 --> 00:02:22,920 so we have saved addresses of all these four letters and three different variables drain directory validation 25 00:02:23,000 --> 00:02:24,800 category and aesthetically 26 00:02:31,940 --> 00:02:42,640 now we have to convert this picture images in the form of values the first step to do this is to read 27 00:02:42,640 --> 00:02:48,760 the picture file then decode the debate contain to already be great of pixel. 28 00:02:49,090 --> 00:02:52,420 So we want three channels red blue and green 29 00:02:55,090 --> 00:03:06,870 then we need to convert this art be floating point values and to a value between 0 and 1 so to do all 30 00:03:06,870 --> 00:03:11,760 these steps we will use gave us image data generator module 31 00:03:15,280 --> 00:03:26,430 this module have functions to perform all this steps using a single function or legacies in both image 32 00:03:26,460 --> 00:03:31,140 data generator module. 33 00:03:31,280 --> 00:03:33,970 Now there are two parts of this image. 34 00:03:34,000 --> 00:03:44,340 Do the generator module first is to get the image and then the second part is to reskill that image 35 00:03:45,960 --> 00:03:56,490 you can feed the images from directory from num by array or from any other source here in our case we 36 00:03:56,490 --> 00:04:04,960 want our images to directly free data from our directory or the formula so we will be using Flo from 37 00:04:04,960 --> 00:04:15,660 directory method of image to to generate the so I have created this green detergent object from immediately 38 00:04:15,660 --> 00:04:16,890 the generator. 39 00:04:17,100 --> 00:04:26,540 And here as an argument we are providing that scaling value to divide our GDP values by 255. 40 00:04:26,560 --> 00:04:36,020 Our RTP values lies between 0 to 255 and to convert them and 2 0 to 1 interval we have to divide that 41 00:04:36,140 --> 00:04:39,200 by 255. 42 00:04:39,310 --> 00:04:46,660 So first we are creating an object with data generator function with reskilling value of 1 divided by 43 00:04:46,660 --> 00:04:47,460 255. 44 00:04:49,660 --> 00:04:55,570 Then we are using slow from Derek through my texts and so if data is in the form of folders or decreased 45 00:04:57,540 --> 00:05:04,890 then we are creating two different generators one for our train data and another one for our validation 46 00:05:04,890 --> 00:05:05,490 data. 47 00:05:06,570 --> 00:05:12,930 For train data first we have to mention the train directory we have already saved the information of 48 00:05:12,930 --> 00:05:17,460 forward train that is to address in this train that a key variable. 49 00:05:17,670 --> 00:05:23,220 So first parameter here is our variable which contains the directory name. 50 00:05:23,220 --> 00:05:28,890 Then the second parameter here is the size of images that we want. 51 00:05:30,720 --> 00:05:40,200 So since a word image sizes are not centralized we are centralizing it using the target size of 150 52 00:05:40,200 --> 00:05:50,260 by 150 pixels so all of our images are going to convert in this size. 53 00:05:50,270 --> 00:05:55,010 Now we have to mention the bed size that we are going to use in our model. 54 00:05:55,880 --> 00:06:01,220 So earlier if you remember last time we were using a bed size of 64. 55 00:06:01,220 --> 00:06:04,580 Now we are using a bed size of 20. 56 00:06:04,880 --> 00:06:16,250 Now this flow from Derrick tree will feed images in the batches of twenty two hour train generated then 57 00:06:16,430 --> 00:06:21,710 we have to provide information that is contained in the form of four letters. 58 00:06:21,770 --> 00:06:28,310 So since we are doing binary classification and we have two four letters one for cat and one for dog 59 00:06:28,760 --> 00:06:31,190 we have to provide last more as binary 60 00:06:34,190 --> 00:06:42,860 the output of this green generator will be in the form of X variables and the via variables via labels 61 00:06:43,040 --> 00:06:46,080 will depend on the name of the four years. 62 00:06:46,130 --> 00:06:49,790 So if we have cats and dogs as our four year 63 00:06:52,810 --> 00:07:00,760 so what virally will will automatically become cats and dogs for all the images that are inside those 64 00:07:00,760 --> 00:07:01,570 four wheelers. 65 00:07:03,840 --> 00:07:08,070 Now let's revise what this strange and neuter is doing. 66 00:07:08,190 --> 00:07:12,460 First we are going indoor green directory. 67 00:07:12,630 --> 00:07:16,370 There are two four letters there cats and dogs. 68 00:07:16,460 --> 00:07:27,170 We are resizing all the images in the shape of 150 by 1 4 pixels we are feeding images in the batches 69 00:07:27,170 --> 00:07:27,890 of 20. 70 00:07:28,610 --> 00:07:40,390 So at the time we are picking 20 images then to create via labels we are using the folder names. 71 00:07:40,700 --> 00:07:46,280 And since there are two folders and it's a binary classification problem we have to grow it class more 72 00:07:46,370 --> 00:07:54,640 as binary then as a result of this function we will have our images in the form of floating point ten 73 00:07:54,650 --> 00:07:58,480 sets with arbitrary values between 0 and 255. 74 00:08:00,210 --> 00:08:10,540 This is the kind of data we used in a what last video then we are reskilling those pixel values between 75 00:08:10,540 --> 00:08:17,690 0 and 1 and that's why we are dividing it by 255. 76 00:08:17,840 --> 00:08:26,640 Now why we have created this train do Dudgeon object this is because instead of vertically feeding all 77 00:08:26,640 --> 00:08:35,520 the data and blow at a fit function we are going to feed 20 images at a time and to our first function 78 00:08:35,700 --> 00:08:44,800 while draining over more than one of the advantage of using this image data generator is that in case 79 00:08:44,800 --> 00:08:54,250 we want augmented data we can directly apply many more functions like Greece scale zoom shear cetera 80 00:08:54,910 --> 00:09:03,620 to generate some more data from our existing data if you want some more detail about this image do to 81 00:09:03,620 --> 00:09:13,680 generate a you can click on this link to open the graphs documentation so here you will get all the 82 00:09:13,680 --> 00:09:16,410 information you need for image people assessing.