International Journal of Engineering and Applied Physics (IJEAP)
Vol. 2, No. 1, January 2022, pp. 339–345 · ISSN: 2737-8071

Face Mask Detection with alert system using Tensorflow, Keras and OpenCV

Bhole Varsha1, Sakshi Tiwari1, Vishal Chaudhari1, Vaishali Patil1
1Dept. of Information Technology, A.C Patil College of Engineering, Navi Mumbai, India

Abstract

As Covid-19 is increasing day by day, it is important to make sure that we should overcome from this. But the question arises here is that how we can overcome from this? like wearing mask, sanitizing ourself, taking necessary precautions and all. Nowadays vaccines are must, do you really think after getting vaccinated you are safe? The answer is no vaccines are to boost up our immunity level, so that if you get infected it will be not much harmful to you, so here we have implemented an application Face mask detection with alert system where we can get to know that whether the person is wearing a mask or not. If person is not wearing a mask in the premises, campus a beep sound is generated to catch that person. In this application a screen is displayed which detects the human face with or without mask and shows the percentage score of the mask worn. This application will be useful for the areas were number of peoples are more like hotels, airport, schools and colleges. Here first the model is trained on a real-world dataset having with or without face mask and then we have trained our model with live video streaming. The accuracy is obtained by increasing and decreasing the epoch value.

Keywords: Covid 19; Keras; MobileNetV2; Open CV; Tensorflow

Received: Jun 16, 2021 · Revised: Aug 27, 2021 · Accepted: Oct 20, 2021 · Published: 2022-01-24

Corresponding author: Vishal Chaudhari, [email protected]

This is an open access article under the CC BY 4.0 license.

How to cite: Bhole Varsha, Sakshi Tiwari, Vishal Chaudhari, Vaishali Patil, "Face Mask Detection with alert system using Tensorflow, Keras and OpenCV," International Journal of Engineering and Applied Physics, vol. 2, no. 1, pp. 339–345, 2022.

1. INTRODUCTION

From past 2 years the deadly Covid 19 disease has spread in such a way that the whole nation is abruptly affected in terms of education, business, economy, etc. As per the data given by WHO there were approximately Covid cases, death upto and recovery upto . As we know the vaccines like covishield and covaxin are available for different ages to boost the immunity level of a particular person so that the death rate should be in control. But the question arises here is that is vaccine is end of covid? Surely no because as mentioned above that it is to boost up our immunity level. It means that after taking the vaccine we should follow the mandatory rules established by government like wearing mask, sanitizing, social distancing, etc.

In this project we are training our model in such a way that it should recognize or find the person without mask in the premises, schools, colleges, office, etc. We are training our model by real world dataset and then by live video streaming. In this way we will be able to identify the person not wearing a mask. So, to take care of this problem we don’t need any guard or person who keeps a watch on people. This system aims at classifying whether a person is wearing a mask or not by taking input from Images and Real time Video streaming. If person is weared a mask then it will show a green frame around the face of that person and give the signal “Mask with percentage” and if person is not wearing a mask, then it will show a red frame around the faces of that person and give the signal “No Mask with percentage”. The Face Mask Detection model is based on computer vision and deep learning. The model is integration between deep learning and classical machine learning techniques with OpenCV, tensor flow and Keras.

Literature review that has been done on Face Mask Detection

LITERATURE REVIEW 1

Paper Name: Covid-19 Face Mask Detection Using TensorFlow, Keras and OpenCV.

Authors Name: Arjya Das, Mohammad Wasif Ansari, Rohini Basak.

Year of Publication: 2020

Content of the paper: Their proposed methodology consists of a cascade classifier and a pre-trained CNN which contains two 2D convolution layers connected to layers of dense neurons [1]. In this paper they have used two steps Data preprocessing and Training Model. In Data preprocessing they have done Data visualization, Conversion of RGB image into gray image and image reshaping. In the second part Training Model they have builded the model using CNN architecture and splitted the data and trained the CNN model.

LITERATURE REVIEW 2

Paper Name: Face mask detection using deep learning: An approach to reduce risk of Coronavirus spread Authors Name: Shilpa Sethi, Mamta Kathuria, Trilok Kaushik.

Year of Publication: 2021

Content of the paper: In their methodology they have mentioned three main components: Backbone, Neck and Head. Where backbone corresponds to a baseline convolutional neural network capable of extracting information from images and converting them to a feature map, the Neck contains all those pre-processing tasks that are needed before the actual classification of images and Head stands for identity detector or predictor that can achieve the desired objective of deep-learning neural network [2].

