Now, let's start our deep segmentation lesson.
And in this lesson, we will be using cameras to load a unit and segment model will train them.
One of the data sets will generate its predictions.
So now let's get started.
So open notebook 53 and we'll begin to lesson.
So in this lesson, what we're going to do, as I said before, is that we're going to load unit and
segment and train them on this data set and then we'll run some predictions.
So to do that, we have to clone this report here.
So initially, this is the original report, but I had to make some slight changes fit to work.
So it is cloned from my report here.
I just left it to credit the original all of this work.
So I've already run this notebook just to make sure everything was working fine before the lesson started.
It takes about one second to execute.
Next, we need to install some of the packages on that repo, so we just see the into that territory
where it's installed.
You can see it here.
Image segmentation.
And then just run.
Python sets up the pie install so that installs all of the packages we need.
It takes.
It's pretty quick, takes about four or five seconds.
Next, we need to download the dataset.
So the dataset.
I'll explore this dataset with you shortly.
It's basically like a street view type dataset where you're looking at traffic pictures here.
So let's take a look at it here.
Let's take a look at some of the test images, since these will load faster because it's less images
in the territory and all that's widened.
So you can see these are all taken basically from a dashcam or camera mounted on top to call.
And then it's annotated afterward, which we can explore the annotations so you can see there's a directory
for images and there's a directory for annotations.
However, in this annotations are coded in a way where it's not easy to visualize, even though it's
a PNG file.
You can see it looks like a black screen.
However, if you look closely, you can just about see the outline of some people here, some objects.
So it is.
It is labeled.
However, it's in probably like in zero one two three four.
So when you represent that as a color, the almost all black.
Unfortunately, there are quite a few other formats for labeling segmentation data.
What I would encourage you to do if you want to see or if you want to label your own data is just go
to remove.
The rubble floor has amazing tools that are free to use for small image datasets, and you can generate
quickly label and generate your own dataset for segmentation and almost all of the popular formats they
offer.
So it's quite good, quite a useful tool, and it improves your workflow tremendously as a computer
vision practitioner.
So next, we have to initialize model.
Basically, this downloads to pre-trained model for a unit.
So we're getting the FG unit model here that takes about 10 seconds to get.
Then we start treating this model so you can see we just have this point.
The training images, the directories here, the training annotations to the directory.
This is a karats format and it automatically loads it.
We also store some checkpoints here in this temporary directory, and we're only going to do five epochs
in this just to just illustrate how it works.
But we actually do get some pretty good results with just five epochs, to be fair.
You can see the accuracy starts at seventy six and then progresses all the way up to zero point nine
one, which is actually pretty good.
Now what are accuracy is measuring?
Remember, segmentation is pixel class predictions every pixel this data class.
So this 91 percent might look quite good, but in reality, it can look quite messy is still because
10 percent of the pixels are being misclassified.
Either way, you can take a look and see how it looks.
So we're going to predict this image here.
This is the directory in the name of the image.
And then we're going to generate the output here and in the temp there, actually, which let's see
where it is.
It's actually really not in this.
It's probably the actual temp territory.
So I'm not going to navigate toward it anyway.
So let's run.
I've run this already.
Now let's import my plot lib and take a look at the output.
So this is pretty good.
You can see that some people have a very common problem in segmentation models is that you can see,
well, this is a person.
They are sometimes the other classes that it predicts around that sometimes.
So they are quite a few models, no like detections, mask or CNN that it worked quite well.
However, the unit.
Unit does work fairly well, though, in my opinion, and to a lesser extent, the unit unit is better.
But either way, you can see it's pretty good it got road and the cars pretty well.
These are building clusters over this weird patch that probably something in the building who thinks
it's it's not even shot, maybe a tree or something.
Next, we can see this is a different vision, a different color mapping of it, just to illustrate
what's going on.
Now we can display it with a legend so you can actually see what the classes are stood sky building,
pool road, pavement tree signs and bluefin's car, pedestrian and bicycle.
And you can see it with the classes labeled here overlaid onto the original image.
So this is quite a good way to visualize what you're looking at, and you can explore and see where
your model is having issues.
So you can see rebel-controlled of pavement, correct building or mostly correct.
However, with this little patch and the traffic light, actually this is correct the same symbol.
This is probably a mistake, something that a store shop sign will have the original image.
I can display it afterwards, but we can see it a bit here.
So, yeah, pedestrians and bicyclists got a piece of the bicycle.
That's a bit unfortunate.
And this guy tends to merge into a car, maybe because of the color of his jacket.
Either way, no, let's load and train a signet model.
So the second model trains a bit quicker.
You can see it takes fifty seven fifty five bucks per person, five seconds per epoch, whereas this
the unit takes about 64 65 so slightly faster.
But you can see it.
Definitely accuracy is not as good after five epochs.
However, I haven't experimented much with these two models on this dataset, so perhaps they are.
If you train the segment for longer, maybe you can get better results.
Who knows?
It's kind of doubtful, though, but because the units, it's generally better.
But now we can take a look at the unit.
I'm sorry to segment predictions and well, it looks a lot cleaner.
Definitely makes more mistakes because you can see the road to us merges into the sidewalk.
You can see no idea what this is.
It's probably a building class mixed with other things.
So you can see it's a lot more cartoony, but it's a lot cleaner, less noise in this one.
So that concludes this lesson on using carrots to load, load and trim image.
When I say load and trim unit and segment in the next section, we'll take a look at loading the deep
love of truth in PyTorch.
So stay tuned for that lesson.
Thank you.