# FaceLivenessDetection - Docker

## Overview

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

It stands for `3D passive face liveness detection docker`, `face anti-spoofing docker`, `face fraudulent check docker`, `face liveness check docker`, `fraud prevention docker`, `spoof prevention docker`, `face fraud detection docker` and `biometric fraud` with liveness detection on `Linux` server.

## SDK

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

## Github

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

## dockerhub

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

## 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%2FroDOxwFnJk20NBmWxhUJ%2Fimage.png?alt=media&#x26;token=620cd700-b70b-4aee-93b8-9b772b891a48" 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:8080/check_liveness>
* Test with a `base64-encoded` image: Send a `POST` request to <http://18.221.33.238:8080/check_liveness_base64>
* You can download the `Postman` collection to easily access and use these `endpoints`. [click here](https://github.com/kby-ai/FaceLivenessDetection-Docker/blob/main/postman/kby-ai-live.postman_collection.json)

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2FS1OVRkxjpppjsRMtAUA8%2Fimage.png?alt=media&#x26;token=3dea51fb-61b3-45d5-b23e-eeb2b9fa927c" 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/FaceLivenessDetection-Windows.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 FaceLivenessDetection-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=1bYl0p5uHXuTQoETdbRwYLpd3huOqA3wY' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1bYl0p5uHXuTQoETdbRwYLpd3huOqA3wY" -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-live:latest .
```

* Run the `Docker` container:

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

* 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%2F7fD20yb54uKGE2z853aQ%2Fimage.png?alt=media&#x26;token=12f43d58-ee55-4f09-b083-2cb3e6d2b7f4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2589216230-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1WwtQK0VFwKRGmIjGA3I%2Fuploads%2Fzh0DsFgeZgdH3ksEUa50%2Fimage.png?alt=media&#x26;token=dd7ba90c-ab28-450e-b900-9ce97377c2b2" 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}:8080/check_liveness>.\
  \
  Test with a `base64-encoded` image: Send a `POST` request to <http://{xx.xx.xx.xx}:8080/check_liveness_base64>.\
  \
  You can download the `Postman` collection to easily access and use these `endpoints`. [click here](https://github.com/kby-ai/FaceLivenessDetection-Docker/blob/main/postman/kby-ai-live.postman_collection.json)<br>

### 3. Execute the Gradio demo

* Setup `Gradio`\
  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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kby-ai.com/help/demo-projects/server-windows-linux/facelivenessdetection-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
