当前位置:网站首页>Mask wearing face data set and mask wearing face generation method
Mask wearing face data set and mask wearing face generation method
2022-06-29 00:39:00 【pan_ jinquan】
Mask wearing face data set and mask wearing face generation method
Catalog
Mask wearing face data set and mask wearing face generation method
(1) Open source datasets - Mask wearing face data set
(2) Generating data sets of face masks
2. Face generation method with mask
(1) The idea of generating face masks
(3) Face generation with mask Demo
(4) Generate face effect display with mask
3. Generate a mask data set and download the source code
4. Mask wearing face detection and mask wearing recognition ( contain Python Android Source code )
At present, many free face recognition programs have been opened on the Internet / Face detection dataset , For example, the common LFW,FDDB,WIDER FACE,300W etc. , I guess it adds up to several memories . But most of these face data are faces without masks , It can not be directly used in face mask recognition . There are also a few open source face data sets with masks on the Internet , I spent some time , Sort out the currently common face data sets with masks , And the synthesis of face data with masks / Generation method .
- contain 5 Data sets : facemask-train1, facemask-train2,facemask-train3, synthetic-train1,synthetic-train2 ,facemask-test , There are about 50000+ The data of :
- Generate mask wearing face code : python create_facemask.py
Project data and generate the source code of face masks : Mask wearing face data set and generating mask wearing face data
1. Mask wearing face data set
(1) Open source datasets - Mask wearing face data set
Some open source , Free face mask data set ,download Come down , It is found that these open source data are dirty , A lot of them are marked incorrectly , I need to clean myself ~
| Data sets | explain |
| virus-mask-dataset |
|
| MaskedFace-Net |
|
| Real-World Masked Face Datase |
(2) Generating data sets of face masks
Most of the face data on the Internet are faces without masks , It can not be directly used in face mask recognition . In view of this , We can consider our own synthesis / Generate face data with masks , The following is my collection and collation of face data sets with masks and synthetic data sets , There are about 50000+ The data of :
| Data sets | explain |
| facemask-train1 |
|
| facemask-train2 |
|
| facemask-train3 |
|
| synthetic-train1 |
|
| synthetic-train2 |
|
| facemask-test |
|
2. Face generation method with mask
(1) The idea of generating face masks
- First, face detection and face key point detection
- According to the face key , Calculate the width of the cheek and the position of the bridge of the nose , Empathy , It is necessary to calculate the size of the outlet cover template 、 Direction and position ;
- Finally, paste the mask template on the face , Wait until the synthetic mask face image
Some masks generate code references :
GitHub - sevenHsu/FaceMask_CelebA: Simulated masked face with dataset CelebA
I tested the current online generated code for wearing masks , For faces that have been corrected , The generation effect is good , But if the original face itself is tilted ( Crooked head ), In this case, use the original code directly , The effect of synthesis is very poor , On this basis , I did optimization work :
- Added mask template , share 29 Different types of mask templates , Provide diversity of synthetic mask data
- The inclination angle of the mask is optimized , Make the face tilt ( Crooked head ) when , The synthetic effect is also good
- Optimized face detection , Using lightweight face detection , Speed up generation
| Original picture | The original code generates wearing masks | After optimization, mask wearing will be generated |
![]() | ![]() | ![]() |
| For faces that have been corrected , The generation effect is good , But if the original face itself is tilted ( Crooked head ), In this case, use the original code directly , The effect of synthesis is very poor | ||
(2) Mask template
Mask template is the mask Mask Images (PNG Format ), Can pass Photoshop A stingy way , Remove the background ; A total of 29 Different types of mask templates , Ensure the diversity of mask data .


