Custom Object (Licence Plate) Detection in Raspberry Pi with YOLO V8 and Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is me Arijit with a new video now in one of my previous videos I showed you how you can print a custom model in Yolo vo8 using Google collab now in this video I showed you how you can train a license plate detection model in yellow V8 now in this video I'm going to show you how you can actually use those custom train models in your Raspberry Pi to detect objects okay so obviously in this video we are going to use that model we have trained in our previous video that was a license plate detection model so we are going to build a license plate detector in Raspberry Pi now the things we are going to do in this video is the very first thing is we are going to install all the libraries we need for uh to install like YOLO V8 like alkalytics and all the different things next I'll show you how you can actually apply this custom trade models on any pre-recorded videos and uh pre-saved images okay and then I'll show you how you can actually do the object detection using the live feed so here I have connected a webcam with my Raspberry Pi so here I'm using Raspberry Pi version 4 with 8GB of ram you can also use the version 4 or 4GB of ram now version 3 I haven't tested with this piece of ports so I cannot commit on that but yes version 4 with 4GB and 8GB both are going to work now here I'm going to use this HP w300 webcam but you can use any other webcam okay so at the highest so where I was like we are also going to see how you can take live feed in using a webcam in Raspberry Pi and we are going to apply that object detection on the live feed okay and then at the very end we are going to discuss about the performance so basically what FPS we are getting and then if it's really worth it using YOLO V8 in Raspberry Pi 4 or not so all these things we are going to cover in this video so and obviously if you have been subscribed to our Channel yet please subscribe so that this kind of videos whenever you'll publish next you will get it and now we without twisting any time let's get started foreign your custom model in Yolo V8 please watch my last video in that video I showed you how you can set up uh the whole how you can train your custom model in Google collab how to install the libraries from where you can get the data set next how to print the model and next how to check if your model is working or not and then finally uh how to predict some new images or videos using your model so all those things I covered in my last video so please watch that video okay and this is the Google cooler file I actually used in my last video that also you will find in the GitHub repo okay so all those things please watch my last video you'll get it so now I can assume that you have a custom model which you have frame in Google collab okay or in your machine also but one thing remember that while you are free while you are training your model in yellow V8 please use this repository that I have provided in my last video or I'm providing in this video to train your model okay because see there are many version of alphabetics and other libraries also so sometimes what happens that you train your model in some other version and then you are you are trying to test it it's a modern model uh in some other version so you will get a lot of problems so I'll recommend that you use this repository to train your model and then you make your custom model next you come to this video and from here you test this model on Raspberry Pi okay now as you can see in the repo I already have my train model bus.pt this is a model I have trained now obviously this is not a best license prediction model so uh basically here I have taken a very small data set of 400 uh 400 license plate images and I have trained the model and I have only 10 up to 100 epochs but still it actually works by well okay so you can watch my last video to see the performance but it works quite well but this is not the best model okay so the purpose of this video is to show you how you can train your custom model and how to use in Raspberry Pi now if you have to make a very good model you need a very big data set okay which I told you last video how to get a very big data set and then also you have to train it for quite a long time then only you are going to get a very good model okay so if this model is not very good for you then train your own model okay and you can do it in Google collab you don't need a very powerful machine for that okay so now from here I will assume that you have a good train model which you have already tested which is working okay and for testing you can use my model so this model you'll get in the depot so you can use this model in Raspberry Pi okay and it will work in most of our license plates I would say okay so now uh at this point uh we have our model and we also have all these files now I'll show you how to uh how you can install all the libraries in Raspberry Pi and how you can actually utilize this model to do the detection okay now here I'm going to use like I already mentioned I'm going to use Raspberry Pi 4 and with the 8GB version and another thing is I am using the 64 64-bit operating system so while you will install that raspberry pios I'll show you here also while we install the OS make sure that you go to choose OS and here you don't choose this raspberry pios 32-bit you go to Raspberry Pi with other and there you select Raspberry Pi over 64-bit y64 bit because in 32-bit installing few libraries will can be little bit of headache and I you can get some problems there but while like in 64-bit it's very easy to install all those libraries that's why I really recommend you that I'm also using 64-bit and you also use 64-bit only okay and from there install raspberry pios and you boot into Raspberry Pi okay and after that so I already have started my Raspberry Pi and also I have connected a camera which is HP 300 camera with my Raspberry Pi you can use any other webcam also next in this video I'm going to use BNC viewer to control my Raspberry Pi but you can also use HDMI connection or whatever you want so here I'll connect with my Pi here I'm inside my pi as you can see now the very first thing is we have to clone our Depot so I'll open my terminal and I'll go to my text job I'll go and in my desktop I have to clone this Repose I'll come here I'll just copy this link next I'll go to my pi and I'll just to get clone [Music] and I'll write this thing paste so it will take few seconds to clone the repo so let's wait for it says done next we will go inside this report so license plate detection using your V8 you will go inside it and you have this many files here okay now what things we have uh we have the model we have two demo files one demo video One demo image we have the requirements or txt file where you have all the libraries required you have a list of that with their versions required and you have to install libraries of this version only if you use some other version you can get problems okay so use these versions only you also have the Google collab file which you don't need in this video and finally you have the alternative fix files which we need in this video okay now here at first what I'll do I'm going to use this uh demo dot uh basically demo.mp4 file so demo.mp4 file actually I can show you I guess I have already downloaded it so I'll show you the demo file okay oh wow I can actually show you in the Raspberry Pi so I can just go here here we have the demo.mp4 and so continue and as you can see this is the demo.mp4 file okay so it is little lagging here in the VLC in our Raspberry Pi okay so just a minute okay it is it is really lagging a lot not little bit uh let me just show you here only demo dot time P4 so this is the demo.np4 file okay it is the result one I guess this is the row one yes this is zero one I want to show you first a little bit the video that I have just a minute turn on the volume yeah so as you can see this is a demo mp4 file we are going to use okay this file you will get in my GitHub repo and it will be downloaded with the while you will clone it so this is the file we are going to use it okay now at first I'm going to test in this file so here we have it now what now to uh basically to apply this uh your this model the custom model biz.pt uh on any MP4 or JPEG file what you really need to do is you need to write python okay before that we need to install libraries I forgot so to install live is very simple with install art requirements.txt that's simple I already have installed the requirements so it will say that all the requirements are satisfied but in your case it will take some time to install the required files okay so once you are done installing the requirements all the required libraries just yes next we are ready to uh basically predict using a video so what you'll do we will write python next you have to go inside a folder so we'll go inside the so basically the folder switch we see ultralytics so python ultralytics slash we have to go inside the YOLO inside that you have to go inside version 8 then inside that detect and then there is a file called predict okay predict.pi this is the predict.5 this is the file which is going to do the prediction on the videos or the images next what next you have to keep the modeling so model equal to in my case it's best DOT PT okay if you use some other model give the chat name okay next file you have to give the source so in my case the source would be our what is the name demo dot MP4 okay you can use any other jpeg image jpg image PNG image whatever you want finally everything which is not necessary but I'll give which is show equal to true what this will do this is going to show us the preview of basically okay how it is detecting a number place if you don't give show equal to true what will happen it is just going to run you're just going to take the file I'm going to uh write the output in a folder but if you give show equal to true it's going to also show you how it is detecting now click the enter it will take few seconds to load the model and initialize all the things so let's just do it for few seconds okay so as you can see as you can see here it is directly number paid quite well okay but as you can see here uh it is directing it but the FPS it's not that's good it's I think it's we are getting around one FPS okay so it's like it's processing one frame per second okay not that of real time I would say but as you can see it's working okay and if you want to see a full demo how it will look like at the end after it will write it I'll show you that also so I'll just close this one so I already have saved that so this is the demo so if I show you this is how the output file after it will complete doing the whole process is going to write that file and this is how it will look like so as you can see it is mostly detecting all the number bits correctly okay so this is how it is going to work next what I'll do another thing is so this is how you can actually uh predict using a mp4 file or a JPEG file okay next also maybe you have connected a camera with your Raspberry Pi and you want to do it live so from your camera feed that also I'll show you so how you can do it you just have to write uh it's just in the last command so let me just clear it so Source equal to demo.mp4 instead of this you need to write Source equal to zero this is the only change you have to do 0 means we are going to use the uh basically Source 0 means that 0 to 8 cam we can say if you have multiple you can see you get one two three four in this way and if you are using Raspberry Pi camera then the process is not that simple in that case you have to capture the frames from raspberry camera and you have to process them in the yellow little bit complicated so webcam is the easiest way okay but yeah you can go it as your camera you have to modify the code so now let's try with this one and let it run in the meantime what I'll do is I'll just come here and I'll just search for uh number place in car okay so and I'll go to images a lot of number plates are here so we are going to try in this number plates so now as you can see the window has opened I'll just make this window little smaller okay in this way and here in this side we have this window so yeah this is fine so this is basically a live window okay and as you can see you I hope you can see me now as you can see you can see me okay so like I said it's not live or my slide but obviously the PS is not that high but still you can see it is detecting number plates quite well as you can see all the number Clicks in the frame these are like these are not in the train set okay these are all just try searching Google but still you as you can see it's detecting the number plus properly even if I scroll down okay you will see a number plates are very small but still it is detecting them quite well let me scroll down a little bit more okay so if I scroll down as you can see in most of our number plates is rejecting them quite well okay so this is how it's working and so as you can see in basically here uh if you use a camera you are going to get a similar FPS which is I think one FPS around okay not more than that you are going to get okay and also it depends on a model so this model is not a very big model that's a very important thing that this is the size of this model is only six MBS it's not a very big model and secondly uh if you check my code and if you know a little bit about YOLO model so here we are using YOLO 8N okay so let me show you my training code so requirements yeah here if you see while training this model I have used aolo v8n now there are more models there is yellow 8 x v8x which is of what I can say it's like more accurate model but the size will be also bigger if this will be less so while you are actually working on devices like Raspberry Pi I really recommend you use YOLO V8 in only so what will happen your model size will be less and secondly if you also use some bigger data set your model size will be bigger if you train it for bigger epoxy the size will be bigger okay now here I have only trained for 100 box and also my images I have user 400 images around so that's why model is very small that's why I'm getting about 1 MPS if your model will be much more complicated you will get a less FPS that's one thing okay now now let's talk about the performance that will we are as you saw like we are getting around one PSP now is it really worth it like create a model in Yolo and then you can then you just take it in Raspberry Pi and you run it it does it really worth it like getting one FPS now the thing is you if you're thinking about application where you need real time so at least you need 20 30 FPS around in that case obviously it does worth it so in real life number plate detection like you want to install it somewhere in the road and you want cars are passing by you want to detect it recognize it not worth it but in some cases where maybe see it's one one apis we are getting that means one frame per second so that means if you have application where you have images and from those images you want to detect something it's here as an example you took number plate but it wouldn't be anything anything you have to detect maybe or you have to segment okay and uh it's not a real time you don't need 20 30 FPS okay you just have got an image and now you do have to do the detection or segmentation in those cases this thing really worth it because it's just taking one second because see uh loading the model will take some time let's say few seconds but then once the model Got Loaded in the memory then it will not take time for a data she will hardly take one second per image okay if you tell if you just incorporate a 64 64 into 64 image it will take hardly once again so in those cases it will go to because see training YOLO is pretty much accurate training a custom model is you in Yolo is easy okay I gave you the whole template you can upload any data set you can train it no problem in it next take the model in Raspberry Pi and you can run in such a easy way so you don't need to write any code you just have to use the Alternatives predict.pi you can use video you can use image you can use even your webcam everything you can use so overall using this overall uh system is very easy creating the model then bring it to YOLO and then bring it to Raspberry Pi then running it is very easy so in those cases it's really worth it okay like it's different on application now if you really want in your in your Raspberry Pi if you want it in real time so if you have application where you want the whole thing in real time in that case what I suggest you can use TF flight so you are already working on a project okay where we are using TF Lite tensorflow Lite to do the object detection in that case we are we can get a very good FPS in Raspberry Pi also without using an external GPU okay so there are many GPU external GPU modules you can use it Raspberry Pi if you use those modules with your also you'll get speed but without those modules also using TF Lite we can get a good FPS and that project we are working on and very soon that project will upload in your in our Channel okay so using TF Lite how you can do almost real time object detection in Raspberry Pi okay so if you want real-time object relation raspberry in that case you can go to those kind of models TF flights and stuff but yeah if you want to a very easy way to train your model and then you want maybe one FPS per second one FPS is fine for you yield is a very good uh option for yourself okay so I think that's all about this video okay so if you have any queries you let me know in the comment section and I'll try to answer you all of the questions okay so this is all about this video guys I hope you have learned something from this video so please hit the like button and subscribe to the channel so many more videos on similar topics like YOLO tensorflow Lite Raspberry Pi we are already working on and very soon those videos will be available in your channel so so that you will not miss them Please Subscribe the channel okay and now I'll see you in the very next video
Info
Channel: SPARKLERS : We Are The Makers
Views: 13,432
Rating: undefined out of 5
Keywords: CustomObjectDetection, YOLOV8, RaspberryPiProjects, PythonProgramming, ComputerVision, DeepLearning, LicensePlateRecognition, AIProjects, MachineLearning, OpenCV, RaspberryPiTutorials, DIYTech, ObjectDetection, ImageProcessing, EmbeddedSystems, RaspberryPiDevelopment, YOLOAlgorithm, CustomAI, OpenSource, RaspberryPiCamera, AIInnovation, Tutorial, Coding, TechEnthusiast, Innovation
Id: sO7uTTq9ee4
Channel Id: undefined
Length: 18min 51sec (1131 seconds)
Published: Sat Sep 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.