Giter Site home page Giter Site logo

vineet019 / face-mask-detection-tf2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from purehing/face-mask-detection-tf2

0.0 1.0 1.0 3.67 MB

A face mask detection using ssd with simplified Mobilenet and RFB in Tensorflow 2.1. Training on your own dataset. Can be converted to kmodel and run on the edge device of k210

Python 100.00%

face-mask-detection-tf2's Introduction

Face mask detection

This model is a lightweight face mask detection model. Based on ssd,the backbone is Mobilenet and RFB.

Key Features

  • Tensorflow 2.1
  • Trainging and Inference
  • Precision with mAP
  • Eager mode training with tf.GradientTape
  • Network function with tf.keras
  • Dataset prepocessing with tf.data.TFRecordDataset
├── assets
│   ├── 1_Handshaking_Handshaking_1_71.jpg
│   ├── out_1_Handshaking_Handshaking_1_71.jpg
│   ├── out_test_00002330.jpg
│   └── test_00002330.jpg
├── checkpoints
│   └── weights_epoch_120.h5
├── components
│   ├── config.py
│   ├── __init__.py
│   ├── kmeans.py
│   ├── prior_box.py
│   └── utils.py
├── dataset
│   ├── check_dataset.py
│   ├── tf_dataset_preprocess.py
│   ├── train_mask.tfrecord
│   ├── trainval_mask.tfrecord
│   ├── val_mask.tfrecord
│   ├── voc_to_tfrecord.py
├── inference.py
├── logs
│   └── train
├── mAP
│   ├── compute_mAP.py
│   ├── detection-results
│   ├── detect.py
│   ├── ground-truth
│   ├── __init__.py
│   ├── map-results
│   └── README.md
├── Maskdata
│   ├── Annotations
│   ├── ImageSets
│        └── Main
│   │       ├── train.txt
│   │       ├── trainval.txt
│   │       └── val.txt
│   └── JPEGImages
├── network
│   ├── __init__.py
│   ├── losses.py
│   ├── model.py
│   ├── net.py
│   ├── network.py
├── README.md
└── train.py
└── requirements.txt

Usage

Installation

Create a new python virtual environment by Anaconda ,pip install -r requirements.txt

Data Preparing

  1. Face Mask Data

    Source data from AIZOOTech , which is a great job.

    I checked and corrected some error to apply my own training network according to the voc dataset format. You can download it here. https://pan.baidu.com/s/1330OWyOL4huB-GWXRkKK6Q code:x5e0

  2. Data Processing

    • Download the mask data images

    • Convert the training images and annotations to tfrecord file with the the script bellow.

      python dataset/voc_to_tfrecord.py --dataset_path Maskdata/  --output_file dataset/train_mask.tfrecord --split train

      you can change the --split parameters to 'val' to get the validation tfrecord, Please modify the inside setting voc_to_tfrecord.py for different situations.

  3. Check tfrecord dataloader by run python dataset/check_dataset.py .

Training

  1. Modify your configuration in components/config.py.

    You can get the anchors by run python components/kmeans.py

  2. Train the model by run python train.py .

Inference

  • Run on video

    python inference.py  --model_path checkpoints/ --camera True
    or
    python inference.py  --model_path checkpoints/*.h5 --camera True
  • Detect on Image

    python inference.py  --model_path checkpoints/*.h5 --img_path assert/1_Handshaking_Handshaking_1_71.jpg

mAP

  • Convert xml to txt file on mAP/ground truth, predicting the bbox and class on mAP/detection-results.

     python mAP/detect.py --model_path checkpoints/*.h5 --dataset_path Maskdata/ --split val 
    
     python mAP/compute_mAP.py

Reference

face-mask-detection-tf2's People

Contributors

purehing avatar

Watchers

 avatar

Forkers

prateekiitr

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.