Coder Social home page Coder Social logo

kokitakeishi / yolov5-face-mask-detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spacewalk01/yolov5-face-mask-detection

0.0 0.0 0.0 58.98 MB

Face Mask Detection using YOLOv5

License: MIT License

Python 0.41% Jupyter Notebook 99.59%

yolov5-face-mask-detection's Introduction

Face Mask Detection

Face mask detection is an object detection task that detects whether people are wearing masks or not in videos. This repo includes a demo for building a face mask detector using YOLOv5 model.

Dataset

The model was trained on Face-Mask dataset which contains 853 images belonging to 3 classes, as well as their bounding boxes in the PASCAL VOC format. The classes are defined as follows:

  • With mask
  • Without mask
  • Mask worn incorrectly

Setup

  • Clone this repo and install YOLOv5:
git clone https://github.com/spacewalk01/face-mask-detection
cd face-mask-detection

# Install yolov5
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt

Training

  • Download Face-Mask dataset from Kaggle and copy it into datasets folder.
  • Execute the following command to automatically unzip and convert the data into the YOLO format and split it into train and valid sets. The split ratio was set to 80/20%.
cd ..
python prepare.py
  • Start training:
cd yolov5
python train.py --img 640 --batch 16 --epochs 100 --data ../mask_config.yaml --weights yolov5s.pt --workers 0

Inference

  • If you train your own model, use the following command for inference:
python detect.py --source ../datasets/input.mp4 --weights runs/train/exp/weights/best.pt --conf 0.2
  • Or you can use the pretrained model models/mask_yolov5s.pt for inference as follows:
python detect.py --source ../datasets/input.mp4 --weights ../models/mask_yolov5.pt --conf 0.2

Results

The following charts were obtained after training YOLOv5s with input size 640x640 on the Face Mask dataset for 100 epochs.

Precision-Recall (PR) measures the accuracy of bounding box overlap between predicted bboxes and ground truth bboxes.

Precision Curve Recall Curve PR Curve

The following metrics were measured on the valid dataset containing 171 images. High precision and recall scores were obtained on with mask and without mask classes. However, the performance on mask weared incorrectly class was poor due to the imbalanced data.

Class #Labels Precision Recall mAPval
0.5
mAPval
0.5:0.95
with mask 630 0.94 0.9 0.95 0.64
without mask 104 0.86 0.82 0.9 0.6
mask weared incorrectly 20 0.72 0.3 0.43 0.24
total 754 0.84 0.67 0.76 0.49

Ground Truths vs Predictions

Ground Truth Prediction

Reference

yolov5-face-mask-detection's People

Contributors

spacewalk01 avatar mirfani340 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.