{"id":23150346,"url":"https://github.com/sofialtamsh/face-mask_detection","last_synced_at":"2025-07-06T13:02:52.211Z","repository":{"id":256536608,"uuid":"855680255","full_name":"sofialtamsh/Face-Mask_Detection","owner":"sofialtamsh","description":"This project is a deep learning-based face mask detection system using Keras and TensorFlow. It employs a CNN classifier with ReLU activation to classify images into two categories: with mask and without mask, enabling real-time mask detection.","archived":false,"fork":false,"pushed_at":"2024-11-23T07:34:26.000Z","size":2491,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T00:29:14.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sofialtamsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-11T09:29:26.000Z","updated_at":"2024-11-23T07:34:29.000Z","dependencies_parsed_at":"2024-09-11T13:55:08.923Z","dependency_job_id":"94099c4a-b300-4840-828f-53e212c770dc","html_url":"https://github.com/sofialtamsh/Face-Mask_Detection","commit_stats":null,"previous_names":["sofialtamsh/face-mask_detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofialtamsh%2FFace-Mask_Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofialtamsh%2FFace-Mask_Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofialtamsh%2FFace-Mask_Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofialtamsh%2FFace-Mask_Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofialtamsh","download_url":"https://codeload.github.com/sofialtamsh/Face-Mask_Detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198413,"owners_count":20900079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T18:17:11.269Z","updated_at":"2025-04-04T14:42:48.461Z","avatar_url":"https://github.com/sofialtamsh.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Face Mask Detection using Keras and TensorFlow 🧑‍⚕️🤖\n\n## Problem Statement 🚨\n\nIn today’s world, ensuring safety and health in public places is crucial. While face masks have become a critical part of protecting ourselves and others, it can be difficult to monitor whether people are wearing them, especially in crowded environments. \n\nThis project solves this problem by leveraging **deep learning** techniques to automatically detect whether individuals are wearing a face mask or not, helping in real-time monitoring for public safety in a variety of settings.\n\n## Why Do We Need This? 💡\n\nFace mask detection systems have become increasingly important as we look for ways to automate and streamline safety protocols. Here’s why this technology is needed:\n\n- **Real-time Monitoring**: Automatically check if people are following mask-wearing protocols in crowded places like malls, public transport, offices, or airports.\n- **Efficiency**: No need for manual supervision, which is time-consuming and often ineffective.\n- **Scalability**: Easily scale up the detection system to handle hundreds or thousands of people with minimal infrastructure.\n- **Cost-effective**: An automated system reduces the cost of human labor and provides instant alerts when someone isn’t wearing a mask.\n\n## Advantages of This Project 🌟\n\n- **Real-Time Detection**: The system uses a trained Convolutional Neural Network (CNN) to detect face masks in real-time.\n- **High Accuracy**: With the help of Keras and TensorFlow, the system can achieve high accuracy in classifying images as \"With Mask\" or \"Without Mask\".\n- **Scalable Solution**: Can be integrated into existing surveillance systems to provide an automated solution for mask detection in crowded spaces.\n- **User-Friendly**: The solution is simple to implement and doesn't require deep technical knowledge to deploy.\n\n## How It Works 🤔\n\n### The Core Mechanism 🔍\n\nAt the heart of this project is a **Convolutional Neural Network (CNN)**, which is a type of deep learning model particularly well-suited for image classification tasks. This model analyzes the image pixels and detects whether an individual is wearing a face mask or not.\n\nHere’s the detailed flow:\n\n### 1. **Data Collection and Preprocessing 📊**\n\nThe first step involves gathering a labeled dataset consisting of images of people with and without masks. The dataset must be preprocessed to make it suitable for training:\n\n- **Resizing** images to a standard size (e.g., 224x224).\n- **Normalizing** pixel values to bring them within a range (usually between 0 and 1).\n- **Data Augmentation** techniques, such as rotation, flipping, or zooming, are applied to increase the diversity of training data and avoid overfitting.\n\n### 2. **Model Building with Keras and TensorFlow 🛠️**\n\nOnce the dataset is prepared, we build the **CNN model** using **Keras** (a high-level neural network API) and **TensorFlow** (the backend framework). \n\nThe architecture of the CNN model consists of several key layers:\n\n- **Convolutional Layers**: These layers apply filters to the image, detecting patterns such as edges, corners, or shapes. This is the most important step in learning image features.\n- **Max Pooling Layers**: These layers help to reduce the spatial dimensions of the image, which reduces computation and helps prevent overfitting.\n- **Fully Connected (Dense) Layers**: These layers take the features detected by the convolutional layers and make final predictions about whether the person in the image is wearing a mask.\n- **Softmax Activation**: A softmax activation function is used in the output layer to classify the image into two categories: “With Mask” or “Without Mask.”\n\n### 3. **Training the Model 🏋️‍♂️**\n\nThe model is trained using the labeled dataset. We use **categorical crossentropy** as the loss function, which is suitable for multi-class classification problems, and the **Adam optimizer** to minimize the loss function and adjust weights during training.\n\nDuring training, the model adjusts its weights based on the error, gradually improving its ability to classify face mask images accurately.\n\n### 4. **Model Evaluation 📈**\n\nAfter training, the model is evaluated on a test dataset to check its performance. Key metrics include:\n\n- **Accuracy**: Percentage of correct predictions (With Mask or Without Mask).\n- **Precision \u0026 Recall**: These metrics are crucial when working with imbalanced datasets, ensuring the model correctly identifies masks without misclassifying.\n\n### 5. **Real-Time Detection 🚶‍♂️**\n\nOnce trained, the model can be deployed for real-time face mask detection. The system uses a webcam or camera feed to continuously capture frames and then passes each frame through the trained model to classify whether the person is wearing a mask.\n\nThe result is displayed on the screen, and alerts can be sent if someone is detected without a mask.\n\n## Why Use Python, TensorFlow, and Keras? 🐍\n\n### **Python**: The Go-To Language for Machine Learning\nPython is a powerful and widely used programming language for machine learning and deep learning projects. It offers a wide range of libraries (like TensorFlow and Keras) and has a large community, making it easy to find support and resources.\n\n### **TensorFlow**: The Backbone for Deep Learning\nTensorFlow is an open-source machine learning framework developed by Google. It’s highly scalable, supports both training and deployment of deep learning models, and has robust support for building and training neural networks.\n\n### **Keras**: Simplifying Deep Learning\nKeras, an easy-to-use interface for building deep learning models, is integrated with TensorFlow. Keras allows us to quickly prototype and experiment with neural network architectures without worrying about the low-level details.\n\n## How to Run the Project 🏃‍♂️\n\nTo run this project, follow these simple steps:\n\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/yourusername/face-mask-detection.git\n   cd face-mask-detection\n\n## How to Run the Project 🏃‍♂️\n\nTo run this project, follow these simple steps:\n\n2. **Install Dependencies**:\nEnsure you have the required libraries installed by running:\n```bash\npip install -r requirements.txt\n```\n\n3. **Prepare the Dataset**:\nPlace the images in the correct folders:\n- `with_mask`: This folder should contain images of individuals wearing face masks.\n- `without_mask`: This folder should contain images of individuals without face masks.\n\n4. **Train the Model**:\nRun the training script:\n```bash\npython train_model.py\n```\n\n5. ### Run Real-Time Detection:\nAfter training, you can run the webcam detection:\n```bash\npython detect_mask.py\n```\n\n## Conclusion 🚀\n\nThis **Face Mask Detection** project is a powerful, deep learning-based solution that leverages the capabilities of **Keras** and **TensorFlow** to automatically detect face masks in real-time. With the growing need for safety and monitoring, this project can be applied in a wide range of environments, offering both efficiency and scalability.\n\nBy utilizing **convolutional neural networks**, **Python**, and modern deep learning frameworks, this system can be deployed in various industries, helping to ensure that health and safety protocols are followed effectively.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofialtamsh%2Fface-mask_detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofialtamsh%2Fface-mask_detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofialtamsh%2Fface-mask_detection/lists"}