{"id":21331419,"url":"https://github.com/tempdata73/mtcnnmaskdetection","last_synced_at":"2025-07-12T10:30:44.483Z","repository":{"id":37662418,"uuid":"262452294","full_name":"tempdata73/MtcnnMaskDetection","owner":"tempdata73","description":"Test the MTCNN face detector for people wearing masks","archived":false,"fork":false,"pushed_at":"2022-12-08T09:51:41.000Z","size":35401,"stargazers_count":5,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-04-05T18:49:43.921Z","etag":null,"topics":["covid-19","face-detection","masks","mtcnn"],"latest_commit_sha":null,"homepage":"","language":"Python","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/tempdata73.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}},"created_at":"2020-05-08T23:56:46.000Z","updated_at":"2022-10-04T07:58:07.000Z","dependencies_parsed_at":"2023-01-25T09:30:39.242Z","dependency_job_id":null,"html_url":"https://github.com/tempdata73/MtcnnMaskDetection","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tempdata73%2FMtcnnMaskDetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tempdata73%2FMtcnnMaskDetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tempdata73%2FMtcnnMaskDetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tempdata73%2FMtcnnMaskDetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tempdata73","download_url":"https://codeload.github.com/tempdata73/MtcnnMaskDetection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225814115,"owners_count":17528290,"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":["covid-19","face-detection","masks","mtcnn"],"created_at":"2024-11-21T22:32:57.792Z","updated_at":"2024-11-21T22:32:58.209Z","avatar_url":"https://github.com/tempdata73.png","language":"Python","readme":"# Case study: MTCNN for mask detection\nThere is a recent surge for wearing masks in public spaces due to the COVID-19 pandemic, which has affected how we go through our everyday lives. Many public services require people to wear masks so as to avoid spreading the virus even more. This is a challenge for face detection mechanisms since the face can be occluded up to the nose, which yields lower confidence intervals for such models. While researchers are trying build new detection models or even retraining them with more difficult examples, I wanted to evaluate how current models perform under these harder scenarios.\n\nThe Multi-task Cascaded Convolutional Networks (MTCNN) designed by Zhang et al. is a three-stage detection model that produces both bounding boxes and facial landmarks. Compared to Viola and Jones face detector, MTCNN has greater recall and precision. I'll make sure to test their detector on the face mask dataset as well, but I think it is safe to say its results will be lower.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"test/results/101d6660a8974050b613dd2e6bd59390.jpg\" alt=\"sample image\" width=\"500\"/\u003e\u003c/p\u003e\n\n## Face tracker\nI also added a face ID tracker which you can use to empirically check out how the MTCNN performs under variable situations where conditions change, such as illumniation and occlusion. The tracker is essentially the same as [PyImageSearch's centroid tracker](https://www.pyimagesearch.com/2018/07/23/simple-object-tracking-with-opencv/), I only did some minor changes.\n\n## Implementation\nUnless you want to verify the results, you're going to find yourself using only *main.py* which has the ID tracker already integrated.\n```console\nfoo@bar:MtcnnMaskDetection$ python main.py camera_id\n```\nFinally, if you do want to run the test as well, cd to the *test* directory and run\n```console\nfoo@bar:MtcnnMaskDetection$ python run_tests.py path/to/labels\n```\n\n## Dataset and test\nThe test images were taken from Kaggle's [Medical Mask Dataset](https://www.kaggle.com/vtech6/medical-masks-dataset), which contains 3000 faces wearing masks and ~700 faces with badly worn masks (or even none at all). The test results didn't take into account people with no masks whatsoever. To the best of my knowledge, **recall is the only available metric** since the groundtruth labels ignore some unmasked faces, which MTCNN may not, so it may seem it has a higher false positive rate.\n\n## Results\nGroundtruth bounding boxes are given in green while predictions are given in red.\n\u003cimg src=\"test/results/Smog-Mask-PM2-5-Carbon-Filter-Face-Masks-Fog-Dust-Air-Cleaner-anti-pollution-Face-Protector.jpg\" alt=\"Easy example\" width=\"350\"/\u003e\n\u003cimg src=\"test/results/AP_20039189423521.jpg\" alt=\"Hard example\" height=\"309\"/\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"test/results/recall.png\" alt=\"recall as function of IoU\" height=\"500\"/\u003e\u003c/p\u003e\n\n## License\nThe code under this repo has an MIT License, so it can be reproduced for private and/or commercial use.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftempdata73%2Fmtcnnmaskdetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftempdata73%2Fmtcnnmaskdetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftempdata73%2Fmtcnnmaskdetection/lists"}