Build Status

Face Privacy Filter Guide

This model contains the capability to generate two submodels: one for face detection and one for face suppression through pixelation.

A model example for face detection from images within Acumos.

Sample image with detection and pixelation/blur filter


This model analyzes static images to detect frontal faces. It utilizes a frontal face cascade from the OpenCV image processing library. Model load time is optimized by creating and maintaining the fixed cascade in memory while operating. Demonstrating the capability of custom classes and requisite member variables, the cascade is serialized with the model as a string asset which is deserialized and loaded from disk upon startup.


Input to the model is an array of one or more tuples of image binary data and a binary mime type. The position of the image within the array is utilized in the output signature as a zero-based index. For example if three images were sent, the output probabilities would have 0, 1, and 2 as index values. The output from this model is a repeated array of detected regions for each face in each input image. So that image data can be cascaded to other models, the original image and mime type are also embedded with the special region code -1 within the output.

A web demo is included with the source code, available via the Acumos Gerrit repository or the mirrored Acumos Github repository. It utilizes a protobuf javascript library and processes input images to detect all faces within an image.

Once deployed, you can quickly jump to the default webhost page and point to your model for a demo; see Demonstrations: Tutorial for Face Privacy for more details.


As this model wraps a preexisting cascade, no formal testing evaluation was performed. However, experimental usage indicates the following highlights.

  • Faces that are too small can easily be missed.
  • Frontal faces perform best, with some tolerance of about 5-10 degrees off-plane rotation.
  • Detection is fairly sensitive to rotation in plane, so try not to let subject faces rotate more than 15 degrees.
  • Dark or low contrast images generally do not perform well for detection.

More Information

As this model uses a generic cascade from OpenCV, readers can easily substituted or update those models with no change in API endpoint required. Additionally, secondary verification methods using pixel validation (e.g. sub-part verification, symmetry tests, or more advanced parts-based verifications) may dramatically improve the false alarm rate, although the current model was tuned for precision (instead of recall) already.

Source Installation

This section is useful for source-based installations and is not generally intended for catalog documentation.

Image Analysis for Face-based Privacy Filtering

This source code creates and pushes a model into Acumos that processes incoming images and outputs a detected faces as well as the original image input (if configured that way). The model uses a python interface to the OpenCV library to detect faces and perform subsequent image processing. This module does not support training at this time and instead uses a pre-trained face cascade, which is included (from OpenCV) in this module.

Package dependencies

Package dependencies for the core code and testing have been flattened into a single file for convenience. Instead of installing this package into your your local environment, execute the command below.

Note: If you are using an anaconda-based environment, you may want to try installing with conda first and then pip.

conda install --yes --file requirements.txt  # suggested first step if you're using conda

Installation of the package requirements for a new environment.

pip install -r requirements.txt


This package contains runable scripts for command-line evaluation, packaging of a model (both dump and posting), and simple web-test uses. All functionality is encapsulsted in the script and has the following arguments.

usage: [-h] [-p PREDICT_PATH] [-i INPUT] [-c]
                       [-f {detect,pixelate}] [-s] [-a PUSH_ADDRESS]
                       [-A AUTH_ADDRESS] [-d DUMP_MODEL]

optional arguments:
  -h, --help            show this help message and exit

main execution and evaluation functionality:
  -p PREDICT_PATH, --predict_path PREDICT_PATH
                        save detections from model (model must be provided via
  -i INPUT, --input INPUT
                        absolute path to input data (image or csv, only during
                        prediction / dump)
  -c, --csv_input       input as CSV format not an image
  -f {detect,pixelate}, --function {detect,pixelate}
                        which type of model to generate
  -s, --suppress_image  do not create an extra row for a returned image

model creation and configuration options:
  -a PUSH_ADDRESS, --push_address PUSH_ADDRESS
                        server address to push the model (e.g.
  -A AUTH_ADDRESS, --auth_address AUTH_ADDRESS
                        server address for login and push of the model (e.g.
  -d DUMP_MODEL, --dump_model DUMP_MODEL
                        dump model to a pickle directory for local running

Example Usages

Please consult the Tutorial dirctory for usage examples including an in-place Demonstrations: Tutorial for Face Privacy.

Face-based Use Cases

This project includes a number of face-based use cases including raw detection, blurring, and other image-based modifications based on detected image regions.

  • Face Detection Use-case - This source code creates and pushes a model that processes incoming images and outputs detected faces.

Metadata Examples