├── README.md ├── gradio ├── app.py └── images │ ├── img1.jpg │ ├── img2.jpg │ ├── img3.jpg │ ├── img4.jpg │ ├── img5.jpg │ ├── img6.jpg │ └── img7.jpg ├── python ├── face_detect.py ├── face_match.py └── test_image │ ├── img1.jpg │ ├── img2.jpg │ ├── img3.jpg │ └── img4.jpg └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Face Recognition Linux SDK

3 | MiniAiLive Logo 5 |
6 | 7 | ## Welcome to the [MiniAiLive](https://www.miniai.live/)! 8 | Check the likelihood that two faces belong to the same person. You will get a confidence score and thresholds to evaluate the similarity. Feel free to use our MiniAI Face Recognition Linux SDK. 9 | 10 | > **Note** 11 | > 12 | > - Our SDK is fully on-premise, processing all happens on hosting server and no data leaves server. 13 | 14 | ## Table of Contents 15 | 16 | - [Installation Guide](#installation-guide) 17 | - [API Details](#api-details) 18 | - [Gradio Demo](#gradio-demo) 19 | - [Python Test API Example](#python-test-api-example) 20 | 21 | ## FaceSDK Installation Guide 22 | 23 | ### Prerequisites 24 | 25 | - Python 3.6+ 26 | - Linux 27 | - CPU: 2 cores or more 28 | - RAM: 8 GB or more 29 | 30 | ### Installation Steps 31 | 32 | 1. **Download the Face Recognition Linux Server Installer:** 33 | 34 | Download the Server installer for your operating system from the following link: 35 | 36 | [Download the On-premise Server Installer](https://drive.google.com/file/d/1DQ1epQVPMQOMBJs_6f-UsJb7Z3bd-jhk/view?usp=sharing) 37 | 38 | 2. **Install the On-premise Server:** 39 | 40 | Run the installer and follow the on-screen instructions to complete the installation. Go to the Download folder and run this command. 41 | ```sh 42 | $ cd Download 43 | $ sudo dpkg -i --force-overwrite MiniAiLive-FaceSDK-LinuxServer.deb 44 | ``` 45 | 46 |
47 | MiniAiLive FaceSDK Installer 48 |
49 | You can refer our Documentation here. https://docs.miniai.live 50 | 51 | 3. **Request License and Update:** 52 | 53 | You can generate the License Request file by using this command: 54 | ```sh 55 | $ cd /opt/miniai/face-rec-service 56 | $ sudo ./MiRequest request /home/ubuntu/Download/trial_key.miq 57 | ``` 58 |
59 | MiniAiLive FaceSDK Installer 60 |
61 | Then you can see the license request file on your directory, and send it to us via email or WhatsApp. 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. 62 | 63 | ```sh 64 | $ sudo ./MiRequest update /home/ubuntu/Download/trial_30.mis 65 | ``` 66 |
67 | MiniAiLive FaceSDK Installer 68 |
69 | 70 | 4. **Verify Installation:** 71 | 72 | After installation, verify that the On-premise Server is correctly installed by using this command: 73 | ```sh 74 | $ systemctl list-units --state running 75 | ``` 76 | If you can see 'Mini-facesvc.service', 'Mini-fdsvc.service', the server has been installed successfully. Refer the below image. 77 |
78 | MiniAiLive FaceSDK Installer 79 |
80 | 81 | ## FaceSDK API Details 82 | 83 | ### Endpoint 84 | 85 | - `POST http://127.0.0.1:8083/api/face_detect` Face Detection, Face Attributes API 86 | - `POST http://127.0.0.1:8083/api/face_detect_base64` Face Detection, Face Attributes API 87 | 88 | - `POST http://127.0.0.1:8083/api/face_match` Face Matching API 89 | - `POST http://127.0.0.1:8083/api/face_match_base64` Face Matching API 90 | 91 | ### Request 92 | 93 | - **URL:** `http://127.0.0.1:8083/api/face_detect` 94 | - **Method:** `POST` 95 | - **Form Data:** 96 | - `image`: The image file (PNG, JPG, etc.) to be analyzed. This should be provided as a file upload. 97 | Screenshot 2024-07-16 at 5 12 01 AM 98 | 99 | - **URL:** `http://127.0.0.1:8083/api/face_detect_base64` 100 | - **Method:** `POST` 101 | - **Raw Data:** 102 | - `JSON Format`: 103 | { 104 | "image": "--base64 image data here--" 105 | } 106 | Screenshot 2024-07-16 at 5 11 34 AM 107 | 108 | ### Response 109 | 110 | The API returns a JSON object with the recognized details from the input Face image. Here is an example response: 111 |
112 | 113 |
114 | 115 | ## Gradio Demo 116 | 117 | We have included a Gradio demo to showcase the capabilities of our Face Recognition SDK. Gradio is a Python library that allows you to quickly create user interfaces for machine learning models. 118 | 119 | ### How to Run the Gradio Demo 120 | 121 | 1. **Install Gradio:** 122 | 123 | First, you need to install Gradio. You can do this using pip: 124 | 125 | ```sh 126 | git clone https://github.com/MiniAiLive/FaceRecognition-Linux.git 127 | pip install -r requirement.txt 128 | cd gradio 129 | ``` 130 | 2. **Run Gradio Demo:** 131 | ```sh 132 | python app.py 133 | ``` 134 | ## Python Test API Example 135 | 136 | To help you get started with using the API, here is a comprehensive example of how to interact with the Face Recognition API using Python. You can use API with another language you want to use like C++, C#, Ruby, Java, Javascript, and more 137 | 138 | ### Prerequisites 139 | 140 | - Python 3.6+ 141 | - `requests` library (you can install it using `pip install requests`) 142 | 143 | ### Example Script 144 | 145 | This example demonstrates how to send an image file to the API endpoint and process the response. 146 | 147 | ```python 148 | import requests 149 | 150 | # URL of the web API endpoint 151 | url = 'http://127.0.0.1:8083/api/face_detect' 152 | 153 | # Path to the image file you want to send 154 | image_path = './test_image.jpg' 155 | 156 | # Read the image file and send it as form data 157 | files = {'image': open(image_path, 'rb')} 158 | 159 | try: 160 | # Send POST request 161 | response = requests.post(url, files=files) 162 | 163 | # Check if the request was successful 164 | if response.status_code == 200: 165 | print('Request was successful!') 166 | # Parse the JSON response 167 | response_data = response.json() 168 | print('Response Data:', response_data) 169 | else: 170 | print('Request failed with status code:', response.status_code) 171 | print('Response content:', response.text) 172 | 173 | except requests.exceptions.RequestException as e: 174 | print('An error occurred:', e) 175 | ``` 176 | 177 | 178 | ## Request license 179 | Feel free to [Contact US](https://www.miniai.live/contact/) to get a trial License. We are 24/7 online on [WhatsApp](https://wa.me/+19162702374). 180 | 181 | 182 | ## Face & IDSDK Online Demo, Resources 183 |
184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 |
196 |
197 | 198 | ## Our Products 199 | 200 | ### Face Recognition SDK 201 | | No | Project | Features | 202 | |----|---------|-----------| 203 | | 1 | [FaceRecognition-SDK-Docker](https://github.com/MiniAiLive/FaceRecognition-SDK-Docker) | 1:1 & 1:N Face Matching SDK | 204 | | 2 | [FaceRecognition-SDK-Windows](https://github.com/MiniAiLive/FaceRecognition-SDK-Windows) | 1:1 & 1:N Face Matching SDK | 205 | | 3 | [FaceRecognition-SDK-Linux](https://github.com/MiniAiLive/FaceRecognition-SDK-Linux) | 1:1 & 1:N Face Matching SDK | 206 | | 4 | [FaceRecognition-LivenessDetection-SDK-Android](https://github.com/MiniAiLive/FaceRecognition-LivenessDetection-SDK-Android) | 1:1 & 1:N Face Matching, 2D & 3D Face Passive Liveness Detection SDK | 207 | | 5 | [FaceRecognition-LivenessDetection-SDK-iOS](https://github.com/MiniAiLive/FaceRecognition-LivenessDetection-SDK-iOS) | 1:1 & 1:N Face Matching, 2D & 3D Face Passive Liveness Detection SDK | 208 | | 6 | [FaceRecognition-LivenessDetection-SDK-CPP](https://github.com/MiniAiLive/FaceRecognition-LivenessDetection-SDK-CPP) | 1:1 & 1:N Face Matching, 2D & 3D Face Passive Liveness Detection SDK | 209 | | 7 | [FaceMatching-SDK-Android](https://github.com/MiniAiLive/FaceMatching-SDK-Android) | 1:1 Face Matching SDK | 210 | | 8 | [FaceAttributes-SDK-Android](https://github.com/MiniAiLive/FaceAttributes-SDK-Android) | Face Attributes, Age & Gender Estimation SDK | 211 | 212 | ### Face Liveness Detection SDK 213 | | No | Project | Features | 214 | |----|---------|-----------| 215 | | 1 | [FaceLivenessDetection-SDK-Docker](https://github.com/MiniAiLive/FaceLivenessDetection-SDK-Docker) | 2D & 3D Face Passive Liveness Detection SDK | 216 | | 2 | [FaceLivenessDetection-SDK-Windows](https://github.com/MiniAiLive/FaceLivenessDetection-SDK-Windows) | 2D & 3D Face Passive Liveness Detection SDK | 217 | | 3 | [FaceLivenessDetection-SDK-Linux](https://github.com/MiniAiLive/FaceLivenessDetection-SDK-Linux) | 2D & 3D Face Passive Liveness Detection SDK | 218 | | 4 | [FaceLivenessDetection-SDK-Android](https://github.com/MiniAiLive/FaceLivenessDetection-SDK-Android) | 2D & 3D Face Passive Liveness Detection SDK | 219 | | 5 | [FaceLivenessDetection-SDK-iOS](https://github.com/MiniAiLive/FaceLivenessDetection-SDK-iOS) | 2D & 3D Face Passive Liveness Detection SDK | 220 | 221 | ### ID Document Recognition SDK 222 | | No | Project | Features | 223 | |----|---------|-----------| 224 | | 1 | [ID-DocumentRecognition-SDK-Docker](https://github.com/MiniAiLive/ID-DocumentRecognition-SDK-Docker) | ID Document, Passport, Driver License, Credit Card, MRZ Recognition SDK | 225 | | 2 | [ID-DocumentRecognition-SDK-Windows](https://github.com/MiniAiLive/ID-DocumentRecognition-SDK-Windows) | ID Document, Passport, Driver License, Credit Card, MRZ Recognition SDK | 226 | | 3 | [ID-DocumentRecognition-SDK-Linux](https://github.com/MiniAiLive/ID-DocumentRecognition-SDK-Linux) | ID Document, Passport, Driver License, Credit Card, MRZ Recognition SDK | 227 | | 4 | [ID-DocumentRecognition-SDK-Android](https://github.com/MiniAiLive/ID-DocumentRecognition-SDK-Android) | ID Document, Passport, Driver License, Credit Card, MRZ Recognition SDK | 228 | 229 | ### ID Document Liveness Detection SDK 230 | | No | Project | Features | 231 | |----|---------|-----------| 232 | | 1 | [ID-DocumentLivenessDetection-SDK-Docker](https://github.com/MiniAiLive/ID-DocumentLivenessDetection-SDK-Docker) | ID Document Liveness Detection SDK | 233 | | 2 | [ID-DocumentLivenessDetection-SDK-Windows](https://github.com/MiniAiLive/ID-DocumentLivenessDetection-SDK-Windows) | ID Document Liveness Detection SDK | 234 | | 3 | [ID-DocumentLivenessDetection-SDK-Linux](https://github.com/MiniAiLive/ID-DocumentLivenessDetection-SDK-Linux) | ID Document Liveness Detection SDK | 235 | 236 | ### Web & Desktop Demo 237 | | No | Project | Features | 238 | |----|---------|-----------| 239 | | 1 | [FaceRecognition-IDRecognition-Playground-Next.JS](https://github.com/MiniAiLive/FaceRecognition-IDRecognition-Playground-Next.JS) | FaceSDK & IDSDK Playground | 240 | | 2 | [FaceCapture-LivenessDetection-Next.JS](https://github.com/MiniAiLive/FaceCapture-LivenessDetection-Next.JS) | Face Capture, Face LivenessDetection, Face Attributes | 241 | | 3 | [FaceMatching-Windows-App](https://github.com/MiniAiLive/FaceMatching-Windows-App) | 1:1 Face Matching Windows Demo Application | 242 | 243 | ## About MiniAiLive 244 | [MiniAiLive](https://www.miniai.live/) is a leading AI solutions company specializing in computer vision and machine learning technologies. We provide cutting-edge solutions for various industries, leveraging the power of AI to drive innovation and efficiency. 245 | 246 | ## Contact US 247 | For any inquiries or questions, please contact us on [WhatsApp](https://wa.me/+19162702374). 248 | 249 |

