An application that overlays a mask on the human face using mediapipe face mesh model.
- Use MakeSense annotation tool to annaotate the mask.
- Refer Mask annotated image for all the key points.
- Refer utils/const.py for three modes of mask annotations and their corresponding key points.
FULL_FACE - For masks that cover entire face.
HALF_FACE - For masks that cover half of the face.
BEARD_FACE - For masks thar cover beard area. - Annotate the mask based on the required mode of mask.
- Place the mask png image and annotations csv files in /data/masks dir.
- Ensure the mask image and annotations csv files have same filename.
- Add the mask png image filename in MASK dict in utils/const.py.
- Record a video of person or enable a live cam.
- Place the camera horizontally facing the person.
- Higher the resolution of input video, higher the quality of result.
pip install -r requirements.txt
python themaskedman.py --video <path to video file> --face <face mode> --mask <mask number> --mesh <face mesh>
Note:
<path to video file> - Path to the input video file. If not provided, enable webcam.
<face mode> - Face mode mentioning single face or multiple faces. Choices: "single" or "multi". Default: single
<mask number> - Mask number corresponding to mask key of MASK dict in utils/const.py. Random mask if argument not provided.
<face mesh> - Add face mesh on detected faces. Choices: "True" or "False". Default: False
⭐ Multiface ⭐
python themaskedman.py --video <path to video file> --mask 6 --face multi --mesh True
Note:
--mask 6 -> 6 corresponds to pikachu.png in MASK dict.
output_multi.mp4
Input video source here.
⭐ Live Cam demo ⭐
python themaskedman.py
live_demo_1.mp4
live_demo_2.mp4
⭐ Fun demo (Spoilers ahead:warning:) ⭐
python themaskedman.py --video <path to video file> --mask 6 --face single --mesh True
out_i_am_your_father_1.mp4
Happy Learning! 😄