Tim M 57b5cefde5 Updated all `.md` files to contain newest image il y a 2 ans
..
detection 8d3d32dbb7 added face mask overlay post il y a 4 ans
experiments 8d3d32dbb7 added face mask overlay post il y a 4 ans
lib 8d3d32dbb7 added face mask overlay post il y a 4 ans
masks 8d3d32dbb7 added face mask overlay post il y a 4 ans
tools 8d3d32dbb7 added face mask overlay post il y a 4 ans
HR18-300W.pth 8d3d32dbb7 added face mask overlay post il y a 4 ans
LICENCE 8d3d32dbb7 added face mask overlay post il y a 4 ans
README.md 57b5cefde5 Updated all `.md` files to contain newest image il y a 2 ans
overlay_with_mask.py 8d3d32dbb7 added face mask overlay post il y a 4 ans
requirements.txt 8d3d32dbb7 added face mask overlay post il y a 4 ans

README.md

Using Facial Landmarks for Overlaying Faces with Medical Masks

This repository contains the code for Using Facial Landmarks for Overlaying Faces with Masks blog post.

download

Most of the code is based on the HRNet-Facial-Landmark-Detection repository, huge thanks to them.

Quick start

Environment

This code is developed using Python 3.6 and PyTorch 1.0.0 on Ubuntu 16.04 with NVIDIA GPU. Other platforms or GPUs are not fully tested.

Installation

  1. Create virtual environment:

You'll need to install virtualenv package if you don't have it:

pip install virtualenv
virtualenv -p python3.6 venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. You will also need the pre-trained weights, which you can take from here HR18-300W.pth:
wget -O HR18-300W.pth https://pscm7q.by.files.1drv.com/y4m1ndEsUHxWtszPoyHY2BQ2Zdvh0-dgYW_5dtTcxX_YFP8p5YYADNSndm3tAj2f-U4aMPMuS6-VyMvWaCYaO2otLab4XWblhouZkbuIgzr3ZGem6A2b1Lm6Kb3WrYQL_m3D2hj8Y3ulD06kXpvsvsoN-YlmXd9NK12snBfQxrgQf7OVXYsP1xWJEZfN_1CKdLPl1xYNaNvCeQik5LiCnmB9g

Run Demo

To run the demo, you need to execute the following command in your terminal:

python3 overlay_with_mask.py --cfg experiments/300w/face_alignment_300w_hrnet_w18.yaml --landmark_model HR18-300W.pth --mask_image masks/anti_covid.png

Try out different masks from the masks folder or use yours, but don't forget to annotate them first.

AI Courses by OpenCV

Want to become an expert in AI? AI Courses by OpenCV is a great place to start.