Face Mask Detection using Python, Keras, OpenCV and MobileNet | Detect masks real-time video streams

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this Python programming video, we will learn building a Face Mask Detector using Keras, Tensorflow, MobileNet and OpenCV. We will also see how to apply this on a Live Video Camera. With further improvements these types of models could be integrated with CCTV cameras to detect and identify people without masks.
    The face mask detector didn't use any morphed masked images dataset. The model is accurate, and since the MobileNetV2 architecture is used, it’s also computationally efficient and thus making it easier to deploy the model to embedded systems (Raspberry Pi, Google Coral, etc.).
    This system can therefore be used in real-time applications which require face-mask detection for safety purposes due to the outbreak of Covid-19. This project can be integrated with embedded systems for application in airports, railway stations, offices, schools, and public places to ensure that public safety guidelines are followed.
    Feel free to play around with the code, change the parameters and come ip with better accuracy. Let me know the changes in the comment section.
    GitHub: github.com/balajisrinivas/Fac...
    Numpy: • Complete Numpy A-Z | N...
    Matplotlib: • Matplotlib Tutorial Pa...
    Learn more about ImageDataGenerator: keras.io/api/preprocessing/im...
    LinkedIn: LinkedIn: / balaji2512
    Stay tuned for more such videos and subscribe to the channel
    #python #FaceMaskDetection #keras #tensorflow #opencv
    Introduction and Demo: (0:00)
    Install Dependancies: (1:18)
    Dataset: (2:10)
    Data Preprocessing: (2:58)
    Training: (9:03)
    Run and View Accuracy: (17:09)
    Use model in real time Camera: (18:20)
    Final Result: (25:30)

