CompreFace Documentation

repository·master·Indexed 27 days ago

https://github.com/exadel-inc/compreface

A free and open-source face recognition system providing a REST API for facial detection, recognition, and verification. It supports various custom builds optimized for CPU and GPU (CUDA), including models like FaceNet, Mobilenet, and SubCenter-ArcFace-r100. The system is deployable via Docker and includes components such as the embedding-calculator service and a Java-based admin application.

Tokens
22.4K
Snippets
57
Records
127
Agent score
93%

What's inside CompreFace

  1. Available CompreFace Face Services and Plugins

    master

    CompreFace provides several face recognition services and plugins via REST API:

    Core Services:

    • Face detection
    • Face recognition
    • Face verification

    Plugins:

    • Landmark detection
    • Age recognition
    • Gender recognition
    • Face mask detection
    • Head pose detection
  2. Understand CompreFace Global Roles

    master

    Global roles define permissions for maintaining the CompreFace system itself. There are three types of global roles:

    • Global Owner: The first user created in the system. Has full rights to manage users and create/manage applications. A global owner cannot delete themselves; they must assign the role to another user first.
    • Global Administrator: Has permissions similar to the owner but cannot manage the Global Owner.
    • Global User: The default role for all new users. These users cannot create applications, manage other users, or access applications unless they are explicitly added to them.
  3. Understand the CompreFace frontend architecture

    master

    The frontend follows a structured Angular architecture organized by responsibility:

    Folder Structure

    • styles/: Common SCSS styles.
    • core/: Global framework-based services.
    • data/: Global models, enums, classes, and interfaces (e.g., user models, permissions, roles). Note: Do not place DTOs here.
    • feature/containers/: Smart/container components that communicate with the store via facades.
    • feature/components/: Presentational/dumb components that communicate with containers via @Input and @Output.
    • pages/: Router modules (e.g., home, login, 404) and components responsible for page layout and feature composition.

    State Management (Store)

    State is managed using NgRx. The store/ directory contains the root index.ts with the union store and reducers. Feature-specific state is organized as follows:

    • store/featureName/module: Encapsulated feature store using StoreModule.forFeature.
    • store/featureName/actions: Actions handled by effects or reducers; can be called via facades.
    • store/featureName/effects: Side-effect handlers (e.g., API calls).
    • store/featureName/selectors: Selectors for retrieving feature state.
    • store/featureName/reducers: Pure functions that handle state changes.
    • store/featureName/feature-entitys.service.ts: Service for accessing entities via NgRx Data patterns.
  4. Understand Face mask detection plugin results

    master

    The Face mask detection plugin automatically detects if a person is wearing a mask correctly. When using this plugin, the model returns one of three possible result labels:

    • without_mask
    • mask_worn_incorrectly
    • mask_worn_correctly

    Disclaimer: This plugin was created by software developers, not medical experts. The model accuracy is not 100%, and it does not provide medical recommendations on how to wear a mask correctly. Use at your own risk.

  5. Choose a CompreFace distribution option

    master

    CompreFace offers three primary deployment methods depending on your environment and needs:

    • Docker Compose (Default): Best for local installation. Offers simple configuration and high reliability through separate services.
    • Kubernetes: Best for production installations. Designed for easy scaling in a cluster environment.
    • Single docker container: Best for local installation if Docker Compose is not supported. It is the simplest to run but the least reliable and hardest to troubleshoot as all services run in one container.
  6. Compare CompreFace custom-builds

    master

    CompreFace offers several custom-builds optimized for different hardware (CPU vs GPU) and performance requirements (speed vs accuracy). When choosing a build, consider your hardware capabilities (AVX/AVX2 instructions or CUDA for GPU) and whether you prioritize speed or detection/recognition accuracy.

    Build Selection Guide

    • General Purpose: Use FaceNet (default). It supports CPUs without AVX2.
    • High Speed (CPU): Use Mobilenet. It is the fastest among CPU-only models but requires AVX2 instructions.
    • High Speed (GPU): Use Mobilenet-gpu. This is the fastest overall model but requires a GPU with CUDA.
    • High Accuracy (CPU): Use SubCenter-ArcFace-r100. This is the most accurate CPU model but is significantly slower.
    • High Accuracy (GPU): Use SubCenter-ArcFace-r100-gpu. This provides the highest accuracy and requires a GPU with CUDA.
    • Experimental (Masked): Use FaceNet Masked for experimental face recognition on masked faces.
    | Custom-build                  | Base library                                              | CPU                     | GPU                 | Face detection model / accuracy on [WIDER Face (Hard)] | Face recognition model / accuracy on [LFW] | Age and gender detection                                                            | Face mask detection                                                            | Comment                                        |
    |-------------------------------|-----------------------------------------------------------|-------------------------|---------------------|---------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|--------------------------------------------------|------------------------------------------------|
    | FaceNet (default)            | [FaceNet](https://github.com/davidsandberg/facenet)       | x86 (AVX instructions)  | not supported       | MTCNN / 80.9%                                                                                                             | FaceNet (20180402-114759) / 99.63%                                                                                    | Custom, the model is taken [here](https://github.com/GilLevi/AgeGenderDeepLearning) | [Custom model](../docs/Mask-detection-plugin.md) | For general purposes. Support CPU without AVX2 |
    | FaceNet Masked (Experimental) | [FaceNet](https://github.com/davidsandberg/facenet)       | x86 (AVX instructions)  | not supported       | MTCNN / 80.9%                                                                                                             | inception_v3_on_mafa_kaggle123 / 98.73%                                                                               | Custom, the model is taken [here](https://github.com/GilLevi/AgeGenderDeepLearning) | [Custom model](../docs/Mask-detection-plugin.md) | For general purposes. Support CPU without AVX2 |
    | Mobilenet                     | [InsightFace](https://github.com/deepinsight/insightface) | x86 (AVX2 instructions) | not supported       | RetinaFace-MobileNet0.25 / 82.5%                                                                                          | MobileFaceNet,ArcFace / 99.50%                                                                                          | InsightFace                                                                         | [Custom model](../docs/Mask-detection-plugin.md) | The fastest model among CPU only models        |
    | Mobilenet-gpu                 | [InsightFace](https://github.com/deepinsight/insightface) | x86 (AVX2 instructions) | GPU (CUDA required) | RetinaFace-MobileNet0.25 / 82.5%                                                                                          | MobileFaceNet,ArcFace / 99.50%                                                                                         | InsightFace                                                                         | [Custom model](../docs/Mask-detection-plugin.md) | The fastest model                              |
    | SubCenter-ArcFace-r100        | [InsightFace](https://github.com/deepinsight/insightface) | x86 (AVX2 instructions) | not supported       | retinaface_r50_v1 / 91.4%                                                                                                 | arcface-r100-msfdrop75 / 99.80%                                                                                       | InsightFace                                                                         | [Custom model](../docs/Mask-detection-plugin.md) | The most accurate model, but the most slow     |
    | SubCenter-ArcFace-r100-gpu    | [InsightFace](https://github.com/deepinsight/insightface) | x86 (AVX2 instructions) | GPU (CUDA required) | retinaface_r50_v1 / 91.4%                                                                                                 | arcface-r100-msfdrop75 / 99.80%                                                                                       | InsightFace                                                                         | [Custom model](../docs/Mask-detection-plugin.md) | The most accurate model                        |
  7. Understand CompreFace Application Roles

    master

    Application roles define a user's permissions within a specific application. To be a member of an application team, a user must first have the Global User role and then be added to the application by a Global Owner, Global Administrator, or Application Owner.

    Application roles include:

    • Application Owner: The user who creates the application. Has full rights to manage the application, its users, and Face Services. An application owner cannot delete themselves without first assigning the role to someone else.
    • Application Administrator: (Requires Global User role) Can create and manage Face Services but cannot manage the application settings or its users.
    • Application User: (Requires Global User role) The least permissive role. This user cannot manage anything within the application but has sufficient access to integrate CompreFace with other applications.
  8. Access CompreFace Documentation and Guides

    master

    The CompreFace documentation repository contains several specialized guides for developers. Key resources include:

  9. Quickstart the CompreFace frontend

    master

    To run the CompreFace web application locally, ensure you have the backend API running (refer to the /dev folder README for API setup instructions). Then, execute the following commands in the ui directory:

    1. Install dependencies: npm install
    2. Start the development server: npm start

    The application will be available at http://localhost:4200.

    npm install
    npm start
  10. Create a Face Verification service

    master

    Use the Face verification service to compare two specific faces and determine if they belong to the same person. It returns a similarity score between the two provided images.

    Setup via UI:

    1. Click Create on the CompreFace application page.
    2. In the Type drop-down, select VERIFICATION.
    3. Enter a service name and save.
    4. Select the service from the list and click Test to upload two pictures for comparison.
  11. Determine the Face Recognition Similarity Threshold

    master

    CompreFace face recognition and face verification services return a similarity score between faces. Because no recognition service is 100% accurate, you must define a similarity threshold to decide whether a match is acceptable.

    • Low Threshold: Increases the risk of False Positives (unknown faces being recognized as known).
    • High Threshold: Increases the risk of False Negatives (known faces being recognized as unknown).

    CompreFace typically produces correct matches with a similarity score above 0.5 and incorrect matches with a score below 0.5.

  12. Choose a CompreFace custom build

    master

    CompreFace offers custom builds to balance face recognition accuracy, system throughput, and hardware support. The default build is optimized for wide hardware compatibility but lacks GPU support and optimization for the latest CPUs.

    Use these guidelines to select a build:

    • Real-time recognition: Choose builds with GPU support.
    • Low-performance/Old hardware: Choose builds using models initially created for mobile.
    • Accuracy vs. Resources: Do not assume the most accurate model is always best; accuracy differences are often minor, but hardware resource requirements can vary significantly.