The last video tutorial we have seen that how we can train the YOLO V8 model on personal protective
equipment dataset and after training or fine tuning the YOLO V8 model on personal protective equipment
dataset.
We have tested our trained model on multiple videos and we have seen that the model depicts a very satisfactory
performance and the model was able to detect the protective handmade jackets, eyewear gloves.
So now as we are discussing how we can integrate YOLO model with Flask, so now I will just use the
best words file.
So.
I have just downloaded the password file of my protective personal protective equipment model.
So here you can see that here I have just have the best weights file after training the V8 model on
the personal protective equipment dataset.
So this is my best weights file.
I will just update this best dot file with TPT.
So I've just updated the name of my best weights file as people's personal protective equipment dataset.
I'd go back towards the court.
So all this code is saying that we are discussing already.
So what changes I will make is, first of all, previously when we are previously when we created our
last web app, so we have used the Pre-trained YOLO V8 model.
So the Pre-trained YOLO V8 model has been trained on Coco dataset, which consists of 80 different classes.
But now as we are, we have trained or fine tuned the YOLO V8 model on custom dataset, which is of
personal protective equipment.
So we have seen that our custom in the personal personal protective equipment dataset, we have seven
different classes.
So I have listed all those classes in the sequence wise over here, which you can see.
Okay.
And this is here, I've just passed the dot weights file, which I have over here.
So this is the best weights file which I've renamed as GPT.
Okay.
And it is placing the YOLO weights folder.
And these are the class names or the classes which I have in my dataset.
Okay.
Everything else is same except what I've made further changes that previously.
You can see that with.
For each bounding box we have a pink color.
Okay, so and then the color of the label rectangle was also pink.
But here we have just changed this color, so.
I have just said that if the class name is dust mask, so if you have a dust mask class, then this
color will be assigned to the bounding box as well as to the label rectangle.
And if the class is glove, then this color will be assigned to the bounding box as as as well as the
label rectangle.
And if the class name is protective helmet or if the class is protective helmet, then this color will
be assigned to the bounding box and the label rectangle.
And if if there is any other class, like for example, if we have shield or jacket class, then this
color will assign to that class which I have given over here.
And plus I have set a limit for the confidence board like the bounding box and will only be drawn around
the detected object if we have a confidence score above 0.5.
So if we have a confidence score above 0.5, then only we will have the bounding box and the rectangle
above the bounding box on which we can put the text.
Okay.
So that is the change which made else all the three statement files are same and the flask app.py is
also the same.
There is no made change.
There is no change made in the flask App.py file.
So let's run the flask App.py file and see what results we have got.
We will test the video on the we will test the train YOLO V8 model on personal protective equipment
dataset on videos as well as the live webcam feed.
So let's get started.
So I'm just running the python flask app.py file.
Okay, so this might take some time.
So let's see.
So that might take some time for it to execute.
So.
So now I will just click over this link.
So it will redirect me to the home page.
Okay, so just close one tab.
But we don't need to tell currently.
Well, now we have the home page.
Now let's first test on some videos.
So I will just click on Choose File.
And then I will just go to zero eight crash course.
And in the video section I have some videos.
Let's first test on this demo video and just after uploading the video, click on submit.
So now we will see if our model is able to detect that jacket, protective helmet, gloves, shield
or not.
Okay.
So.
Let see.
What results do we get?
Okay.
Uh, the reductions are about to start.
So now we can see that our model is able to detect a protective helmet.
You can see, as well as our model is able to detect or our web app is able to detect the jacket as
well.
So now you can see over here, we have detected the jacket as well as the jacket.
So although they are wearing gloves, but we are not able to detect it, but we are able to detect the
jacket and as well as the protective helmet.
Now, let's test on another demo video.
Let's upload this video and then click on Submit and see what results do we get.
This might take a few seconds.
So now you can see here this person is not wearing a jacket.
So we have not detected a jacket or this person is wearing a jacket and we have a bounding box around
the jacket.
You can see over here.
Plus, or both of these persons are wearing protective helmet.
And we have detected that both of these persons are wearing a protective helmet.
Thus, although they are not wearing any gloves and shields.
So we have not detected any gloves or shield.
They are only wearing protective helmets and jacket, which we have detected successfully.
So that's impressive.
Now let's test our model on the live webcam feed.
Test the model on live webcam feed will just go back and just click on live webcam from here and let's
test our model on the live webcam feed and see what results do we get from here.
So my camera is just going to turn on.
And let's test our model on the.
Now, you can see over here, our model is able to detect successfully that I'm wearing a dust mask
from here.
Okay.
All the directions.
Fine.
So as I've been wearing a mask, it has detected successfully that I am wearing a dust mask.
Thus, I'm not wearing a jacket or a helmet, so it hasn't attracted anything from here.
I'm just wearing a dust mask, which it has detected successfully.
Okay.
Well, now you can see that we have tested our model on the video as well as on the live webcam feed,
and the results are very satisfying.
So that's all from this course.
I hope you have learned something from this course.
See you all in the next course.
Till then, bye bye.