This is a project that aims to allow the return of working environment in indoor offices.
It focuses on reading live streams from ip cameras in enterprise environment, after that, it applies a face mask detection model using the state-of-art Artificial Neural Networks.
In addition to detection, it also provides a customization platform for surveillence cameras.
Another service provided from the system is alerting security members via email.
The project consists of 3 containers
idfmi: Contains the Flask application and gunicorn application server
nginx: Contains the Nginx web server
mongo: Contains the MongoDB database
Some info about the stack used
Python version: 3.8.1
Web framework: Flask
Database: MongoDB (Using the pymongo driver)
App server: gunicorn
Worker class: meinheld
Web server: Nginx
Front end: Bootsrap4, JQuery
The system Architecture of IDFMI
The following is how the files are structured inside the project:
In-Door-Face-Mask-Inspector/
.env
.gitignore
docker-compose.yml
LICENSE
README.md
app/
app.py
camera.py
config.py
Dockerfile
requirements.txt
model/
face_mask_detection.pb
load_model.py
utils.py
static/
favicon.ico
main.css
main.js
main.scss
templates/
base.html
auth_error.html
forms/
camera.html
security.html
pages/
home.html
welcome.html
mongo/
Dockerfile
settings-insert.js
setup.sh
nginx/
Dockerfile
idfmi.conf
nginx.conf
- light theme
- dark theme
- light theme
- dark theme
-
Adding a camera
- light theme
- dark theme
-
Adding a security member
- light theme
- dark theme
-
View all security member
- light theme
- dark theme
-
Update forms are similar to create forms.
- light theme
- dark theme
Since the project is containerized, then the only important dependency is to have docker and docker compose installed, installation guides are as follows:
- Docker Desktop for Windows: https://docs.docker.com/docker-for-windows/install/
- Docker Desktop for Mac OS: https://docs.docker.com/docker-for-mac/install/
- Docker Engine for linux: https://docs.docker.com/engine/install/
- Docker-Compose for linux: https://docs.docker.com/compose/install/
Notice that for Windows and Mac you should only install docker desktop, which will download docker engine and docker-compose by default.
This is a requirement for the demo only to simulate the working environment with respect to authentication, authorization, and Secrets.
You can check microsoft's documentation on how to make a project with azure active directory and keyvault.
-
Azure Active Directory: https://azure.microsoft.com/en-us/services/active-directory/#documentation
-
Azure KeyVault: https://azure.microsoft.com/en-us/services/key-vault/#documentation
- could use any email (gmail, yahoo, outlook), but we used gmail for our prototype.
-
clone the repository:
git clone https://github.com/othmanKisha/In-Door-Face-Mask-Inspector.git
-
After finishing all the steps for Azure Active Directory and Key Vault, make sure to create a .env file inside the In-Door-Face-Mask-Inspector folder and inside the file add the following:
KEY_VAULT_NAME=${KEY_VAULT_NAME} # Stored in OS environment AZURE_CLIENT_ID=${AZURE_CLIENT_ID} # Stored in OS environment AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET} # Stored in OS environment AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} # Stored in OS environment AZURE_TENANT_ID=${AZURE_TENANT_ID} # Stored in OS environment MONGODB_DATABASE=<The name of the database to be created> MONGODB_USERNAME=<The username of the database to be created> MONGODB_PASSWORD=<The password of the database to be created> MONGODB_HOSTNAME=mongodb # This is the name of mongodb container MONGODB_PORT=<The port where mongodb will be running> # By default it is 27017 EMAIL_ADDRESS=<The email address created to send alerts> EMAIL_PASSWORD=<The password of the alerts email address> SMTP_SERVER=<The mail server, it is smtp.gmail.com when you use gmail, you can search the other mail servers> SMTP_PORT=<The mail server port> # The port where the smtp server is running by default 587 MODEL_CONFIDENCE=<The confidence of the model> # By default 0.5 MODEL_FILE=face_mask_detection.pb # The name of the model, can be changed MODEL_DIRECTORY=model # The folder containing the model, can be changed
-
make sure you are in the project directory:
cd In-Door-Face-Mask-Inspector
-
run docker-compose command:
docker-compose up -d
-
now you can view the website by typing
localhost
on the browser.
-
Face Mask Detection Model by AIZOOTech
-
Camera Streaming with Flask by Miguel Grinberg
Link: https://github.com/miguelgrinberg/flask-video-streaming
-
Azure Active Directory with Flask by René Bremer
Link:https://github.com/rebremer/ms-identity-python-webapp-backend