Skip to content

Commit 8d3d32d

Browse files
author
Koriukina, Valeriia
committed
added face mask overlay post
1 parent 9db20ed commit 8d3d32d

34 files changed

+4285
-0
lines changed

FaceMaskOverlay/HR18-300W.pth

37.3 MB
Binary file not shown.

FaceMaskOverlay/LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2019] [Microsoft]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

FaceMaskOverlay/README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Using Facial Landmarks for Overlaying Faces with Medical Masks
2+
3+
This repository contains the code for [Using Facial Landmarks for Overlaying Faces with
4+
Masks](https://www.learnopencv.com/using-facial-landmarks-for-overlaying-faces-with-masks/) blog post.
5+
6+
Most of the code is based on the
7+
[HRNet-Facial-Landmark-Detection](https://github.com/HRNet/HRNet-Facial-Landmark-Detection) repository, huge thanks to
8+
them.
9+
10+
## Quick start
11+
12+
### Environment
13+
14+
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
15+
not fully tested.
16+
17+
### Installation
18+
19+
1. Create virtual environment:
20+
21+
You'll need to install [virtualenv](https://pypi.org/project/virtualenv/) package if you don't have it:
22+
23+
```bash
24+
pip install virtualenv
25+
virtualenv -p python3.6 venv
26+
source venv/bin/activate
27+
```
28+
29+
2. Install dependencies:
30+
31+
```bash
32+
pip install -r requirements.txt
33+
```
34+
35+
3. You will also need the pre-trained weights, which you can take from here
36+
[HR18-300W.pth](https://1drv.ms/u/s!AiWjZ1LamlxzeYLmza1XU-4WhnQ):
37+
38+
```bash
39+
wget -O HR18-300W.pth https://pscm7q.by.files.1drv.com/y4m1ndEsUHxWtszPoyHY2BQ2Zdvh0-dgYW_5dtTcxX_YFP8p5YYADNSndm3tAj2f-U4aMPMuS6-VyMvWaCYaO2otLab4XWblhouZkbuIgzr3ZGem6A2b1Lm6Kb3WrYQL_m3D2hj8Y3ulD06kXpvsvsoN-YlmXd9NK12snBfQxrgQf7OVXYsP1xWJEZfN_1CKdLPl1xYNaNvCeQik5LiCnmB9g
40+
```
41+
42+
### Run Demo
43+
44+
To run the demo, you need to execute the following command in your terminal:
45+
46+
```bash
47+
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
48+
```
49+
50+
Try out different masks from the `masks` folder or use yours, but don't forget to annotate them first.
51+
52+
# AI Courses by OpenCV
53+
54+
Want to become an expert in AI? [AI Courses by OpenCV](https://opencv.org/courses/) is a great place to start.
55+
56+
<a href="https://opencv.org/courses/">
57+
<p align="center">
58+
<img src="https://www.learnopencv.com/wp-content/uploads/2020/04/AI-Courses-By-OpenCV-Github.png">
59+
</p>
60+
</a>
Binary file not shown.

0 commit comments

Comments
 (0)