‫Okay.
‫So the last video we got in our labels.
‫Dot CSV, which is now in the DataFrame label CSV and it contains image IDs which are file names and
‫their breed label.
‫And then we checked out the distribution of our breed labels and we figured out there's about 82 or
‫so images per class.
‫Now, it'd be good if we could view an image inside the notebook, because this is part of our exploratory
‫data analysis is checking out our data.
‫Let's do that.
‫Let's view an image.
‫So one way to do that is using I Python.
‫Remember even though we're working in Google Lab, this is still under the hood a jupyter notebook so
‫we can go from a python display import image and then we can write image and then we just pass it.
‫A file name and a little trick here in co lab.
‫Oh.
‫Is before we had to press shift in tab in a Jupiter notebook to find the docstring in column.
‫For me, it's command space shift.
‫Oh, and then Siri comes up.
‫So come on, shift space.
‫There we go.
‫On windows, it might be control instead of command.
‫So there we go.
‫This is our docstring here.
‫We need to pass it some sort of data.
‫And if we want to see it, we need to pass it a file name.
‫Let's grab one of these image IDs, so I'll just copy that.
‫It should be actually.
‫Let's have a look at the dingo.
‫See, I'm from Australia and we're pretty famous for a story called Dingo Took My Baby.
‫I won't go into the details of that, but you can look it up.
‫And then if we go here, so we go drive, we need to pass it a file name.
‫My drive.
‫File path.
‫Sorry.
‫And then we got our dog vision folder.
‫Dog vision slash.
‫It's going to be in the training folder.
‫This and we need to put on the end JPEG because if we come up to Kaggle, we can see that is actually
‫what the file name is.
‫That's the ID, but the full file name has the jpg.
‫Now let's close this badboy and shift and enter.
‫Oh, look at that cute little dingo.
‫But apparently they can be savages at times.
‫That's one way to view images in our notebook.
‫So if we needed to explore what image we're working with while we're turning it into a tensor, we can
‫use this little function here.
‫Or I think there's another one with map plot lib we can use in show, but we'll have a look at that
‫one later.
‫Now we can view an image and we've got their file IDs and their braids.
‫Let's get a list of all the file names so we don't have to type out this every single time because that
‫would get annoying.
‫So what we might do is write a little down cell here.
‫So I'll press command m change that into markdown and go here getting images and their labels.
‫Let's get a list of all of our image.
‫File.
‫Path names.
‫Beautiful.
‫And so how can we do this?
‫So we might go here, create path names from image IDs.
‫Now, we've just done one here.
‫So this is a path name of this particular image.
‫And we did it by stealing this value here from label CSV.
‫We might bring label CSV down here just so we can have a gaze at it while we work with this label csv.
‫Don't head.
‫There we go.
‫So we might create a little variable to loop through this and create these long strings at the same
‫time.
‫So let's see if we can do that with a list comprehension.
‫So phone names equals.
‫Let's just go f name for f name.
‫To start with, we'll start small in labels.
‫CSV id what is this return?
‫Check the first ten full names.
‫Wonderful.
‫So this is just a short little list comprehension.
‫Basically, it's saying it's create a list of F name for F name, which is short of file name in labels,
‫csv id column.
‫So take this ID column, go through each one of them and take the value and save it to the list.
‫So that's what we've got there.
‫Now we need to change it up to be a bit more like this because these at the moment are just ideas.
‫So what we'll do is drive my drive dog vision train.
‫That's what we can do.
‫Drive, slash my drive slash dog vision slash train.
‫And then it's going to be plus f name I.
‫No, and the string plus f name.
‫What does that return.
‫I said, check the first ten here, but I've lied.
‫I didn't put the little slice.
‫Okay.
‫And now we just need to add, of course, the file extension because otherwise it wouldn't work.
‫These are JPEGs.
‫JPG How does this look?
‫Wonderful.
‫Okay.
‫So now we've got a list of all the file names from the ID column of label CSV.
‫What we should do is compare them to the number of files in our training data directory.
‫Why would we do this?
‫Well, this is to make sure that we've got the same amount of file names as we do actual files in our
‫training file.
‫We downloaded this data from Kaggle.
‫We uploaded it to CoLab, or more specifically, our dog vision folder, and then we unzipped it.
‫So we want to make sure that we're working with the same amount of data.
‫So let's do that.
‫So we go here, check whether number of file names, matches, number of actual image files, because
‫otherwise if we just kept going now and we've worked out later on that, hey, we've got some issue
‫with our data, then it's kind of going to undo a lot of the stuff that we've done.
‫So that's a that's a big point is a lot of machine learning is just basically massaging your data into
‫a form so that it works with machine learning, if that makes sense.
‫So that's what we're doing now.
‫We're just verifying that the data we've got is the right format, the right amount, and then we know
‫once we run our machine learning models, they'll be all hunky dory or at least hunky dory as possible.
‫So we're going to import OS and we can check the amount of files in a particular file by using list
‫dir.
‫So Len O's list dir.
‫I'll just write the code and then we'll explain it.
‫Train is that equal to land of file names and if it is print fall names match actual.
‫Amount of false.
‫Proceed.
‫It's like we're giving ourselves a little instruction here.
‫Print and file names.
‫Do not match actual amount of files.
‫Check the target directory.
‫All right.
‫So what this is going to do if you do is list dir.
‫Let's just see what this prints out.
‫Code.
‫Actually, I might only do the first ten again, otherwise it'll be just spam.
‫Name os is not defined.
‫Oh, that would make sense because I've got import os there and not up here.
‫Let's do it up here.
‫So what this is going to do is tell CoLab to, hey, go in to dog vision train.
‫Oh, I'm just call it data.
‫There's no file there.
‫Stop that.
‫By the way, if the executed code is not responding to interrupt.
‫So if this comes up.
‫It's because this cell is unable to stop.
‫So these are the things you'll run into.
‫And the reason why this is going in sort of an infinite loop is because I actually do have a folder
‫called data, which is what this used to be.
‫And within there, there is also a train folder.
‫So it's looping through there.
‫What I might do.
‫Can I.
‫Can that.
‫Boom, canned it.
‫So let me just tell you what it does.
‫Always Lister is just going to go through a directory and then list all the files in that directory.
‫So we're saying if the length of all the files in this drive my drive dog vision.
‫Here's our other warning that's popped up.
‫This is beautiful timing.
‫So these are the actual things that you're going to run into.
‫Go back to our keynote.
‫Here we go.
‫So this is a little error that you might experience if there's something going on with your Google Drive
‫in the way that CoLab is interacting with it.
‫So the good thing is it usually fixes itself.
‫And if you want to click this more info tab.
‫You get this little paragraph of text.
‫So basically it's saying if you have a lot of files in Google Drive in the top folder.
‫So if we come back to Dog Vision.
‫So in this folder here, if you have a lot of files there, Google Drive can time out as well as if
‫you have a lot of files within a particular folder.
‫It can also time out.
‫So that's very handy that we saw that in real time because I don't want you to come across these warnings
‫and not be sure of what to do.
‫But if in doubt, remember, you can always just search this, ask a question.
‫I'm sure someone will be able to help you out.
‫If not, I'll help you out.
‫Click the links.
‫There's a bunch of things you can try out.
‫Let's just run the code.
‫We've spoken about it for too long.
‫Full names match actual amount of falls.
‫Proceed.
‫Now, I will let you test this one out yourself.
‫We're going to follow the orders of this code here and proceed.
‫Okay, so everything's working.
‫We have all the file names in a list and we have the same amount of file names as we have actual images.
‫Let's do one more check to make sure that we're visualizing directly from a file path so we can go here.
‫One more check.
‫Remember, we want to make sure our data is in the right format.
‫Let's go.
‫The 9,000th image and 9,000th index.
‫Good Lord.
‫I wonder what type of dog that is.
‫What an absolute base we can find out probably.
‫Let's go here, labels.
‫CSV ID 9000.
‫Oh, no, we won't breed.
‫That thing looks savage.
‫Look at the size of that chain, Tibetan mastiff.
‫That even sounds like a tough dog.
‫I want one of them.
‫That's a base that's like a dog.
‫Hercules would have OC.
‫Now we've got all of our phone names that are correct, what we're going to have to do.
‫So we've got the file names now.
‫We need to work with our labels.
‫We need to get our labels in a format that we can use.
‫So let's do that in the next video.