Face Recognition Based Smart Attendance System With Web Apps Using Machine Learning.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to my YouTube channel and in this video we're going to build here one yes face recognition base a smart alternative system using Python and machine learning so without any further Ado let's start on the video so well so this is the demo applications you can see here one cool UI you can see a record man whose requirement that I needed and also my YouTube channel name and you can also see here on web app so which you want to show the attendance in real time so let's say I'm going to take the attendance so for that I need to press o from the keyboard you can also here one is thick of the driver's voice like that and now you can see here it automatically reload the attendance for me in my web app right so in this video we are going to just make this out right so we are going to build this product in three staff in Step number one you're going to collect the user data I mean user face and with their name and step number two we are going to test it using the machine learning algorithm and after three number per we are going to use one web app in order to show the attendance so without any further Ado so let's get a starter and start the step number one so in order to build the phase recognization system we need to also collect the new phase data with their corresponding name so in order to collect the phase data first we need to create here on camera and after that you need to detect the face of the person then we are going to crop the face from the frame and we're going to store it inside one pickle file so that's it so now we are going to create who are on camera and also one phase detection system so in order to detect the phase we're going to use here one technique let's call that Cascade classifier and you can see here one file is already available that's called hair Cascade frontal default dot XML file right so now I'm going to create a new python file here let's say add well so our python file is created now we are going to create here the webcam right so in order to create one webcam we need one Library it's called opencb so in order to install this Library you need to open your command block and type here peep install and the library name is called opencd python right so this is the library you need to install that so I'm not going to install it because it already installed in my system I'm just going to click at a crop close that well so now I'm going to import here the CBT module that I missed of import CB2 then in order to create here one camera we need to also create here one video capture object in order to capture the frame so for that I'm going to use your CB2 dot video capture and inside that enter password if you're using here 0 that's me it will open your inbuilt webcam on your laptop if you use an external web Community path here as a one you already see that how can you use that external webcam offer now we are going to store it inside one variable let's say video equal to CB2 dot video capture and inside this argument we're going to pass F0 now we're going to create here one infinite Loop so let's say while true and we are going to read this using this video dot read method and this video.read pattern actually gives you two values number one is one Boolean below that your webcam is okay or not and second below is nothing but our frame so let's say red and frame well now we got the frame right now what we're going to do here we are going to show the framework so for that you can use your CB2 dot I am sure and inside that it will it will actually take one window name you can see on the recommendations window them so let's keep here on window let's call frame and also your material so the material is nothing but our frame well now to add here one keyword binding function so that we can break the low let's finish this infinite law so for that you will use your cb2.wordkey that's called white key I give here one for infinite time the higher intellectual working for One keyboard binding functions so let us sign into variable that's called CAP if k equal equal to ord let's say I am passing Q from the keyboard and this infinitely will be gone and also our video frame will gone now after gone that we need to also release the video which we are actually uh store right so let's say CB video dot let's call release and after that we are going to destroy the all window CB2 dot destroy all the windows this one now what I'm going to do here we can run the code on the terminal and you can also click in this button in order to run the code right so let's try this out using terminal let's say python head Pages dot UI another hit enter from the keyboard now let's hit enter and it will open the webcam for you so now you can see it open the webcam so now what I'm going to do here we're going to detect the face of the person right so for that you see the hair case kit algorithm right so let's press Q from the keyboard let's show it out you can see this is the queue and gone fine so it worked fine now we're going to detect the face other person right so for that what I can do here we are going to use these hair cache kit frontal default.xnl file this file that I'm going to use here so let's copy the path from here and let's create here one variable that's called faces equal to CB2 Dot Cascade classifier and inside that we need to give you the path of that so this part of the folder of the file is actually inside the data folder so now data folder we just go to the data folder and Dot XML okay one we access the phases so now what you can do here we are going to detect a phase using the multi SQL right so in order to or detect the phase we need to also convert this Frame into grayscale because this Cascade classifier actually working well on periodical images so for that what I'm going to do here you're going to convert them into the bgr2 grayscale because opencv read the image in the BGR format so let's say cb2.cbt color that's it and we're going to pass the frame and our color code or conversion that's a CV2 dot vgr to create fine now that's fine let's store into one video let's call it grayskill or it's key effect now you need to detect the faces right so let's so now let's detect the face using these hair Cascade font on default.xml file so let's make it face detect okay so now we are going to use this one call Face detect detect dot detect multiscal this one and we are going to give here our gray skill frame that you convert here from BGR to grayscale then we are going to give you the threshold value 1.3 and comma 5. and we're going to store it inside one variable that's called faces well so now what we are going to do here we are going to actually uh get the coordinate below from the faces so we are going to get here four current value one is X and Y and W and H so X and Y is nothing but the coordinate and W at H are nothing but the width and the height of the images so for that what you're going to do here you're going to iterate through all the value from here so for the you're going to use here the for Loop or you can say for each Loop so let's say x comma y comma W comma H in phases right then we are going to uh create here on a rectangle so that we can see that our face is detected so for that you need to use your CB2 dot rectangle let's call rectangle and you're going to pass your our original frame so that we don't need to see the grayscale frame at all then we're going to give here the Cardinal value so that should be X and Y and it will also give here the width and the height of the channel so let's say X Plus w and y plus if and then what you're going to do here we are going to actually add here another parameter that's called the color that you need to give then we have the thickness and also the Line tab right now we're going to give your own color so let's give here the red color that's a 50 50 comma 255 and also give here the thickness so let's give your thickness as one now we deleted the phases for me right so now if I'm going to save it and I can run the code from here let's click on this button and run the code so well it will try to open my webcam yep you can see here it will open my webcam and also detect my face right cool see how cool is it detect my face now what you're going to do here we're going to cut the faces right we're going to cut the faces and store into one list so that we can actually make it in a pickle file right so let's go on the Whiteboard and understand that how can actually crop the faces and how can you store it and how it will actually look like so well so we already did the phase of the person so let's assume that this is one person I'm also got it out right so this is rejected right so when you detect a face using the detect multi-scale function right so we actually got here four below so one is nothing but our x and y coordinate and you also got the width and the height of the images or the person PDF then you can actually create here one rectangle like that so now what we're going to do here we're going to just craft this rectangle this whole rectangle you're going to crop that from this point to from this point four point then you get a story inside one list that's called faces list we are going to store it and also we need the name with their corresponding faces right so for that we are going to crop them right so how can actually crop them let's say we are going to go go from the x coordinate to X plus W because this is nothing but our x coordinate and this is our y coordinate so let's again this is x coordinate and this is the Y coordinates so this is the height and this is the weight of the channel so if you're trying to crop this based on our width and height so we can use here this X2 X Plus X plus W and we need to use here Y into y plus h like this one so that we can actually curve this uh the faces and after cropping the faces we are going to recite the images let's say 15 cross 50 cross 3 because this is one nothing but call RGB images so you can just crop them and after cropping them we are going to store inside one list and after storing in the inside the list we're going to convert it into the one pickle file okay so let's say we're going to collecting here the 100 images So based on the 100 images we got here 100 Vector now to give here the names with their corresponding Vector let's say I am give your name let's say my name let's say Chando so with their corresponding name so we need to also give here this vector and also the name right so you're going to make this like this kind of where and so you have the 100 vector 100 Vector like that and you have also the name let us see let's see so this is my Vector this is Vector if new face is coming so again I can create one vector with the 100 100 ruin 100 column then we need to also give here the name let's say Michelle so like that we're going to do that and after that we're going to use here one machine learning algorithm in order to calculate the distance of each data point then you have to recall another face right so that's it now what you're going to do here you're going to crop the face of the person you need formula so well so we already take the faces now we're going to crop the faces using the formula that you actually discuss about that so let's say from the frame we're going to go from white to Y plus is and X to X plus W and number of channels that are going to take let's say y to Y plus is and we're going to go from X to X plus W then I'm going to take the all number of Channel now let us sign into one variable let's call Crop image now we are going to resize the images so that we can resize them in one single size that's mean all the faces size should be equal so for that you need to also resize the frame so you can use your cb2.resize method in order to resize the frame so we're going to give here the cop images and we need to also give here the size of our images in a tuple format so we're going to give here 15 comma 15. and it will resize the images in this size and now let's assign it to another variable let's call resize image well now our image is also resized and we also crop our images now we need to store it inside one list so for that you're going to create here one empty list so let's say faces data it's an empty list then we are going to find EMES is actually the size we're going to store it inside the faces data right so for that you can use here the faces underscore data and you're going to app and you're going to append the resize image so this is our resize image this one so high end are the resize image or image taken by the webcam is completed as a hundred so we're going to drag the loop right so for that you can actually add here another condition here so let's say r an of the face data equal equal to 100 we're going to also break the loop well and we need to also stop them the phases data should be appended right so for that we are going to give here another condition let's say if length of the phase data that means this phase data is less equal 100 and also we are going to take the images after uh after 10 frame so that you're going to use here another condition so that you can give here some process smart process so that's why you're actually using this one so let's say I uh modulus 10 equal to equal to 0. and we are going to actually take the images and store it inside the list right so you need to also increment it so let's say I equal to I plus 1 so that's it and it also initialize the I so let's I equal to 0 in any initial positions you can also see it in a put text so for that you need to use here CB2 dot that's in how many picture detects you've taken you can see it inside your frame so for that you're going to use here the cb2.put text and inside that you need to give you the frame then you can you need to give here any kind of text so I'm going to see the land of the faces that's been how many faces is actually going to collect it so for that you're going to use your length of phase data that's when this phase data exit and it also convert it into string because food tax taking Instinct a valid and land of the phase is nothing but one you can get that below so that's why it gave me error so now we are going to give here the origin or you can say the coordinate so let's give the 15 power 15. and the font is let's say CB2 dot there are so many font face actually available inside the CB2 let's say foreign and give your one fond of scale so let's give here one and color let's say give you the red color which is hitting comma 15 comma 255 and the thickness let's keep it one okay so now let's run the code and see that uh how it actually work and after storing the data of the phase data inside our list we need to also store it inside one pickle file so that you can actually use it later on while you're going to build our machine learning model so well I am going to run the code using clicking this button I have to open the webcam and now you can see here it will detect my faces and also it will take the images and after 10 iteration you can see here how cool is it actually taking the images I can give you a pause see how cool is it now what you're going to do here we are going to actually store it inside one pickle file and also the name of the person that you're going to detect I'm used here q and it will I hope it will automatically gone okay this cap lock is on that's why it's not gone well now we are going to store these faces data including the name of the person so let's say I am going to create here one below let's call name and I'm going to use here the input method in order to take the input for the user name so let's say enter your name and to take the username from the users right so after taking all the images so high and loop is gone I mean Loop is bracked then you're going to store the phase data with their name in one pickle file so for that into also import here the pickle so that's the pickle equal so that we can use it later on and after that we can build here one machine learning model well so now we are going to convert this data in into numpy error we need to also import the numpy right so let's say import numpy S and B well so we have our phase data now we're going to convert it inside numpy array let's face as data this our face is data and you could use your NP dot as array these functions that you're going to use here and inside that you're going to pass here our phase data and we need to also reshape them I will reshape the face data so that we can give into inside one machine learning model so we need to make in flatter so we have 100 images so the shape should be hundred cross hundred cross three like that 100 cross we have the 15 cross shifting cross 3 like that and we are taking the 100 images that's mean Vector size should be the 100 so for that we're going to reshape them so let's say faces data dot reshape so this is called reshape so reshape and you're going to use here 100 month form that's in all the value and now you can store into the same video that's called faces underscore data well so now we convert our data into the numpy array now we are going to store it inside the pickle file so well we convert our data into numpy array now what we're going to do here we're going to store it inside one pickle file so that we can use it later on right so for the new to input here another Library it's called OS you can say also operating system you need to check that any file is available or not you can also using this one you can also create here new folder like OS Dot MK deal and now we're going to use here OS dot list G in order to check that the inside a data folder any file is available or not let's say I'm taking the input for the user for the first time just I'm running the file for the first time that's mean no file is available so now we need to check that is there any file is available or not if the file is available we are going to just Uber write it so let's check it for the name form so let's say if foreign right not in OS dot listed so OS store list actually help us to create here one list directory of our files so let's say inside this data folder we don't have any names.pickle file okay then what you're going to do here so if the names dot pickle file is not available so what I'm going to do here we are going to create here one new file for that right so for that even if you're with open and inside the data folder so let's say data you can use your names dot equal as f then you're going to save it inside our tickle file so further even userpical dot Dom and this will take two parameter one is your object and another one is a five so you have the file but we don't have the objects I mean the names right so we are going to actually taking the 100 images right so for that we are going to create here on the backdr or you can sell list of 100 100 names so for that what I'm going to do here you can do make it multiple with 100 that you have our name then you're going to store it inside the variable that's called names right then you're going to just we're going to just pass it instead of a dump and offer file that you actually created well now this is for actually uh nothing but uh creating the names.pikle file if it is not available inside the data folder we need to also create here the list because this is one kind of list of backdoor so that's why I need to convert it into the list now it's fine now if names dot pickle file is available inside a data folder that's when you are taking the input for the another users I mean you are adding number two phase so for that you're going to load this pical file inside the data folder so for that what I'm going to do here else conditions else that's been if the names.pal file is available so we're going to load it from using this put method so for that I'm just going to copy this one just copy this one I'm going to pass it here that I am going to load it just load it so load the file inside a data folder then we are going to Uber write it right so let's store into the variable that's called names so let's say names now we are going to add these names add this name that's mean overwrite it right I mean adding the extra one that's extra name let's say I have the name I have the data of let's say Sandhu now I'm going to add here another letter let's say called new show right so let's say this data is already available now I'm going to add here the Mishu data I mean collecting the face for another user now what you're going to do here we are going to just concatenate it I mean can't connect the new data so for that what we're going to do here we are going to use here let's say name simple names equal to names I mean these names plus name cross 100 simple this one right so we need to also make it inside one list right I'm going to also remove this because this will give me the error now we store the names now what you're going to do here we need to also dump it inside our data folder so for that I am just going to copy this and I am going to again past it and now our file is created well so this is for the names.pickle file now let's do the same thing for Face data.sql File so I'm just going to paste it and now I'm going to convert team should be the faces or underscore data and I'm going to copy this and this should be the same they should be the same they should be the same but there should be some changes uh based on the data right so when the data is not available we are going to just um give here the phase data that is available inside my face data so for that we just going to remove them just we're going to remove that and you're going to just pass here the face is data I mean these faces data now if if I'm trying to add here the new phases that we override the phase data so for that what I'm going to do here is just load it let's say this is the phase data phase is data or let's say faces that we are going to add it so let's say basis equal to NP dot append entry dot append we're going to use their append method and inside that we're going to pass here our faces and also our phase data I mean the data that you actually converted convert it and also the file options not the file actually of the axis of which axis that you're going to save it 0. now we actually save our names.pk names.pikal file inside our name data and also our Facebook file we also have the face data right so well we do here when we stack we don't give here the mode of that so we need to also give the mode so this is nothing but call uh write mode so that's why I need to use here the WB that we need to actually use here the mode of that so this is nothing but Reading Writing if you're trying to load it so you need to use here the RB so this is for load so you need to use here the RB so this for read mode then this is dumb mode so I need to convert it should be the into the right mode and this is the loading part or dumper dumper again write mode and this is the dumper so you need to also make it should be the WB so if you load it so you need to use here the RP mode I mean the read mode then you you are reading this file inside the directory right so now so well so now let's run the code and trying to add the faces on our data folder and now it will open the webcam and you know to also enter your name so let's give my name let's say Mishu and now it will open my webcam so as you can see here it already take my pictures and you can see it already take 47 picture like that and you can see so it will take the 100 picture at a time and after 10 frame it will take the picture so that you can give some posts right you can see I can give CM pose right well so after 100 picture it will actually save it inside the pickle file so see our two pickle file is created one is faces underscore data dot equal file and another one is called the names underscore pickle file now what I'm going to do here we're going to test it out I mean we are going to make our Peak organization system using machine learning algorithm so now let's get started and Jammer part number two so well we compute our step number one so our step number one is nothing but collect the data and now our step number two is nothing but using machine learning algorithm to classify the faces okay or you can say the phase recognization so in order to recognize our face we are going to use here one clustering algorithm from machine learning it's called K N in right so how it actually work here so it is available inside our library is called scikit learn so this is one python machine learning library and inside that Canon is available we can use that so now let's see how it actually work so let's assume that uh we have two phase let's say one phase for let's say chandu and another one phase for let's say issue right so we have 100 vector or you can see the 100 list or you can say 100 picture right so you have also the 100 picture for Mishu so let's assume that this is one dimensions and all the vector value all the vector value are actually floating like that right are floating like that right floating like that or you can assume that we have some just dot value like that right so there are some values for chandu and some Bells form issue are actually I'm just going to plot it right so let's assume that I am going to test it so new data is coming from the webcam of our inbuild webcam our external webcam so higher new data is coming let's say this value is right now uh our stand right now there So based on the Bellow it will try to calculate the distance from the each nearest Value right each nearest below it's changed then if the nearest Value is closer to this value that's coming from webcam so this is nothing but our face I mean our recognize phase again so let's say we have the shape we have the coordinate like that that's why I have some value right so let's say new data is coming from the webcam so this is our new data with our new data now the can and actually help us to calculate the distance from the each Vector that's where this is our new data so this is our nearest Value this is also our nearest Value this is also nearest Value so it will actually calculate the nearest distance for the each data point nearest value of the is data point let's say I am going to give here my neighbor should be 5 if it will calculate the 5 nearest Value from that is actually coming from the webcam then it will actually taking the first value at a phases I mean the recognize one see the new face is coming maybe it should be chandu or it should be issue so it is closer to Chando so it will actually return the value as a channel as a fees right so that is how the Canon actually work so now we are going to use it in order to detect our face right so now let's go on the BS score so well so now we are going to build our machine learning algorithm in order to classify our phases so for that I am going to create here new python file let's say test dot UI well so now I am going to import here my machine learning you can see the machine learning algorithms so for that I mean import it from scale on so let's say from a scalar SK learn dot neighbors I'm going to import here the knnn it's called the K neighbors classifier because this is one classification tax right and also we need to create the camera and also we need to detect the face and after editing the phase we are going to actually uh classify that whose face is actually detected is it Mishu or is it Chando or anything else right so for that I'm just going to copy the code that I know in the add pages and I'm going to draw some modification here so let's I'm going to paste it here so we need to load the faces underscore data.pickle file and also the names.pikle file from our data directory so for that I am going to use this load functionality so I'm just going to copy this and I'm going to paste it here right I'm just going to pass it here just past it so we loot our faces sorry names so names is nothing but our levels so this is one super buy Stacks let's say let's say levels and also we need to load our faces data so this should be the faces uh underscore data dot pickle file so just I'm going to load it well so now this should be the faces so let's say faces and our faces data also loaded so now what you can do here I'm just going to remove here some lines we don't need the name and the iteration part we don't need also the list because you already save the data and also we do need to append the data you just go to feed it using the machine learning algorithm and also we do need the put text and we can also remove this condition from here and we can also remove all the line from here that's it right so we'll load our pickle file correctly now what we're going to do here we are going to uh use the canon in order to feed this phase and also the levels so for that we are going to create here one object for that so let's say can nearest neighbors classifier and inside this I'm going to pass here the neighbor should be 5 that we already discussed on the Whiteboard so let initialize into the variable that's called KNM and now I'm going to feed it based using our features and the levels so for that even use your KN dot fit then we we have our faces and also you have our levels I mean these levels right so if it our algorithm using the faces and with their levels now you're going to predict it right so in order to predict them so you already revise our images in 50 to 50 right right 50 to 50. so for that what you can do here we need to also make it flattened because if I go on the last of the portions of the code you can see 30 third line to reshape our data right so because we're testing it out so we are going to take the one images from the one frame I mean in the single frame so that's why you need to also flatten it and also you need to reshape it right because you're going to pass it inside the machine learning algorithm so that's why I need to make it in one single vector and after that you're going to reshape it means you are going to classify the one image at a time so that's why you just make it reshape and now after reshaping we are going to pass here our algorithm so we are going to use Canon dot predict and you're going to Simply pass here our resize images that is actually coming from here so resize images so we got here Five Below I mean five nearest distance so you can see how we actually pass here the neighbor should be five so that's why I'm just going to make it let's output equal to K N dot predict and this one now I'm going to add here one put text so let's say CB2 dot boot text so this is the put text and I am going to give here my image so this should be the frame and also my text so text is nothing but our output so let's say output so we have the Five Below we are going to access the first index so that's why I give here output 0 so it's better if you if you don't get any error it's better we can actually uh typecasting it in a string format right then we have the origin that we higher we are going to see I see it so you're going to see it uh above the y axis so that's why you are going to manage from here and then we are going to give here the front face so let's say CB2 dot there are so many font are available let's say font here complex and now we have the font skill let's keep your one and let's keep your own color so let's give here the white color that's 2.5 2 5 5 and now also we need to give you the thickness so let's give it one well so now our face requirement system is done and if I am just click here on this run button and run the file and we'll open the webcam and it's trying to detect my face with also my name now you can see here editing my videos correctly and also you can see here my name is already appeared up here that we actually collected so that's all right so now you can do at here one rectangle so this looks so cool and looks good at all and also we are going to create here one create your own background so it just looks very cool that you see in earlier in the demo video right so I'm going to press the Q from the keyboard and it will automatically gone right so now what you're gonna do here you're going to just pass here some blank rectangle so that it just looks so cool foreign okay this is really simple you can also play with them I'm just going to save it again run the code and now I'm going to see the output right just to avoid it will open the webcam yeah now you can see here it looks very cool and you can see my name is also appeared up here issue and that's really good fine now what I can do here you're going to add here the background so that it's look much more better right so let's add the background here so well I already passed here my background.pnd file so this is my background.png file so now I am going to actually set the frame uh in this coordinate so for that you need to also load the background images using the opencb so now let's go on here and try to load these images so for that I am going to use here CB2 dot I am read and I'm going to read it so I need to give you the path so the path is nothing but background.png so let's say background dot PNG and let's assign it to the variable let's call Image background and now I am going to just uh pass it uh just inside this rectangle so I just got here some Corner below I just play with them and I'm going to pass here the Bellow right so now if I run the code here don't worry about the code you can just go get this code on the description of the GitHub link you can just go here and you can play with them so it's not actually uh again pop-up so I think I forget to show the image background because it also show it leave it background because we actually passed the frame already so that's why it's not showing up so again run the code well so now you can see here it looks much better and you can see it also did in my face correctly and the background well so you can see here requirement python opencb sidekick learn and this is my channel name knowledge after so make sure to subscribe to the channels also so now what you're gonna do do here you're going to take the attention right so you can see here press o for take attendance right because higher breath oh it's not taking attendance so it also store the attendance inside one CLG file so for that you're going to import the CSV also so let's do this one so now we're going to actually add the attendance so for that you need to also import here the csb so we are going to actually store the attendance in uh two column that should be the name and also the time and also we need to have one attendance folder so we need to also create here so let's say attendance folder and inside this attendance folder you have the attendance with your corresponding date so we need to also import your time because we need to also uh store the attendance based on our time and also the date so for that you need to also import the date time so let's say from date time I am going to import here the date time well now I am going to create here one instance of that so for that I'm using time dot time and now I'm going to pass it inside our date time so that we can actually get here some dating format so let's say date time dot date time so this is called date time and from the dead time I need to import the steam time right I've been history of time so let's say it's tier of time so no it's still not from time stem inside the time estimate just pass here the time and now we're going to actually get the steer type now we have to give here the date month and uh date then we have the month and we have the year right so for that you need to use here the one double quotation and we have our date the percentage date and we have our month and we have our year right so date month and year so we got our date right now we need to also take that time uh because we're going to show it inside our attendance so that's why we are going to also copy this line and also create here on timestamp so there should be time rest time so that time should be the hour and that should be the minute and also have the second right that's fine so this is nothing about time stem okay that's the time stamp well and now we need to also create here two column of list so let's say this is called the column names equal to we have the name in our CSV file and also we have the time we have the time you can also add here the date that's your text now we need to take the attendance right so for that I am going to create here one variable let's call attendance attendance equal to we have our output output 0 and also we have what time right so this is nothing but in a stream format and we have our timestamp so let's say time as time well so we stored our attendance uh inside one list now what I'm gonna do here we are going to check that is there any file is available inside this attendance full or not if the let's say today is right now 6th April so if the date is right now 6th April so it will just overwrite this data inside the folder so you need to also tag that if there any file is available inside the attendance folder so for that you're going to use here the OS so let's say OS dot path dot is file so let's say is file because we're checking for the file so inside the attendance folder let's add 10 dance and we have the attendance file so let's add 10 dance and the attendance file containing with date and with having the dot CSV right dot csb as extensions so if there any file is available like that so that's called exist so if any file is available like that we are going to just override our attendance I mean you can just add it after the attendance so high and anyone press or from the keyboard and you take the attendance for the if k equal to equal to ord and I am just going to press here the O you can give your smaller Capital it's up to you so let's say it exists I mean if the file is exist so we are going to do one thugs right if the file is not exist we are going to create here new column for that we need to create here the column for name we need to create the column for the time so let's else so what you're going to do here you're going to just open this file so put open we are going to copy this one and we're just going to copy this the file format I mean you're going to open this file inside our directory okay it's not actually it's not actually created right now fine actually open it and we need to also modify it so we can actually use here the alternate one just add so let's add CSD file so after that we're going to create here one writer for that CSV file so for that you can use your CSV that you already import then you are going to use your CSD Dot writer so use this writer I'm just going to create here the method of the writer and now I'm going to assign it to the variable it's called the writer equal to csb.writer now I'm going to create here one row and also the column first you need to create a column because we're going to create this attendance for the first time so for that you're going to use this item dot right row so that's called Write row this one we are going to pass here our column names okay this one columns names and also you need to pass here our attendance so let's say write dot right row so this is our right row and we are going to pass here our attendance so this will be writers or this is our attendance right so attendance well so I'm going to just pass it here attend this and now if I am uh of that and it also close this CSV file that's csb file Dot close just you need to close it so now if the file is already exist what you can do we are going to just uh actually uh necklace a column board so I can just calculate this column part we don't need it so now our attendance is saved inside our CV file so if I run that code here and try to check this out that is really working fine or not so I'm just open the it's open the webcam well so now what I'm going to do here I'm just going to press o from the keyboard so oh okay we got some error expect one argument uh we got zero okay we need to actually pass here the argument so you forget it you need to pass here this is the file and also the CLG file that's why you got this error you can see attendance file is actually created you can see Arduino file is created but no attendance here because we got the error that's why so if I run this file again so it's not it's just override this file it's not creating here the another file you can see here the date okay sorry for that date is starting of seven so you can see here again again I press two but two button from the for the two times so if I press Q from the keyboard and if I go here and you can see attendance taken right it take the attendance in two times take thatness in two times right now you can see your names in the title is not actually appeared because we got here the one error so now if I am trying to remove this file again delete this file just I'm going to delete it and if I am going to save it file again and if I run the file again then you can see it clearly just avoid okay so I press o again press o and press Q if I go here now you can see name and time is appear right so name you can see here the time okay and this is actually appeared on here okay so now what you can do here uh we are going to create here one app so that you can also see it clearly and also that has some problem higher the attendance is taken we can also give here one sound so also let's give your own sound so that you can actually hear it clear that attendance is taken like that right so well so now I'm going to pass here the code for his pick is for it's just only for Windows versions so we can just use this big one just pick one we're just going to copy these functions or you can say method so high-end attendance is taken I mean when you press Q for or from the keyboard and it will just normally speak let's say attendance taken right you can also give here on time.sleep let's attend uh at 10 dance taken right so taken so I am just play out the caps lock so we can also give here some time left flip so that after five seconds it will actually sleep for the program and so that you can actually see it clearly that it is actually taken right so now I'm going to run the code for again and it will open the webcam and you can also hear it well you can see here uh webcam is open uh you know to hear that and it also use my headphone so let's say I am press o from the keyboard attendance taken well so you can hear that attendance taken one found and also frame easily for five seconds so that you can clearly think that yes acne is taken right so again attendance taken so you can see here attendance is taken one so that's fine so now what I'm going to do is here we're going to see it one web application that is in earlier so in order to build our web app we are going to use here the stream lit right so let's try to build this out and also you're going to test it out with another person because I have just one person issue so just we have one data so we are going to also test it out with the another person so that you can also get the clear graph about it so I'm going to press key from the keyboard and it automatically one now I'm going to create here on the web app so that we can see the attendance in real time you don't need to go this folder again and again you can show it inside one web apps so let's say I'm going to use your app.py so in order to create the web app I'm going to use the streamlined so let's say import the stream lead extreme lead as St so in order to load the data from the attendance folder we need to import here the library is called pandas right pandas as feeding so we are going to copy these one because this is our file extensions so now I am going to create here on data frame let's say DF equal to PD dot rate csb and I'm going to just past here the Bellow I mean our attendance so that's it well so we have the date so you know also need to also copy the code from here just I'm going to copy the form and I need to also import the date time so yes that's it and it also Imports the time and also you need to import the date time let's say import okay import time and also we need to import date time so let's say from date time I would import here the date time that's the date time that's it now I'm going to save beat and also show it inside one data frame so for that you'll use St dot data frame so this is our data frame now I'm going to add it the DF and we're going to make some style so for that you see the style dot if I'm trying to highlight the max we can actually give you here the Highlight Max so let's give here highlight Max in the axis number zero so that you can see in the draw column so now if I am trying to run the file from here and uh the command should be stream lit run app.pi it will open this inside one localhost to copy the link and paste it inside on browser so while I am opening my browser and I'm going to pass the link and now you can see the attendance see the attendance is taken okay let's go on the setting and run and save and the white mode and also try to make it light so that you can see it clearly well so you can see here the attendance right you can make it full so that it's come inside in the middle so you can see here two attendance is three four eight and it is taken so now we're going to run the code and try to see it in real time so well now I'm going to run the test.py file and just open this file and we'll open the webcam now I am going to test it on the web app also so let's open the web app so here is our web app right now what I can do I'm just going to press o from the keyboard attendance taken and attendance is taken if I go on here and right now you can see a zero one two three if I reload the applications and you can just see here the one attendance is also added you can see it four now the time but there is a problem that it's not Auto delete I mean or to refresh when you take the attendance so we can also do it after two seconds we can directly how to refresh it just mean we don't need to actually use this reload button I mean we need to reload we do need to reload the pages again and again so for that we can use here another code so that's called or to refresh so I'm just going to pass the code here so this is for steam that auto refresh so it will actually Auto refresh the application after two seconds and we give here one that's one kind of key so that it you can also count it out that auto increase actually working right so I'm just going to save the file and I'm going to open my webcam also and also my browser so now you can see just a while if I go here on the setting and run on Save and also the wet mode now if I am reload the application and you can see here it is running the application after two seconds just to while you can see after two seconds it will run in the whole applications so if I'm trying to make it in the middle so I can also do it so let's make it in the middle so now you can see that this file is in the middle and now if I press oh from the attendance taken this is taken and you can see just a while it will auto delete the application I'm not touching the keyboard I'm touching the keyboard you can see here after five seconds it will automatically reload the application I'm not actually reloading the application right so again see okay that's it here I am just going to see attendance taken so it will attend this is taken and now you can see just a while the attendance will Taken well so that's fine so now I'm going to test to it this out with another person uh so that you can also think that yes it's work for different person also yes now test it out with another person's so let's go so that's so that's it for today now hope you enjoy studio and make sure discover these channels and also don't forget to hit the Bell icon and I'll be back with the video so till then take care and bye
Info
Channel: KNOWLEDGE DOCTOR
Views: 102,906
Rating: undefined out of 5
Keywords: face recognition, python for face recogntion, knowledge doctor face recognition, face recognition using knn, face recognition ml project, face recognition machine learning, face recognition algorithm python, face recognition in web, knowledge doctor, face recognition knowledge doctor, face recognition for ml
Id: BYCKvM8eZGA
Channel Id: undefined
Length: 55min 39sec (3339 seconds)
Published: Fri Apr 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.