TechieYan Technologies

Face mask recognition

Abstract

In this project of face mask recognition, we will be using OpenCV to check whether the people are wearing the mask or not wearing the mask. For performing this analysis a web cam is needed to track the human faces. This project uses image dataset which have the human faces with and without mask the model is trained on the image dataset and the prediction is done in real time.

haarcascade_frontalface_default.xml:

haarcascade_frontalface_default.xml is a face detection algorithm which can easily identify the human face from an image or a video this is existing prior to the Deep learning became famous.

Face mask recognition result

Code Description & Execution

How to Execute?

So, before execution we have some prerequisites that we need to download or install i.e., anaconda environment, python and a code editor. Anaconda: Anaconda is like a package of libraries and offers a great deal of information which allows a data engineer to create multiple environments and install required libraries easy and neat.

Download link:

https://www.anaconda.com/

Python: Python is a most popular interpreter programming language, which is used in almost every field. Its syntax is very similar to English language and even children and learning it nowadays, due to its readability and easy syntax and large community of users to help you whenever you face any issues.

Download link:

https://www.python.org/downloads/

Code editor: Code editor is like a notepad for a programming language which allows user to write, run and execute program which we have written. Along with these some code editors also allows us to debug, which usually allows users to execute the code line by line and allows them to see where and how to solve the errors. But I personally feel visual code is very good to work with any programming language and makes a great deal of attachment with user.

Download links:

How to Execute?

Note: Make sure you have added path while installing the software’s.

Install the prerequisites mentioned above.

Step1

Open anaconda prompt and create a new environment. To create an environment use the commands given below. Replace env_name by the name of environment you want to give.

  • conda create -n “env_name”
  • conda activate “env_name”

Step2

Set up jupyter notebook for your environment

  • conda install –c conda-forge jupyterlab
  • conda install –c anaconda ipython

Step3

Install necessary libraries from requirements.txt file provided.

face recognition file

Go to the directory where your requirement.txt file is present.

  • cd D:\Exicuted Projects\Face-Mask-Detection-master
face recognition code
  • Run command  pip install -r requirements.txt or conda install requirements.txt

Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually. All the required files will be downloaded after you run it. I got requirement already satisfied as I already have them installed.

face mask recognition code

Step4

To run the code, type “python filename.extension” in our case python detect_mask_video.py 

face recognition execution

About the dataset:

The dataset used contains total of 3835 images of which 1916 images have human faces with mask and 119 human faces without mask.

Results

Face mask recognition result
face recognition result 2

Issues Faced

  1. Check adequate light source when in front of camera for accurate results.
  2. If you still face any problems in executing the face mask recognition, please contact us.

Click Here To Download This Code And Associated File.

 

+91 7075575787