Skip to content

About

Trained CNN for hat/beard classification

Resources

Stars

7 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Hat/beard classifier with OpenCV face detector

Script for hat/beard classifying using opencv face detector.

Images are classified into two categories.

  1. The presence of a headgear (class hat): any headgear (hat, cap, etc.) is present or any headgear is completely absent.

  2. The presence of facial hair (class beard): mustache, beard, noticeable stubble or any facial hair is completely absent.

There are HatBeardClassifier and SimpleFaceDetector classes provided.

See main.py as example of using these classes.

1. Installing

Install Python 3.x.

Clone repository and cd to project directory:

git clone https://github.com/Chifffa/hat_beard_classifier.git
cd hat_beard_classifier

Install dependencies:

pip install -r requirements.txt

2. Video processing

Run this to detect all faces in webcam 0 and classify them:

python main.py -v 0

Or run this to process the video file:

python main.py -v path/to/video/file.avi

Webcam/video will be shown frame-by-frame with all found and classified faces. Press q to stop and exit.

3. Image processing

Run this to detect all faces in images in folder image_folder and classify them:

python main.py --images path/to/image_folder

Or run this to classify whole images without face detection:

python main.py --images path/to/image_folder --no_detector

Processed images will be shown frame-by-frame with all found and classified faces. Press any key to continue to next image or press q to exit.

4. Prediction examples:

example_1.png example_2.png example_3.png

About

Trained CNN for hat/beard classification

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages