Enable Face Attribute Recognition

Subject to your needs, you can enable automatic recognition of such face attributes as gender, age, emotions, glasses, beard, and face mask. This functionality can be activated on both GPU- and CPU-accelerated video object detectors.

To enable automatic recognition of face attributes, do the following:

  1. Open the /etc/findface-extraction-api.ini configuration file.

    sudo vi /etc/findface-extraction-api.ini
    
  2. Specify the relevant recognition models in the extractors section, as shown in the example below. Be sure to indicate the right acceleration type for each model, matching the acceleration type of findface-extraction-api: CPU or GPU. Be aware that findface-extraction-api on CPU can work only with CPU-models, while findface-extraction-api on GPU supports both CPU- and GPU-models.

    extractors:
      face_age: faceattr/age.v1.gpu.fnk
      face_beard: faceattr/beard.v0.gpu.fnk
      face_emotions: faceattr/emotions.v1.gpu.fnk
      face_gender: faceattr/gender.v2.gpu.fnk
      face_glasses3: faceattr/glasses3.v0.gpu.fnk
      face_medmask3: faceattr/medmask3.v2.gpu.fnk
    

    The following models are available:

    Face attribute

    Acceleration

    Configure as follows

    age

    CPU

    face_age: faceattr/age.v1.cpu.fnk

    GPU

    face_age: faceattr/age.v1.gpu.fnk

    gender

    CPU

    face_gender: faceattr/gender.v2.cpu.fnk

    GPU

    face_gender: faceattr/gender.v2.gpu.fnk

    emotions

    CPU

    face_emotions: faceattr/emotions.v1.cpu.fnk

    GPU

    face_emotions: faceattr/emotions.v1.gpu.fnk

    glasses

    CPU

    face_glasses3: faceattr/glasses3.v0.cpu.fnk

    GPU

    face_glasses3: faceattr/glasses3.v0.gpu.fnk

    beard

    CPU

    face_beard: faceattr/beard.v0.cpu.fnk

    GPU

    face_beard: faceattr/beard.v0.gpu.fnk

    face mask

    CPU

    face_medmask3: faceattr/medmask3.v2.cpu.fnk

    GPU

    face_medmask3: faceattr/medmask3.v2.gpu.fnk

    Tip

    To leave a recognition model disabled, pass the empty value "" to the relevant parameter. Do not remove the parameter itself. Otherwise, the system will be searching for the default model.

    extractors:
      face_age: ""
      face_beard: ""
      face_emotions: ""
      face_gender: ""
      face_glasses3: ""
      face_medmask3: ""
    

    Note

    You can find face attribute recognition models at /usr/share/findface-data/models/faceattr/.

    ls /usr/share/findface-data/models/faceattr/
    age.v1.cpu.fnk  age.v1.gpu.fnk  beard.v0.cpu.fnk  beard.v0.gpu.fnk  emotions.v1.cpu.fnk  emotions.v1.gpu.fnk  gender.v2.cpu.fnk  gender.v2.gpu.fnk  glasses3.v0.cpu.fnk  glasses3.v0.gpu.fnk medmask3.v2.cpu.fnk medmask3.v2.gpu.fnk liveness.alleyn.v2.gpu.fnk quality.v1.cpu.fnk quality.v1.gpu.fnk
    
  3. Restart findface-extraction-api.

    sudo systemctl restart findface-extraction-api
    
  4. To display the face attribute recognition results in the event list, open the /etc/findface-security/config.py configuration file.

    sudo vi /etc/findface-security/config.py
    
  5. Specify the required models in the following line of the FFSECURITY section, subject to the list of enabled models:

    FFSECURITY = {
        ...
        'FACE_EVENTS_FEATURES': ['gender', 'age', 'emotions', 'beard', 'glasses', 'medmask']
        ...
    }
    
  6. Restart findface-security.

    sudo systemctl restart findface-security