Nolongerwillthatbe a problem, becauseintoday's video, we'regonnalookatcreating a facialrecognitionappwhereyoucanuploadanyphotosyouwant, anditwilltellyouexactlywho's inthatphoto.
Let's getstarted.
NowLet's take a quicklookattheprojectwe'regoingtobuild.
Lastly, I havetheface a P I minimizedlibraryhere, whichwe'regoingtobeusingtodothefacerecognitioninsideofthisproject, andallweneedtodoisadd a newfilehere, whichgoingtobeourindexdothtml.
Thisisgoingtobeforrenderingourpage, andwe'realsogoingtohave a scriptdotJs, whichisgoingtobeallofourcustomcodethatwe'rewritingforrecognizingthesefaces.
Wejustneed a singleinput, whichisgoingtobe a typeoffile, andwejustwanttogiveitan I.
D.
SowecanreferencethisinourJavaScript.
We'rejustgonnasayimageupload, andthen I'm goingtouse a fewstyleshereinsideofthebodyareinsideoftheheadtagbecause I justwanttobeabletostyleourpagethateverythingiscentered.
Andtodothat, we'lljustselectthebody.
We'regoingtogetridofallthemargin, allthepadding.
Wewanttomakethewithhereequalto 100 viewwidths.
Soit's goingtotakeuptheentirewith, andwewanttomaketheheightequalto 100 viewheight, whichagainwillmake a takeuptheentireheight.
We'regoingtouseface a p i dotnetsdotandtheninhereweputthelibrarynamethatwe'reusing, sowe'regonnausefacerecognitionbecausewewanttobuildtorecognizethefaces, Sofacerecognitionnetandwewanttojustloadthissoloadfromyouor I andwe'reloadingthisfromourmodelsfolder, sowejustpassitinhere, a pathtoourmodel's fullday.
Sowe'regoingtocreate a variablehereweretosay, imageandit's goingtobeequaltoourface.
A p I willface a p i dotbuffertoimageandwe'regonnataketheimageupload.
Wewanttogetthefilesfromit, andwejustwannagetthe 1st 1 sincewe'reonlyeveruploadingonefileandwewanttomakesureweawaitthisbecauseit's asynchronousandessentiallywhatthisisgoingtodoisit's goingtotakethefilethatweuploadedandconvertittoanactualimageelementwhichisgoingtobeusablewiththeface a P I library.
Next, wecanusethattogetourdetection, Szesowecancreate a variableherecalleddetectionsagain, We'regoingtoawaitourface a p I.
Sotobethatwecouldjustsayface a p i dotmatchspellthatproperlymatchdimensionsandwejustwanttopassthemhereOurcanvaselementaswellasourdisplaysizedisplaysize.
Sowe'regonnacreate a variableherecalledresizeddetections.
Wewanttosetthisequaltoourface a p i dotresizeresultsjustlikethisandwe'regonnapassinourdetectionsonwherethisisgoingtodoisgoingtoresizeallourboxesforourdetectiontobethecorrectsizebasedonthesizethatwepassitandinourcase, we'regoingtojustpassit.
Now, inordertodrawthatactualboxwewanttodoisyoujustwanttocreate a variablewhichwe'regonnacall a dropbox.
We'regonnasetthisequalto a newface a p i booksface a p i dotdrawdotdrawboxandthisisgoingtoallowustodrawourboxontothescreen, andwefirstwanttopassitthebox, whichinourcase, isjustgoingtobefromourresizeddetections.
Sowe'regonnause a loopherewe'regoingtosaywe'regonnadoforeachoneofthesedetectionsdetections.
Therewego.
Soforeachoneofourdetectioniswewanttodraw a boxandareboxedhere.
Andthenweneedtoknowwhichoneofthesefolderimageswewanttoaccess, whichinourcase, iseithergonnabeoneortwobasedonthis I variableandalloftheseair J pegs.
Sowecanjustsaydot j paidattheendhere.
Now, thisisgoingtoloadallofourdifferentimagesintothesedifferentvariablesonwewanttodoiswewanttoactuallydetectthefacesinthoseimagessowecanjustsayprotectionshereisgoingtobeequaltoawaitface a p i dotdetect a singlefacebecausewejusthaveonefaceinallthesedifferentimagesandwe'regoingtopassintheimage.
Ifyou'reinterestedinmyfacedetectionvideoand I haven't alreadyseenit, makesuretocheckthatoutlinkedoverherealsosubscribetothechannelformorecontentjustlikethis.