# IDLivenessSDK - Linux

{% hint style="success" %}
Our SDK is fully on-premise, processing all happens on hosting server and no data leaves your server.
{% endhint %}

## Introduction

Welcome to the **MiniAiLive** ID Document Liveness Detection SDK! \
\
**MiniAiLive's** Complete Document Liveness Detection Solution for Digital Onboarding here! With 70% of fraud in digital onboarding and KYC happening with document fraud—or document presentation attacks—identity verification is a critical line of defense against the financial and reputational damage of document fraud. That’s where document liveness detection software comes in. It detects when an identity document is not genuine but instead a document presentation attack. With our product suite, you can address the three most common presentation attacks universally across all the common types of identity documents anywhere in the world without needing to train on document templates. Try it out today!

## Installation

### Prerequisites

* Python 3.6+
* Linux
* CPU: 2 cores or more
* RAM: 4GB or more

### Installation Steps

1. **Download the ID Document Liveness Detection Linux Server Installer**

   Download the Server installer for your operating system from the following link:

   [Download the On-premise Server Installer](https://drive.google.com/file/d/1f1G5ORKgg9sCBDxKZR_uPweS8hhO7Cna/view?usp=sharing)
2. **Install the On-premise Server**

   Run the installer and follow the on-screen instructions to complete the installation. Go to the Download folder and run this command.

```
$ cd Download
$ sudo dpkg -i --force-overwrite MiniAiLive-IDLiveness-LinuxServer.deb
```

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2Fqx1jcdjA0VGE0HOyUKw7%2Fimage.png?alt=media&#x26;token=a6dbb261-530e-4f86-857d-a8afdbeb0a1a" alt="" width="563"><figcaption></figcaption></figure>

3. **Request License and Update**\
   You can generate the License Request file by using this command:

```
$ cd /opt/mini-idliveness/
$ sudo ./MiRequest request /home/ubuntu/Download/trial_key.miq
```

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2FkmxWC075gSLRnzxLbRlh%2Fimage.png?alt=media&#x26;token=40b7a209-8f49-46f2-ae5e-fbe5d2d5c876" alt="" width="563"><figcaption></figcaption></figure>

Then you can see the license request file on your directory, and send it to us via [email ](mailto:info@miniai.live)or [WhatsApp](https://wa.me/+19162702374). We will send the license based on your Unique Request file, then you can upload the license file to allow to use. Refer the below images.

```
$ sudo ./MiRequest update /home/ubuntu/Download/trial_key.mis
```

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2F4jMo8IKnlC1E9IFLlUbX%2Fimage.png?alt=media&#x26;token=09d395d6-797d-45b6-84f2-25324d9477ab" alt="" width="563"><figcaption></figcaption></figure>

4. **Verify Installation**\
   After installation, verify that the On-premise Server is correctly installed by using this command:

```
$ systemctl list-units --state running
```

If you can see 'Mini-idliveness-svc.service', the server has been installed successfully. Refer the below image.

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2FOYUxh21QgD8HKFpga0PP%2Fimage.png?alt=media&#x26;token=b016b1b2-36e1-4d0f-8b27-1237eee63c7a" alt="" width="563"><figcaption></figcaption></figure>

## API Reference

1. **Endpoint**

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:8093/api/check_id_liveness`  \<ID Document Liveness Detection API>

* **Form Data:**
  * `image`: The image file (PNG, JPG, etc.) to be analyzed. This should be provided as a file upload

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2FHHLfnIZZ4JVAGYiefd8E%2Fimage.png?alt=media&#x26;token=1a129171-c813-4947-9567-9eea381fe31c" alt=""><figcaption></figcaption></figure>

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:8093/api/check_id_liveness_base64`  \<ID Document Liveness Detection API>

* **Raw Data:**

  * `JSON Format`:&#x20;

  ```json
  {
      "image": "--base64 image data here--"
  }
  ```

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2F6TiKUN9gpFuRrgtEdSjQ%2Fimage.png?alt=media&#x26;token=9737c397-0ba9-4179-b0c5-c023126833ef" alt=""><figcaption></figcaption></figure>

2. **Response**

The API returns a JSON object with the liveness result of the input face image. Here is an example response

<figure><img src="https://559891175-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZNwfjUfgEKAU8sqYBQl4%2Fuploads%2FC0tpektzB1ujkdEEaM1S%2Fimage.png?alt=media&#x26;token=d1c8e099-8346-4b4b-99dd-eb2407ea76a4" alt=""><figcaption></figcaption></figure>

## Testing API

### Gradio Demo

We have included a Gradio demo to showcase the capabilities of our **MiniAiLive** ID Document Liveness Detection SDK. Gradio is a Python library that allows you to quickly create user interfaces for machine learning models.

#### How to Run the Gradio Demo

1. **Install Gradio:**

   First, you need to install Gradio. You can do this using pip:

   ```json
   git clone https://github.com/MiniAiLive/ID-Document-LivenessDetection-Linux-SDK.git
   pip install -r requirement.txt
   cd gradio
   ```
2. **Run Gradio Demo:**

   ```
   python app.py
   ```

### Python Test API Example

To help you get started with using the API, here is a comprehensive example of how to interact with the ID Document Liveness Detection API using Python. You can use API with another language you want to use like C++, C#, Ruby, Java, Javascript, and more

1. **Prerequisites**

* Python 3.6+
* `requests` library (you can install it using `pip install requests`)

2. **Example Script**

This example demonstrates how to send an image file to the API endpoint and process the response.

```
import requests

# URL of the web API endpoint
url = 'http://127.0.0.1:8093/api/check_id_liveness'

# Path to the image file you want to send
image_path = './test_image.jpg'

# Read the image file and send it as form data
files = {'image': open(image_path, 'rb')}

try:
    # Send POST request
    response = requests.post(url, files=files)

    # Check if the request was successful
    if response.status_code == 200:
        print('Request was successful!')
        # Parse the JSON response
        response_data = response.json()
        print('Response Data:', response_data)
    else:
        print('Request failed with status code:', response.status_code)
        print('Response content:', response.text)

except requests.exceptions.RequestException as e:
    print('An error occurred:', e)
```

## Face & IDSDK Online Demo, Resources

| [![](https://camo.githubusercontent.com/806c4c9371684f21d03953dcc53853b790fa8440239f30681a21ce2cf2adcf92/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f6e65775f6769742d312d3330307836372e706e67)](https://github.com/MiniAiLive) | [![](https://camo.githubusercontent.com/28530427ea25f63b9ae20a1dce8d4a92ce76f67af276e92d5cf7ac370f335e08/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f6e65775f68756767696e672d312d3330307836372e706e67)](https://huggingface.co/MiniAiLive) | [![](https://camo.githubusercontent.com/514dcba45bbc416e9ff4d28794755408d015fcafca876e5ef3dc0321e80fa4c6/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f6e65775f67726164696f2d3330307836372e706e67)](https://demo.miniai.live/)                                     |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [![](https://camo.githubusercontent.com/09f3ad9287d86c1c5839adbe83dd7cec21eb4778d845a7e36ad7e58fa64c5fd6/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f612d3330307837302e706e67)](https://docs.miniai.live/)                     | [![](https://camo.githubusercontent.com/3137c2356707552aa1332fea60196413ab2f89ced339c8fe4367e8167d04b16f/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f556e7469746c65642d312d3330307837302e706e67)](https://www.youtube.com/@miniailive)     | [![](https://camo.githubusercontent.com/c642d8abd48cbc0861511ae78bc53ad1c544f7bf59432790bba60a84df44e98a/68747470733a2f2f6d696e6961692e6c6976652f77702d636f6e74656e742f75706c6f6164732f323032342f31302f676f6f676c65706c61792d3330307836322e706e67)](https://play.google.com/store/apps/dev?id=5831076207730531667) |

## Our Products

<table><thead><tr><th width="74">No</th><th>Project</th><th>Feature</th></tr></thead><tbody><tr><td>1</td><td><a href="https://github.com/MiniAiLive/FaceRecognition-Linux">FaceRecognition-Linux</a></td><td>1:1 &#x26; 1:N Face Matching</td></tr><tr><td>2</td><td><a href="https://github.com/MiniAiLive/FaceRecognition-Windows">FaceRecognition-Windows</a></td><td>1:1 &#x26; 1:N Face Matching</td></tr><tr><td>3</td><td><a href="https://github.com/MiniAiLive/FaceRecognition-Docker">FaceRecognition-Docker</a></td><td>1:1 &#x26; 1:N Face Matching</td></tr><tr><td>4</td><td><a href="https://github.com/MiniAiLive/FaceRecognition-Android">FaceRecognition-Android</a></td><td>1:1 &#x26; 1:N Face Matching, 2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>5</td><td><a href="https://github.com/MiniAiLive/FaceRecognition-LivenessDetection-Windows">FaceRecognition-LivenessDetection-Windows</a></td><td>1:1 &#x26; 1:N Face Matching, 2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>6</td><td><a href="https://github.com/MiniAiLive/FaceLivenessDetection-Linux">FaceLivenessDetection-Linux</a></td><td>2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>7</td><td><a href="https://github.com/MiniAiLive/FaceLivenessDetection-Windows">FaceLivenessDetection-Windows</a></td><td>2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>8</td><td><a href="https://github.com/MiniAiLive/FaceLivenessDetection-Docker">FaceLivenessDetection-Docker</a></td><td>2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>9</td><td><a href="https://github.com/MiniAiLive/FaceLivenessDetection-Android">FaceLivenessDetection-Android</a></td><td>2D &#x26; 3D Face Passive LivenessDetection</td></tr><tr><td>10</td><td><a href="https://github.com/MiniAiLive/FaceMatching-Android">FaceMatching-Android</a></td><td>1:1 Face Matching</td></tr><tr><td>11</td><td><a href="https://github.com/MiniAiLive/FaceMatching-Windows">FaceMatching-Windows-Demo</a></td><td>1:1 Face Matching</td></tr><tr><td>12</td><td><a href="https://github.com/MiniAiLive/FaceAttributes-Android">FaceAttributes-Android</a></td><td>Face Attributes, Age &#x26; Gender Estimation</td></tr><tr><td>13</td><td><a href="https://github.com/MiniAiLive/ID-DocumentRecognition-Linux">ID-DocumentRecognition-Linux</a></td><td>IDCard, Passport, Driver License, Credit, MRZ Recognition</td></tr><tr><td>14</td><td><a href="https://github.com/MiniAiLive/ID-DocumentRecognition-Windows">ID-DocumentRecognition-Windows</a></td><td>IDCard, Passport, Driver License, Credit, MRZ Recognition</td></tr><tr><td>15</td><td><a href="https://github.com/MiniAiLive/ID-DocumentRecognition-Docker">ID-DocumentRecognition-Docker</a></td><td>IDCard, Passport, Driver License, Credit, MRZ Recognition</td></tr><tr><td>16</td><td><a href="https://github.com/MiniAiLive/ID-DocumentRecognition-Android">ID-DocumentRecognition-Android</a></td><td>IDCard, Passport, Driver License, Credit, MRZ Recognition</td></tr><tr><td>17</td><td><a href="https://github.com/MiniAiLive/ID-DocumentLivenessDetection-Linux">ID-DocumentLivenessDetection-Linux</a></td><td>ID Document LivenessDetection</td></tr><tr><td>18</td><td><a href="https://github.com/MiniAiLive/ID-DocumentLivenessDetection-Windows">ID-DocumentLivenessDetection-Windows</a></td><td>ID Document LivenessDetection</td></tr><tr><td>19</td><td><a href="https://github.com/MiniAiLive/ID-DocumentLivenessDetection-Docker">ID-DocumentLivenessDetection-Docker</a></td><td>ID Document LivenessDetection</td></tr></tbody></table>

## Request license

Feel free to [Contact US](https://www.miniai.live/contact/) to get a trial License. We are 24/7 online on WhatsApp: [+19162702374](https://wa.me/+19162702374).