(3) Face generation with mask Demo
Install well python Dependent package
pybaseutils
opencv-python==4.5.1.48
face_recognition
tqdm
torch
torchvisionThe code already comes with test images and data , You can also change to your own face data set :
python create_facemask.py# -*-coding: utf-8 -*-
"""
@Author : panjq
@E-mail : [email protected]
@Date : 2022-06-25 22:23:11
@Brief : Generate face data set with mask
"""
import os
import sys
sys.path.insert(0, os.getcwd())
sys.path.insert(0, "libs")
from tqdm import tqdm
from facemask.wearmask import FaceMaskCreator
from pybaseutils import file_utils, image_utils
class FaceMaskDemo(object):
def __init__(self):
self.mask_creator = FaceMaskCreator(detect_face=True, alignment=False)
def create_wear_mask_faces(self, image_dir, out_dir=None, vis=True):
"""
Generate face data set with mask
:param image_dir: Face image directory
:param out_dir: Generate mask face output directory
:param vis: Whether the visual effect
:return:
"""
image_list = file_utils.get_files_lists(image_dir)
for image_path in tqdm(image_list):
image_id = os.path.basename(image_path).split(".")[0]
image = image_utils.read_image(image_path, size=(512, None), use_rgb=True)
mask, face_rects = self.mask_creator.create_masks(image, mask_type="random", vis=vis)
if out_dir:
self.mask_creator.save_image(image, mask, face_rects, out_dir, image_id)
if __name__ == '__main__':
image_dir = "./facemask/test_image" # Face pictures
out_dir = "./output" # Generate mask face output directory
fm = FaceMaskDemo()
fm.create_wear_mask_faces(image_dir, out_dir, vis=True)
(4) Generate face effect display with mask
| Original picture | Figure of synthetic belt mask |
![]() | ![]() |
![]() | ![]() |
![]() | ![]() |
![]() | ![]() |
3. Generate a mask data set and download the source code
The download address contains :
https://mp.weixin.qq.com/s/4dtC9CeP50M-3nn3xel1Ow
- contain 5 Data sets : facemask-train1, facemask-train2,facemask-train3, synthetic-train1,synthetic-train2 ,facemask-test , There are about 50000+ The data of :
- Generate mask wearing face code : python create_facemask.py

4. Mask wearing face detection and mask wearing recognition ( contain Python Android Source code )
Prepare good face data set and face data set with mask , The next step is to start training the mask wearing recognition model , Please refer to :
边栏推荐
- Go1.18 new feature: discard strings Title Method, a new pit!
- How does the JVM bottom layer implement synchronized
- 转载:VTK笔记-裁剪分割-不规则闭合圈选裁剪-vtkSelectPolyData类(黑山老妖)
- Typescript -- Section 3: Interface
- If you can play these four we media operation tools, the sideline income of 6000+ is very easy
- Baidu online disk login verification prompt: unable to access this page, or the QR code display fails, the pop-up window shows: unable to access this page, ensure the web address....
- 2022_ 2_ 16 the second day of learning C language_ Constant, variable
- Haskell configuring vs code development environment (june2022)
- 点击劫持:X-Frame-Options未配置
- Introduction to JVM working principle
猜你喜欢

Leetcode daily question: implementing strstr()

【leetcode】17. Letter combination of telephone number

小白创业做电商,选对商城系统很重要!

Technology sharing | software development process that you must understand if you want to get started with testing

PR 2021 quick start tutorial, how to use audio editing in PR?

Give you a project, how will you carry out performance testing (I)

11. target segmentation

Single machine multi instance MySQL master-slave replication

The company has a new Post-00 test paper king. The old oilman said that he could not do it. He has been

转载:VTK笔记-裁剪分割-不规则闭合圈选裁剪-vtkSelectPolyData类(黑山老妖)
随机推荐
Common mistakes in software testing
Summary of the 25-year-old Ma Nong who graduated three years ago
【LeetCode】21. Merge two ordered linked lists - go language solution
大智慧上开户是安全的吗
Daily practice: delete duplicates in the ordered array
LeetCode每日一题:实现strStr()
How the slip ring motor works
How to calculate the income tax of foreign-funded enterprises
Roson's QT journey 80 qurl class
Daily question 1: the number of numbers in the array 2
Redis是什么
10. Yolo series
be based on. NETCORE development blog project starblog - (13) add friendship link function
After eight years of testing and opening experience and interview with 28K company, hematemesis sorted out high-frequency interview questions and answers
6.28 学习内容
Along with the notes: methods simulating array like classes
基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能
Chrome浏览器的基本使用
6.28 learning content
Introduction to JVM working principle











https://panjinquan.blog.csdn.net/article/details/125428609