This platform permits us to curate better data more easily by helping us visualize, as you could see
here, our data in a very easy and intuitive manner.
Um, also helping us, um, as we said, already curate this, this high quality data sets, you have,
um, public data sets or common data sets like the Coco, Open Images and Active Net, which are already
available.
Thanks to this 51 tool, we could easily find mistakes and this would help us, uh, train better models,
as data quality is a key limiting factor on model performance.
So, uh, the 51 tool permits you to easily identify these mistakes.
We also have this, um, 51 brain, which helps you identify edge cases.
You could check out this figure to the left where we have this visualization of embeddings.
And as you may know, with embeddings or by visualizing embeddings in this way, we are able to get
much more information about our data set.
And this really plays a great role when curating data.
Then finally, because we're able to curate and evaluate our data much faster, this leads to us or
different teams getting to production even faster.
So with this, we will dive into how we could make use of the 51 app to visualize, uh, segmentation
or semantic segmentation data.
Diving back into the code, we'll start by installing 51 and then importing it.
So import 51 as F0.
That's it.
So uh, while this is installing we'll get into the user guide.
So we have this documentations right here which you could feel free to check out.
It's quite elaborate and contains um, a lot of stuff you would want to learn about the 51 app.
So that said we could dive into first of all, you could check out the basics and then, um, dive into
loading data sets.
Let's get back to basics.
Here.
We have the basics here.
You see how we have the key terms explained like data sets.
We have samples.
We have fields media types, tags, metadata labels, data set views and aggregations.
Um nonetheless we're going to dive straight into loading the data sets.
So we have loading data sets loading data sets from disk.
Because we have our data set in our, uh, drive or in our colab notebook, which we've downloaded.
So we could simply search for segmentation.
Segmentation.
You could see already that we have different types of data sets which you could load.
We have object detection, we have image classification.
We have even video data sets.
So feel free to check that out.
Um that's image segmentation.
So there we go.
And what we see here is the formatting of our data set.
And it happens that the way our data sets are formatted suits this um um, 51 um, way of formatting.
So here we have the data set directory.
You have one um directory for the data.
That's for the images.
And then we have another directory which contains the labels exactly what we expect.
Here we have file name one with the extension found and one with the extension.
So that's it.
And then scrolling down you see how to use this in Python or um the command line.
So given that we're working with Python we could simply copy this out.
So let's copy here.
Let's copy this and then get back to our notebook.
There we go.
It's already installed.
Um, we have um, imported our 51.
And then we paste it in our data set directory.
Let's paste it in here we have data set.
Oops.
Let's get back paste that we have data set.
And then we have um you see we have 51 data set from directory.
And we specify data set directory which we've just done.
Then the data set type you see image segmentation directory.
And then we have the name which we've already specified.
So that looks fine.
Now let's run this and see what we get.
We are getting an error data directory um contents data set data does not exist.
Remember from the documentation we had seen okay.
From here we had seen that um.
Oh let's get back up.
We had seen that this if we specify the data set directory then it's going to search for the data directory
uh under the labels directory.
So given that that's not exactly the names we've used here, we are going to follow this uh, second
format.
Here we have the data path and the labels path.
So let's copy this instead.
Um data path labels path.
Uh that should be fine.
So we have let's replace.
Um this data set directory with data path and labels path.
So we'll just go ahead and copy images.
So let's copy that um copy path and then paste in here.
And we do the same for the labels.
So that's it.
We have taken off um this this actually should be with images.
So we should have images and then we oops we paste that in and then we have masks that should caps should
have masks.
Well this is also PNG masks PNG masks okay.
That looks fine.
So now we have data path.
Let's get back a bit to the check out the documentation.
Here we have data path and labels path.
So we just copy this out and paste.
We have data path and labels path.
Let's run this again and see what we obtain.
You still have an error.
Dataset name.
Loading dataset one is not available.
Now, the reason why we're getting this error is because the first time we try to create a dataset with
this dataset with this, um, specific name.
And so this has already been stored in the database.
So we could only load this data set at this point.
So that said we should change this to to run that again.
And we should now be able to get some outputs here.
We get another error.
But you could see where it is that it started loading.
So uh, one out of 923 elements um or samples started loading.
We are getting this next error because the way we named our mass was different from the way we named
the images.
You could see here we have this key error seq and it's number 0001.
So what we have to do now is rename our masks such that they are all um img instead of seq.
Now to rename this, we also have to take into consideration the fact that right from the beginning
we took this to be seq.
So instead of um this we would have img img.
And then here we would have img and then img and then img.
Okay.
So that's what we're going to have now instead of seq.
Um.
Let's go ahead and rename this.
So that should be before or let's let's just put it in here.
So we're going to import OS.
Import OS.
But this looks like it's already been imported.
So we don't need to import this okay.
So we have that.
And then now what we want to do is rename each and every file we have in here.
Now we have our image path in path and annotation path.
At this point we're supposing that we are yet to split.
That is we are yet to um move these files.
So we'll just work on the original folders.
That said, what we want to do at this point is take in the initial path, and then we want to have
the renamed renamed uh, path or renamed file.
So initial file path.
And then we have the initial file path.
And then we have now the renamed file path.
And then we are going to go through all these different images.
So for I or for image in the list let's take the list of all images.
Um in path.
For this list we are going to do the renaming.
Now this image here is going to be the file name.
So let's let's print it out so you could see that clearly.
Print the image then break out of this loop.
There we go.
Let's take this off and print it out.
So once that's printed we see we have the the file name right here.
So what we want to do now is take rename and then take the image path the image path plus this image
or the plus file name.
Or let's let's just call this file name.
So plus a file name we want to have the file name.
And then let's make it shorter file name.
So there we go.
We have file name f name okay.
So we have the file name.
And then we add this to the image path.
And then once we add this to the image path we have this initial file path.
Now for the final or the renamed file path we want to have the same image path.
But plus this time around um image.
And then that's we have the image and then um, plus the file name.
But starting from the, the underscore.
So we have zero one, two three starting from three.
So we want to have um f name starting from three.
That's it.
Now you should note that we don't need to do this for the images because they already have IMG.
We just need to do this for the annotation.
So take this off and do annotation okay.
So that's it.
So this should work fine.
Let's run this and see what we obtain.
Then we just refresh uh no such file or directory.
The reason why we're getting this error is because this was supposed to be annotation path and not the
image path.
So we have annotation run that again.
And all our files now should be um, modified or their names should be modified.
So if we open up masks you should see that or still have sex.
Let's get back and refresh.
Um, then data set PNG masks, open up masks.
And normally they should be fine because we didn't run into any error when running this here.
Okay, so that's fine.
So now we've renamed our files.
Now what we'll do is that we are just going to, um, disconnect and then restart so that we make sure
that both the training and validation sets now, um, have this new, um, file names.
We've restarted the notebook and running this cell.
Now we should get our data set loaded or we still have this problem.
So to run that again and then they should be fine.
You see we have our 923 different samples and we have the sample fields described.
First of all we have the name.
We have the media type image, um, number of samples, uh, whereas the data is persistent or not.
Um tags, no tags, sample fields, ID file, path tags, metadata.
Um ground truth.
Now for this specific sample or for or picking one sample, we could find that it has an ID.
So um, 51 gives the sample each sample an ID uh the major type is specified the file path.
So in this case is this image.
And then um no tag, um, no metadata.
Then the ground truth.
Now this ground truth here is simply our label because we have the input.
That's the image.
And then we have the label.
Now it's segmentation um label.
So that's why this is specified.
And then we.
Have the ID then we have the mask path.
So here we have the image path.
And here we have the mask path.
So this is what we obtain when we print out the data set.
That's a summary.
And when we print out the data set here that's a few samples from our data set.
Now at this point we could go ahead and launch the app.
So we could do um session, session um, 51 launch app, launch app.
And then we specify simply data set.
We now have our app launched.
Don't forget to give the project a star on GitHub, and also join the 51 slack community to meet other,
um, 51 users and computer vision enthusiasts.
Um, okay, so that's it.
So you see, it takes a little bit, it takes a little while and then comes up.
So there we go.
You could see already um, this interface let's reduce so you could see this much clearer.
There we go.
Okay.
So we have this interface.
Well it's taking a little bit too much time.
Let me refresh this.
Let me run this again.
Um, and it should be coming up soon.
This now shows up and you could see at the top here.
Clothing data set.
One could select another data set in case we had created another data set.
Then we have the filters.
We have the meta data uh which you could open up.
Like you could see this with um, metadata with the see there's no result.
There's no height yet.
But we could actually put in this information.
Then looking at the levels we have the ground truth and we have ID max path, um, tags.
And then we have primitives.
That's ID and file path.
Looking to the right we can see our annotated images.
And instead of getting to open up our view images like this in some folder, and then having to get
back and check out the masks like this.
For example, you have this tool combined together for each and every image and also colored for per
per class.
So each class has a specific color.
Now if you to open any one of this you just need to click on it.
And this one loads up.
Once it's loaded you could have here the primitives.
There's the ID and the file path.
Then you could also check out the metadata in case you have given 51 this information.
So um, hovering on the image like we start from those lenses.
You see, uh, you could read out there clearly 47 that's to show, to tell us that the sunglasses have
ID 47 in our, um, labels.
And then you have the max path and the, the ID.
So as you change this, you see, it goes now to 55.
Um, next you could check out shows, for example, 39 socks.
Uh, 45.
Um, and that's it.
You could check out here, 19 you could check out this, uh, pullover five and you could check out
skin.
That's 41.
Now let's get out of this view.
We could, uh, pick another person.
So let's pick a male.
Um, here we have something similar to what we had already here.
Again, we have those different levels from hair, skin, um, shirt, coat, um, trouser shoe or maybe
socks.
So that's it.
Now you could check take out the ground truth by simply clicking on this.
So once I click on our ground truth, um, I have the original image.
And when I click back at the ground truth, you see, I have now the original image with its mask.
We could also swipe and move to the next image.
So we load the next image.
Here you have the color settings.
Click on this.
You have color settings.
I could modify this opacity of the levels.
So let's reduce this opacity.
Um and then we have save as default.
You see that reducing the opacity makes it look much more transparent.
Let's increase that and then um save as default.
And you see that it looks it uh, it kind of now covers the, the image.
So depending on how you want to view your data set you could modify that opacity.
Now let's get back here.
We'll start by filtering by mask path.
We'll skip the filter by ID and dive straight into filter by mask path.
So depending on the path you want to filter the the image.
So let's say we have 0001.
Let's see you see it filters that image.
And we have this image um 001.
You could see by opening up opening up this um, image here that this is exactly what we expect.
So this is the image 00001.
Um, this is this image with the size, the type file size, and, um, the folder given.
Then when we get back here, you could see that same exact same image.
So you could simply or if you want to see a specific image you could simply filter.
So let's say zero 0 or 0 0990099.
Uh no results.
Um, most probably this has been sent to the validation data set.
So that's why we're not seeing that.
Well we made an error and instead searched in this ID so let's check that out instead in the mask.
So we have 0099 the mask path we should obtain the that that specific image.
And there we go.
We obtain our image.
So this is that 0099 um dot png file.
Now another interesting thing you could do is actually to search again for another let's say six.
You see now we have this, we have selected this two.
So our view right here will be made of only these two images.
So you may have some specific criteria.
You or based on some criteria you want to filter uh, some parts of the data set so that you can just
view only those.
And.
Um, the 51 app makes it very easy to carry out these kinds of filtering and visualizations.
Then from here, another thing you could do is simply save this view.
So if you're interested in only these two images, then you could save that view.
So let me say um save current filters as view.
So your view name we'll call it zero 99 um 1000.
So zero zero 99 okay.
Uh, just some random, um, images.
There we go.
Color.
Let's let's maintain that gray and then we save the view.
So that's it.
So we have our views now saved.
Um, we should get back to the we could get back to the original, um, view that's without having to
filter.
So let's take this off.
Or let's reset this.
Actually resetting this will take all this off.
So now we have the original view with our 923 samples.
And then each time we want to view this, you see each time I want to view this I just need to click.
And there we go.
Just click on that.
And uh, my two images, um show up.
That's it for this section on data preparation.
The next section we'll dive into modeling and training with a sick farmer model, which is available
on Hugging Face.