Skip to content

Brotherta/Facial-Mask-Recognition

Repository files navigation

Facial-Mask-Recognition

Introduction

This is a GUI Application, written with Python and PyQT.

The purpose is to allow the user to create a project, import images, and assign categories to user-drawn rectangles zones of the images.

The user can create multiple projects and save wherever he wants.

We created this application in order to prepare data for machine learning purpose.

Screenshots

project_list_window

main window

editor window

Prequirements

Make sur to import modules with pip !

pip install -r requirement.txt

How to use the classificator

Usage :

usage: main_predictor.py [-h] [--mode MODE] [--path PATH] [--model MODEL]

Facial Mask Recognition script.

optional arguments:
  -h, --help     show this help message and exit
  --mode MODE    Launch the script with the given option. Options: [train, predict, preprocess]
  --path PATH    The path of the input file/directory, needed for preprocess and predict mode. For the training mode,
                 if --path is not specified, it will take the folder resized_images/ by default.
  --model MODEL  The path of the model you want for train. By default the model 'final_model.h5' is loaded.

Examples :

python main_predictor.py --mode predict --path my_image.png

Result :

maskdetect

How to use the annotator

0 - Run the program :

python app.py

1 - Create the project :

create project

2 - Open the project

open project

3 - Import images

import images 2

import images

4 - Create new labels

create label

create label 2

5 - Open an image

open an image

6 - Draw a rectangle with the left mouse button

draw rectangle

7 - Double click the rectangle and assign a label to it

double click

8 - Validate

validate

9 - Do not forget to save the project

save

11 - The project folder looks like this :

project folder

12 - That's all !

Project files syntax

Project.ini

[PROJECT]
name = Masks
filepath = /Users/jipey/Desktop/masks
labels = /Users/jipey/Desktop/masks/labels.json
box = /Users/jipey/Desktop/masks/box.json
images = /Users/jipey/Desktop/masks/images

Box.json

[
    {
        "filepath": "/Users/jipey/Desktop/masks/images/image.jpg",
        "boxList": [
            {
                "x": 995,
                "y": 141,
                "width": 557,
                "height": 411,
                "label": {
                    "name": "white mask"
                }
            }
        ],
        "imageSize": [
            2048,
            1152
        ]
    },
    {
        "filepath": "/Users/jipey/Desktop/masks/images/mask1.jpg",
        "boxList": [
            {
                "x": 495,
                "y": 143,
                "width": 106,
                "height": 113,
                "label": {
                    "name": "blue mask"
                }
            },
            {
                "x": 813,
                "y": 169,
                "width": 87,
                "height": 89,
                "label": {
                    "name": "blue mask"
                }
            },
            {
                "x": 335,
                "y": 136,
                "width": 57,
                "height": 68,
                "label": {
                    "name": "blue mask"
                }
            },
            {
                "x": 181,
                "y": 128,
                "width": 63,
                "height": 68,
                "label": {
                    "name": "blue mask"
                }
            }
        ],
        "imageSize": [
            1024,
            682
        ]
    }
]

Labels.json

[
    {
        "name": "blue mask"
    },
    {
        "name": "white mask"
    }
]