250 | www.miniai.live  251 | www.miniai.live  252 |

253 | -------------------------------------------------------------------------------- /gradio/app.py: -------------------------------------------------------------------------------- 1 | import gradio as gr 2 | import os 3 | import requests 4 | import json 5 | from PIL import Image 6 | 7 | import requests 8 | import base64 9 | from PIL import Image 10 | from io import BytesIO 11 | 12 | def face_detect(frame): 13 | url = "http://127.0.0.1:8083/api/face_detect" 14 | files = {'image': open(frame, 'rb')} 15 | r = requests.post(url=url, files=files) 16 | response = r.json() 17 | 18 | detections = response.get("detections", {}) 19 | table_rows = "" 20 | face_images = [] 21 | 22 | for face_id, details in detections.items(): 23 | attributes = details.get("attributes", {}) 24 | # landmarks = details.get("landmarks", []) 25 | # position = details.get("position", []) 26 | face_base64 = details.get("face", "") 27 | 28 | # Decode face image 29 | face_image = f"" if face_base64 else "N/A" 30 | 31 | # Prepare attributes text without specific keys 32 | keys_to_remove = {"Emotion", "ForeheadCovering", "HeadCovering", "Occlusion", "StrongMakeup"} 33 | filtered_attributes = {key: value for key, value in attributes.items() if key not in keys_to_remove} 34 | 35 | attributes_text = "
".join(f"{key}: {value}" for key, value in filtered_attributes.items()) 36 | 37 | # # Prepare landmarks text 38 | # landmarks_text = ", ".join(str(landmark) for landmark in landmarks) 39 | 40 | # Add table row for the face 41 | table_rows += f""" 42 | 43 | {face_id} 44 | {face_image} 45 | {attributes_text} 46 | 47 | """ 48 | 49 | # Create final HTML table 50 | html = f""" 51 | 52 | 53 | 54 | 55 | 56 | 57 | {table_rows} 58 |
Face IDFace ImageAttributes
59 | """ 60 | return html 61 | 62 | def face_match(frame1, frame2): 63 | url = "http://127.0.0.1:8083/api/face_match" 64 | files = {'image1': open(frame1, 'rb'), 'image2': open(frame2, 'rb')} 65 | r = requests.post(url=url, files=files) 66 | response = r.json() 67 | 68 | detections = response.get("detections", []) 69 | matches = response.get("match", []) 70 | detection_rows = "" 71 | match_rows = "" 72 | 73 | # Process detections 74 | for detection in detections: 75 | face_image = detection.get("face", "") 76 | face_img_tag = f"" if face_image else "N/A" 77 | first_face_index = detection.get("firstFaceIndex", "N/A") 78 | second_face_index = detection.get("secondFaceIndex", "N/A") 79 | 80 | detection_rows += f""" 81 | 82 | {first_face_index} 83 | {second_face_index} 84 | {face_img_tag} 85 | 86 | """ 87 | 88 | # Process matches 89 | for match in matches: 90 | first_face_index = match.get("firstFaceIndex", "N/A") 91 | second_face_index = match.get("secondFaceIndex", "N/A") 92 | similarity = match.get("similarity", "N/A") 93 | 94 | match_rows += f""" 95 | 96 | {first_face_index} 97 | {second_face_index} 98 | {similarity:.6f} 99 | 100 | """ 101 | 102 | # Create HTML tables 103 | detections_table = f""" 104 |

