{"id":27998761,"url":"https://github.com/vijayg15/keras-facemask-detection-system","last_synced_at":"2025-05-08T22:54:53.990Z","repository":{"id":245714344,"uuid":"259861424","full_name":"vijayg15/Keras-FaceMask-Detection-System","owner":"vijayg15","description":"Face-mask detection system using YOLOv3 in Keras","archived":false,"fork":false,"pushed_at":"2020-04-30T22:47:58.000Z","size":25508,"stargazers_count":14,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T22:54:47.741Z","etag":null,"topics":["artificial","computer-vision","convolutional-neural-networks","covid19","deep-learning","detection","face-mask","facemask-detection","image-processing","keras","keras-neural-networks","labelimg","machine-learning","neural-networks","object-detection","object-detection-keras","tensorflow","yolov3"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/vijayg15.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":"2020-04-29T07:56:53.000Z","updated_at":"2023-09-27T05:53:26.000Z","dependencies_parsed_at":"2024-06-23T17:05:33.613Z","dependency_job_id":null,"html_url":"https://github.com/vijayg15/Keras-FaceMask-Detection-System","commit_stats":null,"previous_names":["vijayg15/keras-facemask-detection-system"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijayg15%2FKeras-FaceMask-Detection-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijayg15%2FKeras-FaceMask-Detection-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijayg15%2FKeras-FaceMask-Detection-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijayg15%2FKeras-FaceMask-Detection-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vijayg15","download_url":"https://codeload.github.com/vijayg15/Keras-FaceMask-Detection-System/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253160805,"owners_count":21863625,"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":["artificial","computer-vision","convolutional-neural-networks","covid19","deep-learning","detection","face-mask","facemask-detection","image-processing","keras","keras-neural-networks","labelimg","machine-learning","neural-networks","object-detection","object-detection-keras","tensorflow","yolov3"],"created_at":"2025-05-08T22:54:52.258Z","updated_at":"2025-05-08T22:54:53.984Z","avatar_url":"https://github.com/vijayg15.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FaceMask-Detection system using YOLOv3 in Keras\n\nFirst of all, I must mention that this code used in this project originally is not mine. I was inspired by [qqwweee/keras-yolo3](https://github.com/qqwweee/keras-yolo3), he wrote this code to train custom YOLOv3 Keras model.\n\nFew changes are:\n1. To load images for detection, replaced PIL with opencv.\n2. Used the same opencv font for drawing text on detected images.\n3. Wrote seperate detection script for images and videos.\n\n# Dependencies :\n- Python 3.6.10\n- Keras 2.2.4 `conda install keras=2.2.4`\n- Tensorflow 1.15 `conda install tensorflow-gpu=1.15` or `conda install tensorflow`\n- OpenCV-python\n- PIL\n- NumPy\n- Moviepy(for the detection of videos)  `pip install moviepy`\n- LabelImg\n\n\nNote that keras and tensorflow have their own dependencies. I recommend using [Anaconda](https://www.anaconda.com/) for handlinng the packages.\n\n# Dataset :\nI created the dataset for this project. It is divided into two categories ie \"with_face_mask\" and \"without_face_mask\". I downloaded the images for both categories from internet and saved them in respective folder in the local disk.\n\nThe most important part is the creation of Annotations and bounding boxes; for that purpose I used the [LabelImg](https://github.com/tzutalin/labelImg) annotation tool and created the labels and bounding boxes for each image.\n\nIn LabelImg, the annotations files are available in two format ie VOC format(XML file) or YOLO format. So, I got the data annotation file in YOLO format directly from labelImg ie [dataset_train.txt](YOLOv3/dataset_train.txt) file.\n\n# Usage :\n- Either download YOLOv3 weights from [YOLO website](https://pjreddie.com/media/files/yolov3.weights) \u0026 convert them, or download the YOLOv3 weights in keras format from [release section](https://github.com/vijayg15/FaceMask-Detection/releases/tag/yolo_weights).\\\nCopy downloaded weights file to \"model_data\" folder.\n- Run the \"train.py\" file for training the model. (I opt batch_size = 4, increase the batch_size if have more memory). \\\nI tried to train with GTX1650, received memory error while using \"batch_size = 32 or 16\", was able to train with 4. \\\nIncrease epochs count for better model accuracy.\n- After finishing training, in \"trained_weights/003/\" folder there should be created new \"trained_weights_final.h5\" model file. \\\nThis will be used for custom detection.\n- Test YOLOv3 with images, use \"image_detect.py\" \\\nSimply change \"model_path\" and \"classes_path\", to the used files. Then at the end of file, change the test image name and directory.\n- Test YOLOv3 with videos, use \"video_detect.py\" \\\nSimply change \"model_path\" and \"classes_path\", to the used files. Then at the end of file, just change the video and video_output directory.\n\n\n# Screenshots :\n\u003cimg src=\"Dataset/test/both1_detect.jpg\" width=\"660\"\u003e\n\u003cimg src=\"Dataset/test/nm16_detect.jpg\" width=\"660\"\u003e\n\n\u003cp float=\"left\"\u003e\n\u003cimg src=\"Dataset/test/m15_detect.jpg\" height=\"330\" /\u003e\n\u003cimg src=\"Dataset/test/m8_detect.jpg\" height=\"330\" /\u003e\n\u003c/p\u003e\n\n\u003cp float=\"left\"\u003e\n\u003cimg src=\"Dataset/test/nm8_detect.jpg\" height=\"360\" /\u003e\n\u003cimg src=\"Dataset/test/m14_detect.jpg\" height=\"360\" /\u003e\n\u003cimg src=\"Dataset/test/nm11_detect.jpg\" height=\"360\" /\u003e\n\u003c/p\u003e\n\n\u003cimg src=\"Dataset/test/m6_detect.jpg\" height=\"390\"\u003e\n\n\u003cp float=\"left\"\u003e\n \u003cimg src=\"Dataset/test/m10_detect.jpg\" height=\"370\" /\u003e \n  \u003cimg src=\"Dataset/test/nm12_detect.jpg\" height=\"370\" /\u003e \n\u003c/p\u003e\n\n\u003cimg src=\"Dataset/test/m16_detect.jpg\" width=\"660\"\u003e\n\u003cimg src=\"Dataset/test/m4_detect.jpg\" height=\"370\"\u003e\n\u003cimg src=\"Dataset/test/m11_detect.jpg\" height=\"460\"\u003e\n\u003cimg src=\"Dataset/test/m12_detect.jpg\"\u003e\n\u003cimg src=\"Dataset/test/nm13_detect.jpg\"\u003e\n\u003cimg src=\"Dataset/test/m17_detect.jpg\" width=\"660\"\u003e\n\u003cimg src=\"Dataset/test/m13_detect.jpg\"\u003e\n\u003cimg src=\"Dataset/test/nm9_detect.jpg\" height=\"550\"\u003e\n\n# Video\n#### I've also checked the final model on a video file. The output file can be seen [here](https://github.com/vijayg15/FaceMask-Detection/blob/master/Dataset/test/video1_output.mp4).\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijayg15%2Fkeras-facemask-detection-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvijayg15%2Fkeras-facemask-detection-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijayg15%2Fkeras-facemask-detection-system/lists"}