Enable Body and Body Attribute Recognition

FindFace Multi allows you to recognize individual human bodies and body attributes (currently only clothing color).

To enable recognition of human bodies and their attributes, do the following:

  1. Specify neural network models for body object and body attribute recognition in the /etc/findface-extraction-api.ini configuration file. Do the following:

    Important

    Be sure to choose 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.

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

      sudo vi /etc/findface-extraction-api.ini
      
    2. Specify the body detector model in the detectors -> models section by pasting the following code:

      GPU

      detectors:
      
        ...
        models:
          ...
          glenn:
            aliases:
            - body
            - silhouette
            model: pedet/glenn_005.gpu.fnk
            options:
              min_object_size: 32
              resolutions: [256x256, 384x384, 512x512, 768x768, 1024x1024, 1536x1536, 2048x2048]
      
        ...
      

      CPU

      detectors:
      
        ...
        models:
          ...
          glenn:
            aliases:
            - body
            - silhouette
            model: pedet/glenn_005.cpu.fnk
            options:
              min_object_size: 32
              resolutions: [256x256, 384x384, 512x512, 768x768, 1024x1024, 1536x1536, 2048x2048]
      
        ...
      
    3. Specify the extraction models in the extractors -> models section, subject to the extractors you want to enable:

      GPU

      extractors:
         ...
         models:
          body_color: pedattr/pedattr.color.v1.gpu.fnk
          body_emben: pedrec/andariel.gpu.fnk
          body_quality: pedattr/pedattr.quality.v0.gpu.fnk
      

      CPU

      extractors:
         ...
         models:
          body_color: pedattr/pedattr.color.v1.cpu.fnk
          body_emben: pedrec/andariel.cpu.fnk
          body_quality: pedattr/pedattr.quality.v0.cpu.fnk
      

      The following extractors are available:

      Recognition type

      Configure as follows

      clothing color

      body_color: pedattr/pedattr.color.v1.gpu.fnk

      body_color: pedattr/pedattr.color.v1.cpu.fnk

      individual body object

      body_emben: pedrec/andariel.gpu.fnk

      body_emben: pedrec/andariel.cpu.fnk

      body quality

      body_quality: pedattr/pedattr.quality.v0.gpu.fnk

      body_quality: pedattr/pedattr.quality.v0.cpu.fnk

      Tip

      To leave a 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:
         ...
         models:
          body_color: ''
          body_emben: ''
          body_quality: ''
      
    4. Make sure that the normalizers section contains a model for the cropbbox normalizer, as shown in the example below. This normalizer is required for the extractors specified in the previous step.

      GPU

      normalizers:
        ...
      
        models:
          ...
          cropbbox:
            model: facenorm/cropbbox.v2.gpu.fnk
      

      CPU

      normalizers:
        ...
      
        models:
          ...
          cropbbox:
            model: facenorm/cropbbox.v2.cpu.fnk
      
    5. Make sure that the objects -> body section contains the quality_attribute: body_quality:

      GPU

      objects:
        ...
        body:
          base_normalizer: facenorm/cropbbox.v2.gpu.fnk
          quality_attribute: body_quality
        ...
      

      CPU

      objects:
        ...
        body:
          base_normalizer: facenorm/cropbbox.v2.cpu.fnk
          quality_attribute: body_quality
      
    6. After completing the configuration file modification, make sure it looks similar to the following example.

    7. Restart findface-extraction-api.

      sudo systemctl restart findface-extraction-api
      
  2. Modify the /etc/findface-video-worker-gpu.ini (/etc/findface-video-worker-cpu.ini) configuration file. In the body section, specify the neural network models by analogy with the example below. Restart findface-video-worker-gpu (findface-video-worker-cpu).

    GPU

    sudo vi /etc/findface-video-worker-gpu.ini
    
    #------------------------------
    [body]
    #------------------------------
    ## detector param
    ## type:number env:CFG_BODY_MIN_SIZE longopt:--body-min-size
    min_size = 60
    
    ## path to body detector
    ## type:string env:CFG_BODY_DETECTOR longopt:--body-detector
    detector = /usr/share/findface-data/models/pedet/glenny_005_fast.gpu.fnk
    
    ## path to normalizer (usually crop2x)
    ## type:string env:CFG_BODY_NORM longopt:--body-norm
    norm = /usr/share/findface-data/models/facenorm/cropbbox.v2.gpu.fnk
    
    ## path to body quality extractor
    ## type:string env:CFG_BODY_QUALITY longopt:--body-quality
    quality = /usr/share/findface-data/models/pedattr/pedattr.quality.v0.gpu.fnk
    
    ## path to body quality normalizer
    ## type:string env:CFG_BODY_NORM_QUALITY longopt:--body-norm-quality
    norm_quality = /usr/share/findface-data/models/facenorm/cropbbox.v2.gpu.fnk
    
    sudo systemctl restart findface-video-worker-gpu.service
    

    CPU

    sudo vi /etc/findface-video-worker-cpu.ini
    
    #------------------------------
    [body]
    #------------------------------
    ## detector param
    ## type:number env:CFG_BODY_MIN_SIZE longopt:--body-min-size
    min_size = 60
    
    ## path to body detector
    ## type:string env:CFG_BODY_DETECTOR longopt:--body-detector
    detector = /usr/share/findface-data/models/pedet/glenny_005_fast.cpu.fnk
    
    ## path to normalizer (usually crop2x)
    ## type:string env:CFG_BODY_NORM longopt:--body-norm
    norm = /usr/share/findface-data/models/facenorm/cropbbox.v2.cpu.fnk
    
    ## path to body quality extractor
    ## type:string env:CFG_BODY_QUALITY longopt:--body-quality
    quality = /usr/share/findface-data/models/pedattr/pedattr.quality.v0.cpu.fnk
    
    ## path to body quality normalizer
    ## type:string env:CFG_BODY_NORM_QUALITY longopt:--body-norm-quality
    norm_quality = /usr/share/findface-data/models/facenorm/cropbbox.v2.cpu.fnk
    
    sudo systemctl restart findface-video-worker-cpu.service
    
  3. Open the /etc/findface-video-manager.conf configuration file and make sure it contains the body section in detectors that looks similar to the example below.

    Tip

    As a reference value for the filter_min_quality parameter, you can take the MINIMUM_BODY_QUALITY parameter value from the /etc/findface-security/config.py configuration file.

    sudo vi /etc/findface-video-manager.conf
    
    detectors:
        ...
        body:
          filter_min_quality: 0.6
          filter_min_size: 1
          filter_max_size: 8192
          roi: ''
          fullframe_crop_rot: false
          fullframe_use_png: false
          jpeg_quality: 95
          overall_only: true
          realtime_post_first_immediately: false
          realtime_post_interval: 1
          realtime_post_every_interval: false
          track_interpolate_bboxes: true
          track_miss_interval: 1
          track_overlap_threshold: 0.25
          track_max_duration_frames: 0
          track_send_history: false
          post_best_track_frame: true
          post_best_track_normalize: true
          post_first_track_frame: false
          post_last_track_frame: false
    
  4. Enable the recognition of bodies and body attributes in the /etc/findface-security/config.py configuration file. Do the following:

    1. In the FFSECURITY section, set 'ENABLE_BODIES': True.

      sudo vi /etc/findface-security/config.py
      
      FFSECURITY = {
          ...
      
          # optional objects to detect
          'ENABLE_BODIES': True,
          ...
      
    2. In the same section, specify the body attributes (color) that you want to display for the body recognition events.

      # available features are: color
      'BODY_EVENTS_FEATURES': ['color'],
      
    3. Restart the findface-security service.

      sudo systemctl restart findface-security.service