Similarity score: {str_score}
Similarity score: {str_score}
Face Recognition {version}
+🤝 Contact us for our on-premise Face Recognition, Liveness Detection SDKs deployment
+ + +Activation Success!
""") + else: + gr.Markdown("""Activation Failed!
""") + + gr.Textbox(device_id, label="Hardware ID") + + with gr.Row(): + with gr.Column(scale=2): + with gr.Row(): + with gr.Column(scale=1): + compare_face_input1 = gr.Image(label="Image1", type='filepath', elem_classes="example-image") + gr.Examples([os.path.join(root_path,'examples/1.jpg'), + os.path.join(root_path,'examples/2.jpg'), + os.path.join(root_path,'examples/3.jpg'), + os.path.join(root_path,'examples/4.jpg')], + inputs=compare_face_input1) + with gr.Column(scale=1): + compare_face_input2 = gr.Image(label="Image2", type='filepath', elem_classes="example-image") + gr.Examples([os.path.join(root_path,'examples/5.jpg'), + os.path.join(root_path,'examples/6.jpg'), + os.path.join(root_path,'examples/7.jpg'), + os.path.join(root_path,'examples/8.jpg')], + inputs=compare_face_input2) + + with gr.Blocks(): + with gr.Column(scale=1, min_width=400, elem_classes="block-background"): + txt_threshold = gr.Textbox(f"{MATCH_THRESHOLD}", label="Matching Threshold", interactive=True) + compare_face_button = gr.Button("Compare Face", variant="primary", size="lg") + with gr.Row(elem_classes="face-row"): + face_output1 = gr.Image(value=os.path.join(gradio_path,'icons/face.jpg'), label="Face 1", scale=0, elem_classes="face-image") + compare_result = gr.Image(value=os.path.join(gradio_path,'icons/blank.png'), min_width=30, scale=0, show_download_button=False, show_label=False) + face_output2 = gr.Image(value=os.path.join(gradio_path,'icons/face.jpg'), label="Face 2", scale=0, elem_classes="face-image") + similarity_markdown = gr.Markdown("") + txt_speed = gr.Textbox(f"", label="Processing Time (ms)", interactive=False, visible=False) + with gr.Group(): + gr.Markdown(""" face1""") + txt_bbox1 = gr.Textbox(f"", label="Rect", interactive=False) + txt_feature1 = gr.Textbox(f"", label="Feature", interactive=False, max_lines=5) + with gr.Group(): + gr.Markdown(""" face2""") + txt_bbox2 = gr.Textbox(f"", label="Rect", interactive=False) + txt_feature2 = gr.Textbox(f"", label="Feature", interactive=False, max_lines=5) + + compare_face_button.click(compare_face_clicked, inputs=[compare_face_input1, compare_face_input2, txt_threshold], outputs=[face_output1, face_output2, compare_result, similarity_markdown, txt_bbox1, txt_bbox2, txt_feature1, txt_feature2, txt_speed]) + + demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False) + +if __name__ == '__main__': + g_activation_result = activate_sdk() + launch_demo(g_activation_result) diff --git a/gradio/icons/blank.png b/gradio/icons/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..d713c2db43625b7f2b7d6af267279563b7eca7fa Binary files /dev/null and b/gradio/icons/blank.png differ diff --git a/gradio/icons/different.png b/gradio/icons/different.png new file mode 100644 index 0000000000000000000000000000000000000000..a10f4237d79047b4b02adbedbfe2fe6058979fb4 Binary files /dev/null and b/gradio/icons/different.png differ diff --git a/gradio/icons/face.jpg b/gradio/icons/face.jpg new file mode 100644 index 0000000000000000000000000000000000000000..497bd744734b412dbb26c7a7ce05fe4b64ba5301 Binary files /dev/null and b/gradio/icons/face.jpg differ diff --git a/gradio/icons/same.png b/gradio/icons/same.png new file mode 100644 index 0000000000000000000000000000000000000000..d12fe203947dacdca200fa2a95aa54daeae26551 Binary files /dev/null and b/gradio/icons/same.png differ diff --git a/install.sh b/install.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa7ea3a82c21b161b4d4b6f323cb6ee5918baa5d --- /dev/null +++ b/install.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +echo "Install environment..." + +. /etc/os-release +ubuntu_version="$VERSION_ID" +echo "Ubuntu version: $ubuntu_version" + +# Check if the version is 20.04 or later +if [ "$ubuntu_version" \< "20.04" ]; then + # Print an error message and exit + echo "Error: Ubuntu version must be 20.04 or later" + exit 1 +fi + +# Install packages: +sudo apt-get update -y && sudo apt-get install -y python3 python3-pip python3-opencv libcurl4-openssl-dev libssl-dev libtbb-dev + +# Install requirements: +python3 -m pip install --upgrade pip && python3 -m pip install opencv-python flask flask-cors gradio + +# Copy libraries to /usr/lib based on Ubuntu version +if [ "$ubuntu_version" = "20.04" ]; then + # Copy library for Ubuntu 20.04 + sudo cp -f dependency/libimutils.so /usr/lib +elif [ "$ubuntu_version" = "22.04" ]; then + # Copy library for Ubuntu 22.04 + sudo cp -f dependency/libimutils.so_for_ubuntu22 /usr/lib/libimutils.so +else + # Print an error message for unsupported Ubuntu versions + echo "Error: Unsupported Ubuntu version" + exit 1 +fi + +# Copy OpenVino library +sudo cp -rf dependency/openvino /usr/lib + +echo "Installed successfully!" \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..714dd21c8f2d93a4efee5e14c3e9b002c050de0a --- /dev/null +++ b/license.txt @@ -0,0 +1,6 @@ +{ + "licenseKey": "eyJQcm9kdWN0SWQiOjE4MzgyLCJJRCI6MjMsIktleSI6IkROUkRYLVRNSUdWLUxIR0VKLVFZU0xSIiwiQ3JlYXRlZCI6MTcxMDE2MTM2NSwiRXhwaXJlcyI6MTcxMjc1MzM2NSwiUGVyaW9kIjozMCwiRjEiOnRydWUsIkYyIjpmYWxzZSwiRjMiOmZhbHNlLCJGNCI6ZmFsc2UsIkY1IjpmYWxzZSwiRjYiOmZhbHNlLCJGNyI6ZmFsc2UsIkY4IjpmYWxzZSwiTm90ZXMiOm51bGwsIkJsb2NrIjpmYWxzZSwiR2xvYmFsSWQiOjQ0MDQ0OSwiQ3VzdG9tZXIiOm51bGwsIkFjdGl2YXRlZE1hY2hpbmVzIjpbeyJNaWQiOiI1V2lmSjJ4VWJzbnBxWnd6OEdzblR5T2pySDkzUElvNms2NGxMVzAxSVlBTWFMeWp2Z1lqaDNIR3NWOTM0Vms2IiwiSVAiOiIzOC43NS4xMzcuOTciLCJUaW1lIjoxNzEwMTYxNDg2fV0sIlRyaWFsQWN0aXZhdGlvbiI6ZmFsc2UsIk1heE5vT2ZNYWNoaW5lcyI6NCwiQWxsb3dlZE1hY2hpbmVzIjoiIiwiRGF0YU9iamVjdHMiOltdLCJTaWduRGF0ZSI6MTcxMDM0NDYxMX0=", + "signature": "UG8KP3r7OyqM5pCXFBdkd0xJTUTifI3CW50XrvsZTZXdhQXDbxPyeojObY01hNjV5JeWnt+Ot12L9zQYZnCfI2jcXvHfoqIev9QDdlgH9EASoiAEq4TKmFplVVhLZ5Vi+nRXrts+aHO0jNLbIDS/Qu1+FnE8jaBB9quS4ECoeutYBPx10UwnLfnS/VeZrvDZ4RuB/fmLFz5ZYXb8p8q9vlbCMF/zPUJEyV2w/1yzXrwowEjw3WWwypCLzmvKnhi3cAdbKGt/9sUOO7TgD45pJGs6Ajf+fzd7caaoIKXqfCk30g9LNRS1v05pDW/j+Nyegk3GzKslhzV1IpJjUVZCLQ==", + "result": 0, + "message": "" +} \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..19226867247041870b894db4e1d1e5f2c68c912e --- /dev/null +++ b/readme.txt @@ -0,0 +1,43 @@ +Guide - Face Recognition Linux for eKYC + +Read more details on https://docs.recognito.vision/ + +1. System OS, Requirements + - OS: Ubuntu 20.04 or later + - Requirements + CPU: 4 cores or more (Recommended: 8 cores) + RAM: 4 GB or more (Recommended: 8 GB) + HDD: 4 GB or more (Recommended: 8 GB) +2. Installation of dependency + - Run the install.sh script. + ./install.sh +3. Set SDK license key (online or offline mode) + - Online: Set online license key as an environment variable. + export FR_LICENSE_KEY="XXXXX-XXXXX-XXXXX-XXXXX" + - Offline: Copy 'license.txt' license file to the work directory + For offline licensing, you must first provide us with the hardware ID of your machine. + You can get your Hardware ID when running demos. + +4. Run demo + - Run flask, gradio demo script + ./run_demo.sh [OPTION --gradio(-g), --flask(-f), --help(-h)] + - Docker + 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)] + +5. Test + - Flask + To test the API, you can use Postman. Here are the endpoints for testing: + Test with image files: Send a POST request with [image1], [image2] in form-data format to http://{xx.xx.xx.xx}:8000/api/compare_face. + e.g. http://127.0.0.1:8000/api/compare_face + Test with base64-encoded images: Send a POST request with [image1], [image2] in raw format to http://{xx.xx.xx.xx}:8000/api/compare_face_base64. + If testing in Docker container, use the URL http://{xx.xx.xx.xx}:8001/ instead of 8000 PORT. + - Gradio + Run http://{xx.xx.xx.xx}:7860/ on web browser. + e.g. http://127.0.0.1:7860/ + If testing in Docker container, use the URL http://{xx.xx.xx.xx}:7861/ instead of 7860 PORT. + +6. Contact us if any issue + email: hassan@recognito.vision + whatsapp: +14158003112 + telegram: @recognito_vision diff --git a/run_demo.sh b/run_demo.sh new file mode 100644 index 0000000000000000000000000000000000000000..383bd1b8d4e37eec1ee6825693d82ccb47b345ca --- /dev/null +++ b/run_demo.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# Add the current directory to PYTHONPATH +export PYTHONPATH=$(dirname "$(pwd)"):$PYTHONPATH + +# Set LD_LIBRARY_PATH +export LD_LIBRARY_PATH="/usr/lib/openvino:$LD_LIBRARY_PATH" + +show_help() { + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " -f, --flask Run flask demo" + echo " -g, --gradio Run gradio ui demo" + echo " -h, --help Show this help message" +} + +# Parse command-line options +if [ $# -eq 0 ] || [ $# -gt 1 ]; then + show_help +else + # Check the provided option + case $1 in + --gradio|-g) + python3 gradio/app.py + ;; + --flask|-f) + python3 flask/app.py + ;; + --help|-h) + show_help + ;; + *) + echo "Invalid option: $1" + show_help + ;; + esac +fi \ No newline at end of file