Skip to content

An AI solution based on YOLOv5 model to detect those who are wearing mask or not.

License

Notifications You must be signed in to change notification settings

rohandubey/Face-Mask-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face-Mask-Detector

pypi versions PyPI status

In the amidst of COVID-19, as there is no proper channel to effectively monitor people wearing mask and not. So to tackle this problem, I made an AI solution based on YOLOv5 model to detect those who are not wearing mask. This software is tested by Rajasthan Police (Govt. of India), and is designed to be installed alongside their CCTVs for efficient working. This software can multi-stream many sources together and collects data contionuously from those streams. Based on YOLOv5 model and RetinaNet Architecture, having

Accuracy 98%
Mean Average Precision (val) 54.98
FPS (max) 300+

Model runs on on a variety of sources like images, videos, directory, glob, http/rtsp/rtmp streams.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Inference

Linux : execute : ./run.sh
Windows : execute : crun.bat
For more smoother inference visit CUDA/CUDNN, Python and PyTorch to verify for correct versions

Working

  • When the program is initialized by running ./run.sh or run.bat, we see the following GUI having 3 inputs namely, Camera, Web Links, Videos/Images/Folders.
  • 1. Camera: Submit the Camera ID for any local cameras connected to your device. ( 0 for default camera)
  • 2. Web Links: Choose the link type : http/rtmp/rtsp and enter the IP address, if IP is password protected, then enter Username and password(if required)
  • 3. Images/Videos/Folders: for any Videos/Images/Folder that contains Videos/Images, choose the path in Browse button and after choosing we can see progress of detection and time left.
    • Progress :

Detection Results

For Videos/Images the output videos/images is stored in imference/output Post-Detection.
For Live streams from Webcam or WebStream (ex. http://ip), all images without mask are stored in inference/data/<DATE>/<TIME>.png format, so all the images detectedin a day are stored in one folder time-wise like :

$ tree --dirsfirst
├── inference\data\

│	├── 21_Dec_20                    (folder name = date)
   	├── 21_Dec_20 15_28_54.png       (time is 15:28:54)
   	└── 21_Dec_20 12_20_05.png
...	│   ...
│	├── 22_Dec_20
   	├── 22_Dec_20 05_08_04.png    
   	└── 22_Dec_20 02_00_55.png

Demo Pic form Live Stream

Demo Video from YouTube
Click to open!

Built With

  • YOLOv5 - Object Detection Algorithm
  • OpenCV - Video/Image Streaming
  • Tkinter - GUI toolkit for Python.
  • PyTorch - Model training/detection Framework.
  • Batch/Bash - Easy execution Programming languages for Windows/Linux respectively.
  • onnx - An ecosystem for interchanging different ML Model Frameworks.

Training Results

  • Model is trained os NVIDA 940MX 2GB(used TensorFlow-GPU with CUDA).
  • I created and labelled my own dataset using Label data Helper.
  • Added multi-threading to make detection smoother and faster.
  • Added GUI for easy support and analysis.
  • Converted raw pyton files to batch and bash script for direct usage.

Authors

Made with ❤️ by Rohan Dubey

References

About

An AI solution based on YOLOv5 model to detect those who are wearing mask or not.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages