Create Labels and Annotations for Custom YOLOv3 Google Images Dataset | LabelImg Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what's going on guys welcome back to the channel in today's video I'm going to be showing you guys how to make custom labels and annotations for your data set and we're gonna be getting images for your data set from Google images you can use any Google images you want and I'll show you how to download them in mass super quick so that you can then use an annotation tool called label image to draw your annotations on the custom images and create a custom data set for your custom object detector super fast super easy and let's get into it first if you're not subscribed to the channel please smash that subscribe button it helps me grow and you'll be up-to-date with all the latest Yolo content and then also smash that like button while you're at it it'll help me grow the channel and means a lot to me personally so let's get into it so in order to download the Google images we need the help of a Python script and some Java JavaScript code so you're gonna want to head over to my github repository github the AI guys code and head to my download google images repository I'm gonna link this down in the description below so you can just scroll down and click on this as well and we're gonna go ahead and clone this so we're gonna copy this we're gonna pop open a command shell command prompt and just go get clone and this is being wherever you want to clone the files - and we're gonna paste it the link in there and we're gonna go ahead and that'll clone the code needed so now we can CD into our download google images folder and run the command code dot which if you have v/s code installed this will go ahead and pop open the folder so now we can go ahead and see that it has four files one is the readme another is Python script download images our console j/s and the requirements so right after you've downloaded this you're going to want to go ahead and do pip install - our requirements dot txt and this will go ahead and download all the requirements necessary to run these commands as I already have them but if you didn't have them this would go ahead and get them so that you can now download the Google images accordingly so this console j/s is gonna be what we're actually run in google images to go ahead and get us the URLs for every single one of google images files and I'll show you how to do that I want to first disclaimer that I got this code from a blog post which I will go-ahead pie image search I'm gonna go ahead and put the link in the description below as well because I did get the code from him but I'm gonna do this tutorial so what the console that J's codes gonna do is it's gonna pull down jQuery into the JavaScript console and use the Google API to query the URLs and then it's going to write the URLs to a text file which will then be used by our Python script to search those URLs and download the images into a folder so that's the basis so now we can actually go to Google Images and this is where you're gonna want to type in the query for whatever types of images you're looking whether it's dog cat snowman I don't know I'm gonna do a classic not hot dog hot dog detector from the Silicon Valley TV show so I'm going to go ahead and query hot dog and then I'm gonna pop over to Google Images and so now here comes the bit where as long as the images are loaded our console j/s code will get them all so you'll see that as I scroll down more hot dog pictures will load in so see more loaded in or taskbar it's more space so as long as they're loaded in we'll be able to access them and load it again so you want to keep scrolling down until the quality of the images or the images become less relevant so if the quality of images like this one's not really a picture I would want to detect but some of these are they're good these are kind of getting Effie so once that quality of image really depreciates to a spot where you don't want to detect it you're gonna want to stop there and then you're gonna go ahead and just right click on screen scroll down to the inspect and you're gonna go click on that and open up the inspect and then you're gonna want to hover over the console tab and go ahead and click on that don't worry about any warnings that pop up here that's just chrome being dumb and now is where we're gonna go back to our code or a console j/s code and line by line we're gonna go ahead and copy go back paste and hit enter that's good and we're just gonna go ahead and just line by line paste enter and so this is getting jQuery and getting the elements and now we're gonna this will go ahead and grab the urls for all the images so now we have the images and now we got to write them to the file that we want to save it to so yeah you gotta make sure you go line by line oh I missed a line there there we go and this is gonna go ahead and generate a urls txt file that has the urls of all these images and then now we've got run this final dot click which will activate it and we should see it download perfect so we see that urls dot txt seems to have downloaded it's gonna go in our downloads folder and we'll show you where to move that so i've popped up my two file folders this one I'm just gonna go to downloads we can see our URLs and then this is our root directory for our download google images repository where we cloned it and I'm just going to go ahead and drag the URLs over and you can get rid of that so now we have it inside of our cloned repository and now comes for the Python script so we're gonna open up our command prompt again and you're just gonna write actually first things first let's go ahead and create a new folder called images this is where we're gonna save our images to and just in case you were downloading multiple classes like multiple different queries I'm gonna make a folder called hot dog so now we can go ahead and run our Python download images dot I - - URLs and this is gonna point to our URLs dot txt and then our next one is - - output and this is specifying the folder to save it to so I just created images - hot dog and then you should go ahead and run it and it might not output right away because it's gonna be downloading quite a few images but you'll see right away that if I and actually go into hot dog you can see that they're downloading and the images are actually going to download and great thing about the download images if we look at the code for the downloaded images script it will actually at the end it will try to open all the URLs and the urls that cannot be opened from OpenCV dot m read so ones that are not JPEGs it will actually go ahead and delete for us so we don't have to do that it's automated that it just delete any of the garbage images that are no weird full weird like file format so let's see still going it's still downloading because it'll it'll stop running when it's finished but you'll see that it's we're getting quite a few images and it saves them all in this nice format of incrementing the filename by one so you can see it's got o still going it's got over a hundred and fifty m at 150 images right now it's still going because we scroll down so far on the hot dogs page it got quite a few images but if you just do it right away based off of not scrolling down it'll download by default images because that's what Google shows so if you're just looking for a small data set of like a hundred images you can just right click and inspect right away and that'll get you a hundred images so we go back to our command prompt we can see that it's finished downloading and it's actually downloaded three hundred over three hundred ninety images oh yeah went up to three ninety-eight and then it went through and looked for the images that OpenCV open computer vision couldn't open if it couldn't open it just goes ahead and deletes them says those are garbage we don't want them so does that so it actually cleans the files for you and then I recommend that you just you just go in open it up and just do a quick manual search if there's not too many by just right clicking and scrolling through and just cleansing to make sure you can go pretty fast to this that there are all indeed good images of what you want to classify or and what you're trying to detect because you're going to want to filter out any like garbage like if there was a picture of a actual dog and not a hot dog in here or something I would want to filter that out and make sure I looked at that so that's good so now you can see how you easily we have a data set of over 300 images super easily and it now comes to the actual drawing the labels custom lis on the images themselves and for this I'm gonna use a tool called label image label image is an open source tool and I'm gonna hop into that and show you so we now have the repository open for label image on github by the guy named - Talon so we're gonna go ahead and just clone it it's a free tool go back to our here CD back to where we do our code and do get clone paste and we're gonna go ahead and download that well we've got to finish so once it's downloaded CD into the directory and now it needs a couple more requirements so you're going to do pip install right here in the repository it says hi qt5 this is just the graphical user interface that lets you pop open the UI so this is gonna go ahead and download and then when this is downloaded we're gonna do the second pip install and it's all XML so perfectly got that and now we're gonna go pip install Oh Oh XML so those are the two requirements for this so now that we have those two dependencies we can now go ahead and run this line right here which is PI R CCC this just downloads the resources required by the user interface to open up the tool so we're going to go ahead that'll run it won't help put anything but it's finished so for label image you're gonna want to do open a code editor as well by doing code dot four vs code because you're going to want to now classify or create your custom labels dot txt so I'm just gonna call this classes dot txt and if you've done darknet before you know that for this file you just go and write on each line you write per one line a class so I would do could do dog cat and just keep going whatever this classifier you want to make classes wise you put write them at one for each line but I just have hot dogs I'm gonna go ahead and save that and now we can go ahead and open label in the job so once you've gotten your class files now we can open up label image so python label image pi takes in two parameters the first is the path to our images so ours are up one folder into download google images images and a hot dog and then the second parameter label image takes in is the classes so now we can just do classes dot txt and you can run Python label images up high with out these two parameters and it'll just open up default but for us we are trying to do the hot classifier so we're gonna do these two files when we run it it goes ahead and opens up label image so this is the user interface it's very simple and easy to do so now you gonna want to go into left and it's first it's set to Pascal Valk saving format for the annotations but if you click on that it'll change to Yolo so we want Yolo annotations so that's what we're gonna go ahead and do and then now the easiest part you just go create rectangle and you just drag and boom it's created it it's hot dog okay and we just go you just keep going to next image oh wait first you want to save and we want to save it to the hot dog this into the hot dog images folder yep that's good and it's saved and now we can go to our next image and you're just gonna keep on doing this so you just keep on going create rectangle and I'm not sure you gonna do one around both of these two hot dogs see if I can get it opened drag so yeah it's just drag and it's that simple you're just gonna keep dragging hot dog perfect create rectangle hot dog and you're just gonna keep doing this hitting save each time and then just keep on going to the next images next image nice image next image this can be a time-consuming process since I said I have over 300 images but it's a must for object detection you have to have good labels on your image especially if you're doing a custom object detector this is the only way to do the hand labels and be effective so yeah you're gonna want to go ahead and do this but you can do it pretty fast you can do like 500 images probably in an hour I know it sounds like a lot but you have to do it but once again this is the way just create the rectangle box try to make it as tight as possible drag and press okay and then save it's just like that you have to do it and you can do multiple different labels if you have them and you'll see that if we go into our hot dog folder it's gonna save them in the txt format that we need to train our custom Yolo on so once you've done that and you've saved all of your images you're gonna want to go ahead and just drag them all I would do them all when I have them all saved but for time and then you're gonna want to just go to your darknet so I have it in repose darknut into your data folder and you're gonna create a new file here called object or where you're gonna hold all your images and then just paste them all in here and then follow off from my previous video on how to train a custom Yolo object detector and that'll run you through how to train your custom detector and do its habits detections the inference for those and be able to properly classify your custom classes so I'll put that link to that video down below I recommend checking it out and I hope you guys like this video if you could please drop me a like it helps my channel enormous ly if you're not subscribed subscribe to the channel I mean I have some cool awesome Yolo videos coming soon about how to do it with tensorflow and how to deploy your custom object detector using docker and kubernetes so if you're looking forward to those videos subscribe to the channel it means a lot thanks bye [Music]
Info
Channel: The AI Guy
Views: 45,466
Rating: 4.970696 out of 5
Keywords: yolov3, yolo, object detection, darknet, labels, image labels, image annotations, dataset, custom dataset, labelimg yolo, labelimg, computer vision, tutorial, artificial intelligence, machine learning, machine vision, opencv, python
Id: EGQyDla8JNU
Channel Id: undefined
Length: 17min 31sec (1051 seconds)
Published: Sun Jan 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.