# Sample Application

## Installation

### - Download

Download [**WinFaceSDKDemo.rar \[145M\]**](https://drive.google.com/file/d/1X31r6vHNYGVkhQNO2ph-bJmvCurTkNJX/view?usp=drive_link)

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</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><strong>video_surveillance_demo\</strong></td><td>1:N Video Surveillance demo code</td></tr></tbody></table>

### - Install dependencies

Install `python-3.8.9.exe`, `VC_redist.2013.exe`, `VC_redist.2015-2022.exe` files from `dependency` directory.

{% hint style="warning" %}
When install `python-3.8.9.exe`, have to tick the `Add Python3.8 to PATH` option.

<img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FZ3ocvOk7zS6Giwp9qBJy%2Fpython389.png?alt=media&#x26;token=7c6be4f9-9c29-43a9-9136-b586b21e94d8" alt="" data-size="original">
{% endhint %}

### - Setting Up SDK License Key

Copy the `license.txt` license file to the `engine` directory.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FDVX1LGI4PzfAI5mJFpUS%2Flicense.png?alt=media&#x26;token=de4f1eec-82cd-4564-9d72-ca3c7d0d09e8" alt=""><figcaption></figcaption></figure>

***

## Test

### - Test Flask Server APIs

* Install sub-dependencies for Flask Demo

{% code overflow="wrap" %}

```sh
cd flask
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FFxRypOOFx5ECbtUMRfcy%2Frun_flask.png?alt=media&#x26;token=8ffc4850-989e-4687-b86d-934fddd8a018" alt=""><figcaption></figcaption></figure>

* 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/analyze\_face

&#x20; Perform face analysis on an image file

&#x20;   **Parameters**

&#x20;        **image:** image file

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

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

&#x20;        **face\_rect:** face bounding box of detected face

&#x20;        **attribute:** attributes(age, gender, liveness, mask,  wear\_glass) of detected face

#### &#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

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FXiKAsuQW8cFTSnLstoiN%2Flite-liveness-flask.png?alt=media&#x26;token=6ddff0c5-27fd-4a47-8fd0-a8f0f9944381" alt=""><figcaption><p>Postman usage guide for Flask Demo (analyze_face)</p></figcaption></figure>

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2Fcwhtud6F2W1cjx28qFzo%2Flite-recognition-flask.png?alt=media&#x26;token=68240977-4a66-4167-a42f-fc717cfcad20" alt=""><figcaption><p>Postman usage guide for Flask Demo (compare_face)</p></figcaption></figure>

### - Test Gradio

* Install sub-dependencies for Gradio Demo

{% code overflow="wrap" %}

```sh
cd gradio
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FhVmsxGgp5rKP9y7VY0Ez%2Frun.png?alt=media&#x26;token=b75f1504-eb9e-474f-8ad1-624a0b67b022" alt=""><figcaption></figcaption></figure>

* 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%2Fe9y4LtvoT053lAllL7Sr%2Flite-liveness-gradio.png?alt=media&#x26;token=ef7ecbf2-a7e3-4c93-86a6-c535c1d0a25e" alt=""><figcaption><p>Gradio Demo (face attribute)</p></figcaption></figure>

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FwUDsxoicXI7jvLtaD3Hu%2Flite-recognition-gradio.png?alt=media&#x26;token=bda491ce-f1b2-4f24-a215-265736081ae4" alt=""><figcaption><p>Gradio Demo (face recognition)</p></figcaption></figure>

### - Test 1:N Surveillance

* Install sub-dependencies for Surveillance Demo

{% code overflow="wrap" %}

```sh
cd video_surveillance_demo
python -m pip install -r requirements.txt
```

{% endcode %}

* Run `app.py` script:

{% code overflow="wrap" %}

```shell
python app.py
```

{% endcode %}

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FOAOP22WMFlpixoXY4SUq%2Fsurveillance.png?alt=media&#x26;token=6e04e6c0-2efe-416a-bb96-4534ff09bc9d" alt=""><figcaption></figcaption></figure>

* Main Page

When you run the `app.py` script, the main page appears first.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FkWwYnzRsFFZLP9EvsRdA%2Fvd_main.png?alt=media&#x26;token=0b77f868-54aa-44de-8b7a-be1e2214166d" alt=""><figcaption><p>main page in 1:N surveillance</p></figcaption></figure>

* Register Person Page

You can enroll user from image.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FkD9dpwoyE45TRu0LYaTG%2Fvd_register.png?alt=media&#x26;token=641d78c5-05d2-4d18-8bd0-677fc8802528" alt=""><figcaption><p>user registration page</p></figcaption></figure>

* User List Page

The registered user list is displayed.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FMTVAD9DkDMBqhhyGZTa2%2Fvd_userlist.png?alt=media&#x26;token=b4cfda68-d6cd-4f3c-bcbe-90abe86806f8" alt=""><figcaption><p>user list page</p></figcaption></figure>

* Photo Match Page

You can identify registered users from selected image.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2F55u5bezT6XKpjsH4mCld%2Fvd_photomatch.png?alt=media&#x26;token=99e93789-bf3a-402c-b6eb-cc741e894c3c" alt=""><figcaption><p>photo match page</p></figcaption></figure>

* Video Surveillance Page

You can identify registered users from video stream.

Media file, RTSP stream, Web Camera can be used as video stream.

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FbliuDiYopStpf9cqMYnn%2Fvd_videoinput.png?alt=media&#x26;token=40812b06-9fe8-43ee-b5e5-31b118f73fee" alt=""><figcaption><p>select video stream page</p></figcaption></figure>

<figure><img src="https://3902005046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxiEW2bRNeDz3JZIL41gD%2Fuploads%2FoMgWJCLE5AUCeHvKayuK%2Fvd_video.jpg?alt=media&#x26;token=cc35350b-d808-4906-8180-fa4df5003140" alt=""><figcaption><p>video surveillance page</p></figcaption></figure>
