Git Product home page Git Product logo

covid-19-face-mask-and-social-distancing-detection's Introduction

Covid-19-Face-Mask-and-Social-Distancing-Detection

This project is used to detect face mask and social distancing violations from input image, video and webcam feeds.

Models and Techniques

Pretrained Yolov3 is used to detect people

Pretrained SSD is used to detect faces

Trained MobileNetV2 is used as face mask classifier

Euclidean distance is used to calculate social distancing violations

Getting Started

Prerequisites

  • face-detection
  • flask
  • imutils
  • keras
  • matplotlib
  • opencv-python
  • pandas
  • scikit-learn
  • tensorflow
  • opencv-python

Quickstart (Demo)

Download the pretrained Yolov3 weights using this link and save it to the yolo-coco/ directory

Create a virtual environment and install the required dependencies using the command pip install -r requirements.txt

Face mask detection on images

Test the face mask classifier using the command python detect_face_mask_image.py --image input/image/path

The output image is stored as output_fm.png

You can also use the flask web app using the command python app.py and the application runs in the address http://0.0.0.0:12000/

Social distancing detection on images

Test the social distancing detection on images using the command python detect_social_distance_image.py --image input/image/path --distance [default=100.0]

Experiment --distance value for different images. The output is stored as output_sd.jpg

Face mask and social distancing detection on videos/webcam

Use the command python video.py --video input/video/path --distance [default=100.0] --frames [default=20] to test on video files

Experiment --distance value for different video files and --frames to skip frames. The result frames are stored in result_frames/ directory

Use the command python webcam.py to test using a webcam device

Docker for Face Mask Detection on Images

Use the Docker image to run the face mask detector microservice

Pull the docker image using the command docker pull rakeshraj97/project1:0.0.1

Run the docker using the command docker run -p 12000:12000 rakeshraj97/project1:0.0.1

Ensure working of the microservice using the command curl http://0.0.0.0:12000/ or open the link http://0.0.0.0:12000/ in a web browser to use the web application

Train Face Mask Detector

Dataset description

The dataset used to train face mask detector can be downloaded using this link

This is a balanced dataset containing faces with and without masks with a mean height of 283.68 and mean width of 278.77

data

Train

Use the command python train_mask_detector.py --dataset input/dataset/path to train the face mask classifier

plot

Output of the Trained Model

Face Mask detection

output_fm

Social Distancing detection

output_sd

References

*https://www.pyimagesearch.com/2020/06/01/opencv-social-distancing-detector/

*https://www.pyimagesearch.com/2020/05/04/covid-19-face-mask-detector-with-opencv-keras-tensorflow-and-deep-learning/

covid-19-face-mask-and-social-distancing-detection's People

Contributors

rakeshraj97 avatar

Watchers

 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.