LITERATURE REVIEW 3

Paper Name: SSDMNV2: A real time DNN-based face mask detection system using single shot multibox detector and MobileNetV2.

Authors Name: Preeti Nagrath, Rachna Jain, Agam Madan, Rohan Arora, Piyush Kataria, Jude Hemanth. Year of Publication: 2021

Content of the paper: In their paper they have an accurate face detection model is required to detect faces, so that the SSDMNV2 model can classify whether the person is wearing a mask or not. The task in this paper is to raise the accuracy of mask detection without being too resource-heavy. For doing this task, the DNN module was used from OpenCV, which contains a ‘Single Shot Multibox Detector’ (SSD)object detection model with ResNet-10 as its backbone architecture [3].

2. RESEARCH METHOD

The proposed system focuses on how to identify the person on image/video stream wearing face mask or not with the help of computer vision and deep learning algorithm by using Open CV, Tensorflow, Keras, Pytorch, Numpy, MobileNetV2 and Pygame where,

Open CV: It is an open-source library for machine learning used to process images, videos to identify faces. Tensorflow: It is an open-source artificial intelligence library, using data flow graphs to build models. Keras: It is a free open-source python library used for developing and evaluating deep learning models. Pytorch: It is an open-source machine learning library used in deep learning application.

Numpy: It is used to do mathematical operations on array

MobileNetV2: It is used to extract the data fast and easily.

Pygame: This library is used to create a peep sound if person is not wearing a mask

Algorithm for the model

Step 1: Create Dataset (Arrays).

Step 2: Create python file Train Mask Detector and import libraries.

Step 3: Append images to data List.

Step 4: Go through Path and Create Loops for Images with and without Mask.

Step 5: Use Keras and MobilenetV2 for preprocessing.

Step 6: Use Label by arrays method which includes sklearn module.

Step 7: For deep learning Model Convert into numpy Arrays.

Step 8: Track the Accuracy Matrix to save generated model.

Step 9: Plot the accuracy using matplotlib. Run and check the Accuracy.

Step 10: Train the model by images/Live Webcam to check whether the person is wearing a mask or not. Step 11: A beep sound is generated whether the person is wearing a mask or not.

The below diagram shows the proposed system of the model.

Figure 1. Proposed system diagram

First it captures the image using webcam and then face mask detection model is applied on that face if person is not wearing a mask the notification is displayed on the screen that not wearing a mask with an accurate percentage with a peep sound which is generated by using pygame library and if the person has weared a mask a notification is displayed that wearing mask with an accurate percentage. It also shows that if a person is wearing a mask but not in a proper way i.e below the nose then also it will show “No mask with percentage”. We have created the Dataset of almost 4000 images of with and without mask.

Figure 2. Dataset images without Mask

Figure 3. Dataset Images with mask

3. RESULTS AND DISCUSSIONS

Successfully able to install all libraries required for the project. Gathered around 4000 datasets having with mask and without mask images. Figure 4. shows the model accuracy of the project having precision, recall, f1-score and support. Figure 5. describes the accuracy level of 98% in the form of graph and figure 6. describes the accuracy level of 99.99% when epoch value is 20. Here we have got a highest accuracy for the face mask detection.

Figure 4. Model Accuracy

Figure 5. Training Loss and Accuracy 1

Figure 6. Training Loss and Accuracy 2

Figure 7. Output

As described in the introduction that the person with no mask will be shown in red frame with percentage and the person with mask will be shown in green frame with percentage and the Figure 7. describes the same. Image A shows the output as “No Mask: 100%”, Image B shows that “Mask: 100%”, Image C shows the output as “No Mask: 81.30%” and Image D shows that “Mask: 99.97%”.

4. CONCLUSION

This paper briefly explains the Face mask detection using Training and Dataset model using various Libraries of Python. The accuracy of the model had been achieved to a higher level i.e 99.99%. We can prevent peoples from Virus Transmission through this System. So instead of standing and guarding the people, we can do this digitally!!! and by using pygame library we can punish that person without mask because by using this library we will be able to generate a beep sound through our system. In future it will be useful for other viral diseases. It will also become a compulsorily deployed model for the places were gathering of people is more. This model will serve the nation to become a COVID-19 free nation. By this model one can again experience a classroom, office, chill environment i.e only offline mode. As we have gained the maximum accuracy and detected that if a person is wearing the mask properly or not, the thing to improve in this paper is to identify the person is wearing a virus prone mask like surgical mask, N95 mask or not and push the alert message to the higher authority to catch the person via mails, message, etc.

