Giter VIP home page Giter VIP logo

azure-facemask-detector's Introduction

Try it out!

Please allow access to your camera!

Azure Facemask Detector

Real implementation of a facemask detection service powered by Azure ML, Function App and Azure API Management Service.

Index

Introduction

COVID-19 has changed our daily lives and continues to do so. Many retail stores and companies have gone out of business, unable to offer their services to their clients. However some others which have opted for the reopening of their businesses in turn have had to adapt to the times.This includes public institutions such as museums, libraries, etc. All these establishments have taken their precautionary measures, generating new regulations, such as forcing customers and / or visitors to wear face masks at all times. 1.

Given this new environment, businesses have had to create neew kinds of jobs or jobs to be done. One of these is to check the use of the mask and check the temperature of the customers before entering the establishment, risking not only the worker who is checking the temperature of the customers, but to the customers who enter the place.

  1. https://www.who.int/emergencies/diseases/novel-coronavirus-2019/advice-for-public/when-and-how-to-use-masks?gclid=Cj0KCQjwlvT8BRDeARIsAACRFiX_NyUiqU0d44aUqMNK7LVrXMOQWMfqr0MUUo8TKrJLpObf91qRUcUaAjKbEALw_wcB

Problem

This job generates an annual cost per worker of at least $30,000 [1] and if that employee were to become ill with covid-19, by law (in the United States) they would have to pay him at least $511 a day [2].

These costs (both moneetary and health wise) for an employee who performs a repetitive task is excessive but necessary, because the solutions currently created are not yet sufficient to replace this position.

Most of the devices on the market only detect the use of the mask, however this project seeks to generate a complete solution for access control.

  1. https://www.ziprecruiter.com/Salaries/Retail-Security-Officer-Salary
  2. https://www.dol.gov/sites/dolgov/files/WHD/posters/FFCRA_Poster_WH1422_Non-Federal.pdf

Solution

Materials

Optional *

Hardware

Software

Connection Diagram

AzureML Model Training

The artificial intelligence model was trained on the Azure Machine Learning platform, with the TensorFlow framework, all the characteristics of the training environment were the following:

Azure ML Settings

  • Compute Attributes:
    • Region: centralus
    • Virtual machine size:
      • STANDARD_DS2_V2 (2 Cores, 7 GB RAM, 14 GB Disk)
    • Processing Unit:
      • CPU - General purpose
    • Kernel:
      • Python 3.6.9

All the code in in the following link:

https://github.com/altaga/Azure-Facemask-Detector/tree/main/Azure%20ML%20Train

Once you download it you will have to put it in the Azure interface as follows.

Once this is done we can run the training without problem, the code is already designed to download the database from our repository.

https://github.com/altaga/Facemask-Opt-Dataset

After the training begins, pay close attention to the Link that will appear on the interface, since with this link we will be able to access the model when the program ends.

Once the training is finished we can download our model in the following way, the model we are downloading is a model optimized for tensorflow lite.

Now we will go on to show how we carry out the deployment of our model in a Function App.

Azure Model Deployment

For the cloud deployment of our model, we make an app function, which is the one that will be in charge of executing the interpretation of the model and its evaluation, each time we pass an image to it.

Azure Function App

The relevant specifications of this function are as follows:

  • App Service Plan:
    • CentralUSLinuxDynamicPlan (Y1: 0)
  • Location:
    • CentralUS
  • Environment:
    • Python 3.7
    • Tflite Interpreter 1.0.1
    • OpenCV 4.5.1.48

All the files that make this function work are in the URL.

https://github.com/altaga/Azure-Facemask-Detector/tree/main/Azure%20Function%20App

Specifically for it to work we have to have the following packages in the requirements.txt file of the function.

azure-functions
https://github.com/google-coral/pycoral/releases/download/v1.0.1/tflite_runtime-2.5.0-cp37-cp37m-linux_x86_64.whl
opencv-python

All the images that we send to be evaluated in the function must maintain an aspect ratio of 4: 3 or 3: 4, regardless of the size of the image.

Azure Function App Deployment as API

To perform the API of this function we will add an API Management from the side menu, to use this function we require that the POST operation is available.

After all this setup we can go to Postman:

curl --location --request POST 'https://facemask-apim.azure-api.net/tensorpython37/HttpTrigger1?flag=read' \
--header 'Ocp-Apim-Subscription-Key: YOURAPPKEY' \
--header 'Content-Type: text/plain' \
--data-raw 'Base64Image'

The image used for this is in the following folder:

https://github.com/altaga/Azure-Facemask-Detector/tree/main/PostmanDemoImage

Azure API implementation

Thanks to the fact that it is a service that can be consumed by API, we can practically use any HW or SW device to perform the implementation. In this case, we can show how we carry out this implementation in the following devices and platforms.

Hardware Tested with the API

Codes: https://github.com/altaga/Azure-Facemask-Detector/tree/main/Devices%20Tested

  • ESP32 Cam

Video (Demo ESP32): Click on the image DEMOesp

  • RPI4 with Camera

Video (Demo Raspberry): Click on the image DEMORPI

Devices Tested with the webapp

WebpageCode:

(the web page consumes directly from the same API, you can test the web page yourself in the following link):

Video (Demo Smartphone): Click on the image DEMOsmartphone

Video (Demo Desktop): Click on the image DEMOsmartphone

Device Images on businesses

Icecream Shop:

Make Up Shop:

EPIC DEMO

Video: Click on the image

DEMO

azure-facemask-detector's People

Contributors

altaga avatar eddoliver 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.