face-mask-detection-yolov5

A machine learning project with YoloV5 model to detect images with Face Mask and No Face Mask

https://github.com/ninjaifti/face-mask-detection-yolov5

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary

Keywords

machine-learning python3 yolov5
Last synced: 6 months ago · JSON representation ·

Repository

A machine learning project with YoloV5 model to detect images with Face Mask and No Face Mask

Basic Info
  • Host: GitHub
  • Owner: NinjaIfti
  • License: agpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 1.3 MB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 2
  • Releases: 0
Topics
machine-learning python3 yolov5
Created about 1 year ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Citation

README.md

**

  • [ ]

Face Mask Detection with YOLOv5

** A deep learning-based solution for detecting face masks in images and live video feeds using the YOLOv5 framework. This project helps ensure safety by identifying people with and without masks in real-time.


Features


  • Detects faces with and without masks in images, videos, and live streams.

  • High accuracy and fast inference speed using YOLOv5.

  • Supports both CPU and GPU for inference.

  • Customizable confidence threshold and input sizes.

Installation

Prerequisites

  • [ ] Python 3.7 or higher
  • [ ] PyTorch installed (with GPU support if available)
  • [ ] pip package manager

Steps

  • [ ] Clone the Repository

    git clone https://github.com/NinjaIfti/Face-Mask-Detection-YoloV5.git
    

    cd face-mask-detection

Set up a Virtual Environment (Optional but Recommended) A virtual environment helps isolate project dependencies, making it easier to manage and avoid conflicts with other Python projects on your system.

  • [ ] Create a Virtual Environment:

    python -m venv yolov5-env
    Activate the Virtual Environment:
    

On Linux/macOS:

source yolov5-env/bin/activate

On Windows:

yolov5-env\Scripts\activate
  • [ ] Install Dependencies Once the virtual environment is active, install the required dependencies:

    pip install -r requirements.txt
    
  • [ ] Download Pre-trained YOLOv5 Model You can either use a pre-trained YOLOv5 model or train a custom model for face mask detection.

To use the pre-trained model, simply download it:

 wget https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
  • [ ] Running the Detection

On Images

bash
python detect.py --source images --weights yolov5s.pt --conf 0.5

On Video

bash
python detect.py --source video.mp4 --weights yolov5s.pt --conf 0.5

The detected results will be saved in the runs/detect/exp folder.

Live Detection For live webcam detection, simply run:

bash
python detect.py --source 0 --weights yolov5s.pt --conf 0.5

*

How It Works

*

Model Training

The model is based on YOLOv5, a state-of-the-art object detection model. It has been fine-tuned to detect faces and classify them as "with mask" or "no mask."

Image and Video Processing

Once the model is loaded, it takes images or video frames as input, performs face detection, and classifies the face as either "mask" or "no mask."

*

Troubleshooting

*

Error: ModuleNotFoundError

If you encounter errors related to missing modules, ensure that all dependencies are installed using:

bash
pip install -r requirements.txt

Low Detection Accuracy

If the model doesn't perform well, consider retraining it with your own dataset for better accuracy.

License

This project is licensed under the MIT License - see the LICENSE file for details.

*

**Acknowledgments**

*

YOLOv5

OpenCV

PyTorch

Owner

  • Name: Iftikhar Ahmed
  • Login: NinjaIfti
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
preferred-citation:
  type: software
  message: If you use YOLOv5, please cite it as below.
  authors:
  - family-names: Jocher
    given-names: Glenn
    orcid: "https://orcid.org/0000-0001-5950-6979"
  title: "YOLOv5 by Ultralytics"
  version: 7.0
  doi: 10.5281/zenodo.3908559
  date-released: 2020-5-29
  license: AGPL-3.0
  url: "https://github.com/ultralytics/yolov5"

GitHub Events

Total
  • Watch event: 2
  • Issue comment event: 2
  • Push event: 2
  • Pull request event: 1
  • Create event: 3
Last Year
  • Watch event: 2
  • Issue comment event: 2
  • Push event: 2
  • Pull request event: 1
  • Create event: 3

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/ci-testing.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • slackapi/slack-github-action v2.0.0 composite
.github/workflows/cla.yml actions
  • contributor-assistant/github-action v2.6.1 composite
.github/workflows/docker.yml actions
  • actions/checkout v4 composite
  • docker/build-push-action v6 composite
  • docker/login-action v3 composite
  • docker/setup-buildx-action v3 composite
  • docker/setup-qemu-action v3 composite
.github/workflows/format.yml actions
  • ultralytics/actions main composite
.github/workflows/links.yml actions
  • actions/checkout v4 composite
  • ultralytics/actions/retry main composite
.github/workflows/merge-main-into-prs.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/stale.yml actions
  • actions/stale v9 composite
FastAPI/Dockerfile docker
  • python 3.8-slim-buster build
utils/docker/Dockerfile docker
  • pytorch/pytorch 2.0.0-cuda11.7-cudnn8-runtime build
utils/google_app_engine/Dockerfile docker
  • gcr.io/google-appengine/python latest build
FastAPI/requirements.txt pypi
  • Pillow *
  • PyYAML >=5.3.1
  • black *
  • flask *
  • matplotlib >=3.2.2
  • numpy >=1.18.5
  • opencv-python >=4.1.2
  • pandas *
  • requests *
  • scipy >=1.4.1
  • seaborn >=0.11.0
  • tensorboard >=2.4.1
  • thop *
  • torch >=1.7.0
  • torchvision >=0.8.1
  • tqdm >=4.41.0
pyproject.toml pypi
  • matplotlib >=3.3.0
  • numpy >=1.22.2
  • opencv-python >=4.6.0
  • pandas >=1.1.4
  • pillow >=7.1.2
  • psutil *
  • py-cpuinfo *
  • pyyaml >=5.3.1
  • requests >=2.23.0
  • scipy >=1.4.1
  • seaborn >=0.11.0
  • thop >=0.1.1
  • torch >=1.8.0
  • torchvision >=0.9.0
  • tqdm >=4.64.0
  • ultralytics >=8.1.47
requirements.txt pypi
  • PyYAML >=5.3.1
  • gitpython >=3.1.30
  • matplotlib >=3.3
  • numpy >=1.23.5
  • opencv-python >=4.1.1
  • pandas >=1.1.4
  • pillow >=10.3.0
  • psutil *
  • requests >=2.32.2
  • scipy >=1.4.1
  • seaborn >=0.11.0
  • setuptools >=70.0.0
  • thop >=0.1.1
  • torchvision >=0.9.0
  • tqdm >=4.66.3
utils/google_app_engine/additional_requirements.txt pypi
  • Flask ==2.3.2
  • gunicorn ==22.0.0
  • pip ==23.3
  • werkzeug >=3.0.1
  • zipp >=3.19.1