ACKNOWLEDGEMENTS

Our team members are sincerely thankful to all those people who have been giving us any kind of assistance in the making of this project.

We would hereby, make most of the opportunity by expressing our sincerest thanks to all my faculties whose teachings gave us conceptual understanding and clarity of comprehension, which ultimately made our job easy. Credit also goes to all my friends whose encouragement kept us in good stead. Their continuous support has given me the strength and confidence to complete the project without any difficulty.

We would like to thank our teacher V.Y bhole and Shaila Pawar and our principal Dr V.N Pawar for their support and guidance. Without them it would not have possible to make this huge project.

References

  1. A. Das, M. Wasif Ansari, and R. Basak, "Covid-19 face mask detection using TensorFlow, Keras and OpenCV," in Proc. IEEE 17th India Council Int. Conf. (INDICON), 2020, pp. 1–5, doi: 10.1109/INDICON49873.2020.9342585.
  2. S. Sethi, M. Kathuria, and T. Kaushik, "Face mask detection using deep learning: An approach to reduce risk of coronavirus spread," J. Biomed. Inform., vol. 120, Art. no. 103848, 2021, doi: 10.1016/j.jbi.2021.103848.
  3. P. Nagrath, R. Jain, A. Madan, R. Arora, P. Kataria, and J. Hemanth, "SSDMNV2: A real time DNN-based face mask detection system using single shot multibox detector and MobileNetV2," Sustain. Cities Soc., vol. 66, Art. no. 102692, 2021, doi: 10.1016/j.scs.2020.102692.
  4. K. Suresh, M. Palangappa, and S. Bhuvan, "Face mask detection by using optimistic convolutional neural network," in Proc. 6th Int. Conf. Inventive Computation Technologies (ICICT), 2021, pp. 1084–1089, doi: 10.1109/ICICT50816.2021.9358653.
  5. A. Chavda, J. Dsouza, S. Badgujar, and A. Damani, "Multi-stage CNN architecture for face mask detection," in Proc. 6th Int. Conf. Convergence in Technology (I2CT), 2021, pp. 1–8.
  6. S. Balaji, B. Balamurugan, T. Ananth Kumar, R. Rajmohan, and P. Praveen Kumar, "A brief survey on AI based face mask detection system for public places," Irish Interdiscip. J. Sci. Res. (IIJSR), 2021.
  7. M. Loey, G. Manogaran, M. H. N. Taha, and N. E. M. Khalifa, "Fighting against COVID-19: A novel deep learning model based on YOLO-v2 with ResNet-50 for medical face mask detection," Sustain. Cities Soc., vol. 65, Art. no. 102600, 2021.
  8. M. Grassi and M. Faundez-Zanuy, "Face recognition with facial mask application and neural networks," in Computational and Ambient Intelligence (IWANN 2007), F. Sandoval, A. Prieto, J. Cabestany, and M. Graña, Eds., Lecture Notes in Computer Science, vol. 4507. Berlin, Heidelberg: Springer, 2007, doi: 10.1007/978-3-540-73007-1_85.
  9. Y. Chen et al., "Face mask assistant: Detection of face mask service stage based on mobile phone," IEEE Sensors J., vol. 21, no. 9, pp. 11084–11093, 2021.
  10. S. Pooja and S. Preeti, "Face mask detection using AI," in Predictive and Preventive Measures for Covid-19 Pandemic. Singapore: Springer, 2021, pp. 293–305.
  11. S. Yadav, "Deep learning based safe social distancing and face mask detection in public areas for COVID-19 safety guidelines adherence," Int. J. Res. Appl. Sci. Eng. Technol., vol. 8, no. 7, pp. 1368–1375, 2020.
  12. M. Jiang, X. Fan, and H. Yan, "RetinaMask: A face mask detector," 2020, arXiv:2005.03950.
  13. G. J. Chowdary, N. S. Punn, S. K. Sonbhadra, and S. Agarwal, "Face mask detection using transfer learning of InceptionV3," in Proc. Int. Conf. Big Data Analytics, Cham: Springer, Dec. 2020, pp. 81–90.
  14. I. B. Venkateswarlu, J. Kakarla, and S. Prakash, "Face mask detection using MobileNet and global pooling block," in Proc. IEEE 4th Conf. Information & Communication Technology (CICT), Dec. 2020, pp. 1–5.
  15. H. Adusumalli, D. Kalyani, R. K. Sri, M. Pratapteja, and P. P. Rao, "Face mask detection using OpenCV," in Proc. 3rd Int. Conf. Intelligent Communication Technologies and Virtual Mobile Networks (ICICV), Feb. 2021, pp. 1304–1309.
  16. C. M. A. K. Basha, B. N. Pravallika, and E. B. Shankar, "An efficient face mask detector with PyTorch and deep learning," EAI Endorsed Trans. Pervasive Health Technol., vol. 7, no. 25, Art. no. e4, 2021.
  17. A. Dumala, A. Papasani, and S. Vikkurty, "COVID-19 face mask live detection using OpenCV," in Smart Computing Techniques and Applications. Singapore: Springer, 2021, pp. 347–352.
  18. S. Asif, Y. Wenhui, Y. Tao, S. Jinhai, and K. Amjad, "Real time face mask detection system using transfer learning with machine learning method in the era of Covid-19 pandemic," in Proc. 4th Int. Conf. Artificial Intelligence and Big Data (ICAIBD), May 2021, pp. 70–75.
  19. B. U. Mata, "Face mask detection using convolutional neural network," J. Nat. Remedies, vol. 21, no. 12(1), pp. 14–19, 2021.
  20. R. Nayak and N. Manohar, "Computer-vision based face mask detection using CNN," in Proc. 6th Int. Conf. Communication and Electronics Systems (ICCES), Jul. 2021, pp. 1780–1786.
  21. S. M. Azzam, K. Sriram, and M. J. Lavanya, "Face mask detection using deep learning."
  22. A. Nowrin, S. Afroz, M. S. Rahman, I. Mahmud, and Y. Z. Cho, "Comprehensive review on facemask detection techniques in the context of Covid-19," IEEE Access, 2021.
  23. S. R. Rudraraju, N. K. Suryadevara, and A. Negi, "Face mask detection at the fog computing gateway," in Proc. 15th Conf. Computer Science and Information Systems (FedCSIS), Sep. 2020, pp. 521–524.
  24. C. M. A. K. Basha, B. N. Pravallika, and E. B. Shankar, "An efficient face mask detector with PyTorch and deep learning," EAI Endorsed Trans. Pervasive Health Technol., vol. 7, no. 25, Art. no. e4, 2021.
  25. G. Niu and Q. Chen, "Learning a video frame-based face detection system for security fields," J. Vis. Commun. Image Represent., vol. 55, pp. 457–463, 2018.

