face-mask
face-mask copied to clipboard
The Face Mask Detection script is a real-time application that utilizes deep learning techniques to identify whether a person in a webcam feed is wearing a face mask or not.
Face Mask Detection using TensorFlow and OpenCV
This is a Python script for real-time face mask detection using a pre-trained MobileNetV2 model with TensorFlow and OpenCV. It can process live video from a webcam and classify faces as wearing a mask or not wearing a mask.
Requirements
Before running the code, make sure you have the following dependencies installed:
- TensorFlow
- OpenCV
- imutils
- NumPy
You can install these dependencies using pip
:
pip install tensorflow opencv-python imutils numpy
Usage
-
Clone the repository or download the code files to your local machine.
-
Download the pre-trained face detection model and save it in the
face_detector
directory. You can get the model files from the OpenCV GitHub repository: -
Download the pre-trained face mask detection model (
mask_detector.model
) and place it in the same directory as the script. -
Run the script:
python face_mask_detection.py
- A window will open, showing the webcam feed with face mask predictions. Press 'q' to quit the application.
How It Works
-
The script uses the MobileNetV2 model for face mask detection. It first detects faces in each frame using the pre-trained face detection model.
-
If a face is detected, it extracts the face region, pre-processes it, and passes it through the face mask detection model to classify whether the person is wearing a mask or not.
-
The result is displayed on the video feed, with bounding boxes and labels.
License
This project is licensed under the MIT License.