|
import gradio as gr |
|
import sys |
|
import os |
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'dist')) |
|
|
|
|
|
try: |
|
from core_logic import * |
|
except ImportError as e: |
|
print(f"Error: Obfuscated module not found: {e}") |
|
print("Current directory:", os.getcwd()) |
|
print("Files in dist:", os.listdir('dist') if os.path.exists('dist') else 'dist not found') |
|
sys.exit(1) |
|
|
|
|
|
processor = DocumentProcessor() |
|
|
|
def check_id(frame): |
|
return processor.check_id(frame) |
|
|
|
def check_bank(frame): |
|
return processor.check_bank(frame) |
|
|
|
def check_mrz(frame): |
|
return processor.check_mrz(frame) |
|
|
|
def open_whatsapp(): |
|
import webbrowser |
|
phone_number = "+19162702374" |
|
message = "Hello! I'm interested in your ID Document Recognition API service." |
|
whatsapp_url = f"https://wa.me/{phone_number}?text={message}" |
|
webbrowser.open(whatsapp_url) |
|
return "WhatsApp opened in your browser!" |
|
|
|
|
|
COMPANY_INFO = """ |
|
## About US |
|
### MiniAiLive is a global leader in touchless biometric authentication and identity verification solutions. We deliver robust, cutting-edge technologies including facial recognition, liveness detection, palmprint and palm vein recognition, as well as ID document verification. |
|
### Our solutions are designed for seamless integration with existing client systems, ensuring both enhanced security and operational efficiency. |
|
""" |
|
|
|
custom_css = """ |
|
.button-gradient { |
|
background: linear-gradient(45deg, #ff416c, #ff4b2b, #ff9b00, #ff416c); |
|
background-size: 400% 400%; |
|
border: none; |
|
padding: 14px 28px; |
|
font-size: 16px; |
|
font-weight: bold; |
|
color: white; |
|
border-radius: 10px; |
|
cursor: pointer; |
|
transition: 0.3s ease-in-out; |
|
animation: gradientAnimation 2s infinite linear; |
|
box-shadow: 0 4px 10px rgba(255, 65, 108, 0.6); |
|
} |
|
@keyframes gradientAnimation { |
|
0% { background-position: 0% 50%; } |
|
25% { background-position: 50% 100%; } |
|
50% { background-position: 100% 50%; } |
|
75% { background-position: 50% 0%; } |
|
100% { background-position: 0% 50%; } |
|
} |
|
.button-gradient:hover { |
|
transform: scale(1.05); |
|
box-shadow: 0 6px 15px rgba(255, 75, 43, 0.8); |
|
} |
|
""" |
|
|
|
|
|
with gr.Blocks(css=custom_css) as MiniAIdemo: |
|
gr.Markdown( |
|
""" |
|
<a href="https://miniai.live" style="display: flex; align-items: center;"> |
|
<img src="https://miniai.live/wp-content/uploads/2024/02/logo_name-1-768x426-1.png" style="width: 10%; margin-right: 15px;"/> |
|
<div> |
|
<p style="font-size: 50px; font-weight: bold; margin-right: 20px;">ID Document Recognition Playground</p> |
|
</div> |
|
</a> |
|
""" |
|
) |
|
|
|
gr.Markdown(COMPANY_INFO) |
|
|
|
|
|
with gr.Row(): |
|
with gr.Column(scale=7): |
|
pass |
|
with gr.Column(scale=3): |
|
whatsapp_status = gr.Textbox(label="Status", visible=False) |
|
whatsapp_btn = gr.Button("� Contact Us on WhatsApp", elem_classes="button-gradient") |
|
whatsapp_btn.click(open_whatsapp, outputs=whatsapp_status) |
|
|
|
with gr.Tabs(): |
|
with gr.Tab("ID Document Recognition"): |
|
with gr.Row(): |
|
with gr.Column(scale=3): |
|
im_id_in = gr.Image(type='filepath', height=300) |
|
gr.Examples( |
|
[ |
|
"images/id/demo1.jpg", |
|
"images/id/demo2.png", |
|
"images/id/demo3.png", |
|
], |
|
inputs=im_id_in |
|
) |
|
btn_f_id = gr.Button("Check Document Details", elem_classes="button-gradient") |
|
with gr.Column(scale=5): |
|
table_id_out = gr.HTML() |
|
with gr.Column(scale=2): |
|
im_id_out = gr.HTML() |
|
|
|
btn_f_id.click(check_id, inputs=im_id_in, outputs=[table_id_out, im_id_out]) |
|
|
|
with gr.Tab("Bank/Credit Recognition"): |
|
with gr.Row(): |
|
with gr.Column(scale=3): |
|
im_bank_in = gr.Image(type='filepath', height=300) |
|
gr.Examples( |
|
[ |
|
"images/bank/demo1.jpg", |
|
"images/bank/demo2.png", |
|
"images/bank/demo3.png", |
|
], |
|
inputs=im_bank_in |
|
) |
|
btn_f_bank = gr.Button("Check Document Details", elem_classes="button-gradient") |
|
with gr.Column(scale=5): |
|
table_bank_out = gr.HTML() |
|
with gr.Column(scale=2): |
|
im_bank_out = gr.HTML() |
|
|
|
btn_f_bank.click(check_bank, inputs=im_bank_in, outputs=[table_bank_out, im_bank_out]) |
|
|
|
with gr.Tab("MRZ/Barcode Recognition"): |
|
with gr.Row(): |
|
with gr.Column(scale=3): |
|
im_mrz_in = gr.Image(type='filepath', height=300) |
|
gr.Examples( |
|
[ |
|
"images/mrz_barcode/demo1.png", |
|
"images/mrz_barcode/demo2.png", |
|
], |
|
inputs=im_mrz_in |
|
) |
|
btn_f_mrz = gr.Button("Check Document Details", elem_classes="button-gradient") |
|
with gr.Column(scale=5): |
|
table_mrz_out = gr.HTML() |
|
with gr.Column(scale=2): |
|
im_mrz_out = gr.HTML() |
|
|
|
btn_f_mrz.click(check_mrz, inputs=im_mrz_in, outputs=[table_mrz_out, im_mrz_out]) |
|
|
|
gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiniAiLive%2FID-Document-Recognition-Demo"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiniAiLive%2FID-Document-Recognition-Demo&label=VISITORS&labelColor=%2337d67a&countColor=%23ff8a65&style=plastic&labelStyle=none" /></a>') |
|
|
|
if __name__ == "__main__": |
|
MiniAIdemo.launch( |
|
show_api=False, |
|
server_name="0.0.0.0", |
|
server_port=7860 |
|
) |