Instance Segmentation in 12 minutes with YOLOv8 and Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you haven't been living under the rack for the past week or so you most likely know that yellow V8 is out it is the latest iteration of yellow algorithm This Time released by ultralytics team the company behind yellow V3 and yellow V5 we already have two videos about this model at roboflow channel the first one done by Jacob where he went deep into the changes that were introduced in yellow V8 the second one done by myself done by me where I showed you guys how to train your leviate object detection model on custom data set this time we'll do a little bit of the same but instead of training object detection we will train instant segmentation model I will not go deep into the API changes in this video so if you want to learn more about yellow V8 make sure to watch those two previous videos the links to them are in the description below and in the card in top right corner so without further Ado let jump into the code and let's train some models as usual we start our journey in roboflow notebooks repository where we store all the code we use in our tutorials and at the very top we have three fresh notebooks related to Yellow V8 this time we are going for instance segmentation so the second one from the top so let's open that in Google call up and after that is done let's create a copy of that notebook and save it on our Google Drive that can take few seconds to do we can now close the original notebook and before we start let's go into the runtime change runtime type and confirm that we are using the GPU accelerated version of the notebook in my case that's exactly where we are so I can just close the notebook and I'm pretty much ready to go let me just increase the font size a bit so you would have easier time following my steps over here we can scroll a little bit lower to the first cell that's Nvidia SMI command it is here only to make sure that when the actual run time starts we will have access to the GPU and indeed is the case we have Tesla T4 at our disposal so we can scroll a little bit lower once again create this helper constant go home that will point to our home directory it is here to make it easier for us to manage data sets and images and weights Buffs cool now we should be ready to install the actual ultralytics pip package that contains YOLO V8 model there are two ways to do that the first way is to do it via peep the second one is to clone the repository and install from Source the PIP way is easier so that's what we will be doing but if you feel that you want to try the second option the command to do that is in a Cell below so just to confirm that the installation went properly let's import yellow from ultralytics that wouldn't work if the installation would fail but in our case it worked so far so good so let's quickly test YOLO V8 segmentation model in action we will use pre-trained model that was trained on Coca data set and run it on one of my own images we will do it in two ways first using CLI and second using SDK that line is pretty much okay I will just use bigger model let's run it that will download the image download the weights load weights into the memory and then run the model on my image the weights are quite heavy because I selected X model which is I believe the largest one but I really want to see true potential of that model I don't want to use S just yet okay so the model just inferred and save the results so let's take a look okay so this is the result from the model once again I used extra large model so on a smaller model that result May differ in fact let's run the same command but with different model this time let's say YOLO s and compare the accuracy that we can expect it's pretty easy we just need to copy this line paste it here and change the type of the model obviously once again the model needs to get downloaded but those weights should be a lot lighter yeah the model is already downloaded and the inference is done now we just need to copy this line paste it here and change the name of the directory because it's most likely named like predict2 and here it is yeah so it's clear that the difference in accuracy is significant when it comes to those different models in previous image I'm pretty fine with the results obviously larger segmentation model most likely would be able to pick up that part of the backpack or wouldn't classify that part of the image as person but all around it's pretty accurate on the other hand this model most of everything that was detected got classified as a person let's take a look at the speed so the first model the larger one in third in 61 milliseconds the smaller one in 22 so that's also a difference speed of detection is like three times larger with the first one okay let's jump into training so I was scrolling through Universe looking for some cool data set that we can use for that purpose and there is one that I really like Coral segmentation 4. apparently it has over 4 000 images that looks like a pretty very cool candidate for us to use in our tutorial those segmentations look like somebody really put a lot of effort into making them let's start with clicking in download the data set button and now what we need to do is select the right format for instance segmentation let's go for YOLO V8 click continue and the universe will generate code snippet that we can just copy and paste into the notebook and we should be good to go that data set is pretty large over 4K images so the zipping takes a little bit of time but we should be ready to go in just a second now like I said we can just copy that and go back to our notebook so we're back in the notebook I'm just pasting this here unfortunately I cannot show you the full snippet because it contains my API key it is hidden in the UI but the moment I paste it here in the cell it gets human readable visible now I just click shift enter what is happening is the roboflow package is being installed that's first and second of all the data set is being downloaded depending on the size of a data set the resolution of the images and all other factors your internet connection the downloading part May of course take longer or shorter data set is finally downloaded so we are ready for the moment that everybody was waiting for which is the training of the actual model the next cell contains pretty much ready to use command but I will adjust few hyper parameters just for the sake of explaining what do they mean so first of all we will not wait for 100 epochs for that model to train let's make it 25 I just don't want to wait like five hours for the model to complete training however I will maybe use a little bit larger version of the model let's say medium one and smaller input resolution those changes May cancel each other out an input resolution has the influence on the quality and accuracy and I selected smaller value so that may be deteriorating however it will be training faster and larger and deeper Network may increase the accuracy we'll see usually you would train with different settings and compare the accuracy at the end we will just train a single version as usual shift enter yellow V8 will download the model at the very beginning and after that load the checkpoint create the data loaders and we will start training yeah the first Epoch just started now you can just sit back relax drink some coffee we'll be back after the training completes I just don't want to wait like five hours for the model to complete training yeah it's 1 30 in the morning and I started that training like at 11 p.m so yeah it wasn't five hours but it also wasn't like 15 minutes either finally the training is completed and we can evaluate the model great so the first thing that we'll be doing is to take a look at the content of the training directory the weight are here so everything is fine we can take a look at the confusion Matrix looking surprisingly good especially for 4 000 image data set let's take a look at the charts that were produced during the training the confusion Matrix looks good and the charts or box loss and segmentation loss also tend to suggest that we could even train the model longer and get even better results cool okay in that case let's validate first and then do some inference on example images here we just do shift enter and wait a little bit because the data set is quite large foreign I was stressed for a second but it was a honest mistake it just messed up the weights path that should work hopefully that's a relief I would be really unhappy okay we got some errors talking something about pawns this just shows you how unpolished yellow V8 is still there are plenty of backs but we should be fine maybe we will not get some charts but they really don't care that much about the charts in my case it's mostly about having the map and other metrics displayed on the screen it's good enough for me and the last thing is the inference on test set and displaying some example images I would really like to see that model in action yeah it works 400 images which should be done in no time let's take a look awesome really awesome I love the results yeah the model looks amazing amazing at least I'm happy that it works that's all for today if you liked the video make sure to like And subscribe and stay tuned for more yellow V8 content coming to this channel soon I guess we have at least two more videos that we want to release but you can always let us know in the comments and in the discussion section in roboflow notebooks repository what videos would you like to see next we are always there answering your questions so give it a star give it a try and see you there my name was Peter bye
Info
Channel: Roboflow
Views: 32,655
Rating: undefined out of 5
Keywords: yolo, yolov8, roboflow, ultralytics, deep learning, machine learning, yolo deep learning, yolo python, instance segmentation, yolo instance segmentation, yolo instance segmentation tutorial, instance segmentation deep learning, yolo instance segmentation video, instance segmentation using yolo, yolo instance segmentation pytorch, real-time segmentation, instance segmentation for beginners, real time instance segmentation yolov8, instance segmentation with python
Id: pFiGSrRtaU4
Channel Id: undefined
Length: 12min 15sec (735 seconds)
Published: Fri Jan 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.