Choosing a face classification model

Face Classification objects, embedding pretrained DNN models, are implemented in module inaFaceAnalyzer.face_classifier.

Face Classification classes inherits from abstract class FaceClassifier. They assume

They implement implement a FaceClassifier.preprocessed_img_list() method, allowing.

FaceClassifier.__call__() method.

>>> from inaFaceAnalyzer.face_classifier import Resnet50FairFaceGRA
>>> classif = Resnet50FairFaceGRA()
>>> classif.preprocessed_img_list(['./media/diallo224.jpg', './media/knuth224.jpg'])
                filename  sex_decfunc  age_decfunc sex_label  age_label
0  ./media/diallo224.jpg    -5.632371     3.072337         f  25.723367
1   ./media/knuth224.jpg     7.255364     6.689072         m  61.890717

sdfsdf

class inaFaceAnalyzer.face_classifier.FaceClassifier[source]

Bases: abc.ABC

Abstract class to be implemented by face classifiers

__call__(limg, verbose=False)[source]

Classify a list of images images are supposed to be preprocessed faces: aligned, cropped :param limg: :type limg: list of images, a single image can also be used

Returns

  • feats – face features used as input to the final classifier

  • label (str) – f for female, m for male

  • decision_value (float) – decision function value (negative for female, positive for male)

preprocessed_img_list(lfiles, batch_len=32)[source]

Performs classification on a list of preprocessed face images Preprocessed face images are assumed to contain a single face which is already detected, cropped, aligned and scaled to classifier’s input dimensions (for now: 224*224 pixels)

Parameters
  • lfiles (list) – list of image paths: [‘/path/to/img1’, ‘/path/to/img2’]

  • batch_len (int, optional) – DNN batch size. Larger batch_len results in faster processing times. Batch lenght is dependent on available GPU memory. Defaults to 32 (suitable for a laptop GPU).

Returns

pandas.DataFrame. a DataFrame with one record for each input image

class inaFaceAnalyzer.face_classifier.Resnet50FairFace[source]

Bases: inaFaceAnalyzer.face_classifier.FaceClassifier

class inaFaceAnalyzer.face_classifier.Resnet50FairFaceGRA[source]

Bases: inaFaceAnalyzer.face_classifier.Resnet50FairFace

Resnet50FairFaceGRA predicts age and gender and is the most accurate proposed. It uses Resnet50 architecture and is trained to predict gender, age and race on FairFace. After consultation of French CNIL (French data protection authority) and DDD (French Rights Defender), racial classification layers were erased from this public distribution in order to prevent their use for non ethical purposes. These models can however be provided for free after examination of each demand.

class inaFaceAnalyzer.face_classifier.OxfordVggFace(hdf5_svm=None)[source]

Bases: inaFaceAnalyzer.face_classifier.FaceClassifier

OxfordVggFace instances are based on pretrained VGG16 architectures pretrained using a triplet loss paradigm allowing to obtain face neural representation, that we use to train linear SVM classification systems.

The approach used is fully described in Zohra Rezgui’s internship report at INA: Détection et classification de visages pour la description de l’égalité femme-homme dans les archives télévisuelles, Higher School of Statistics and Information Analysis, University of Carthage, 2019

This class takes advantage of Refik Can Malli’s keras-vggface module, providing pretrained VGG16 models https://github.com/rcmalli/keras-vggface

class inaFaceAnalyzer.face_classifier.Vggface_LSVM_YTF[source]

Bases: inaFaceAnalyzer.face_classifier.OxfordVggFace

class inaFaceAnalyzer.face_classifier.Vggface_LSVM_FairFace[source]

Bases: inaFaceAnalyzer.face_classifier.OxfordVggFace