284 - Installing Mask RCNN and troubleshooting errors

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back in the last video we went through the basics of mass power cnn in fact i provided a quick overview of uh cnn's rcnn faster cnn faster rcnn and finally mass car cnn that is based on faster rcnn and i promised to show you how to get your system ready for mask or cnn and that's exactly the goal for this video i am going to show this on windows 10 using tensorflow 2.2 and of course on python environment 3.7 so that is the plan and let us start by looking at the repository the most famous repository for mask or cnn on github and that one is or has been tested on tensorflow 1.0 1.x and there are a bunch of repositories on github that converted that into tensorflow two-point whatever the version that you pick and the goal is for us to identify one of those repositories clone it and make it run on our system but there are a few other things that we need to get ready like creating a new environment and within that environment installing the required libraries and running the code to see if it actually runs if it doesn't what do we do that is the plan so let's go ahead and jump onto github repo where the original tensorflow based mask rcn and you know code will be can be found so let's jump into that right away so the original repo can be found under mat report mask rcnn and as you can see there's a lot of good documentation down here and i am going to scroll all the way down so i can show you the requirements so it's python 3.4 tensorflow 1.3 keras2 and so on now our goal is to find a two point sum version so let's go ahead and search i searched for mass garcia and tf2 again many many uh reports that you will find and the one i picked is by amit f gad and again it looks very similar to the original mask or cnn you know but it's for 2.0 and uh yeah so let's go ahead and use this and remember this url because we need to get you know clone from this repository later on let's start by opening our anaconda prompt you can use windows command prompt if you want i am using anaconda prompt i'm going to run it as administrator so what am i going to do so step number one is to create an environment and for that my condy environment i mean conda is good so i'm going to create a new environment called mask tutorial and let's specify python equals to 3.7.11 why because that's what i have in my other repo where things are working fine so there you go proceed yes and it should take just a few seconds and any time now it should be ready there you go and now let's jump into our python and let's check if we have some of the repositories import numpy numpy is there import let's look at the version number right there version 123. okay and import import let's do scipy and let's just check what the version number is scipy dot underscore underscore version there you go oh let me exit we are in the base right there we need to change the environment sorry we created the environment we haven't so conda activate what did we call our package what did we call our package it's mask rcnn tutorial is that it let's confirm what we call sorry not package or environment yeah mask tutorial not mask or cnn so let's go back to our command and then type mask tutorial so now we are in the right repository sorry about that let's go into our python prompt import numpy we should not see anything this is why i was surprised a bit ago so now let's go ahead and import pip just to see what version pip we have here it should be 22 something um nine for some reason it's installing older pip so let me take care of that let me install uh let me install uh the right version and come back okay uh sorry about that let me pause all i'm gonna do is pip upgrade okay now i updated my pip and it should have the latest version so let's go ahead and test it out so import pip and i should see pip underscore version so it should be 22.1 so that's okay i have no clue why i started off with the older version so let's go ahead and exit out okay now what am i going to do i'm trying to type and think at the same time so now that we have this the next step is to just go back to our uh downloads directory and download the repository that we actually have so let me go back to stream cd downloads and cd mask now we haven't downloaded the repo yet so let's look at our downloads there you go i have nothing it's empty so copy the url come back to if you have a git bash like uh get for windows go ahead and use it you need obviously some sort of a git and let's go ahead and get clone let's paste this and add an extension of dot zip oh sorry dot g i t there you go it's downloading the repository it created the folder right there and it should populate it with some files pretty soon and there you go so now when i open it you should see exactly the same structure that we have right here on the web page so all we did is basically downloaded the downloaded the repository now if you open the requirements.txt you can see that all the libraries are uh noted right there i i don't like that numpy scipy polo they don't have like a version number because if you run it in future it may not work so let me give some version numbers right there again i'm giving these version numbers based on uh based on the one other environment that i already have where i know this will work so let's skip that matplotlib it doesn't matter it's certainly used for plotting so i can leave it opencv requires even dot 60 so let's go ahead and do that image.0.4.4 so those are the versions i have so let us go ahead and pip install you know i hope you know how to do that so basically it's going through my requirements.txt file looking at all the requirements that i have and installing it okay i paused the video for a second for it to install everything and now it's done and let us continue python let's go into the prompt just to see if everything gets got installed tensorflow stf and yeah that's a good sign and now let's type tf dot underscore underscore version so just to see what version python we have 2.2 great now everything looks good okay let's exit out of this prompt and let's move on to the next step which is installing mask or cnn library how do you do that python setup.pi install and that will install it so basically i'm running the setup.pi library sorry file within this environment so it says it's installed yep everything is good now what let us go ahead and go into python and import our mask or cnn how do you do that import mr cnn and uh yeah it's imported fine so we are all set that's it it's as easy as that so now we need to fire up our ide whatever ide you plan on using and run the test file that comes with this there's a kangaroo data set so let's go ahead and run that okay so first thing uh first to run it we need to download the h5 the coco uh i mean it's downloading right there the weights the coco weights because that is what we're going to use as a starting point this is all transfer learning that we are doing so once it's downloaded i'm going to move that into the kangaroo directory so we can go ahead and do the training for our kangaroo detection object detection algorithm right there so let me move the masker cnn right there so i think we have everything ready so let me fire up the ide so i'm going to use spider ide but i don't think i installed that in this environment so let me open anaconda navigator there are many ways you can do this if you're not using anaconda and spider that's okay do whatever you normally do so let me change the environment this is the easiest way for most people so that's why i'm following this so mask or cnn mask tutorial there you go the spider is not installed and it's asking me to install let me click that it should take a few seconds sometimes minutes depending on your environment so let me launch it okay it's there oh come on come on come on i'm losing my patience here okay there you go so now we have our spider ide let me clean up and open where is my kangaroo there you go let me bring it here mask rcnn kangaroo transfer learning and let's open both the training and prediction um so i believe we need to train because we don't have the kangaroo weights here and if you look inside this directory you can see all the images as part of the repo only a handful of them and corresponding annotations if you're curious go ahead and open annotations it's xml annotations in this case and i'm opening that in notepad plus plus you can see how it shows the bounding box the dimensions and what category it belongs to i mean classic belongs to and all that okay now let me minimize this go back to our code and zoom in so you can see things a bit better and let's do one more thing let's actually import tensorflow stf i just want to make sure everything is fine uh in my ide so let's do the version number tf.version it should be 2.2 there you go we're good i am happy now let's go to our kangaroo prediction and you see it requires kangaroo mass rcn and trained dot h5 we don't have that we haven't trained our model yet so we are i mean as you can see obviously all we have are the cocoa weights so let's go to training and do the training part and let's uh do a quick training to generate that h5 file to make sure everything is working fine so what do i need right now i need to i'm trying to find where the epoxy is so we have a gpu there that's the and if i scroll down yeah i think it's for one epoch let's go ahead and start it just to see if it throws any error errors or if it actually works fine that's a good sign it's actually opening my my cuda drivers and all that and uh yeah everything looks very good keeping my fingers crossed okay uh something's happened so syntax is incorrect yeah this is on a windows system it doesn't recognize this back two backslashes right so you only put one backslash so somewhere in one of the libraries it is using two backslashes so where is it yeah if you look at this.eg file in [Music] three online seven it's throwing this error it says hey there is something going on right there so we need to find that and edit it this is if you have other errors go ahead and look at this and uh and uh fix the errors so first thing first let's go ahead and find it let me move it to the side so we can navigate to the same place users srinivas anaconda 3 anaconda 3 environments environments where the heck is environments and uh yeah there you go and which one mask tutorial is our environment and lib is where we need to go lib yep and site packages if i can find it site packages there you go site packages and we need to find mask rcnn tf2 something something right tf2.10 and so on but that is not here as part of one of the folders that is because it's a dot eg extension think of it as a zip file it's a compressed file and it is located right somewhere here there you go so that is the file inside that container inside that directory we have a file that we need to edit that's it so let's copy it and let's change the let's call this backup back up and let's uh play with this.eg the easiest way is just change the extension to zip and oh we are actively using it so it's not going to allow us to do anything i guess so let's cancel let's copy this and work in our downloads folder because we have more control over there and we'll move that file later back here so let me go ahead and paste that.tgg now i can change the extension to dot zip okay let's go ahead and do that and inside here you see there are two four two folders this is a zip file and let's extract the contents of that zip file into a temp directory extract here and there you go so mrcnn is the one that that has this file that we need and within that file which is uh model.pi we have to look for line number two three four seven okay so one step at a time model.pi and now look for two three four seven let's scroll this down to three four seven that's a pretty large file okay two two two three four seven two three four seven okay there you go i don't see anything obvious right that's because it's looking for a log directory right there and the log directory where are we referencing it so let's go back up and see where it is first referenced right there right in two two seven nine you see the two backslashes i'm gonna delete one of those so let's go ahead and uh gosh what's happening okay let's go ahead and delete that delete that save the file that's all we needed to do so all the zip changing and all that just to make sure we have access to this file and now let's go ahead and compress it back into a zip you know zip zip folder so let's uh copy the file name shall we do this from here or from the other location that's okay first of all let's go ahead into our temp right click and add to archive i'm using winrar you can use anything that that allows you to work with zip files so uh let me paste it temp oh gosh let's go back to our site packages and copy the file name so we make sure we are giving it exactly the same name i can't speak and do things at the same time okay there you go and now let's go ahead and paste it here and okay so it's going to compress everything into a zip now we need to change the extension of the zip to dot egg okay um we are oh sorry i keep okay so this file let us change the extension of this one let's click and where do we need to move it we need to move that to site packages so let's change the extension to eg uh i apologize if you think i'm slow i'm trying to talk and trying to make sure everything is i'm not messing anything up okay there you go dot egg right so we replaced the previous one with the new one and all we did was just change uh let me launch it while i'm talking just change this back two backslashes to one backslash that's it and let's hope now it is ready to be used in windows system maybe you don't even think that's an issue in linux but let us let me zoom in i'm gonna run this exact file one more time okay let me zoom in right there run it okay i'm not gonna celebrate yet i'll celebrate when the training starts we were here before right after this we got an error i'll give this a few more seconds oh that's a good sign epoch 1 or 1. so it is actually doing something let me open the task manager um right now let's see hopefully my gpu should be fired up there you go this that's a good sign so it's using my gpu it's using tensorflow and it's actually running this so let me pause this video until this this this epoch is done and i'll uh i'll continue right after that and i think we are running this for one epoch let's confirm that that's the default if i am not wrong i i can't see anything yeah where is it where is it yeah model.train you can see it's epoch one yeah so right there exactly right there so i'll pause the video and i'll continue as soon as the training is done okay the training is done now and what am i trying to do go ahead and find our mask our cnn folder right there now you see the dot h5 file with the kangaroo so we that is the trained model that we just created right now which means now we can go back to our prediction and just do the prediction obviously the result is not going to be amazing it's just one epoch using a handful of data that's it so sample2.jpg there is nothing like that here um am i doing anything wrong yeah there's nothing like that there so let's go ahead and run it uh we should get some error opencv error obviously there is no image uh right here yeah there you go uh let's let's just create an image let's actually put an image right there i'm gonna copy something from our images and rename it so let us just pick this one okay go back go back let's paste it here and change this to kanga okay and let's do that here kanga.jpg now i hope this should run run so we're just using our train model yep there you go obviously the semantic segmentation part is not great but the box the bounding box is doing an amazing job and the semantic segmentation part or the instant segmentation part right there uh where it paints the pixels will get better if we train it for i don't know 20 epochs 100 epochs so the more as you know the more accurate it is so let's go back to one i think we should test this on one other image so let's go back and find uh let's see find another image where we have multiple things maybe a person and kangaroo or or oh i see i see this one that has car and a kangaroo so that's not a bad one let's see if it picks the kangaroo bounding box correctly bounding box is easy the semantic segmentation part is a difficult part i'm going to call this rou where do i change it yeah right there r-o-o let's run the whole thing wow isn't that great it picked up the kangaroo part fine and uh yeah it's it's that's it's working fine so your system is ready right now my system is ready right now for the next tutorial in the next tutorial let's go ahead and focus on using a normal data set that we download from maybe kaggle and use the environment that we just created it should be a pretty quick video so i'll see you in the next video guys
Info
Channel: DigitalSreeni
Views: 29,243
Rating: undefined out of 5
Keywords: microscopy, python, image processing
Id: Fu_km7FXyaU
Channel Id: undefined
Length: 21min 44sec (1304 seconds)
Published: Wed Aug 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.