Skip to main content

This repository is used for face classification.

Project description

Face classifier

This repository is used for face classification. It can detect:

  • open-closed eyes
  • sunglasses
  • profile/frontal
  • blurry image.

You can find the repository on github.

If you want to use the library directly, go to pypi.

Disclaimer

The classifier works better with face cropped pictures, the models have been trained using this face recognition repossitory on group pictures.

Better use them in combination or crop the face picture yourself.

This repository comes with absolutely no guarantees.

Use Examples

Closed eyes

from face_classify import classifier
classifier(image_or_path='face_classify/data/open_test/closed5.jpg')

png

Output:

{'name': 'face1',
 'blurry': 0.0,
 'profile': 0.0,
 'sunglasses': 0.002,
 'eyes': (0.009, 0.011)}

with crop face

classifier(image_or_path='face_classify/data/open_test/closed5.jpg', crop_face = True)

png

Output:

{'name': 'face1',
 'blurry': 0.0,
 'profile': 0.0,
 'sunglasses': 0.0,
 'eyes': (0.0, 0.0)}

Open eyes

classifier(image_or_path='face_classify/data/open_test/open2.jpg', crop_face = True)

png

Output:

{'name': 'face2',
 'blurry': 0.0,
 'profile': 0.0,
 'sunglasses': 0.0,
 'eyes': (0.918, 0.924)}

Profile

classifier(image_or_path='face_classify/data/profile_test/profile2.jpg', crop_face = True)

png

Output:

{'name': 'face3',
 'blurry': 0.001,
 'profile': 1.0,
 'sunglasses': None,
 'eyes': None}

Sunglasses

classifier(image_or_path='face_classify/data/sunglasses_test/sunglass1.jpg', crop_face = True)

png

Output:

{'name': 'face4',
 'blurry': 0.0,
 'profile': 0.0,
 'sunglasses': 0.313,
 'eyes': (0.0, 0.0)}

Blurry

classifier(image_or_path='face_classify/data/blurry_test/blurry12.jpg', crop_face = True)

png

Output:

{'name': 'face5',
 'blurry': 1.0,
 'profile': None,
 'sunglasses': None,
 'eyes': None}

Requirements

  • matplotlib==3.3.4
  • numpy==1.19.5
  • tensorflow==2.9.1
  • face_recognition==1.3.0

Models

These models have been trained separately using the code from this other repository that I created for 'weddings' pictures classification. Specially bad pictures with closed eyes.

I used a pretrained model MobilenetV2. And then retrained using my own dataset.

The models have been trained with around 10k pictures each.

I cannot upload the datasets as they are mostly from weddings of a friend photographer.

How it works

The main goal is to find if a face has opened or closed eyes. For this purpose the program will check a condition and then continue to the next one depending on the result, the order is as follows:

  1. Check if Blurry picture -> Continues if its not blurry
  2. Profile/Frontal picture -> Continues if its frontal
  3. Wearing Sunglasses -> Continue if not sunglasses detected
  4. Check Open-Closed eyes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

face_classify-0.0.9.tar.gz (33.7 MB view details)

Uploaded Source

Built Distribution

face_classify-0.0.9-py3-none-any.whl (33.7 MB view details)

Uploaded Python 3

File details

Details for the file face_classify-0.0.9.tar.gz.

File metadata

  • Download URL: face_classify-0.0.9.tar.gz
  • Upload date:
  • Size: 33.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.5

File hashes

Hashes for face_classify-0.0.9.tar.gz
Algorithm Hash digest
SHA256 e9458c2e66765f4a508d01197661425b7f9384c8a54d51170846497b0685dc59
MD5 4103b5cd55489b8b369b3285fa6158fc
BLAKE2b-256 43392c2f77bc8c39ba568d394081c3a345b1c6ec8f0f7d7488bdb42d0ebff4b8

See more details on using hashes here.

File details

Details for the file face_classify-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for face_classify-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 abfd1fc978d7a0b432134e048d2f4fa270e60c05297b0f89cc74fe7170dfdb4b
MD5 6fd07397f4d790ae86d9882d4f8e1f2e
BLAKE2b-256 abd9564367d2f12cbfff7c2b7246468f6d56810b487fa0d35264aaffae3ef322

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page