Komentáře • 1K

  • @CHITUS
    @CHITUS Před 3 lety +12

    Amazing tutorial. You're underrated bro.

  • @leojoyjr2755
    @leojoyjr2755 Před 3 lety +8

    This is the First video ...
    And you got my subscription 😍
    Perfect explanation

  • @chaithanyarajashekhar5043

    Amazinggg!! Perfect speed, understandable thank you so much for this video!!

  • @andreeasrh
    @andreeasrh Před 3 lety +7

    In my opinion, I think that you are the best Indian who makes tutorial like this. Very very very easy to follow and you learn so much! Thanks! ❤

  • @danielaramirez7923
    @danielaramirez7923 Před 3 lety +3

    Bro.... You are great at what you do. Good Job!!!

  • @jathiswarbhaskar2479
    @jathiswarbhaskar2479 Před 3 lety +1

    Thanks a lot for this. Easily understandable explanation and codes.

  • @shilpakamble7791
    @shilpakamble7791 Před 3 lety +2

    This is really very very useful video sir. Thank you so much to explain in such good way and giving amazing explanation. Once again thank you sir.

  • @liamhan8145
    @liamhan8145 Před 3 lety +6

    If I were to run this on raspberry pi, will I have to convert both the mask_detecting model AND the face recognition model to tflite? Or just the tf lite?

  • @abhishekd1012
    @abhishekd1012 Před 3 lety +9

    Hi balaji, I'm in the beginning of Deep Learning concepts right now. Thanks for this video, this really keeps me motivated. After finishing those concepts I'll come back to this project.

  • @kingchan9577
    @kingchan9577 Před 2 lety +2

    you save my life from my class project Thank you bro!!!

  • @daddyofalltrades
    @daddyofalltrades Před 3 lety +1

    Wonderful. This cleared a lot of doubts I had. Thank you sir

  • @neelraja8620
    @neelraja8620 Před 3 lety +8

    This project saved my life at the last moment of my codeathon
    Thank you very much Sir
    It helped a lot

    • @geethanjaligajulapalli3189
      @geethanjaligajulapalli3189 Před 3 lety

      hii. will u help me in this project. am getting tensorflow errors. this weekened i need to submit the project. am getting fear , till now i didnt rectified the errors. please help me

    • @h.o.p.e3071
      @h.o.p.e3071 Před 3 lety

      U completed this project??

    • @neelraja8620
      @neelraja8620 Před 3 lety

      @@geethanjaligajulapalli3189 ok

    • @neelraja8620
      @neelraja8620 Před 3 lety +1

      @@h.o.p.e3071 yea

    • @geethanjaligajulapalli3189
      @geethanjaligajulapalli3189 Před 3 lety

      do u have documentation for this project?

  • @Reeve61
    @Reeve61 Před 3 lety +3

    bro if you dont mind can you please explain what's going on in the detect_and_predict_mask function in the execution program.

    • @KHM95
      @KHM95 Před 3 lety

      Here's a paid course for this: It's amazing
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

  • @shiyamprasad3213
    @shiyamprasad3213 Před 3 lety

    Easily understandable 👌 Thank you man

  • @contico8768
    @contico8768 Před 3 lety +2

    Amazing youtube channel for python projects

  • @venkateshbrabhu3689
    @venkateshbrabhu3689 Před 3 lety +3

    Hey, actually that was a easy and simple as you explain .
    I'm really interested to see your other videos as well. If I have any quires i ll reach you either through mail or any other social media .
    I plan to start my learning completely with your videos 😂.
    I'm currently working as a python developer .

  • @arthurarturo4625
    @arthurarturo4625 Před 3 lety +5

    Is there a way where you can add a third dataset, to have a option of "bad mask"?
    Where they have the mask on wrong, with the nose out?

    • @goldmanhadad
      @goldmanhadad Před 3 lety +6

      Simple collect images where nose is out
      And create a third folder and adjust the changes in code aswell

    • @lakshmipriyaanumula9506
      @lakshmipriyaanumula9506 Před 3 lety

      @@goldmanhadad I actually trying this,it's not accepting more than 2 datasets,can u please tell where should i modify code??

    • @luohaoran3285
      @luohaoran3285 Před 3 lety

      @@lakshmipriyaanumula9506you can probably google the multiple class classification sample coding for CNN, I think there are many samples out there.

    • @subrinas7830
      @subrinas7830 Před 3 lety

      Could anyone tell whether this project is based on neural networks??

    • @ThouheethaA
      @ThouheethaA Před 3 lety

      @@subrinas7830 yes its cnn model

  • @masterjay_photography
    @masterjay_photography Před 2 lety +2

    Thank you so much. I've done this for my semester project and it is working perfectly.:)

  • @ramandeepsingh2695
    @ramandeepsingh2695 Před 3 lety

    very helpful brother you saved me from deadline of project submission

  • @babithasiddula3446
    @babithasiddula3446 Před 3 lety +5

    What algorithms are used in the project?

  • @saivasista8440
    @saivasista8440 Před 4 lety +14

    It was really helpful, can you give any suggestions for detecting mask from a long distance.
    This model supports approx 2 meters.

    • @amolikvivian
      @amolikvivian Před 3 lety +3

      Can probably change the Face Detection Model to improve detection distance. YOLO's pre-trained face models should work fine for the same.

    • @epicgamer9643
      @epicgamer9643 Před 3 lety +3

      you could try training different images to detect mask wearing from a long distance

    • @saisharaneruventi2180
      @saisharaneruventi2180 Před 3 lety

      Have you done ppt bro

  • @shylajah.n3960
    @shylajah.n3960 Před 3 lety

    Really a very good demonstration of the code for mask face detection

  • @rakeshranjankumar1051
    @rakeshranjankumar1051 Před 2 lety

    Thank u sir very very much aaj apke wajah se bina project kiye hi marks mil jaeyga..thank u

  • @anthonygonsalvis121
    @anthonygonsalvis121 Před 3 lety +9

    @Balaji, very nice video! Very helpful narration. Thank you. I'm a newbie in this area and plan tp watch your other videos. In general, how do you decide which specific model to use for a certain application/use case? TensorFlow itself has so many different 'families' of options (MobileNet, Inception, ResNet, Hourglass just to name a few - let alone the dozens of feature_extractors in each family). Then there are other classifications such as RCNN, SSD, Center_Net, etc.). Too confusing choices for new learners. Would you please make a separate video just comparing them all?
    Separately and completely unrelated, would you please create similar video on Predictive Maintenance of capital assets (i.e. machinery and equipment) directly applicable to the manufacturing industry, where the manufacturer wants to know when to send in maintenance service personnel to the client site for maintenance/repair/part replacement based on the telemetry (sensor) data. Two typical questions are: (1) What's the RUL (Remaining Useful Life) of the machine or one of its components, and (2) Will the machine or a specific component fail in the next 24 hours/week/month/quarter/year (whichever time horizon is most appropriate for that machinery and its operating demands).

    • @nksg2756
      @nksg2756 Před 2 lety

      On which ide is he coding ???

    • @kathir6581
      @kathir6581 Před rokem

      @@nksg2756 same doubt bro

    • @nksg2756
      @nksg2756 Před rokem

      @@kathir6581 sublime text

  • @rajsaraiya7125
    @rajsaraiya7125 Před 4 lety +9

    Amazing work Balaji can i know what is the training and validation accuracy you have achieved???

  • @hikt1731
    @hikt1731 Před 3 lety

    The idea is very good and I liked it. I hope you keep doing these kind of things!

  • @marksathish2783
    @marksathish2783 Před 3 lety

    lot of subject ,much better than many youtube videos

  • @ichigo6386
    @ichigo6386 Před 2 lety +2

    Hello, your code is amazing. However I also want to detect wearing face masks incorrectly, what should I do ?

  • @dishamankawle2586
    @dishamankawle2586 Před 3 lety +3

    ERROR: Could not find a version that satisfies the requirement tensorflow>=1.15.2 (from -r requirements.txt (line 1)) (from versions: none)
    ERROR: No matching distribution found for tensorflow>=1.15.2 (from -r requirements.txt (line 1))

    • @abdullah_khan6887
      @abdullah_khan6887 Před 2 lety

      install python and opencv first then try

    • @aksh2588
      @aksh2588 Před 4 měsíci

      ​@@abdullah_khan6887brother I got the same problem... Can you please elaborate how can I fix this issue

  • @explors91
    @explors91 Před 2 lety

    Thank you so much. Keep posting the videos because that help us to learn things in best way.

  • @h.o.p.e3071
    @h.o.p.e3071 Před 3 lety +1

    Thanku so much sir.. Wonderful project. All things worked in 3hours

    • @abdengineering8226
      @abdengineering8226 Před 3 lety

      amazing , can you tell me what is the version of tensorflow that you use it?

  • @swapnadeepsarkar5850
    @swapnadeepsarkar5850 Před 4 lety +13

    It was really helpful, can u make a tutorial on face recognition using one shot learning??

    • @BalajiSrinivasan25
      @BalajiSrinivasan25  Před 4 lety +5

      Sure, will do it!

    • @swapnadeepsarkar5850
      @swapnadeepsarkar5850 Před 4 lety +3

      @@BalajiSrinivasan25 Thank u sir, It will be really helpful as there's no video on practical one shot learning and triplet loss in practice for face recognition...

    • @sathyacris1399
      @sathyacris1399 Před 3 lety

      @@cricketlovers3286 keras is part of tensorflow.

    • @snvlogs7901
      @snvlogs7901 Před 3 lety

      @@BalajiSrinivasan25 sir can you create a code for live face mask

    • @KHM95
      @KHM95 Před 3 lety

      Here's a paid course for this: It's amazing
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

  • @ajayjoshi_aj
    @ajayjoshi_aj Před 3 lety +10

    hello sir, can u mention your PC specs. in detail for ram, cpu and gpu etc. and please tell us in next video that how to use GPU while training model

    • @WanuX
      @WanuX Před 2 lety

      from tensorflow

    • @shivangichandrajain4380
      @shivangichandrajain4380 Před 2 lety

      can u recognise the face if i send u a video ,

    • @aksh2588
      @aksh2588 Před 4 měsíci

      ​@@WanuXbro I got same issue of tensorflow... How can I resolve it

  • @aliffnabil5542
    @aliffnabil5542 Před 2 lety

    bro thanks a lot. i applied your code logic to detect if the eyes are close or not and it works!

  • @farrukhiqbal9415
    @farrukhiqbal9415 Před 3 lety +1

    its really helpful , extremely thanks bro you did a great job

  • @sajjadmuslim6514
    @sajjadmuslim6514 Před 3 lety +8

    wonderful project appreciate if trigger an email when ever a person appears in camera with out mask. is it possible??

    • @mahalakshmi1460
      @mahalakshmi1460 Před 3 lety

      Yep it is possible with basic if else. If the person is not wearing a mask, send a mail. U can refer youtube to see how to send a mail.

    • @____puthiyavidiyal4589
      @____puthiyavidiyal4589 Před 3 lety

      What algorithm is used in this project can u tell???plz

    • @krishnaraj1280
      @krishnaraj1280 Před 3 lety

      Yes it's possible bro

  • @mikhailsloushch5052
    @mikhailsloushch5052 Před 3 lety +3

    Hi! Great job! Why it could detect face only when it's close to the camera? Am I able to get detection when I'm 4-5 meters far?

  • @AtomicFleaHD
    @AtomicFleaHD Před 3 lety

    Lovely explanation. Helped a lot. Thank You

  • @prathibam9859
    @prathibam9859 Před 3 lety

    Thank you so much anna .Really very useful for me such a great video.I got the output correctly.

  • @karimmache4018
    @karimmache4018 Před 3 lety +13

    Great job, nice thank you. I would like to know more files inside face_detector folder: deploy.prototxt and res10_300x300_ssd_iter_140000.caffemodel how you construct them

    • @andraputra9997
      @andraputra9997 Před 3 lety

      Same here

    • @noelthomasbejoy3089
      @noelthomasbejoy3089 Před 3 lety +1

      Downloaded from elsewhere,preexists

    • @binayakpanda5749
      @binayakpanda5749 Před 3 lety

      @@NithishKumar-se9ev how did u open the file?

    • @deepakraj008
      @deepakraj008 Před 3 lety +1

      caffee model is pre-trained deep learning model for face detection made with caffee frameworks like Tensorflow and PyTorch. You can create caffeemodel with that or you can also create with tensorflow.

    • @NithishKumar-se9ev
      @NithishKumar-se9ev Před 3 lety +1

      @@binayakpanda5749 it's on his github link in the desc

  • @uniqueemperor4306
    @uniqueemperor4306 Před 3 lety +26

    WHAT IF SOMEONE HAS BIG BEARDS .??WILL IT BE DETECTED AS MASK??

  • @sruthimolt3870
    @sruthimolt3870 Před 3 lety

    Best tutorial
    💯Working
    Thankyou sir

  • @venkatraj7775
    @venkatraj7775 Před 3 lety

    Good job with simple implementation

  • @kalyanasundaram6368
    @kalyanasundaram6368 Před 3 lety +3

    Some files are like ERROR: Could not find a version that satisfies the requirement opencv-python==4.2.0.*
    ERROR: No matching distribution found for opencv-python==4.2.0.*

    • @sairajpoojari3160
      @sairajpoojari3160 Před 2 lety +1

      ERROR: No matching distribution found for numpy==1.18.2 my error is this can any one help please

    • @ashpakshaikh2417
      @ashpakshaikh2417 Před 2 lety

      Hi i am facing similar error where you able to fix this issue please help if u can

  • @sheezankhan
    @sheezankhan Před 3 lety +6

    Hi Balaji!
    I tried to execute the source code. But getting some errors. Could you please help?

    • @muhiuddinhazari4229
      @muhiuddinhazari4229 Před 3 lety +1

      make sure that you have created a new environment in anaconda and then install the packages given in the video in that environment. You can find tutorials on youtube on how to create envrironment using anaconda prompt

  • @artistry72
    @artistry72 Před 8 měsíci

    Very nice video and simply explained... Many thanks..

  • @sauvagyaranjanbehera9096

    i learnt much more after watching this video

  • @pavithiranb5765
    @pavithiranb5765 Před 3 lety +4

    Simple doubt, WILL IT SHOW IF WE ARE WEARING A TRANSPARENT MASK !!!! 😐🔥

  • @geethanjaligajulapalli3189

    when i tried, it is showing that failed to load native tensorflow runtime. what to do now? can you please help me

  • @robertkaramagi6801
    @robertkaramagi6801 Před 3 lety +2

    This is great work.

  • @alifaditya1547
    @alifaditya1547 Před 3 lety

    Thankyou sir, your explanation so easy to understand, the code flow also looks clear

    • @BruceWayne-xq7bb
      @BruceWayne-xq7bb Před 2 lety

      Traceback (most recent call last):
      File "c:\Users\user\Documents\object detect\Face-Mask-Detection\train.py", line 38, in
      path=os.path.join(DR, CATEGORIES)
      File "C:\Users\user\anaconda3\envs\tensorflow_env\lib
      tpath.py", line 117, in join
      genericpath._check_arg_types('join', path, *paths)
      File "C:\Users\user\anaconda3\envs\tensorflow_env\lib\genericpath.py", line 152, in _check_arg_types
      raise TypeError(f'{funcname}() argument must be str, bytes, or '
      TypeError: join() argument must be str, bytes, or os.PathLike object, not 'list'
      getting this error

  • @himanshuranjan8634
    @himanshuranjan8634 Před 3 lety +7

    Can i use your project as my college project?

  • @sushmithareddy7564
    @sushmithareddy7564 Před 3 lety +5

    Could I get the documentation on this project

  • @pranjalprasad7544
    @pranjalprasad7544 Před 2 lety

    Thank you So much! Great tutorial :)

  • @rushikesh.mahajan
    @rushikesh.mahajan Před 3 lety

    amazing tutorial ... to make it more acurate i ncreased the dataset

  • @yashjha2661
    @yashjha2661 Před 3 lety +6

    And here I am not able to write hello world program😂

  • @p.jayaraman2742
    @p.jayaraman2742 Před 3 lety

    Really Nice explanation 👌 Thank you 😊

  • @swagnbconnects
    @swagnbconnects Před 4 lety +1

    Amazing Video. Very well designed and explained in detail step by step.

  • @sumitpandey13
    @sumitpandey13 Před 2 lety

    Great video, explanation and code!
    Thank you so much!

  • @akhilsettipally7398
    @akhilsettipally7398 Před 3 lety

    Explained it very well..👌👍👏

  • @anirudhsowrirajan3768
    @anirudhsowrirajan3768 Před 3 lety

    thanks balaji! this helps me a lot!

  • @yerraharibaba4241
    @yerraharibaba4241 Před 4 lety +2

    Thank you sir 🔥
    Crystal clear explanation 💥

  • @yashbhalala4972
    @yashbhalala4972 Před 3 lety

    Great learning experience with you

  • @labadepradip7734
    @labadepradip7734 Před 3 lety

    The great work sir,
    Make it more videos.

  • @devyanshibohra6518
    @devyanshibohra6518 Před 3 lety

    thanks a lot for making a super amazing video........its very useful

  • @mafone4885
    @mafone4885 Před 3 lety

    Thank u very much. So amazing!

  • @SANJAY2ROKA
    @SANJAY2ROKA Před 3 lety

    I have subscrived to your channel wonderful explanation.................................to all topics...... please upload more video in deep learning image classification object detection in image and video behaviour detection..................Good Video Sir....................

  • @bhavanireddy4512
    @bhavanireddy4512 Před 3 lety

    Tq so much it helped a lot to my major project

  • @mohammedsohilshaikh6831

    Really amazing explanation.

  • @aakarshitsrivastava6888

    Thank you so much Sir this video helped me a lot

  • @ssdeepika1403
    @ssdeepika1403 Před 2 lety

    Thankyou, Very helpful!

  • @sentinelhz6915
    @sentinelhz6915 Před 3 lety

    Amazing work bro !!!...me becoming follower

  • @editingandtutorials
    @editingandtutorials Před rokem

    man youre saviour thank u bro

  • @younusaliakash
    @younusaliakash Před 3 lety

    Just Awesome brother.

  • @senduranravikumar3554
    @senduranravikumar3554 Před 3 lety

    Superb anna.. romba helpful ah irunthichu 😍

  • @saravindsamy4228
    @saravindsamy4228 Před 3 lety

    Thank you so much bro for your idea to share with us..

  • @projuktimoitra6246
    @projuktimoitra6246 Před 3 lety

    Worked for me ..Thank you

  • @nikhilakalwadi2860
    @nikhilakalwadi2860 Před 3 lety

    Great Job!! learnt quite a lot from this video, and will play around with the code for sure

    • @ps6846
      @ps6846 Před 3 lety

      can u pls tell me what is (1,1,200,7) showing on cmd after running detect_mask_video file in the last?

  • @RSElectronics3901
    @RSElectronics3901 Před 3 lety

    finally i got success for making Mask Detection
    Thanks a lot Sir

    • @thavanamsravani5961
      @thavanamsravani5961 Před 3 lety

      Hi can u share me documentation for face mask detection

    • @phuahkinyin766
      @phuahkinyin766 Před 2 lety

      hi can u share me the code and dataset? very appreciate it

  • @fahamarafi2781
    @fahamarafi2781 Před 4 lety +1

    Hi Balaji Thanks, just wanted to get your feedback I want to run this facemask use case on Intel servers using Linux OS with IP Camera can you give your feedback on this how can I proceed with this setup

  • @Stevekevlar_
    @Stevekevlar_ Před 3 lety

    the video is very informative thank you

  • @rakshithrajpulluri3515

    Great video ....thanks🙏🙏

  • @nishajshetty6191
    @nishajshetty6191 Před 3 lety

    Very helpful ☺️👍... Keep going

  • @shwetanshusood9450
    @shwetanshusood9450 Před 3 lety +1

    Thank u so much for help. Past few days i was having many errors. And now after seeing this. All my doubts are cleared❤❤

  • @Wetu_Vexo
    @Wetu_Vexo Před 2 lety

    thank you for your video!
    Hope you have a nice day sir !

  • @bhaumikchaudhari1495
    @bhaumikchaudhari1495 Před 3 lety

    Best explanation..Thank you🙏🏻🙏🏻

  • @Display670
    @Display670 Před 3 lety

    Super amazing project bro

  • @opalparich.1047
    @opalparich.1047 Před 3 lety

    Thank you so much for your sharing. This is very helpful.

  • @bibibiti1098
    @bibibiti1098 Před 2 lety

    Thank you so much bro 👍🏻 keep going 🌻🌻🌻🌻🌻🌻🌻🪐🪐🪐🪐🪐great job 😊

  • @merveozdas1193
    @merveozdas1193 Před 2 lety

    What can I use instead of labelbinarizer for categorical values? If I use labelencoder do I need to use like that? I mean do I need to write just lableencoder instead of labelbinarizer?

  • @ankitha423
    @ankitha423 Před 2 lety

    Worked👍..
    Thanks..

  • @sushmithareddy7564
    @sushmithareddy7564 Před 3 lety +1

    superb work

  • @skyskitchen7872
    @skyskitchen7872 Před 2 lety

    CZcams never rewards valuable content

  • @ananyagm1317
    @ananyagm1317 Před 3 měsíci

    Thank you so much sir 🙏

  • @mahalakshmin2394
    @mahalakshmin2394 Před 2 lety

    Thank you very much sir

  • @devinanugrahpapalangi3899

    Sorry i want to ask something about the dataset. From your video, you saved the dataset in your local dir and called in the code. For my case, can i use a cloud service such as AWS, Firebase, etc for storing the dataset? If possible can you show me how?

  • @abhijitdas8617
    @abhijitdas8617 Před 3 lety +2

    Very nice explanation! Did you resize all the images used? If I want to add more images to the dataset do I need to resize or pre process them?

    • @rishiAura
      @rishiAura Před rokem

      Bro can you tell me algo used in this to detect the mask and face without mask......?

    • @demonlegit9012
      @demonlegit9012 Před rokem +1

      @@rishiAura Adam optimization algorithm

  • @ankitkelwadkar22
    @ankitkelwadkar22 Před 3 lety +2

    Try to install pakage for tensorflow>=1.15.2 but got error no version satisfy please suggest

  • @rudrakshmahajan7897
    @rudrakshmahajan7897 Před 3 lety

    great job man

  • @003abhinashkumarjha8
    @003abhinashkumarjha8 Před 2 lety

    hats off to you brother