.. _bodies: Enable Body and Body Attribute Recognition ============================================== FindFace Multi allows you to recognize individual human bodies and body attributes. The body attributes are the following: * clothing type: * generalized category of upper body wear: long sleeves, short sleeves, no sleeve * specific type of upper body wear: jacket, coat, sleeveless vest, sweatshirt, T-shirt, shirt, dress * type of lower body wear: pants, skirt, shorts, obscured * type of headgear: hat, hood, none * clothing color (top/bottom) To enable recognition of human bodies and their attributes, do the following: #. 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. #. Open the ``/etc/findface-extraction-api.ini`` configuration file. .. code:: sudo vi /etc/findface-extraction-api.ini #. Specify the body detector model in the ``detectors -> models`` section by pasting the following code: .. rubric:: GPU .. code:: 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] ... .. rubric:: CPU .. code:: 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] ... #. Specify the extraction models in the ``extractors -> models`` section, subject to the extractors you want to enable: .. rubric:: GPU .. code:: extractors: ... models: body_clothes: pedattr/pedattr.clothes_type.v0.gpu.fnk body_color: pedattr/pedattr.color.v1.gpu.fnk body_emben: pedrec/andariel.gpu.fnk body_quality: pedattr/pedattr.quality.v0.gpu.fnk .. rubric:: CPU .. code:: extractors: ... models: body_clothes: pedattr/pedattr.clothes_type.v0.cpu.fnk 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 type | ``body_clothes: pedattr/pedattr.clothes_type.v0.gpu.fnk`` | | +---------------------------------------------------------------------------------+ | | ``body_clothes: pedattr/pedattr.clothes_type.v0.cpu.fnk`` | +------------------+---------------------------------------------------------------------------------+ | clothing color | ``body_color: pedattr/pedattr.color.v1.gpu.fnk`` | | +---------------------------------------------------------------------------------+ | | ``body_color: pedattr/pedattr.color.v1.cpu.fnk`` | +------------------+---------------------------------------------------------------------------------+ | individual body | ``body_emben: pedrec/andariel.gpu.fnk`` | | object +---------------------------------------------------------------------------------+ | | ``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. .. code:: extractors: ... models: body_clothes: '' body_color: '' body_emben: '' body_quality: '' #. 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. .. rubric:: GPU .. code:: normalizers: ... models: ... cropbbox: model: facenorm/cropbbox.v2.gpu.fnk .. rubric:: CPU .. code:: normalizers: ... models: ... cropbbox: model: facenorm/cropbbox.v2.cpu.fnk #. Make sure that the ``objects -> body`` section contains the ``quality_attribute: body_quality``: .. rubric:: GPU .. code:: objects: ... body: base_normalizer: facenorm/cropbbox.v2.gpu.fnk quality_attribute: body_quality ... .. rubric:: CPU .. code:: objects: ... body: base_normalizer: facenorm/cropbbox.v2.cpu.fnk quality_attribute: body_quality #. After completing the configuration file modification, make sure it looks similar to the :download:`following example <_scripts/findface-extraction-api.txt>`. #. Restart ``findface-extraction-api``. .. code:: sudo systemctl restart findface-extraction-api #. 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``). .. rubric:: GPU .. code:: 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 .. code:: sudo systemctl restart findface-video-worker-gpu.service .. rubric:: CPU .. code:: 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 ## path to body track features extractor ## type:string env:CFG_BODY_TRACK_FEATURES longopt:--body-track-features track_features = ## path to body track features normalizer ## type:string env:CFG_BODY_TRACK_FEATURES_NORM longopt:--body-track-features-norm track_features_norm = .. code:: sudo systemctl restart findface-video-worker-cpu.service #. 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. .. code:: sudo vi /etc/findface-video-manager.conf detectors: ... body: filter_min_quality: 0.65 filter_min_size: 1 filter_max_size: 8192 roi: "" fullframe_crop_rot: false fullframe_use_png: false jpeg_quality: 95 overall_only: false 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 tracker_type: simple_iou track_deep_sort_matching_threshold: 0.65 track_deep_sort_filter_unconfirmed_tracks: true #. Enable the recognition of bodies and body attributes in the ``/etc/findface-security/config.py`` configuration file. Do the following: #. In the ``FFSECURITY`` section, set ``'ENABLE_BODIES': True``. .. code:: sudo vi /etc/findface-security/config.py FFSECURITY = { ... # optional objects to detect 'ENABLE_BODIES': True, ... #. In the same section, specify the body attributes that you want to display for the body recognition events. .. code:: # available features are: color, clothes 'BODY_EVENTS_FEATURES': ['color', 'clothes'], #. Restart the ``findface-security`` service. .. code:: sudo systemctl restart findface-security.service