# FaceRecognition - Docker

## Overview

This project demonstrates an advanced `face recognition` technology implemented via a `Dockerized Flask API`.

It stands for `face recognition docker`, `facial recognition docker`, `face liveness check docker`, `spoofing prevention docker`, `face matching docker`, `face comparison docker`, `face search engine docker`, `face identification docker` on `Linux` server.

## SDK

{% content-ref url="../../product/face-liveness-detection-sdk-face-recognition-sdk/face-recognition-sdk-server" %}
[face-recognition-sdk-server](https://docs.kby-ai.com/help/product/face-liveness-detection-sdk-face-recognition-sdk/face-recognition-sdk-server)
{% endcontent-ref %}

## Github

{% embed url="<https://github.com/kby-ai/FaceRecognition-Docker>" %}

## dockerhub

{% embed url="<https://hub.docker.com/r/kbyai/face-recognition>" %}

## Test Online

{% embed url="<https://web.kby-ai.com/>" %}

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FsZXEMzebOPYa3xcKRvFZ%2Fimage.png?alt=media&#x26;token=70bcdc66-882f-486e-9c16-bad6723b271a" alt=""><figcaption></figcaption></figure>

## Postman

To test the `API`, you can use `Postman`. Here are the `endpoints` for testing:

* Test with an image file: Send a `POST` request to <http://18.221.33.238:8081/compare_face>
* Test with a `base64-encoded` image: Send a `POST` request to <http://18.221.33.238:8081/compare_face_base64>
* You can download the `Postman` collection to easily access and use these `endpoints`. [click here](https://github.com/kby-ai/FaceRecognition-Docker/tree/main/postman/kby-ai-face.postman_collection.json)

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Frd10ypFBGD2lT90R5pJW%2Fimage.png?alt=media&#x26;token=2fb386f6-5a51-48db-9166-5ea7365a25fc" alt=""><figcaption></figcaption></figure>

## How to Run

### 1. System Requirements

**CPU:** 2 cores or more (Recommended: 8 cores)&#x20;

**RAM:** 4 GB or more (Recommended: 8 GB)&#x20;

**HDD:** 4 GB or more (Recommended: 8 GB)&#x20;

**OS:** Ubuntu 20.04 or later&#x20;

**Dependency:** OpenVINO™ Runtime (Version: 2022.3)

### 2. Setup and Test

* Clone the project:

```bash
git clone https://github.com/kby-ai/FaceRecognition-Docker.git
```

* Download the model from `Google Drive` and unzip it: [click here](https://drive.google.com/file/d/1bYl0p5uHXuTQoETdbRwYLpd3huOqA3wY/view?usp=share_link)

```bash
cd FaceRecognition-Docker

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=19vA7ZOlo19BcW8v4iCoCGahUEbgKCo48' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=19vA7ZOlo19BcW8v4iCoCGahUEbgKCo48" -O data.zip && rm -rf /tmp/cookies.txt

unzip data.zip
```

* Build the `Docker` image:

```bash
sudo docker build --pull --rm -f Dockerfile -t kby-ai-face:latest .
```

* Run the `Docker` container:

```bash
sudo docker run -v ./license.txt:/home/openvino/kby-ai-face/license.txt -p 8081:8080 kby-ai-face
```

* Send us the `machine code` and replace the `license.txt` file you received. Then, run the `Docker` container again.

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Fxf7yv2UOiSUFpzQlfO5l%2Fimage.png?alt=media&#x26;token=ff7ff920-c920-4094-908c-7d743fec6ac1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FuGe4FDcCBWrnp2aup0Bc%2Fimage.png?alt=media&#x26;token=44acf994-6b94-45c2-b7df-6063fee77254" alt=""><figcaption></figcaption></figure>

* To test the `API`, you can use `Postman`. Here are the `endpoints` for testing:\
  \
  Test with an image file: Send a `POST` request to <http://{xx.xx.xx.xx}:8081/compare_face>\
  \
  Test with a `base64-encoded` image: Send a `POST` request to <http://{xx.xx.xx.xx}:8081/compare_face_base64>\
  \
  You can download the `Postman` collection to easily access and use these `endpoints`. [click here](https://github.com/kby-ai/FaceRecognition-Docker/tree/main/postman/kby-ai-face.postman_collection.json)<br>

### 3. Execute the Gradio demo

* Setup `Gradio`&#x20;

Ensure that you have the necessary dependencies installed.\
\
`Gradio` requires `Python 3.6` or above.\
\
You can install `Gradio` using `pip` by running the following command:

```bash
pip install gradio
```

* Run the demo by using the following command:

```bash
cd gradio
python demo.py
```

* You can test within the following `URL`:\
  \
  <http://127.0.0.1:9000>
