Twitter Face Image Mining for Recognition of Different Face Mask Types
- Intro
- Requirements
- General Instructions
- Preliminary Dataset
- Face Mask Recognition
- Install the necessary libraries:
- wget
- tweepy
- PyTorch version 1.10.0+ and torchvision 0.3.0+
- Clone this repository
$ git clone https://github.com/GibranBenitez/FaceMask_Twitter.git
- Update your Twitter API V2 Academic Research access level credentials in
./MaskTwitter/credentials.py
- Download the ConvNeXt weights (190MB) on
./MaskClassify/weights/
- Modify the date range and keywords of faceMaskTwitter.py and demo_covid_classy.py and run these commands.
$ python ./RetinaFace/faceMaskTwitter.py
$ python ./MaskClassify/demo_covid_classy.py
- Example values for faceMaskTwitter.py (keywords and date range):
keywords = ["n95","ffp2","face mask","cubrebocas","barbijo"]
dates = ["2019-12-01","2019-12-31"]
- Example values for demo_covid_classy.py (keywords and folder name of dates):
keywords = ["n95","ffp2","face mask","cubrebocas","barbijo"]
dates = "2019-12-01__2022-12-31"
- We manually annotate 10,500 images based on the four face mask types: surgical masks, cloth masks, respirators, and valved mask, as well as unmasked faces.
- You can download the dataset from Google Drive (460MB)
- The number of images for train, validation, and test sets are as follows
Set |
Surgical |
Cloth |
Respirator |
Valved |
Unmasked |
Total |
Train |
2200 |
1700 |
1000 |
1000 |
2100 |
8000 |
Val. |
200 |
200 |
200 |
100 |
300 |
1000 |
Test |
350 |
330 |
300 |
170 |
350 |
1500 |
- We train a ConvNeXt architecture with our preliminary dataset. The results obtained with validation and test sets are 94.8% and 94.1%, respectively.
- To run a classification demo you have to download the ConvNeXt weights (190MB) on
./MaskClassify/weights/
- Modify the data path
data_dir
, the output folder out_dir
, and run $ python ./MaskClassify/demo_covid_classy.py
- Example of modifications from demo_covid_classy.py (data_dir, includes 10 demo images):
############## Uncomment this section for demo classy only ################
dates = None
############## Chose pahts for demo classy only ###########################
data_dir = "./MaskClassify/demo_imgs"
out_dir = "./MaskClassify/output"