Face Detection

105 | 106 | 107 | 108 | 109 | 110 | 111 | {detection_rows} 112 |
First Face IndexSecond Face IndexFace Image
113 | """ 114 | 115 | matches_table = f""" 116 |

Matching Results

117 | 118 | 119 | 120 | 121 | 122 | 123 | {match_rows} 124 |
First Face IndexSecond Face IndexSimilarity
125 | """ 126 | 127 | return detections_table + matches_table 128 | 129 | # APP Interface 130 | with gr.Blocks() as MiniAIdemo: 131 | gr.Markdown( 132 | """ 133 | 134 | 135 |
136 |

FaceRecognition SDK Demo

137 |

Experience our NIST FRVT Top Ranked FaceRecognition, iBeta 2 Certified Face Liveness Detection Engine

138 |
139 |
140 |
141 |
142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 |
154 |
155 |
156 | """ 157 | ) 158 | with gr.Tabs(): 159 | with gr.TabItem("Face Detection"): 160 | with gr.Row(): 161 | with gr.Column(): 162 | im_detect_input = gr.Image(type='filepath', height=300) 163 | gr.Examples( 164 | [ 165 | os.path.join(os.path.dirname(__file__), "images/img1.jpg"), 166 | os.path.join(os.path.dirname(__file__), "images/img2.jpg"), 167 | os.path.join(os.path.dirname(__file__), "images/img3.jpg"), 168 | ], 169 | inputs=im_detect_input 170 | ) 171 | btn_f_detect = gr.Button("Detect", variant='primary') 172 | with gr.Column(): 173 | txt_detect_output = gr.HTML() 174 | btn_f_detect.click(face_detect, inputs=im_detect_input, outputs=txt_detect_output) 175 | with gr.Tab("Face Recognition"): 176 | with gr.Row(): 177 | with gr.Column(): 178 | im_match_in1 = gr.Image(type='filepath', height=300) 179 | gr.Examples( 180 | [ 181 | "images/img2.jpg", 182 | "images/img3.jpg", 183 | "images/img4.jpg", 184 | ], 185 | inputs=im_match_in1 186 | ) 187 | with gr.Column(): 188 | im_match_in2 = gr.Image(type='filepath', height=300) 189 | gr.Examples( 190 | [ 191 | "images/img5.jpg", 192 | "images/img6.jpg", 193 | "images/img7.jpg", 194 | ], 195 | inputs=im_match_in2 196 | ) 197 | with gr.Column(): 198 | txt_match_out = gr.HTML() 199 | btn_f_match = gr.Button("Check Comparing!", variant='primary') 200 | btn_f_match.click(face_match, inputs=[im_match_in1, im_match_in2], outputs=txt_match_out) 201 | 202 | if __name__ == "__main__": 203 | MiniAIdemo.launch(server_port=8085, server_name="0.0.0.0") -------------------------------------------------------------------------------- /gradio/images/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img1.jpg -------------------------------------------------------------------------------- /gradio/images/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img2.jpg -------------------------------------------------------------------------------- /gradio/images/img3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img3.jpg -------------------------------------------------------------------------------- /gradio/images/img4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img4.jpg -------------------------------------------------------------------------------- /gradio/images/img5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img5.jpg -------------------------------------------------------------------------------- /gradio/images/img6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img6.jpg -------------------------------------------------------------------------------- /gradio/images/img7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/gradio/images/img7.jpg -------------------------------------------------------------------------------- /python/face_detect.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | # URL of the web API endpoint 4 | url = 'http://127.0.0.1:8083/api/face_detect' 5 | 6 | # Path to the image file you want to send 7 | image_path = './test_image/img1.jpg' 8 | 9 | # Read the image file and send it as form data 10 | files = {'image': open(image_path, 'rb')} 11 | 12 | try: 13 | # Send POST request 14 | response = requests.post(url, files=files) 15 | 16 | # Check if the request was successful 17 | if response.status_code == 200: 18 | print('Request was successful!') 19 | # Parse the JSON response 20 | response_data = response.json() 21 | print('Response Data:', response_data) 22 | else: 23 | print('Request failed with status code:', response.status_code) 24 | print('Response content:', response.text) 25 | 26 | except requests.exceptions.RequestException as e: 27 | print('An error occurred:', e) -------------------------------------------------------------------------------- /python/face_match.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | # URL of the web API endpoint 4 | url = 'http://127.0.0.1:8083/api/face_match' 5 | 6 | # Path to the image file you want to send 7 | image_path_1 = './test_image/img1.jpg' 8 | image_path_2 = './test_image/img2.jpg' 9 | 10 | # Read the image file and send it as form data 11 | files = { 12 | 'image1': open(image_path_1, 'rb'), 13 | 'image2': open(image_path_2, 'rb') 14 | } 15 | 16 | try: 17 | # Send POST request 18 | response = requests.post(url, files=files) 19 | 20 | # Check if the request was successful 21 | if response.status_code == 200: 22 | print('Request was successful!') 23 | # Parse the JSON response 24 | response_data = response.json() 25 | print('Response Data:', response_data) 26 | else: 27 | print('Request failed with status code:', response.status_code) 28 | print('Response content:', response.text) 29 | 30 | except requests.exceptions.RequestException as e: 31 | print('An error occurred:', e) -------------------------------------------------------------------------------- /python/test_image/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/python/test_image/img1.jpg -------------------------------------------------------------------------------- /python/test_image/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/python/test_image/img2.jpg -------------------------------------------------------------------------------- /python/test_image/img3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/python/test_image/img3.jpg -------------------------------------------------------------------------------- /python/test_image/img4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiniAiLive/FaceRecognition-SDK-Linux/0c03832664bf0b5db3196651711033defac93a38/python/test_image/img4.jpg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | gradio 2 | requests --------------------------------------------------------------------------------