# Sample Application

{% hint style="info" %}
**Looking for 1:N face search demo?**

<https://github.com/recognito-vision/Linux-FaceRecognition-FaceLivenessDetection/tree/main/Identification(1%3AN)-Demo>
{% endhint %}

***

## Docker

Pull the Docker image and run the container:

{% code overflow="wrap" %}

```sh
sudo docker pull recognito/face-recognition:latest
sudo docker run -it -e FR_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX" -p 8001:8000 -p 7861:7860 recognito/face-recognition:latest [OPTION --gradio(-g), --flask(-f)]
```

{% endcode %}

***

## Installation

### - Download

Download [**FaceRecognition-Demo.zip\[191M\]**](https://www.dropbox.com/scl/fi/be0v2plf32zcolhvpz807/FaceRecognition-Demo.zip?rlkey=kcev5ywd0qiotz177vxble92s\&st=xhhlgyaw\&dl=0)

The Demo directory contains the following directories and files:

<table data-header-hidden><thead><tr><th width="206"></th><th></th></tr></thead><tbody><tr><td><strong>dependency\</strong></td><td>Dependency files</td></tr><tr><td><strong>engine\</strong></td><td>SDK engine files</td></tr><tr><td><strong>examples\</strong></td><td>Sample images for face recognition</td></tr><tr><td><strong>flask\</strong></td><td>Flask server side demo code</td></tr><tr><td><strong>gradio\</strong></td><td>Gradio demo code</td></tr><tr><td>Dockerfile</td><td>Dockerfile for building a Docker image</td></tr><tr><td>install.sh</td><td>Script for install environment</td></tr><tr><td>license.txt</td><td>License key file</td></tr><tr><td>run_demo.sh</td><td>Script for run demo</td></tr></tbody></table>

### - Install dependencies

Run the `install.sh` script to install dependencies:

```sh
./install.sh
```

### - Setting Up SDK License Key

* **Online Licensing:** Set the online license key as an environment variable:

{% code overflow="wrap" %}

```sh
export FR_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX"
```

{% endcode %}

* **Offline Licensing:** Copy the `license.txt` license file to the demo directory.

***

## Test

### - Run Demo

Run the demo script with the desired option:

{% code overflow="wrap" %}

```sh
./run_demo.sh [OPTION --gradio(-g), --flask(-f), --help(-h)]
```

{% endcode %}

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FibLz5FRHlsfTNAyFKda6%2Frecognition-gradio.png?alt=media&#x26;token=3b1fb9c5-0d12-4444-b47d-fbd7761a2354" alt=""><figcaption></figcaption></figure>

### - Test Flask Server APIs

To test the Flask Server API, you can use [Postman](https://www.postman.com/downloads/). Here are the endpoints for testing:

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face

&#x20; Perform face match between two face image files

&#x20;   **Parameters**

&#x20;        **image1:** image file for the 1st face

&#x20;        **image2:** image file for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

#### &#x20; <mark style="background-color:blue;">POST</mark> /api/compare\_face\_base64

&#x20; Perform face match between two face base64 images

&#x20;   **Parameters**

&#x20;        **image1:** base64 image for the 1st face

&#x20;        **image2:** base64 image for the 2nd face

&#x20;   **Response**&#x20;

&#x20;        **result:** face match result

&#x20;        **similarity:** similarity between two faces

&#x20;        **detection:** face bounding boxes of two faces

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FZQpQ5U6U2h7syZ4hRbV7%2Fpostman.png?alt=media&#x26;token=f21ec19e-1099-4adc-8649-d8125aba9771" alt=""><figcaption><p>Postman usage guide for Flask Demo</p></figcaption></figure>

### - Test Gradio

Go to <http://127.0.0.1:7860/> on a web browser.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FVUCjluR6MPHYIAlAFqQL%2Ffacerecognition-gradio.png?alt=media&#x26;token=f9cf5fce-47b1-453d-a3be-7d36fa6abe06" alt=""><figcaption><p>Gradio Demo</p></figcaption></figure>
