OK so last video we got in our labels dot CSB which is now in the data frame labels say it's vague and
it contains image ideas which are file names and that their brave label and then we checked out the
distribution of our breed labels and we figured out there's about 80 to also 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 you an image.
So one way to do that is using Python.
Remember even though we're working in Google lab this is still under the hood.
You put a notebook so we can go from Python.
Don't display import Image.
Then we can write image and then we just pass it a file name and a little trick here in collab oh is
before we had to press shift and TAB energy for notebook to find the doctoring in collab and me it's
command space shift and then Siri comes up.
So command shift space.
There we go on Windows it might be control instead of command.
So there we go.
This is our doctoring 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 I.D. so I'll just copy that.
It should be.
Actually let's have a look at a 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 we go dry.
We need a positive file name.
My drive file path sorry.
And then we go now.
Dog vision folder dog vision slash.
It's going to be in the training folder.
This and we need to put on the end j peg because if we come up to Kaggle we can see that is actually
what the phone name is.
That's the I.D. but the full phone name has the Dodge IPG.
Now let's close this bad boy and shift in into 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 Matt Lib we can use in the show but
we'll have a look at that one later.
Now we can view an image and we've got the Firefly days 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 mock down cell here.
So press command M.M. changed 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 I.D. 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 so we might bring
labels CSB down here just so we can have a gaze at it while we work with this label CSA dot 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 file names equals let's just go f name for
F name to start with.
We'll start small in labels CSA idea what does this return
check the first 10 phone aims.
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 file name in labels CSP
idea column.
So take this idea 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 trying as we can to drive slash my drive slash dog vision
slash train and then it's gonna be plus f name on a and destroying plus f name.
What does that return I said check the first 10 here but I've lied.
I didn't put the little slice
OK.
And now we just need to add of course the file extension because otherwise it wouldn't work.
These are GI pigs don't JP How does this look.
Wonderful.
OK.
So now we've got a list of all the file names from the I.D. column of labels CSB 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 collaborate 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 the 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 it.
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 input ours and we can check the amount of files in a particular file by using list.
So Len OS Lister.
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 phone aims match actual amount of files
proceed.
It's like we're giving ourselves a little instruction in print and phone names do not match actual amount
of files check the target directory.
All right.
So what this is going to do if you do our list list lets you see what this prints out
code.
Actually I might only do the first 10 again otherwise it'll be just spam name always is not defined.
Oh that would make sense because of the import os there and not here.
Let's do it up here.
So what this is going to do is tell collab to hey go into dog vision train.
Oh I've just called it data.
There's no file there.
Stop that.
By the way if the executing 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 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 try and follow so it's looping through there.
What I'm gonna do.
Can I can that then candidate.
So let me just tell you what it does always Lister is just gonna 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 dark vision
his our other warning that's popped up this is beautiful timing.
So these are the actual things that you're going to run into.
Get back to our keynote.
Here we go.
So this is a little area that you might experience if there's something going on with your google drive
and the way that collab is interacting with it.
So the good thing is it usually fixes itself.
And if you want to put this more info tab you'll 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.
Go 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 asset question.
I'm sure someone will be out 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.
File names match actual amount of files.
Proceed.
Now I will let you test this one out yourself.
We're going to follow the orders of this code here and proceed.
OK 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 fall apart 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 nine thousand.
Image nine thousand index.
Good Lord.
I wonder what type of dog that is.
What an absolute base we can find out.
Really.
Let's go here.
Labels CSB I'd say nine thousand
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.
OK.
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.