Skip to content

kby-ai/FaceRecognition-Windows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤗 Hugging Face - Here

📚 Product & Resources - Here

🛟 Help Center - Here

💼 KYC Verification Demo - Here

🙋‍♀️ Docker Hub - Here

FaceRecognition-Windows

Overview

This repository demonstrates an advanced face recognition technology by implementing face comparison based on face feature extraction and face matching algorithm.
It includes features that allow for testing face recognition between two images using both image files and base64-encoded images.

In this repo, we integrated KBY-AI's face recognition solution into Windows Server SDK.
We can customize the SDK to align with your specific requirements.

◾FaceSDK(Server) Details

Face Liveness Detection 🔽 Face Recognition
Face Detection Face Detection
Face Liveness Detection Face Recognition(Face Matching or Face Comparison)
Pose Estimation Pose Estimation
68 points Face Landmark Detection 68 points Face Landmark Detection
Face Quality Calculation Face Occlusion Detection
Face Occlusion Detection Face Occlusion Detection
Eye Closure Detection Eye Closure Detection
Mouth Opening Check Mouth Opening Check

◾FaceSDK(Server) Product List

No. Repository SDK Details
1 Face Liveness Detection - Linux Face Livness Detection
2 Face Liveness Detection - Windows Face Livness Detection
3 Face Recognition - Linux Face Recognition
➡️ Face Recognition - Windows Face Recognition
5 Face Recognition - C# Face Recognition

To get Face SDK(mobile), please visit products here:

Try the API

Online Demo

You can test the SDK using images from the following URL: https://web.kby-ai.com

image

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:8081/compare_face.

  • Test with a base64-encoded image: Send a POST request to http://18.221.33.238:8081/compare_face_base64.

    You can download the Postman collection to easily access and use these endpoints. click here

    image

SDK License

This project uses KBY-AI's Face Recognition Server SDK, which requires a license per machine.

  • The code below shows how to use the license:

    licensePath = "license.txt"
    license = ""
    machineCode = getMachineCode()
    print("machineCode: ", machineCode.decode('utf-8'))
    try:
    with open(licensePath, 'r') as file:
    license = file.read()
    except IOError as exc:
    print("failed to open license.txt: ", exc.errno)
    print("license: ", license)
    ret = setActivation(license.encode('utf-8'))
    print("activation: ", ret)

  • To request the license, please provide us with the machine code obtained from the getMachineCode function.

Please contact us:

🧙Email: contact@kby-ai.com
🧙Telegram: @kbyai
🧙WhatsApp: +19092802609
🧙Skype: live:.cid.66e2522354b1049b
🧙Facebook: https://www.facebook.com/KBYAI

How to run

We have not published facesdk2.dll. If you need the SDK dynamic file(*.dll), please get in touch with us.

1. System Requirements

  • CPU: 2 cores or more (Recommended: 2 cores)
  • RAM: 4 GB or more (Recommended: 8 GB)
  • HDD: 4 GB or more (Recommended: 8 GB)
  • OS: Windows 7 or later
  • Dependency: OpenVINO™ Runtime (Version: 2022.3), ncnn Runtime(20220721) or later, Vulkan SDK Runtime(1.3.250)

2. Setup and Test

  • Clone the project:

    git clone https://github.com/kby-ai/FaceRecognition-Windows.git
  • Download the model from Google Drive and unzip: click here

  • Run the python code:

    python test.py
  • Send us the machine code and then we will give you a license key.

    After that, update the license.txt file by overwriting the license key that you received. Then, run python code again.

    image

    image

About SDK

1. Initializing the SDK

  • Step One

    First, obtain the machine code for activation and request a license based on the machine code.

    machineCode = getMachineCode()
    print("machineCode: ", machineCode.decode('utf-8'))
  • Step Two

    Next, activate the SDK using the received license.

    setActivation(license.encode('utf-8'))

    If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

  • Step Three

    After activation, call the initialization function of the SDK.

    initSDK("data".encode('utf-8'))

    The first parameter is the path to the model.

    If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

2. Enum and Structure

  • SDK_ERROR

    This enumeration represents the return value of the initSDK and setActivation functions.

    Feature Value Name
    Successful activation or initialization 0 SDK_SUCCESS
    License key error -1 SDK_LICENSE_KEY_ERROR
    AppID error (Not used in Server SDK) -2 SDK_LICENSE_APPID_ERROR
    License expiration -3 SDK_LICENSE_EXPIRED
    Not activated -4 SDK_NO_ACTIVATED
    Failed to initialize SDK -5 SDK_INIT_ERROR
  • FaceBox

    This structure represents the output of the face detection function.

    Feature Type Name
    Face rectangle int x1, y1, x2, y2
    Face angles (-45 ~ 45) float yaw, roll, pitch
    Face quality (0 ~ 1) float face_quality
    Face luminance (0 ~ 255) float face_luminance
    Eye distance (pixels) float eye_dist
    Eye closure (0 ~ 1) float left_eye_closed, right_eye_closed
    Face occlusion (0 ~ 1) float face_occlusion
    Mouth opening (0 ~ 1) float mouth_opened
    68 points facial landmark float [68 * 2] landmarks_68
    Face templates unsigned char [2048] templates

    68 points facial landmark

3. APIs

  • Face Detection

    The Face SDK provides a single API for detecting faces, determining face orientation (yaw, roll, pitch), assessing face quality, detecting facial occlusion, eye closure, mouth opening, and identifying facial landmarks.

    The function can be used as follows:

    faceBoxes = (FaceBox * maxFaceCount)()
    faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)

    This function requires 5 parameters.

    • The first parameter: the byte array of the RGB image buffer.
    • The second parameter: the width of the image.
    • The third parameter: the height of the image.
    • The fourth parameter: the FaceBox array allocated with maxFaceCount for storing the detected faces.
    • The fifth parameter: the count allocated for the maximum FaceBox objects.

    The function returns the count of the detected face.

  • Create Template

    The SDK provides a function that enables the generation of templates from RGB data. These templates can be used for face verification between two faces.

    The function can be used as follows:

    templateExtraction(image_np1, image_np1.shape[1], image_np1.shape[0], faceBoxes1[0])

    This function requires 4 parameters.

    • The first parameter: the byte array of the RGB image buffer.
    • The second parameter: the width of the image.
    • The third parameter: the height of the image.
    • The fourth parameter: the FaceBox object obtained from the faceDetection function.

    If the template extraction is successful, the function will return 0. Otherwise, it will return -1.

  • Calculation similiarity

    The similarityCalculation function takes a byte array of two templates as a parameter.

    similarity = similarityCalculation(faceBoxes1[0].templates, faceBoxes2[0].templates)

    It returns the similarity value between the two templates, which can be used to determine the level of likeness between the two individuals.

4. Thresholds

The default thresholds are as the following below:

verifyThreshold = 0.7