Biographies of Authors

BIOGRAPHIES OF AUTHORS

degree from Mumbai University. She has 14 years of teaching experience. She is the member of Indian Society of Technical education (ISTE) and Computer Science of India (CSI). She has published 4 National and 2 International Conference papers. Her research interests are Image processing, Soft Computing, Big Data Analytics, Cloud Computing

and Internet of Things (IOT).

Email- [email protected]

Sakshi Tiwari is currently a student of A.C Patil College of Engineering, Kharghar. She is

Sakshi Tiwari is currently a student of A.C Patil College of Engineering, Kharghar. She is pursuing her fourth year IT engineering. She had worked on many projects like IOT based home automation, Travelling Website using HTML, CSS, PHP and IOT based gas leakage detection.

She knows the language like HTML, CSS, PHP, JAVA, C, MYSQL, PYTHON.

Email- [email protected]

Vishal Chaudhari is currently a student of A.C Patil College of Engineering, Kharghar. He is pursuing his fourth year IT engineering. He had worked on many projects like IOT based home automation, Travelling Website using HTML, CSS, PHP and IOT based gas leakage detection. He knows the language like HTML, CSS, PHP, JAVA, C++, MYSQL, PYTHON, MACHINE

LEARNING.

Email- [email protected]

Vaishali Patil is currently a student of A.C Patil College of Engineering, Kharghar. She is

Vaishali Patil is currently a student of A.C Patil College of Engineering, Kharghar. She is pursuing her fourth year IT engineering. She had worked on many projects like IOT based home automation, Travelling Website using HTML, CSS, PHP and IOT based gas leakage detection.

She knows the language like PYTHON, HTML, CSS, C, C++, JAVA.

Email- [email protected]