{"id":19581272,"url":"https://github.com/farhansadaf/face-mask-detection","last_synced_at":"2025-04-27T09:33:10.164Z","repository":{"id":218261546,"uuid":"289722763","full_name":"FarhanSadaf/face-mask-detection","owner":"FarhanSadaf","description":"Real-time face mask detection.","archived":false,"fork":false,"pushed_at":"2021-01-31T14:22:55.000Z","size":3210,"stargazers_count":15,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-01-20T20:23:35.004Z","etag":null,"topics":["computer-vision","haarcascade-frontalface","keras","mtcnn-face-detection"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FarhanSadaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-08-23T16:19:56.000Z","updated_at":"2024-01-20T20:23:37.337Z","dependencies_parsed_at":"2024-01-20T20:23:37.143Z","dependency_job_id":"d29b57c8-483c-4ad1-95c5-524b128fae81","html_url":"https://github.com/FarhanSadaf/face-mask-detection","commit_stats":null,"previous_names":["farhansadaf/face-mask-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarhanSadaf%2Fface-mask-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarhanSadaf%2Fface-mask-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarhanSadaf%2Fface-mask-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarhanSadaf%2Fface-mask-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FarhanSadaf","download_url":"https://codeload.github.com/FarhanSadaf/face-mask-detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224067688,"owners_count":17250237,"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":["computer-vision","haarcascade-frontalface","keras","mtcnn-face-detection"],"created_at":"2024-11-11T07:34:40.387Z","updated_at":"2024-11-11T07:34:41.419Z","avatar_url":"https://github.com/FarhanSadaf.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real-time Face Mask Detection\n\n## Overview\nFace masks help reduce the transmission of \u003ca href=\"https://en.wikipedia.org/wiki/Severe_acute_respiratory_syndrome_coronavirus_2\"\u003eSARS-CoV-2\u003c/a\u003e by interfering with the spread of virus-laden droplets ejected from the nose and mouth. \nWearing face mask is one of the precautionary steps an individual can take in order to lessen the spread of \u003ca href=\"https://en.wikipedia.org/wiki/Coronavirus_disease_2019\"\u003eCOVID-19\u003c/a\u003e.\nIn this simple project, a video camera detects if an individual is wearing a face mask or not in real-time.\n\u003cbr/\u003eThe detection steps looks somewhat like this:\n\u003cimg src=\"images/overview.png\" /\u003e\n\n## Quickstart the project\n1. Download the code in `ZIP` or open with `GitHub Desktop` or `git clone https://github.com/FarhanSadaf/face-mask-detection.git`. If you face issues downloading weight file, you can download from this \u003ca href=\"https://drive.google.com/file/d/16B5N0LT5YGlH6MPnmsoF-9ri0MhO3bNv/view\"\u003egoogle drive link\u003c/a\u003e.\n2. Install required python dependencies into your python environment / virtual environment using `pip install -r requirements.txt`.\n3. Run `script-1.py` for real-time detection using webcam. If detection isn't to your liking, try running `script-2.py`.\n\n## Dataset\nThe dataset used to train the face-mask detection model taken from \u003ca href=\"https://www.kaggle.com/andrewmvd/face-mask-detection\"\u003ehere\u003c/a\u003e.\n\nThis dataset contains 853 images belonging to the 3 classes, as well as their bounding boxes in the PASCAL VOC format.\nThe classes are:\n- With mask\n- Without mask\n- Mask worn incorrectly\n\n\u003cimg src=\"images/dataset-value-counts.png\" /\u003e\n\nThough the dataset is pretty imbalanced with most of the data belonging to `With mask` class, it works pertty well detecting `With mask` and `Without mask` classes.\nBut more data for `Mask worn incorrectly` class is needed in order to detect this class properly.\n\n## Workflow\n1. \u003cb\u003e\u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/1_data-preprocessing.ipynb\"\u003eData preprocessing\u003c/a\u003e\u003c/b\u003e : \nAll images have their bounding boxes in the PASCAL VOC format and their info saved in `XML` format in `annotaions` directory. \nOnly the region bounded by bounding box taken as input and their respective labels taken as output.\n\n2. \u003cb\u003e\u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/2_training-face-mask-model.ipynb\"\u003eTraining mask detector model\u003c/a\u003e\u003c/b\u003e :\nTransfer learning was used to train the inputs. The classifier model was built with \u003ca href=\"https://www.tensorflow.org/api_docs/python/tf/keras/applications/InceptionV3\"\u003eInceptionV3\u003c/a\u003e neural network architecture.\nAfter training for 20 epochs, accuracy on test set was 96.81%.\n\n3. \u003cb\u003e\u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/3.2_detecting-mask-w-mtcnn.ipynb\"\u003eDetecting face mask \u003c/a\u003e\u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/3.1_detecting-mask-w-haarcascade.ipynb\"\u003ein real-time\u003c/a\u003e\u003c/b\u003e :\nFirst task was to detect faces from each frame of the video. \nAt first I used \u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/3.1_detecting-mask-w-haarcascade.ipynb\"\u003eHaarcascade classifer\u003c/a\u003e from OpenCV for face detection. Average FPS I got while running on my machine was around 16. \nBut face detection wasn't that accurate. This classifer struggled detecting faces with mask. In low-light condition it struggled the most.\n\u003cbr/\u003eThen I tried \u003ca href=\"https://github.com/FarhanSadaf/face-mask-detection/blob/master/3.2_detecting-mask-w-mtcnn.ipynb\"\u003eMTCNN\u003c/a\u003e for face detection. \nThis algorithm performed great detecting faces, even in the low light. But while running on my machine, the average FPS I got was about 1.4. \nWhich is pretty slow comparing with haarcascade classifier. \n\n## Results\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eInput\u003c/th\u003e\n\u003cth\u003eOutput\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg src=\"images/test.jpg\"/\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cimg src=\"images/test-result.png\"/\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Links and References\n- Face Mask Detection dataset: https://www.kaggle.com/andrewmvd/face-mask-detection\n- InceptionV3: https://www.tensorflow.org/api_docs/python/tf/keras/applications/InceptionV3\n- Face Detection using Haar Cascades: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html\n- How to Perform Face Detection with Deep Learning: https://machinelearningmastery.com/how-to-perform-face-detection-with-classical-and-deep-learning-methods-in-python-with-keras/\n- GitHub MTCNN: https://github.com/ipazc/mtcnn\n\n## Licensing\nThe code in this project is licensed under [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarhansadaf%2Fface-mask-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarhansadaf%2Fface-mask-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarhansadaf%2Fface-mask-detection/lists"}